Archiviert
13
0

SPIGOT-449: Fix the wrong caller being used in chain execute commands

Dieser Commit ist enthalten in:
Thinkofdeath 2015-01-25 15:17:48 +00:00
Ursprung 4b6df5adfe
Commit 15e81cf551
3 geänderte Dateien mit 30 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -1,5 +1,5 @@
--- ../work/decompile-8eb82bde//net/minecraft/server/CommandBlockListenerAbstract.java 2014-12-27 14:58:24.901254690 +0000
+++ src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java 2014-12-27 14:58:24.905254690 +0000
--- ../work/decompile-8eb82bde//net/minecraft/server/CommandBlockListenerAbstract.java 2015-01-25 15:16:21.156837700 +0000
+++ src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java 2015-01-25 15:16:21.156837700 +0000
@@ -4,6 +4,13 @@
import java.util.Date;
import java.util.concurrent.Callable;
@ -82,7 +82,7 @@
+ if (!((VanillaCommandWrapper) commandBlockCommand).testPermission(bSender)) {
+ return 0;
+ }
+ return ((VanillaCommandWrapper) commandBlockCommand).dispatchVanillaCommand(sender, as);
+ return ((VanillaCommandWrapper) commandBlockCommand).dispatchVanillaCommand(bSender, sender, as);
+ }
+
+ // Make sure this is a valid command

Datei anzeigen

@ -1,14 +1,17 @@
--- ../work/decompile-8eb82bde//net/minecraft/server/CommandExecute.java 2015-01-04 23:24:40.781538505 +0000
+++ src/main/java/net/minecraft/server/CommandExecute.java 2015-01-04 23:24:40.781538505 +0000
@@ -2,6 +2,7 @@
--- ../work/decompile-8eb82bde//net/minecraft/server/CommandExecute.java 2015-01-25 15:16:56.720837314 +0000
+++ src/main/java/net/minecraft/server/CommandExecute.java 2015-01-25 15:16:56.720837314 +0000
@@ -2,6 +2,10 @@
import java.util.Collection;
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 {
@@ -19,7 +20,7 @@
@@ -19,7 +23,7 @@
return "commands.execute.usage";
}
@ -17,7 +20,7 @@
if (astring.length < 5) {
throw new ExceptionUsage("commands.execute.usage", new Object[0]);
} else {
@@ -52,12 +53,28 @@
@@ -52,12 +56,30 @@
ICommandHandler icommandhandler = MinecraftServer.getServer().getCommandHandler();
try {
@ -25,12 +28,14 @@
-
+ // CraftBukkit start
+ org.bukkit.command.CommandSender sender = null;
+ if (icommandlistener.f() != null) {
+ sender = icommandlistener.f().getBukkitEntity();
+ } else if (icommandlistener instanceof DedicatedServer) {
+ if (icommandlistener instanceof DedicatedServer) {
+ sender = MinecraftServer.getServer().server.getConsoleSender();
+ } else if (icommandlistener instanceof TileEntityCommandListener) {
+ sender = ((TileEntityCommandListener) 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]);
+ }
@ -48,7 +53,7 @@
throw new CommandException("commands.execute.failed", new Object[] { s, entity.getName()});
}
}
@@ -70,4 +87,11 @@
@@ -70,4 +92,11 @@
public boolean isListStart(String[] astring, int i) {
return i == 0;
}

Datei anzeigen

@ -10,6 +10,7 @@ import org.apache.logging.log4j.Level;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.ProxiedCommandSender;
import org.bukkit.command.RemoteConsoleCommandSender;
import org.bukkit.command.defaults.*;
import org.bukkit.craftbukkit.CraftServer;
@ -39,7 +40,7 @@ public final class VanillaCommandWrapper extends VanillaCommand {
if (!testPermission(sender)) return true;
ICommandListener icommandlistener = getListener(sender);
dispatchVanillaCommand(icommandlistener, args);
dispatchVanillaCommand(sender, icommandlistener, args);
return true;
}
@ -51,7 +52,9 @@ public final class VanillaCommandWrapper extends VanillaCommand {
return (List<String>) vanillaCommand.tabComplete(getListener(sender), args, new BlockPosition(0, 0, 0));
}
public final int dispatchVanillaCommand(ICommandListener icommandlistener, String[] as) {
public static CommandSender lastSender = null; // Nasty :(
public final int dispatchVanillaCommand(CommandSender bSender, ICommandListener icommandlistener, String[] as) {
// Copied from net.minecraft.server.CommandHandler
int i = getPlayerListSize(as);
int j = 0;
@ -71,6 +74,8 @@ public final class VanillaCommandWrapper extends VanillaCommand {
while (iterator.hasNext()) {
Entity entity = iterator.next();
CommandSender oldSender = lastSender;
lastSender = bSender;
try {
as[i] = entity.getUniqueID().toString();
vanillaCommand.execute(icommandlistener, as);
@ -83,6 +88,8 @@ public final class VanillaCommandWrapper extends VanillaCommand {
ChatMessage chatmessage = new ChatMessage(commandexception.getMessage(), commandexception.getArgs());
chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
icommandlistener.sendMessage(chatmessage);
} finally {
lastSender = oldSender;
}
}
as[i] = s2;
@ -140,6 +147,9 @@ public final class VanillaCommandWrapper extends VanillaCommand {
if (sender instanceof ConsoleCommandSender) {
return ((CraftServer) sender.getServer()).getServer();
}
if (sender instanceof ProxiedCommandSender) {
return ((ProxiedNativeCommandSender) sender).getHandle();
}
return null;
}