mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-22 00:04:59 +01:00
SPIGOT-2134: Support /execute being chained
This commit is contained in:
parent
f060bba1ca
commit
a4786c824f
1 changed files with 32 additions and 11 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Reference in a new issue