SPIGOT-3456: Expand calling of ServerCommandEvent

Existing usage preserved by checking sender.
This commit is contained in:
md_5 2017-07-28 18:10:38 +10:00
parent d00c0574cd
commit 2c5c611d0c

View File

@ -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<String[]> commands = new ArrayList<String[]>();
+