Introduce "last player standing" to death event.

It is now possible to check if an arena player who died was the last
player alive in the arena. Useful for special rewards and stuff.
This commit is contained in:
garbagemule
2013-08-08 06:09:07 +02:00
parent e3381e895d
commit 544fd91de9
4 changed files with 25 additions and 6 deletions
+14 -3
View File
@@ -98,6 +98,9 @@ public class ArenaImpl implements Arena
// Scoreboards
private ScoreboardManager scoreboard;
// Last player standing
private Player lastStanding;
/**
* Primary constructor. Requires a name and a world.
@@ -484,6 +487,9 @@ public class ArenaImpl implements Arena
if (event.isCancelled()) {
return false;
}
// Reset last standing
lastStanding = null;
// Set the running boolean and disable arena if not disabled.
boolean en = enabled;
@@ -652,9 +658,9 @@ public class ArenaImpl implements Arena
public void playerDeath(Player p)
{
// Fire the event
ArenaPlayerDeathEvent event = new ArenaPlayerDeathEvent(p, this);
ArenaPlayerDeathEvent event = new ArenaPlayerDeathEvent(p, this, arenaPlayers.size() == 1);
plugin.getServer().getPluginManager().callEvent(event);
arenaPlayers.remove(p);
if (!settings.getBoolean("auto-respawn", true)) {
@@ -1053,7 +1059,7 @@ public class ArenaImpl implements Arena
private void replacePermissions(Player p, PermissionAttachment rep) {
PermissionAttachment old = attachments.get(p);
if (old != null) {
p.removeAttachment(old);
old.remove();
p.recalculatePermissions();
}
if (rep != null) {
@@ -1403,6 +1409,11 @@ public class ArenaImpl implements Arena
public boolean hasIsolatedChat() {
return isolatedChat;
}
@Override
public Player getLastPlayerStanding() {
return lastStanding;
}
/**
* The "perfect equals method" cf. "Object-Oriented Design and Patterns"