2015-06-25 04:59:28 +02:00
|
|
|
package nautilus.game.arcade.stats;
|
|
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
|
|
|
import nautilus.game.arcade.game.Game;
|
|
|
|
import nautilus.game.arcade.game.games.skywars.events.PlayerOpenChestEvent;
|
|
|
|
|
2015-06-26 09:05:29 +02:00
|
|
|
import org.bukkit.Material;
|
2015-06-25 04:59:28 +02:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventPriority;
|
2015-06-26 09:05:29 +02:00
|
|
|
import org.bukkit.event.block.BlockBreakEvent;
|
2015-06-25 04:59:28 +02:00
|
|
|
|
|
|
|
public class WinWithoutOpeningChestStatTracker extends StatTracker<Game>
|
|
|
|
{
|
|
|
|
|
|
|
|
private final Set<UUID> _openChest = new HashSet<>();
|
|
|
|
|
|
|
|
public WinWithoutOpeningChestStatTracker(Game game)
|
|
|
|
{
|
|
|
|
super(game);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void onOpenChest(PlayerOpenChestEvent e) {
|
|
|
|
|
|
|
|
Player player = e.getPlayer();
|
|
|
|
UUID uuid = player.getUniqueId();
|
|
|
|
|
|
|
|
_openChest.add(uuid);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-06-26 09:05:29 +02:00
|
|
|
@EventHandler
|
|
|
|
public void onBreakChest(BlockBreakEvent event)
|
|
|
|
{
|
|
|
|
if (event.getBlock().getType() == Material.CHEST)
|
|
|
|
_openChest.add(event.getPlayer().getUniqueId());
|
|
|
|
}
|
|
|
|
|
2015-06-25 04:59:28 +02:00
|
|
|
@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)
|
|
|
|
{
|
|
|
|
if (!_openChest.contains(winner.getUniqueId()))
|
|
|
|
addStat(winner, "NoChest", 1, true, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|