2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/CommandExecute.java
+++ b/net/minecraft/server/CommandExecute.java
2016-05-10 13:47:39 +02:00
@@ -4,6 +4,10 @@
2016-02-29 22:32:46 +01:00
import java.util.Collections;
2015-01-05 00:25:31 +01:00
import java.util.List;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
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 {
2016-06-09 03:43:49 +02:00
@@ -55,7 +59,10 @@
2016-04-20 12:24:48 +02:00
}
String s = a(astring, b0);
- ICommandListener icommandlistener1 = new ICommandListener() {
+ // CraftBukkit start - name class
+ class ProxyListener implements ICommandListener {
+ private final ICommandListener base = icommandlistener;
+ // CraftBukkit end
public String getName() {
return entity.getName();
}
2016-10-09 05:00:04 +02:00
@@ -100,25 +107,59 @@
2016-04-20 12:24:48 +02:00
return entity.h();
}
};
+ ICommandListener icommandlistener1 = new ProxyListener(); // CraftBukkit
2016-02-29 22:32:46 +01:00
ICommandHandler icommandhandler = minecraftserver.getCommandHandler();
2015-01-05 00:25:31 +01:00
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;
2016-04-20 12:24:48 +02:00
+ ICommandListener listener = icommandlistener;
+ while (sender == null) {
+ if (listener instanceof DedicatedServer) {
2016-10-09 05:00:04 +02:00
+ sender = minecraftserver.console;
+ } else if (listener instanceof RemoteControlCommandListener) {
+ sender = minecraftserver.remoteConsole;
2016-04-20 12:24:48 +02:00
+ } else if (listener instanceof CommandBlockListenerAbstract) {
+ sender = ((CommandBlockListenerAbstract) listener).sender;
+ } else if (listener instanceof ProxyListener) {
2016-05-01 21:38:40 +02:00
+ listener = ((ProxyListener) listener).base; // Search deeper
2016-04-20 12:24:48 +02:00
+ } else if (VanillaCommandWrapper.lastSender != null) {
+ sender = VanillaCommandWrapper.lastSender;
+ } else if (listener.f() != null) {
+ sender = listener.f().getBukkitEntity();
+ } else {
+ throw new CommandException("Unhandled executor " + icommandlistener.getClass().getSimpleName(), new Object[0]);
+ }
2015-01-05 00:25:31 +01:00
+ }
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()});
}
}
2016-02-29 22:32:46 +01:00
}
2016-05-10 13:47:39 +02:00
public List<String> tabComplete(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring, @Nullable BlockPosition blockposition) {
2016-02-29 22:32:46 +01:00
- return astring.length == 1 ? a(astring, minecraftserver.getPlayers()) : (astring.length > 1 && astring.length <= 4 ? a(astring, 1, blockposition) : (astring.length > 5 && astring.length <= 8 && "detect".equals(astring[4]) ? a(astring, 5, blockposition) : (astring.length == 9 && "detect".equals(astring[4]) ? a(astring, (Collection) Block.REGISTRY.keySet()) : Collections.emptyList())));
+ return astring.length == 1 ? a(astring, minecraftserver.getPlayers()) : (astring.length > 1 && astring.length <= 4 ? a(astring, 1, blockposition) : (astring.length > 5 && astring.length <= 8 && "detect".equals(astring[4]) ? a(astring, 5, blockposition) : (astring.length == 9 && "detect".equals(astring[4]) ? a(astring, (Collection) Block.REGISTRY.keySet()) : Collections.<String>emptyList()))); // CraftBukkit - decompile error
}
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
}