--- a/net/minecraft/server/CommandExecute.java +++ b/net/minecraft/server/CommandExecute.java @@ -4,6 +4,10 @@ import java.util.Collections; import java.util.List; import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.command.ProxiedNativeCommandSender; +import org.bukkit.craftbukkit.command.VanillaCommandWrapper; +// CraftBukkit end public class CommandExecute extends CommandAbstract { @@ -59,26 +63,61 @@ } String s = a(astring, b0); - CommandListenerWrapper commandlistenerwrapper = CommandListenerWrapper.a(icommandlistener).a(entity, new Vec3D(d0, d1, d2)).a(minecraftserver.worldServer[0].getGameRules().getBoolean("commandBlockOutput")); + CommandListenerWrapper commandlistenerwrapper = CommandListenerWrapper.a(icommandlistener).a(entity, new Vec3D(d0, d1, d2)).a(minecraftserver.worlds.get(0).getGameRules().getBoolean("commandBlockOutput")); // CraftBukkit ICommandHandler icommandhandler = minecraftserver.getCommandHandler(); try { - int i = icommandhandler.a(commandlistenerwrapper, s); + // CraftBukkit start + org.bukkit.command.CommandSender sender = null; + ICommandListener listener = icommandlistener; + while (sender == null) { + if (listener instanceof DedicatedServer) { + sender = minecraftserver.console; + } else if (listener instanceof RemoteControlCommandListener) { + sender = minecraftserver.remoteConsole; + } else if (listener instanceof CommandBlockListenerAbstract) { + sender = ((CommandBlockListenerAbstract) listener).sender; + } else if (listener instanceof CustomFunctionData.CustomFunctionListener) { + sender = ((CustomFunctionData.CustomFunctionListener) listener).sender; + } else if (listener instanceof CommandListenerWrapper) { + listener = ((CommandListenerWrapper) listener).base; // Search deeper + } 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]); + } + } + int i = CommandBlockListenerAbstract.executeCommand(commandlistenerwrapper, new ProxiedNativeCommandSender(commandlistenerwrapper, sender, entity.getBukkitEntity()), s); + // CraftBukkit end if (i < 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()}); } } } public List tabComplete(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring, @Nullable BlockPosition blockposition) { - 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.emptyList()))); // CraftBukkit - decompile error } public boolean isListStart(String[] astring, int i) { return i == 0; } + + // CraftBukkit start - fix decompiler error + @Override + public int compareTo(ICommand o) { + return a((ICommand) o); + } + // CraftBukkit end }