Skip to content

Commit

Permalink
Use command block's world for /gamerule. Fixes BUKKIT-3274
Browse files Browse the repository at this point in the history
In vanilla, gamerules are global, across all worlds. Maps created for
vanilla that use command blocks expect this behavior, which is broken
when they are placed on a world that is not the default world (world #0).

This commit changes that by using the command block's current world when
executing the command, forcing the game rules executed to be executed in
the world the command block is currently in.
  • Loading branch information
riking authored and turt2live committed Aug 21, 2013
1 parent 91d0f8b commit 47ef04f
Showing 1 changed file with 3 additions and 0 deletions.
Expand Up @@ -3,6 +3,7 @@
import com.google.common.collect.ImmutableList;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.util.StringUtil;
Expand Down Expand Up @@ -61,6 +62,8 @@ private World getGameWorld(CommandSender sender) {
if (world != null) {
return world;
}
} else if (sender instanceof BlockCommandSender) {
return ((BlockCommandSender) sender).getBlock().getWorld();
}

return Bukkit.getWorlds().get(0);
Expand Down

0 comments on commit 47ef04f

Please sign in to comment.