2014-08-21 01:20:11 +02:00
|
|
|
package nautilus.game.arcade.stats;
|
|
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventPriority;
|
|
|
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
|
|
|
|
|
|
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
|
|
|
import nautilus.game.arcade.game.Game;
|
|
|
|
import nautilus.game.arcade.game.games.hideseek.HideSeek;
|
2014-11-08 00:28:28 +01:00
|
|
|
import nautilus.game.arcade.game.games.hideseek.forms.CreatureForm;
|
2014-08-21 01:20:11 +02:00
|
|
|
|
|
|
|
public class BadHiderStatTracker extends StatTracker<HideSeek>
|
|
|
|
{
|
|
|
|
private final Set<UUID> _disqualified = new HashSet<>();
|
|
|
|
|
|
|
|
public BadHiderStatTracker(HideSeek game)
|
|
|
|
{
|
|
|
|
super(game);
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
2014-08-26 22:30:55 +02:00
|
|
|
public void onChangeForm(HideSeek.PlayerChangeFormEvent event)
|
2014-08-21 01:20:11 +02:00
|
|
|
{
|
2014-08-25 22:27:02 +02:00
|
|
|
if (getGame().GetState() != Game.GameState.Live)
|
|
|
|
return;
|
|
|
|
|
2014-11-08 00:28:28 +01:00
|
|
|
if (event.getForm() instanceof CreatureForm)
|
|
|
|
_disqualified.add(event.getPlayer().getUniqueId());
|
2014-08-21 01:20:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
|
|
|
public void onPlayerDeath(PlayerDeathEvent event)
|
|
|
|
{
|
2014-08-25 22:27:02 +02:00
|
|
|
if (getGame().GetState() != Game.GameState.Live)
|
|
|
|
return;
|
|
|
|
|
2014-08-21 01:20:11 +02:00
|
|
|
_disqualified.add(event.getEntity().getUniqueId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
|
|
|
public void onGameStateChange(GameStateChangeEvent event)
|
|
|
|
{
|
|
|
|
if (event.GetState() == Game.GameState.End)
|
|
|
|
{
|
|
|
|
for (Player player : getGame().getHiders().GetPlayers(true))
|
|
|
|
{
|
|
|
|
if (!_disqualified.contains(player.getUniqueId()))
|
2014-08-26 22:30:55 +02:00
|
|
|
addStat(player, "BadHider", 1, true, false);
|
2014-08-21 01:20:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|