2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/CommandExecute.java
+++ b/net/minecraft/server/CommandExecute.java
2015-01-25 16:17:48 +01:00
@@ -2,6 +2,10 @@
2015-01-05 00:25:31 +01:00
import java.util.Collection;
import java.util.List;
2015-01-25 16:17:48 +01:00
+// CraftBukkit start
2015-01-05 00:25:31 +01:00
+import org.bukkit.craftbukkit.command.ProxiedNativeCommandSender;
2015-01-25 16:17:48 +01:00
+import org.bukkit.craftbukkit.command.VanillaCommandWrapper;
+// CraftBukkit end
2015-01-05 00:25:31 +01:00
public class CommandExecute extends CommandAbstract {
2015-02-26 23:41:06 +01:00
@@ -94,12 +98,31 @@
2015-01-05 00:25:31 +01:00
ICommandHandler icommandhandler = MinecraftServer.getServer().getCommandHandler();
try {
2015-02-26 23:41:06 +01:00
- int j = icommandhandler.a(icommandlistener1, s);
2015-01-05 00:25:31 +01:00
+ // CraftBukkit start
+ org.bukkit.command.CommandSender sender = null;
2015-01-25 16:17:48 +01:00
+ if (icommandlistener instanceof DedicatedServer) {
2015-01-05 00:25:31 +01:00
+ sender = MinecraftServer.getServer().server.getConsoleSender();
2015-02-26 23:41:06 +01:00
+ } else if (icommandlistener instanceof CommandBlockListenerAbstract) {
+ sender = ((CommandBlockListenerAbstract) icommandlistener).sender;
2015-01-25 16:17:48 +01:00
+ } else if (VanillaCommandWrapper.lastSender != null) {
+ sender = VanillaCommandWrapper.lastSender;
+ }else if (icommandlistener.f() != null) {
+ sender = icommandlistener.f().getBukkitEntity();
2015-01-05 00:25:31 +01:00
+ } else {
+ throw new CommandException("Unhandled executor " + icommandlistener.getClass().getSimpleName(), new Object[0]);
+ }
2015-02-26 23:41:06 +01:00
+ int j = CommandBlockListenerAbstract.executeCommand(icommandlistener1, new ProxiedNativeCommandSender(icommandlistener1, sender, entity.getBukkitEntity()), s);
2015-01-05 00:25:31 +01:00
+ // CraftBukkit end
2015-02-26 23:41:06 +01:00
2015-01-05 00:25:31 +01:00
if (j < 1) {
throw new CommandException("commands.execute.allInvocationsFailed", new Object[] { s});
}
} catch (Throwable throwable) {
+ // CraftBukkit start
+ if (throwable instanceof CommandException) {
+ throw (CommandException) throwable;
+ }
+ // CraftBukkit end
throw new CommandException("commands.execute.failed", new Object[] { s, entity.getName()});
}
}
2015-02-26 23:41:06 +01:00
@@ -112,4 +135,11 @@
2015-01-05 00:25:31 +01:00
public boolean isListStart(String[] astring, int i) {
return i == 0;
}
+
+ // CraftBukkit start - fix decompiler error
+ @Override
2015-02-26 23:41:06 +01:00
+ public int compareTo(ICommand o) {
2015-01-05 00:25:31 +01:00
+ return a((ICommand) o);
+ }
+ // CraftBukkit end
}