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 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;
}
}

View File

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

View File

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

View File

@ -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 HashMap<Player, Float> _yaw = new HashMap<Player, Float>();
private HashMap<Player, Long> _idle = new HashMap<Player, Long>();
private HashMap<Player, Integer> _beep = new HashMap<Player, Integer>();
private final ArcadeManager _arcadeManager;
private final Map<Player, Float> _yaw = new HashMap<>();
private final Map<Player, Long> _idle = new HashMap<>();
private final Map<Player, Integer> _beep = new HashMap<>();
private boolean _enabled = true;
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;
}
}