summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThinkofdeath <thinkofdeath@spigotmc.org>2015-01-25 15:17:48 +0000
committerThinkofdeath <thinkofdeath@spigotmc.org>2015-01-25 15:17:48 +0000
commit15e81cf551facaee9e808b598655a6cf1274ffb1 (patch)
tree43d4dcc4ec9c3e7747808d7e56ce874ccfbdc35a /src
parent4b6df5adfeb92cd09428e59a963a6ee56d7d28d6 (diff)
downloadcraftbukkit-15e81cf551facaee9e808b598655a6cf1274ffb1.tar
craftbukkit-15e81cf551facaee9e808b598655a6cf1274ffb1.tar.gz
craftbukkit-15e81cf551facaee9e808b598655a6cf1274ffb1.tar.lz
craftbukkit-15e81cf551facaee9e808b598655a6cf1274ffb1.tar.xz
craftbukkit-15e81cf551facaee9e808b598655a6cf1274ffb1.zip
SPIGOT-449: Fix the wrong caller being used in chain execute commands
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java
index 2e85c12b..5be09a34 100644
--- a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java
+++ b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java
@@ -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,7 +88,9 @@ 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;
} else {
@@ -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;
}