Disabled AFK kick in Draw My Thing

This commit is contained in:
CoderTim 2014-11-07 18:28:06 -05:00
parent 96f54c2949
commit ae35e82e22
4 changed files with 48 additions and 16 deletions

View File

@ -143,6 +143,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
private ServerStatusManager _serverStatusManager; private ServerStatusManager _serverStatusManager;
private InventoryManager _inventoryManager; private InventoryManager _inventoryManager;
private CosmeticManager _cosmeticManager; private CosmeticManager _cosmeticManager;
private final IdleManager _idleManager;
private AchievementManager _achievementManager; private AchievementManager _achievementManager;
private StatsManager _statsManager; private StatsManager _statsManager;
@ -261,7 +262,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
new GameLootManager(this, petManager); new GameLootManager(this, petManager);
_gameWorldManager = new GameWorldManager(this); _gameWorldManager = new GameWorldManager(this);
new MiscManager(this); new MiscManager(this);
new IdleManager(this); _idleManager = new IdleManager(this);
new HalloweenManager(this); new HalloweenManager(this);
_arcadeRepository = new ArcadeRepository(plugin); _arcadeRepository = new ArcadeRepository(plugin);
@ -1065,4 +1066,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{ {
_youtube.remove(event.getPlayer()); _youtube.remove(event.getPlayer());
} }
public IdleManager getIdleManager()
{
return _idleManager;
}
} }

View File

@ -1246,4 +1246,9 @@ public abstract class Game implements Listener
_statTrackers.clear(); _statTrackers.clear();
} }
public ArcadeManager getArcadeManager()
{
return Manager;
}
} }

View File

@ -110,6 +110,8 @@ public class Draw extends SoloGame
new KeenEyeStatTracker(this), new KeenEyeStatTracker(this),
new PureLuckStatTracker(this) new PureLuckStatTracker(this)
); );
getArcadeManager().getIdleManager().setEnabled(false);
} }
@Override @Override

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.managers; package nautilus.game.arcade.managers;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C; 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.ArcadeManager;
import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.Game.GameState;
import org.bukkit.Bukkit;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -20,30 +22,32 @@ import org.bukkit.event.player.PlayerQuitEvent;
public class IdleManager implements Listener public class IdleManager implements Listener
{ {
ArcadeManager Manager; private final ArcadeManager _arcadeManager;
private final Map<Player, Float> _yaw = new HashMap<>();
private HashMap<Player, Float> _yaw = new HashMap<Player, Float>(); private final Map<Player, Long> _idle = new HashMap<>();
private HashMap<Player, Long> _idle = new HashMap<Player, Long>(); private final Map<Player, Integer> _beep = new HashMap<>();
private HashMap<Player, Integer> _beep = new HashMap<Player, Integer>(); private boolean _enabled = true;
public IdleManager(ArcadeManager manager) public IdleManager(ArcadeManager manager)
{ {
Manager = manager; _arcadeManager = manager;
Manager.GetPluginManager().registerEvents(this, Manager.GetPlugin()); Bukkit.getPluginManager().registerEvents(this, getArcadeManager().GetPlugin());
} }
@EventHandler @EventHandler
public void KickIdlePlayers(UpdateEvent event) public void kickIdlePlayers(UpdateEvent event)
{ {
if (!isEnabled())
return;
if (event.getType() != UpdateType.FAST) if (event.getType() != UpdateType.FAST)
return; return;
if (!Manager.IsPlayerKickIdle()) if (!getArcadeManager().IsPlayerKickIdle())
return; return;
if (Manager.GetGame() == null) if (getArcadeManager().GetGame() == null)
return; return;
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
@ -58,10 +62,10 @@ public class IdleManager implements Listener
{ {
if (UtilTime.elapsed(_idle.get(player), 120000)) 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; continue;
if (Manager.GetClients().Get(player).GetRank().Has(Rank.MODERATOR)) if (getArcadeManager().GetClients().Get(player).GetRank().Has(Rank.MODERATOR))
continue; continue;
//Start Beeps //Start Beeps
@ -77,7 +81,7 @@ public class IdleManager implements Listener
if (count == 0) if (count == 0)
{ {
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f); player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f);
Manager.GetPortal().SendPlayerToServer(player, "Lobby"); getArcadeManager().GetPortal().SendPlayerToServer(player, "Lobby");
} }
else else
{ {
@ -105,10 +109,25 @@ public class IdleManager implements Listener
} }
@EventHandler @EventHandler
public void Quit(PlayerQuitEvent event) public void onPlayerQuit(PlayerQuitEvent event)
{ {
_yaw.remove(event.getPlayer()); _yaw.remove(event.getPlayer());
_idle.remove(event.getPlayer()); _idle.remove(event.getPlayer());
_beep.remove(event.getPlayer()); _beep.remove(event.getPlayer());
} }
public boolean isEnabled()
{
return _enabled;
}
public void setEnabled(boolean enabled)
{
_enabled = enabled;
}
public ArcadeManager getArcadeManager()
{
return _arcadeManager;
}
} }