From ae35e82e229be1ec6555bb43e101c0b3bcb92bd6 Mon Sep 17 00:00:00 2001 From: CoderTim Date: Fri, 7 Nov 2014 18:28:06 -0500 Subject: [PATCH] Disabled AFK kick in Draw My Thing --- .../nautilus/game/arcade/ArcadeManager.java | 8 ++- .../src/nautilus/game/arcade/game/Game.java | 5 ++ .../game/arcade/game/games/draw/Draw.java | 2 + .../game/arcade/managers/IdleManager.java | 49 +++++++++++++------ 4 files changed, 48 insertions(+), 16 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 5c05db3c1..ca4edf115 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -143,6 +143,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation private ServerStatusManager _serverStatusManager; private InventoryManager _inventoryManager; private CosmeticManager _cosmeticManager; + private final IdleManager _idleManager; private AchievementManager _achievementManager; private StatsManager _statsManager; @@ -261,7 +262,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation new GameLootManager(this, petManager); _gameWorldManager = new GameWorldManager(this); new MiscManager(this); - new IdleManager(this); + _idleManager = new IdleManager(this); new HalloweenManager(this); _arcadeRepository = new ArcadeRepository(plugin); @@ -1065,4 +1066,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation { _youtube.remove(event.getPlayer()); } + + public IdleManager getIdleManager() + { + return _idleManager; + } } 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 deef76245..892c03dfa 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 @@ -1246,4 +1246,9 @@ public abstract class Game implements Listener _statTrackers.clear(); } + + public ArcadeManager getArcadeManager() + { + return Manager; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java index b96abfe88..c83e00783 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java @@ -110,6 +110,8 @@ public class Draw extends SoloGame new KeenEyeStatTracker(this), new PureLuckStatTracker(this) ); + + getArcadeManager().getIdleManager().setEnabled(false); } @Override 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 c6071d5a4..925a95b5b 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 @@ -1,6 +1,7 @@ package nautilus.game.arcade.managers; import java.util.HashMap; +import java.util.Map; import mineplex.core.common.Rank; import mineplex.core.common.util.C; @@ -12,6 +13,7 @@ import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; +import org.bukkit.Bukkit; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -20,30 +22,32 @@ import org.bukkit.event.player.PlayerQuitEvent; public class IdleManager implements Listener { - ArcadeManager Manager; + private final ArcadeManager _arcadeManager; + private final Map _yaw = new HashMap<>(); + private final Map _idle = new HashMap<>(); + private final Map _beep = new HashMap<>(); + private boolean _enabled = true; - private HashMap _yaw = new HashMap(); - private HashMap _idle = new HashMap(); - private HashMap _beep = new HashMap(); - - public IdleManager(ArcadeManager manager) { - Manager = manager; + _arcadeManager = manager; - Manager.GetPluginManager().registerEvents(this, Manager.GetPlugin()); + Bukkit.getPluginManager().registerEvents(this, getArcadeManager().GetPlugin()); } @EventHandler - public void KickIdlePlayers(UpdateEvent event) + public void kickIdlePlayers(UpdateEvent event) { + if (!isEnabled()) + return; + if (event.getType() != UpdateType.FAST) return; - if (!Manager.IsPlayerKickIdle()) + if (!getArcadeManager().IsPlayerKickIdle()) return; - if (Manager.GetGame() == null) + if (getArcadeManager().GetGame() == null) return; for (Player player : UtilServer.getPlayers()) @@ -58,10 +62,10 @@ public class IdleManager implements Listener { if (UtilTime.elapsed(_idle.get(player), 120000)) { - if (Manager.GetGame().GetState() != GameState.Recruit && !Manager.GetGame().IsAlive(player)) + if (getArcadeManager().GetGame().GetState() != GameState.Recruit && !getArcadeManager().GetGame().IsAlive(player)) continue; - if (Manager.GetClients().Get(player).GetRank().Has(Rank.MODERATOR)) + if (getArcadeManager().GetClients().Get(player).GetRank().Has(Rank.MODERATOR)) continue; //Start Beeps @@ -77,7 +81,7 @@ public class IdleManager implements Listener if (count == 0) { player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f); - Manager.GetPortal().SendPlayerToServer(player, "Lobby"); + getArcadeManager().GetPortal().SendPlayerToServer(player, "Lobby"); } else { @@ -105,10 +109,25 @@ public class IdleManager implements Listener } @EventHandler - public void Quit(PlayerQuitEvent event) + public void onPlayerQuit(PlayerQuitEvent event) { _yaw.remove(event.getPlayer()); _idle.remove(event.getPlayer()); _beep.remove(event.getPlayer()); } + + public boolean isEnabled() + { + return _enabled; + } + + public void setEnabled(boolean enabled) + { + _enabled = enabled; + } + + public ArcadeManager getArcadeManager() + { + return _arcadeManager; + } }