Fixed DragonEscape win stat tracker
This commit is contained in:
parent
b67e127902
commit
bdef9acecd
@ -18,7 +18,9 @@ import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@ -43,6 +45,27 @@ import nautilus.game.arcade.stats.WinMapStatTracker;
|
||||
|
||||
public class DragonEscape extends SoloGame
|
||||
{
|
||||
public static class PlayerFinishEvent extends PlayerEvent
|
||||
{
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public PlayerFinishEvent(Player who)
|
||||
{
|
||||
super(who);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return getHandlerList();
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<DragonScore> _ranks = new ArrayList<DragonScore>();
|
||||
private ArrayList<String> _lastScoreboard = new ArrayList<String>();
|
||||
|
||||
@ -254,6 +277,8 @@ public class DragonEscape extends SoloGame
|
||||
_winner = player;
|
||||
this.SetCustomWinLine(player.getName() + " reached the end of the course!");
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new PlayerFinishEvent(player));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,10 @@
|
||||
package nautilus.game.arcade.stats;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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;
|
||||
import nautilus.game.arcade.game.games.dragonescape.DragonEscape;
|
||||
|
||||
public class WinMapStatTracker extends StatTracker<Game>
|
||||
{
|
||||
@ -17,17 +14,8 @@ public class WinMapStatTracker extends StatTracker<Game>
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onGameStateChange(GameStateChangeEvent event)
|
||||
public void onDragonEscapePlayerFinish(DragonEscape.PlayerFinishEvent event)
|
||||
{
|
||||
if (event.GetState() == Game.GameState.End)
|
||||
{
|
||||
List<Player> winners = getGame().getWinners();
|
||||
|
||||
if (winners != null)
|
||||
{
|
||||
for (Player winner : winners)
|
||||
addStat(winner, "Win." + getGame().WorldData.MapName, 1, true, false);
|
||||
}
|
||||
}
|
||||
addStat(event.getPlayer(), "Win." + getGame().WorldData.MapName, 1, true, false);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user