diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java index 71ce6d0a5..d2a53c936 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java @@ -37,6 +37,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerToggleFlightEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index b779723c5..05331fbc1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.managers; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; import mineplex.core.common.Rank; @@ -32,6 +33,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.Plugin; public class GameHostManager implements Listener { @@ -58,6 +60,8 @@ public class GameHostManager implements Listener private boolean _isEventServer = false; + private HashMap _permissionMap = new HashMap(); + public GameHostManager(ArcadeManager manager) { Manager = manager; @@ -144,11 +148,17 @@ public class GameHostManager implements Listener _host = event.getPlayer(); _hostRank = Manager.GetClients().Get(_host).GetRank(); System.out.println("Game Host Joined."); + + if (isEventServer()) + worldeditPermissionSet(event.getPlayer(), true); } else if (isAdmin(event.getPlayer(), false)) { System.out.println("Admin Joined."); _onlineAdmins.add(event.getPlayer()); + + if (isEventServer()) + worldeditPermissionSet(event.getPlayer(), true); } } @@ -162,10 +172,31 @@ public class GameHostManager implements Listener { System.out.println("Game Host Quit."); _host = null; + + if (isEventServer()) + worldeditPermissionSet(event.getPlayer(), false); } else if (isAdmin(event.getPlayer(), false)) { _onlineAdmins.remove(event.getPlayer()); + + if (isEventServer()) + worldeditPermissionSet(event.getPlayer(), false); + } + } + + public void worldeditPermissionSet(Player player, boolean hasPermission) + { + if (!_permissionMap.containsKey(player) || _permissionMap.get(player) != hasPermission) + { + for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) + { + player.addAttachment(plugin, "worldedit.*", hasPermission); + } + + _permissionMap.put(player, hasPermission); + + UtilPlayer.message(player, "World Edit Permissions: " + F.tf(hasPermission)); } } @@ -431,6 +462,9 @@ public class GameHostManager implements Listener _adminList.add(player.getName()); _onlineAdmins.add(player); UtilPlayer.message(player, F.main("Server", "You were given admin privileges.")); + + if (isEventServer()) + worldeditPermissionSet(player, true); } public void removeAdmin(String playerName) @@ -448,6 +482,9 @@ public class GameHostManager implements Listener UtilPlayer.message(player, F.main("Server", "Your admin privileges were removed.")); player.setGameMode(GameMode.SURVIVAL); + + if (isEventServer()) + worldeditPermissionSet(player, false); } }