mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-11 19:56:52 +01:00
65 lines
3.4 KiB
Diff
65 lines
3.4 KiB
Diff
--- a/net/minecraft/server/CommandExecute.java
|
|
+++ b/net/minecraft/server/CommandExecute.java
|
|
@@ -3,6 +3,10 @@
|
|
import java.util.Collection;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
+// CraftBukkit start
|
|
+import org.bukkit.craftbukkit.command.ProxiedNativeCommandSender;
|
|
+import org.bukkit.craftbukkit.command.VanillaCommandWrapper;
|
|
+// CraftBukkit end
|
|
|
|
public class CommandExecute extends CommandAbstract {
|
|
|
|
@@ -97,22 +101,48 @@
|
|
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;
|
|
+ } else if (VanillaCommandWrapper.lastSender != null) {
|
|
+ sender = VanillaCommandWrapper.lastSender;
|
|
+ }else if (icommandlistener.f() != null) {
|
|
+ sender = icommandlistener.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
|
|
|
|
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()});
|
|
}
|
|
}
|
|
}
|
|
|
|
public List<String> tabComplete(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring, 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.<String>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
|
|
}
|