mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-23 11:06:14 +01:00
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:
parent
e3381e895d
commit
544fd91de9
@ -1,7 +1,7 @@
|
||||
name: MobArena
|
||||
author: garbagemule
|
||||
main: com.garbagemule.MobArena.MobArena
|
||||
version: 0.95.5.11
|
||||
version: 0.95.5.12
|
||||
softdepend: [Spout,Towny,Heroes,MagicSpells,Vault]
|
||||
commands:
|
||||
ma:
|
||||
|
@ -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"
|
||||
|
@ -11,10 +11,12 @@ public class ArenaPlayerDeathEvent extends Event
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Player player;
|
||||
private Arena arena;
|
||||
private boolean last;
|
||||
|
||||
public ArenaPlayerDeathEvent(Player player, Arena arena) {
|
||||
public ArenaPlayerDeathEvent(Player player, Arena arena, boolean last) {
|
||||
this.player = player;
|
||||
this.arena = arena;
|
||||
this.arena = arena;
|
||||
this.last = last;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
@ -24,6 +26,10 @@ public class ArenaPlayerDeathEvent extends Event
|
||||
public Arena getArena() {
|
||||
return arena;
|
||||
}
|
||||
|
||||
public boolean wasLastPlayerStanding() {
|
||||
return last;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
|
@ -239,4 +239,6 @@ public interface Arena
|
||||
public boolean canSpec(Player p);
|
||||
|
||||
public boolean hasIsolatedChat();
|
||||
|
||||
public Player getLastPlayerStanding();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user