Added small cooldown to be able to click hub clock after your gamestate changes. (prevents accidental clicking)

Moved stat stuff to gamemanager.
This commit is contained in:
Chiss 2014-09-21 09:26:34 +10:00
parent 767a0247a6
commit 9fce0b1926
4 changed files with 33 additions and 17 deletions

View File

@ -1184,23 +1184,7 @@ public abstract class Game implements Listener
}
}
@EventHandler
public void onGameEnd(GameStateChangeEvent event)
{
if (event.GetState() == GameState.End)
{
for (StatTracker tracker : getStatTrackers())
HandlerList.unregisterAll(tracker);
if (CanAddStats)
{
Manager.saveBasicStats(this);
if (Manager.IsTournamentServer())
Manager.saveLeaderboardStats(this);
}
}
}
public Collection<StatTracker<? extends Game>> getStatTrackers()
{

View File

@ -26,6 +26,7 @@ import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.stats.StatTracker;
import org.bukkit.ChatColor;
import org.bukkit.Color;
@ -36,6 +37,7 @@ import org.bukkit.FireworkEffect.Type;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
public class GameManager implements Listener
@ -316,6 +318,24 @@ public class GameManager implements Listener
}
}
@EventHandler
public void StatGameRecord(GameStateChangeEvent event)
{
if (event.GetState() == GameState.End)
{
for (StatTracker tracker : event.GetGame().getStatTrackers())
HandlerList.unregisterAll(tracker);
if (event.GetGame().CanAddStats)
{
Manager.saveBasicStats(event.GetGame());
if (Manager.IsTournamentServer())
Manager.saveLeaderboardStats(event.GetGame());
}
}
}
@EventHandler
public void ScoreboardTitle(UpdateEvent event)
{

View File

@ -26,10 +26,12 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.Donor;
import mineplex.core.recharge.Recharge;
import mineplex.core.shop.page.ConfirmationPage;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.events.PlayerStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam;
@ -139,6 +141,12 @@ public class GamePlayerManager implements Listener
}
}
@EventHandler
public void PlayerStateChange(PlayerStateChangeEvent event)
{
Recharge.Instance.useForce(event.GetPlayer(), "Return to Hub", 4000);
}
@EventHandler
public void InventoryClick(InventoryClickEvent event)
{

View File

@ -5,6 +5,7 @@ import java.util.List;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
@ -148,6 +149,9 @@ public class MiscManager implements Listener
if (player.getItemInHand().getType() != Material.WATCH)
return;
if (!Recharge.Instance.usable(event.getPlayer(), "Return to Hub"))
return;
Manager.GetPortal().SendPlayerToServer(player, "Lobby");
}