From b860a69d463a311a5dac3d02d2d3bf3314b679af Mon Sep 17 00:00:00 2001 From: cnr Date: Fri, 1 Sep 2017 23:14:26 -0500 Subject: [PATCH 1/3] 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!")); From 871f178419ee77562a86bb7d26153bb39cf8bee2 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 2 Sep 2017 17:08:29 -0400 Subject: [PATCH 2/3] Update ranks sql system to block a race condition and improve performance --- .../account/repository/AccountRepository.java | 46 +++++++++++-------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java index 9129d4a85..cbfb7a1c5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java @@ -42,7 +42,7 @@ public class AccountRepository extends MinecraftRepository private static String CREATE_RANKS_TABLE = "CREATE TABLE IF NOT EXISTS accountRanks (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, rankIdentifier VARCHAR(40), primaryGroup BOOL, PRIMARY KEY(id), INDEX accountIndex (accountId), INDEX rankIndex (rankIdentifier), UNIQUE INDEX additionalIndex (accountId, rankIdentifier, primaryGroup), FOREIGN KEY (accountId) REFERENCES accounts(id));"; private static String UPDATE_PRIMARY_RANK = "UPDATE accountRanks SET rankIdentifier=? WHERE accountId=? AND primaryGroup=true;"; - private static String ADD_PRIMARY_RANK = "INSERT INTO accountRanks (accountId, rankIdentifier, primaryGroup) VALUES (?, NULL, true);"; + private static String ADD_PRIMARY_RANK = "INSERT INTO accountRanks (accountId, rankIdentifier, primaryGroup) VALUES (?, 'NULL', true);"; private static String ADD_ADDITIONAL_RANK = "INSERT INTO accountRanks (accountId, rankIdentifier, primaryGroup) VALUES (?, ?, false);"; private static String REMOVE_ADDITIONAL_RANK = "DELETE FROM accountRanks WHERE accountId=? AND rankIdentifier=? AND primaryGroup=false;"; private static String REMOVE_ADDITIONAL_RANKS = "DELETE FROM accountRanks WHERE accountId=? AND primaryGroup=false;"; @@ -100,11 +100,10 @@ public class AccountRepository extends MinecraftRepository statement.execute("SELECT * FROM accountRanks WHERE accountId=" + accountId + ";"); try (ResultSet rankSet = statement.getResultSet()) { - boolean anyRows = false; while (rankSet.next()) { - anyRows = true; - PermissionGroup group = PermissionGroup.valueOf(rankSet.getString("rankIdentifier")); + String identifier = rankSet.getString("rankIdentifier"); + PermissionGroup group = identifier.equals("NULL") ? null : PermissionGroup.valueOf(identifier); boolean primary = rankSet.getBoolean("primaryGroup"); if (primary) @@ -113,14 +112,12 @@ public class AccountRepository extends MinecraftRepository } else { - extraRanks.add(group); + if (group != null) + { + extraRanks.add(group); + } } } - - if (!anyRows) - { - statement.execute(UPDATE_PRIMARY_RANK.replace("?", "" + accountId)); - } } final int finalId = accountId; @@ -239,7 +236,7 @@ public class AccountRepository extends MinecraftRepository { if (!rs.next() || rs.getInt(1) == 0) { - s.execute(ADD_PRIMARY_RANK.replace("?", "" + accountId)); + s.execute(ADD_PRIMARY_RANK.replace("?", String.valueOf(accountId))); } } @@ -341,13 +338,7 @@ public class AccountRepository extends MinecraftRepository { try (Statement s = c.createStatement()) { - try (ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM accountRanks WHERE accountId=" + accountId + " AND primaryGroup=true;")) - { - if (!rs.next()) - { - s.execute(ADD_PRIMARY_RANK.replace("?", "" + accountId)); - } - } + int primaryFound = 0; try (ResultSet rs = s.executeQuery("SELECT * FROM accountRanks WHERE accountId=" + accountId + ";")) { while (rs.next()) @@ -356,11 +347,19 @@ public class AccountRepository extends MinecraftRepository { removed.add(PermissionGroup.valueOf(rs.getString("rankIdentifier"))); } + else + { + primaryFound++; + } } } + if (primaryFound < 1) + { + s.execute(ADD_PRIMARY_RANK.replace("?", String.valueOf(accountId))); + } } - executeUpdate(c, UPDATE_PRIMARY_RANK, () -> {}, new ColumnVarChar("rankIdentifier", 255, "PLAYER"), new ColumnInt("accountId", accountId)); + executeUpdate(c, UPDATE_PRIMARY_RANK, () -> {}, new ColumnVarChar("rankIdentifier", 255, PermissionGroup.PLAYER.name()), new ColumnInt("accountId", accountId)); executeUpdate(c, REMOVE_ADDITIONAL_RANKS, () -> success.set(false), new ColumnInt("accountId", accountId)); } catch (SQLException e) @@ -406,7 +405,14 @@ public class AccountRepository extends MinecraftRepository { if (rs.getBoolean("primaryGroup")) { - primary.set(PermissionGroup.valueOf(rs.getString("rankIdentifier"))); + if (rs.getString("rankIdentifier").equals("NULL")) + { + primary.set(null); + } + else + { + primary.set(PermissionGroup.valueOf(rs.getString("rankIdentifier"))); + } } else { From 64c2c65bd0fc5c7e29c0fbc783cbb889a116771d Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 2 Sep 2017 20:03:28 -0400 Subject: [PATCH 3/3] Fix debug permissions --- .../game/arcade/game/DebugCommand.java | 1 - .../src/nautilus/game/arcade/game/Game.java | 6 +++++- .../game/arcade/game/games/bridge/Bridge.java | 5 +++-- .../arcade/game/games/event/EventModule.java | 2 +- .../game/arcade/game/games/moba/Moba.java | 3 ++- .../game/games/moba/gold/GoldManager.java | 3 ++- .../game/games/moba/minion/MinionManager.java | 3 ++- .../moba/progression/MobaProgression.java | 5 +++-- .../games/moba/training/MobaTraining.java | 3 ++- .../arcade/game/games/smash/SuperSmash.java | 11 ++++++----- .../games/speedbuilders/SpeedBuilders.java | 3 ++- .../arcade/game/games/typewars/TypeWars.java | 5 +++-- .../game/arcade/game/games/uhc/UHC.java | 19 ++++++++++--------- .../arcade/game/modules/RejoinModule.java | 3 ++- 14 files changed, 43 insertions(+), 29 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/DebugCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/DebugCommand.java index 84d6aa518..dcc19814f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/DebugCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/DebugCommand.java @@ -5,7 +5,6 @@ import org.bukkit.entity.Player; import mineplex.core.Managers; import mineplex.core.account.permissions.Permission; import mineplex.core.command.CommandBase; - import nautilus.game.arcade.ArcadeManager; public class DebugCommand extends CommandBase diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index bd7caafef..40f5d157e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -537,9 +537,13 @@ public abstract class Game extends ListenerComponent implements Lifetimed } } - public & Permission> void registerDebugCommand(String commandName, T permission, DebugCommandExecutor executor) + public & Permission> void registerDebugCommand(String commandName, T permission, PermissionGroup defaultRank, DebugCommandExecutor executor) { DebugCommand command = new DebugCommand(commandName, permission, executor); + if (defaultRank != null) + { + defaultRank.setPermission(permission, true, true); + } if (UtilServer.isTestServer()) { PermissionGroup.QA.setPermission(permission, true, true); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java index 0defbd396..831f41ecc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java @@ -46,6 +46,7 @@ import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.util.Vector; import mineplex.core.account.permissions.Permission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -274,13 +275,13 @@ public class Bridge extends TeamGame implements OreObsfucation } } - registerDebugCommand("bridge", Perm.DEBUG_BRIDGE_COMMAND, (caller, args) -> + registerDebugCommand("bridge", Perm.DEBUG_BRIDGE_COMMAND, PermissionGroup.ADMIN, (caller, args) -> { caller.sendMessage(F.main("Debug", "Spawning the bridges.")); _bridgeTime = 3000; }); - registerDebugCommand("bridgeinfo", Perm.DEBUG_BRIDGEINFO_COMMAND, (caller, args) -> + registerDebugCommand("bridgeinfo", Perm.DEBUG_BRIDGEINFO_COMMAND, PermissionGroup.ADMIN, (caller, args) -> { if (_animation == null || !(_animation instanceof CustomBridgeAnimation)) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java index 053d7bdae..3e1891684 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java @@ -108,7 +108,7 @@ public class EventModule extends MiniPlugin PermissionGroup.ADMIN.setPermission(Perm.SET_HOST_COMMAND, true, true); if (_plugin.getConfig().getString("serverstatus.name").equals("SMTestServer-1")) { - PermissionGroup.QA.setPermission(Perm.SET_HOST_COMMAND, true, true); + PermissionGroup.SRMOD.setPermission(Perm.SET_HOST_COMMAND, true, true); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 501ff5469..9dfab4c01 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -27,6 +27,7 @@ import com.mineplex.anticheat.checks.move.Speed; import mineplex.core.Managers; import mineplex.core.account.permissions.Permission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.antihack.AntiHack; import mineplex.core.common.Pair; import mineplex.core.common.util.F; @@ -172,7 +173,7 @@ public class Moba extends TeamGame .setGiveCompassToAlive(false) .register(this); - registerDebugCommand("kit", Perm.DEBUG_KIT_COMMAND, (caller, args) -> + registerDebugCommand("kit", Perm.DEBUG_KIT_COMMAND, PermissionGroup.ADMIN, (caller, args) -> { StringBuilder builder = new StringBuilder(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java index 32de630a6..2b56c9eda 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java @@ -9,6 +9,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.account.permissions.Permission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.updater.UpdateType; @@ -44,7 +45,7 @@ public class GoldManager implements Listener _playerGold = new HashMap<>(); - host.registerDebugCommand("gold", Perm.DEBUG_GOLD_COMMAND, (caller, args) -> + host.registerDebugCommand("gold", Perm.DEBUG_GOLD_COMMAND, PermissionGroup.ADMIN, (caller, args) -> { if (args.length < 1) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index 75217b8c1..be066d671 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -15,6 +15,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import mineplex.core.account.permissions.Permission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -51,7 +52,7 @@ public class MinionManager implements Listener _waves = new HashSet<>(); _enabled = true; - host.registerDebugCommand("removeminions", Perm.DEBUG_REMOVEMINIONS_COMMAND, (caller, args) -> + host.registerDebugCommand("removeminions", Perm.DEBUG_REMOVEMINIONS_COMMAND, PermissionGroup.DEV, (caller, args) -> { for (MinionWave wave : _waves) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java index 66f7b2bd1..ad0266d3f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java @@ -18,6 +18,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import mineplex.core.account.permissions.Permission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -67,13 +68,13 @@ public class MobaProgression implements Listener _roleViewers = new HashMap<>(); _roleShop = new MobaRoleShop(host.getArcadeManager()); - host.registerDebugCommand("fakeexp", Perm.DEBUG_FAKEEXP_COMMAND, (caller, args) -> + host.registerDebugCommand("fakeexp", Perm.DEBUG_FAKEEXP_COMMAND, PermissionGroup.DEV, (caller, args) -> { int exp = Integer.parseInt(args[0]); _host.GetGems(caller).put("Fake Exp", new GemData(exp, false)); caller.sendMessage(F.main("Debug", "Gave you " + F.elem(exp) + " fake exp.")); }); - host.registerDebugCommand("setmobalevel", Perm.DEBUG_SETMOBALEVEL_COMMAND, (caller, args) -> + host.registerDebugCommand("setmobalevel", Perm.DEBUG_SETMOBALEVEL_COMMAND, PermissionGroup.DEV, (caller, args) -> { MobaRole role = MobaRole.valueOf(args[0].toUpperCase()); int exp = getExpFor(Integer.parseInt(args[1]) - 1); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java index 7455fc567..7b0245de3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java @@ -25,6 +25,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.ItemStack; import mineplex.core.account.permissions.Permission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -194,7 +195,7 @@ public class MobaTraining extends Moba (int) (Math.ceil(subject.getHealth() / 2D))) .register(this); - registerDebugCommand("skip", Perm.DEBUG_SKIP_COMMAND, (caller, args) -> + registerDebugCommand("skip", Perm.DEBUG_SKIP_COMMAND, PermissionGroup.PLAYER, (caller, args) -> { if (!safeFunction.apply(caller)) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java index 467ebdb99..f984fb115 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java @@ -33,6 +33,7 @@ import org.bukkit.scheduler.BukkitRunnable; import com.google.common.collect.Sets; import mineplex.core.account.permissions.Permission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -147,7 +148,7 @@ public abstract class SuperSmash extends Game new PerkSpreadsheetModule(this, "SMASH_KITS"); - registerDebugCommand("cooldown", Perm.DEBUG_COOLDOWN_COMMAND, (caller, args) -> + registerDebugCommand("cooldown", Perm.DEBUG_COOLDOWN_COMMAND, PermissionGroup.ADMIN, (caller, args) -> { for (Player other : UtilServer.getPlayers()) { @@ -156,16 +157,16 @@ public abstract class SuperSmash extends Game Announce(C.cWhiteB + caller.getName() + C.cAquaB + " reset cooldowns!"); }); - registerDebugCommand("nextsmash", Perm.DEBUG_NEXTSMASH_COMMAND, (caller, args) -> + registerDebugCommand("nextsmash", Perm.DEBUG_NEXTSMASH_COMMAND, PermissionGroup.ADMIN, (caller, args) -> { _nextPowerup = System.currentTimeMillis() + 1000; Announce(C.cWhiteB + caller.getName() + C.cAquaB + " spawned a smash crystal!"); }); - registerDebugCommand("smash", Perm.DEBUG_SMASH_COMMAND, (caller, args) -> + registerDebugCommand("smash", Perm.DEBUG_SMASH_COMMAND, PermissionGroup.ADMIN, (caller, args) -> { giveSmashItem(caller); }); - registerDebugCommand("kit", Perm.DEBUG_KIT_COMMAND, (caller, args) -> + registerDebugCommand("kit", Perm.DEBUG_KIT_COMMAND, PermissionGroup.ADMIN, (caller, args) -> { String kit = ""; @@ -187,7 +188,7 @@ public abstract class SuperSmash extends Game caller.sendMessage(F.main("Kit", "Sorry that is not a kit!")); }); - registerDebugCommand("lives", Perm.DEBUG_LIVES_COMMAND, (caller, args) -> + registerDebugCommand("lives", Perm.DEBUG_LIVES_COMMAND, PermissionGroup.ADMIN, (caller, args) -> { Announce(C.cWhiteB + caller.getName() + C.cAquaB + " reset their lives!"); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java index 4183d54aa..658a779c2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java @@ -56,6 +56,7 @@ import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; import mineplex.core.account.permissions.Permission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; @@ -213,7 +214,7 @@ public class SpeedBuilders extends SoloGame .setGiveCompassToAlive(false) .register(this); - registerDebugCommand("setnext", Perm.DEBUG_SETNEXT_COMMAND, (caller, args) -> + registerDebugCommand("setnext", Perm.DEBUG_SETNEXT_COMMAND, PermissionGroup.BUILDER, (caller, args) -> { if (!UtilServer.isTestServer()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java index a1bc7f4c5..5702aadcb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java @@ -29,6 +29,7 @@ import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.util.Vector; import mineplex.core.account.permissions.Permission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -194,12 +195,12 @@ public class TypeWars extends TeamGame .giveHotbarItem() .register(this); - registerDebugCommand("money", Perm.DEBUG_MONEY_COMMAND, (caller, args) -> + registerDebugCommand("money", Perm.DEBUG_MONEY_COMMAND, PermissionGroup.ADMIN, (caller, args) -> { _moneyMap.put(caller, 1000); UtilPlayer.message(caller, F.main("Money", "You got some Money")); }); - registerDebugCommand("boss", Perm.DEBUG_BOSS_COMMAND, (caller, args) -> + registerDebugCommand("boss", Perm.DEBUG_BOSS_COMMAND, PermissionGroup.DEV, (caller, args) -> { if (!IsPlaying(caller)) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java index 4c9568e64..6819d2df6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java @@ -71,6 +71,7 @@ import org.bukkit.scoreboard.Objective; import org.spigotmc.ActivationRange; import mineplex.core.account.permissions.Permission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.boosters.event.BoosterItemGiveEvent; import mineplex.core.common.Pair; import mineplex.core.common.util.C; @@ -311,7 +312,7 @@ public abstract class UHC extends Game registerQuestTrackers(new TameQuestTracker(this)); - registerDebugCommand("startpvp", Perm.DEBUG_STARTPVP_COMMAND, (caller, args) -> + registerDebugCommand("startpvp", Perm.DEBUG_STARTPVP_COMMAND, PermissionGroup.ADMIN, (caller, args) -> { if (!IsLive()) { @@ -331,7 +332,7 @@ public abstract class UHC extends Game UtilPlayer.message(caller, F.main("Debug", "Started PvP")); }); - registerDebugCommand("worldinfo", Perm.DEBUG_WORLDINFO_COMMAND, (caller, args) -> + registerDebugCommand("worldinfo", Perm.DEBUG_WORLDINFO_COMMAND, PermissionGroup.ADMIN, (caller, args) -> { if (args == null || args.length == 0) { @@ -439,16 +440,16 @@ public abstract class UHC extends Game } return; }); - registerDebugCommand("uhcgames", Perm.DEBUG_UHCGAMES_COMMAND, (caller, args) -> + registerDebugCommand("uhcgames", Perm.DEBUG_UHCGAMES_COMMAND, PermissionGroup.ADMIN, (caller, args) -> { UtilPlayer.message(caller, F.main("Debug", "As of now, there have been " + _gamesRun + " games played")); }); - registerDebugCommand("uhcgc", Perm.DEBUG_GC_COMMAND, (caller, args) -> + registerDebugCommand("uhcgc", Perm.DEBUG_GC_COMMAND, PermissionGroup.DEV, (caller, args) -> { System.gc(); UtilPlayer.message(caller, F.main("Debug", "Cleaned up!")); }); - registerDebugCommand("setcombatlogtimeout", Perm.DEBUG_SETCOMBATLOGTIMEOUT_COMMAND, (caller, args) -> + registerDebugCommand("setcombatlogtimeout", Perm.DEBUG_SETCOMBATLOGTIMEOUT_COMMAND, PermissionGroup.DEV, (caller, args) -> { CombatLogModule module = getModule(CombatLogModule.class); if (module == null) @@ -474,14 +475,14 @@ public abstract class UHC extends Game UtilPlayer.message(caller, F.main("Debug", "That's not a number!")); } }); - registerDebugCommand("dm", Perm.DEBUG_DEATHMATCH_COMMAND, (caller, args) -> + registerDebugCommand("dm", Perm.DEBUG_DEATHMATCH_COMMAND, PermissionGroup.ADMIN, (caller, args) -> { SAFE_TIME = 0; MINING_TIME = 1000; startPreDeathmatch(); UtilPlayer.message(caller, F.main("Debug", "Starting deathmatch")); }); - registerDebugCommand("uhcentities", Perm.DEBUG_ENTITIES_COMMAND, (caller, args) -> + registerDebugCommand("uhcentities", Perm.DEBUG_ENTITIES_COMMAND, PermissionGroup.DEV, (caller, args) -> { for (Entity entity : caller.getNearbyEntities(5.0, 5.0, 5.0)) { @@ -497,7 +498,7 @@ public abstract class UHC extends Game caller.sendMessage(debug); } }); - registerDebugCommand("uhcchunk", Perm.DEBUG_CHUNK_COMMAND, (caller, args) -> + registerDebugCommand("uhcchunk", Perm.DEBUG_CHUNK_COMMAND, PermissionGroup.DEV, (caller, args) -> { net.minecraft.server.v1_8_R3.Chunk chunk = ((CraftChunk) caller.getLocation().getChunk()).getHandle(); try @@ -539,7 +540,7 @@ public abstract class UHC extends Game t.printStackTrace(); } }); - registerDebugCommand("uhcallchunks", Perm.DEBUG_CALLCHUNKS_COMMAND, (caller, args) -> + registerDebugCommand("uhcallchunks", Perm.DEBUG_CALLCHUNKS_COMMAND, PermissionGroup.DEV, (caller, args) -> { for (net.minecraft.server.v1_8_R3.Chunk chunk : ((CraftWorld) caller.getWorld()).getHandle().chunkProviderServer.chunks.values()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/RejoinModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/RejoinModule.java index 267590ac4..ca3f26b6b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/RejoinModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/RejoinModule.java @@ -14,6 +14,7 @@ import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.account.permissions.Permission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -39,7 +40,7 @@ public class RejoinModule extends Module @Override protected void setup() { - getGame().registerDebugCommand("rejoin", Perm.DEBUG_REJOIN_COMMAND, (caller, args) -> + getGame().registerDebugCommand("rejoin", Perm.DEBUG_REJOIN_COMMAND, PermissionGroup.ADMIN, (caller, args) -> { if (args.length < 1) {