2014-08-18 22:41:16 +02:00
|
|
|
package nautilus.game.arcade.stats;
|
|
|
|
|
2014-08-25 22:27:02 +02:00
|
|
|
import java.util.List;
|
2014-08-18 22:41:16 +02:00
|
|
|
|
2014-08-25 22:27:02 +02:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventPriority;
|
|
|
|
|
|
|
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
|
|
|
import nautilus.game.arcade.game.Game;
|
2014-08-18 22:41:16 +02:00
|
|
|
|
|
|
|
public class WinStatTracker extends StatTracker<Game>
|
|
|
|
{
|
|
|
|
public WinStatTracker(Game game)
|
|
|
|
{
|
|
|
|
super(game);
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
|
|
|
public void onGameStateChange(GameStateChangeEvent event)
|
|
|
|
{
|
|
|
|
if (event.GetState() == Game.GameState.End)
|
|
|
|
{
|
|
|
|
List<Player> winners = getGame().getWinners();
|
|
|
|
|
|
|
|
if (winners != null)
|
|
|
|
{
|
|
|
|
for (Player winner : winners)
|
|
|
|
{
|
2014-08-26 22:30:55 +02:00
|
|
|
addStat(winner, "Wins", 1, false, false);
|
2014-08-25 22:27:02 +02:00
|
|
|
|
|
|
|
if (getGame().GetKit(winner) != null)
|
2014-08-26 22:30:55 +02:00
|
|
|
addStat(winner, getGame().GetKit(winner).GetName() + " Wins", 1, false, false);
|
2014-08-18 22:41:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|