summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2018-07-19 10:58:31 +1000
committermd_5 <git@md-5.net>2018-07-19 10:59:16 +1000
commitfc1b107579cf85654e84cbaf074dd5eaceeae3c6 (patch)
tree45668e346c40f25123a4c6d9d6aab12b37490b97 /src
parent80f4c10c8f863658ec21bd81fa7d7c825456b89e (diff)
downloadcraftbukkit-fc1b107579cf85654e84cbaf074dd5eaceeae3c6.tar
craftbukkit-fc1b107579cf85654e84cbaf074dd5eaceeae3c6.tar.gz
craftbukkit-fc1b107579cf85654e84cbaf074dd5eaceeae3c6.tar.lz
craftbukkit-fc1b107579cf85654e84cbaf074dd5eaceeae3c6.tar.xz
craftbukkit-fc1b107579cf85654e84cbaf074dd5eaceeae3c6.zip
SPIGOT-4046: Fix selectors in tick functions
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java
index f6bc346c..b57eb251 100644
--- a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java
+++ b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java
@@ -12,6 +12,7 @@ import net.minecraft.server.CommandListenerWrapper;
import net.minecraft.server.DedicatedServer;
import net.minecraft.server.EntityMinecartCommandBlock;
import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.WorldServer;
import org.apache.commons.lang.Validate;
import org.bukkit.Location;
import org.bukkit.command.BlockCommandSender;
@@ -64,6 +65,35 @@ public final class VanillaCommandWrapper extends BukkitCommand {
return results;
}
+ public static class WorldRescueContext {
+
+ private WorldServer[] prev;
+
+ public WorldRescueContext start(WorldServer def) {
+ // Some commands use the worldserver variable but we leave it full of null values,
+ // so we must temporarily populate it with the world of the commandsender
+ prev = MinecraftServer.getServer().worldServer;
+ MinecraftServer server = MinecraftServer.getServer();
+ server.worldServer = new WorldServer[server.worlds.size()];
+ server.worldServer[0] = def;
+ int bpos = 0;
+ for (int pos = 1; pos < server.worldServer.length; pos++) {
+ WorldServer world = server.worlds.get(bpos++);
+ if (server.worldServer[0] == world) {
+ pos--;
+ continue;
+ }
+ server.worldServer[pos] = world;
+ }
+
+ return this;
+ }
+
+ public void end() {
+ MinecraftServer.getServer().worldServer = prev;
+ }
+ }
+
private CommandListenerWrapper getListener(CommandSender sender) {
if (sender instanceof Player) {
return ((CraftPlayer) sender).getHandle().getCommandListener();