3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 04:20:08 +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,24 +11,45 @@
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();
try {
- int j = icommandhandler.a(icommandlistener1, s);
+ // CraftBukkit start
+ org.bukkit.command.CommandSender sender = null;
+ if (icommandlistener instanceof DedicatedServer) {
+ sender = MinecraftServer.getServer().server.getConsoleSender();
+ } else if (icommandlistener instanceof CommandBlockListenerAbstract) {
+ sender = ((CommandBlockListenerAbstract) icommandlistener).sender;
+ ICommandListener listener = icommandlistener;
+ while (sender == null) {
+ if (listener instanceof DedicatedServer) {
+ sender = minecraftserver.server.getConsoleSender();
+ } else if (listener instanceof CommandBlockListenerAbstract) {
+ sender = ((CommandBlockListenerAbstract) listener).sender;
+ } else if (listener instanceof ProxyListener) {
+ listener = ((ProxyListener) icommandlistener).base; // Search deeper
+ } else if (VanillaCommandWrapper.lastSender != null) {
+ sender = VanillaCommandWrapper.lastSender;
+ }else if (icommandlistener.f() != null) {
+ sender = icommandlistener.f().getBukkitEntity();
+ } 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);
+ // CraftBukkit end