From b860a69d463a311a5dac3d02d2d3bf3314b679af Mon Sep 17 00:00:00 2001 From: cnr Date: Fri, 1 Sep 2017 23:14:26 -0500 Subject: [PATCH] Allow event hosts to use /game --- .../nautilus/game/arcade/ArcadeManager.java | 23 +++++++++---------- .../game/arcade/command/GameCommand.java | 22 ++++++++++++++---- .../game/arcade/command/SetCommand.java | 7 +++++- .../game/arcade/command/StartCommand.java | 7 +++++- .../game/arcade/command/StopCommand.java | 7 +++++- 5 files changed, 46 insertions(+), 20 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index bd832a5a7..6856d6a1e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -179,9 +179,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation KIT_UNLOCK_COMMAND, TAUNT_COMMAND, GAME_COMMAND, - SET_GAME_COMMAND, - START_GAME_COMMAND, - STOP_GAME_COMMAND, AUTO_OP, KIT_ACCESS, FEATURED_SERVER, @@ -627,19 +624,10 @@ public class ArcadeManager extends MiniPlugin implements IRelation PermissionGroup.CONTENT.setPermission(Perm.KIT_UNLOCK_COMMAND, true, true); PermissionGroup.PLAYER.setPermission(Perm.TAUNT_COMMAND, true, true); PermissionGroup.ADMIN.setPermission(Perm.GAME_COMMAND, true, true); - PermissionGroup.ADMIN.setPermission(Perm.SET_GAME_COMMAND, true, true); - PermissionGroup.ADMIN.setPermission(Perm.START_GAME_COMMAND, true, true); - PermissionGroup.ADMIN.setPermission(Perm.STOP_GAME_COMMAND, true, true); if (UtilServer.isTestServer()) { PermissionGroup.QA.setPermission(Perm.GAME_COMMAND, true, true); - PermissionGroup.QA.setPermission(Perm.SET_GAME_COMMAND, true, true); - PermissionGroup.QA.setPermission(Perm.START_GAME_COMMAND, true, true); - PermissionGroup.QA.setPermission(Perm.STOP_GAME_COMMAND, true, true); PermissionGroup.MAPLEAD.setPermission(Perm.GAME_COMMAND, false, true); - PermissionGroup.MAPLEAD.setPermission(Perm.SET_GAME_COMMAND, false, true); - PermissionGroup.MAPLEAD.setPermission(Perm.START_GAME_COMMAND, false, true); - PermissionGroup.MAPLEAD.setPermission(Perm.STOP_GAME_COMMAND, false, true); } if (UtilServer.isTestServer() || UtilServer.isDevServer()) { @@ -925,6 +913,17 @@ public class ArcadeManager extends MiniPlugin implements IRelation return true; } + public boolean canPlayerUseGameCmd(Player player) + { + if (!GetClients().Get(player).hasPermission(Perm.GAME_COMMAND) && !(_gameHostManager.isEventServer() && _gameHostManager.isAdmin(player, false))) + { + player.sendMessage(F.main("Game", "You are not allowed to use game commands.")); + return false; + } + + return true; + } + @EventHandler public void StaffIncognito(IncognitoStatusChangeEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCommand.java index d1fde493e..c75e46ec9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCommand.java @@ -3,6 +3,8 @@ package nautilus.game.arcade.command; import org.bukkit.ChatColor; import org.bukkit.entity.Player; +import mineplex.core.account.permissions.Permission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.command.MultiCommandBase; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -14,21 +16,31 @@ import static nautilus.game.arcade.command.SetCommand.SOURCE_PREFIX; public class GameCommand extends MultiCommandBase { + public enum Perm implements Permission + { + GAME_COMMAND_DUMMY_PERM, + } + public GameCommand(ArcadeManager plugin) { - super(plugin, ArcadeManager.Perm.GAME_COMMAND, "game"); + super(plugin, Perm.GAME_COMMAND_DUMMY_PERM, "game"); AddCommand(new StartCommand(Plugin)); AddCommand(new StopCommand(Plugin)); AddCommand(new SetCommand(Plugin)); + + PermissionGroup.PLAYER.setPermission(Perm.GAME_COMMAND_DUMMY_PERM, true, true); } @Override protected void Help(Player caller, String[] args) { - UtilPlayer.message(caller, F.main("Game", "Available Commands")); - UtilPlayer.message(caller, F.help("/game start", "Start the current game", ChatColor.DARK_RED)); - UtilPlayer.message(caller, F.help("/game stop", "Stop the current game", ChatColor.DARK_RED)); - caller.sendMessage(F.help(String.format("/game set [%s(gamemode)] [%s(mapsource)] [%s(mapname)]", MODE_PREFIX, SOURCE_PREFIX, MAP_PREFIX), "Set the current game or next game", ChatColor.DARK_RED)); + if (!Plugin.canPlayerUseGameCmd(caller)) + { + UtilPlayer.message(caller, F.main("Game", "Available Commands")); + UtilPlayer.message(caller, F.help("/game start", "Start the current game", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/game stop", "Stop the current game", ChatColor.DARK_RED)); + caller.sendMessage(F.help(String.format("/game set [%s(gamemode)] [%s(mapsource)] [%s(mapname)]", MODE_PREFIX, SOURCE_PREFIX, MAP_PREFIX), "Set the current game or next game", ChatColor.DARK_RED)); + } } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java index 7bc228eeb..fe716f1c9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java @@ -26,12 +26,17 @@ public class SetCommand extends CommandBase public SetCommand(ArcadeManager plugin) { - super(plugin, ArcadeManager.Perm.SET_GAME_COMMAND, "set"); + super(plugin, GameCommand.Perm.GAME_COMMAND_DUMMY_PERM, "set"); } @Override public void Execute(Player caller, String[] args) { + if (!Plugin.canPlayerUseGameCmd(caller)) + { + return; + } + if (Plugin.GetGame() == null) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java index 9ae7feb17..dab44fb83 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java @@ -13,12 +13,17 @@ public class StartCommand extends CommandBase { public StartCommand(ArcadeManager plugin) { - super(plugin, ArcadeManager.Perm.START_GAME_COMMAND, "start"); + super(plugin, GameCommand.Perm.GAME_COMMAND_DUMMY_PERM, "start"); } @Override public void Execute(Player caller, String[] args) { + if (!Plugin.canPlayerUseGameCmd(caller)) + { + return; + } + if (Plugin.GetGame() == null || Plugin.GetGame().GetState() == GameState.Loading) { UtilPlayer.message(caller, F.main("Game", "The game is currently loading, it cannot be started!")); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StopCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StopCommand.java index 333693168..e4af7ab35 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StopCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StopCommand.java @@ -14,12 +14,17 @@ public class StopCommand extends CommandBase { public StopCommand(ArcadeManager plugin) { - super(plugin, ArcadeManager.Perm.STOP_GAME_COMMAND, "stop"); + super(plugin, GameCommand.Perm.GAME_COMMAND_DUMMY_PERM, "stop"); } @Override public void Execute(Player caller, String[] args) { + if (!Plugin.canPlayerUseGameCmd(caller)) + { + return; + } + if (Plugin.GetGame() == null) { UtilPlayer.message(caller, F.main("Game", "There is no game to stop!"));