3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 12:30:06 +01:00

SPIGOT-2134: Support /execute being chained

Dieser Commit ist enthalten in:
Thinkofname 2016-04-20 11:24:48 +01:00
Ursprung f060bba1ca
Commit a4786c824f

Datei anzeigen

@ -11,23 +11,44 @@
public class CommandExecute extends CommandAbstract { public class CommandExecute extends CommandAbstract {
@@ -97,22 +101,48 @@ @@ -49,7 +53,10 @@
}
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();
}
@@ -94,25 +101,57 @@
return entity.h();
}
};
+ ICommandListener icommandlistener1 = new ProxyListener(); // CraftBukkit
ICommandHandler icommandhandler = minecraftserver.getCommandHandler(); ICommandHandler icommandhandler = minecraftserver.getCommandHandler();
try { try {
- int j = icommandhandler.a(icommandlistener1, s); - int j = icommandhandler.a(icommandlistener1, s);
+ // CraftBukkit start + // CraftBukkit start
+ org.bukkit.command.CommandSender sender = null; + org.bukkit.command.CommandSender sender = null;
+ if (icommandlistener instanceof DedicatedServer) { + ICommandListener listener = icommandlistener;
+ sender = MinecraftServer.getServer().server.getConsoleSender(); + while (sender == null) {
+ } else if (icommandlistener instanceof CommandBlockListenerAbstract) { + if (listener instanceof DedicatedServer) {
+ sender = ((CommandBlockListenerAbstract) icommandlistener).sender; + sender = minecraftserver.server.getConsoleSender();
+ } else if (VanillaCommandWrapper.lastSender != null) { + } else if (listener instanceof CommandBlockListenerAbstract) {
+ sender = VanillaCommandWrapper.lastSender; + sender = ((CommandBlockListenerAbstract) listener).sender;
+ }else if (icommandlistener.f() != null) { + } else if (listener instanceof ProxyListener) {
+ sender = icommandlistener.f().getBukkitEntity(); + listener = ((ProxyListener) icommandlistener).base; // Search deeper
+ } else { + } else if (VanillaCommandWrapper.lastSender != null) {
+ throw new CommandException("Unhandled executor " + icommandlistener.getClass().getSimpleName(), new Object[0]); + 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 j = CommandBlockListenerAbstract.executeCommand(icommandlistener1, new ProxiedNativeCommandSender(icommandlistener1, sender, entity.getBukkitEntity()), s); + int j = CommandBlockListenerAbstract.executeCommand(icommandlistener1, new ProxiedNativeCommandSender(icommandlistener1, sender, entity.getBukkitEntity()), s);
+ // CraftBukkit end + // CraftBukkit end