From 2c5c611d0c3c198c1ac904e8d64051a8437a8720 Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 28 Jul 2017 18:10:38 +1000 Subject: SPIGOT-3456: Expand calling of ServerCommandEvent Existing usage preserved by checking sender. --- nms-patches/CommandBlockListenerAbstract.patch | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/nms-patches/CommandBlockListenerAbstract.patch b/nms-patches/CommandBlockListenerAbstract.patch index ba41673f..5f6ef041 100644 --- a/nms-patches/CommandBlockListenerAbstract.patch +++ b/nms-patches/CommandBlockListenerAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/CommandBlockListenerAbstract.java +++ b/net/minecraft/server/CommandBlockListenerAbstract.java -@@ -4,6 +4,14 @@ +@@ -4,6 +4,15 @@ import java.util.Date; import javax.annotation.Nullable; @@ -10,12 +10,13 @@ +import com.google.common.base.Joiner; +import java.util.logging.Level; +import org.bukkit.command.CommandSender; ++import org.bukkit.event.server.ServerCommandEvent; +// CraftBukkit end + public abstract class CommandBlockListenerAbstract implements ICommandListener { private static final SimpleDateFormat a = new SimpleDateFormat("HH:mm:ss"); -@@ -15,6 +23,7 @@ +@@ -15,6 +24,7 @@ private String g = ""; private String h = "@"; private final CommandObjectiveExecutor i = new CommandObjectiveExecutor(); @@ -23,7 +24,7 @@ public CommandBlockListenerAbstract() {} -@@ -107,7 +116,9 @@ +@@ -107,7 +117,9 @@ if (minecraftserver != null && minecraftserver.M() && minecraftserver.getEnableCommandBlock()) { try { this.f = null; @@ -34,7 +35,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Executing command block"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Command to be executed"); -@@ -149,6 +160,163 @@ +@@ -149,6 +161,171 @@ } } @@ -58,6 +59,14 @@ + if (command.startsWith("/")) { + command = command.substring(1); + } ++ ++ ServerCommandEvent event = new ServerCommandEvent(bSender, command); ++ org.bukkit.Bukkit.getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ return 0; ++ } ++ command = event.getCommand(); ++ + String[] args = command.split(" "); + ArrayList commands = new ArrayList(); + -- cgit v1.2.3