diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/ToggleAfkKickCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/ToggleAfkKickCommand.java new file mode 100644 index 000000000..836cba08c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/ToggleAfkKickCommand.java @@ -0,0 +1,40 @@ +package nautilus.game.arcade.command; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.GameServerConfig; +import nautilus.game.arcade.managers.IdleManager; +import org.bukkit.entity.Player; + +public class ToggleAfkKickCommand extends CommandBase +{ + public ToggleAfkKickCommand (ArcadeManager plugin) + { + super(plugin, IdleManager.Perm.TOGGLE_AFK_KICK_COMMAND, "toggleafkkick", "afkkick"); + } + + public void toggleAfkKick() { + GameServerConfig config = Plugin.GetServerConfig(); + + config.PlayerKickIdle = !config.PlayerKickIdle; + } + + @Override + public void Execute(Player caller, String[] args) { + toggleAfkKick(); + + String message = C.cGray + "AFK kick is now "; + + if (Plugin.IsPlayerKickIdle()) { + message += C.cGreen + "enabled"; + } else { + message += C.cRed + "disabled"; + } + + message += C.cGray + "."; + + caller.sendMessage(F.main("Game", message)); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/IdleManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/IdleManager.java index f127f5de4..c302c2b8b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/IdleManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/IdleManager.java @@ -6,6 +6,9 @@ import java.util.Map; import java.util.Set; import java.util.UUID; +import mineplex.core.command.CommandCenter; +import nautilus.game.arcade.command.ToggleAfkKickCommand; +import nautilus.game.arcade.game.GameServerConfig; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -33,6 +36,7 @@ public class IdleManager implements Listener public enum Perm implements Permission { BYPASS_KICK, + TOGGLE_AFK_KICK_COMMAND } private final ArcadeManager _arcadeManager; @@ -45,7 +49,9 @@ public class IdleManager implements Listener { _arcadeManager = manager; UtilServer.RegisterEvents(this); - + + CommandCenter.Instance.addCommand(new ToggleAfkKickCommand(manager)); + generatePermissions(); } @@ -53,6 +59,12 @@ public class IdleManager implements Listener { PermissionGroup.MOD.setPermission(Perm.BYPASS_KICK, true, true); + + PermissionGroup.ADMIN.setPermission(Perm.TOGGLE_AFK_KICK_COMMAND, true, true); + + if (UtilServer.isTestServer()) { + PermissionGroup.QA.setPermission(Perm.TOGGLE_AFK_KICK_COMMAND, true, true); + } } @EventHandler