Lives modifier sign: Added dying if no lives are left

This commit is contained in:
Daniel Saukel 2016-06-21 13:55:53 +02:00
parent 882393a027
commit 101c821af6
3 changed files with 19 additions and 10 deletions

View File

@ -134,16 +134,7 @@ public class PlayerListener implements Listener {
}
if (dPlayer.getLives() == 0 && dPlayer.isReady()) {
DPlayerKickEvent dPlayerKickEvent = new DPlayerKickEvent(dPlayer, DPlayerKickEvent.Cause.DEATH);
plugin.getServer().getPluginManager().callEvent(dPlayerKickEvent);
if (!dPlayerKickEvent.isCancelled()) {
MessageUtil.broadcastMessage(DMessages.PLAYER_DEATH_KICK.getMessage(player.getName()));
dPlayer.leave();
if (game.getRules().getKeepInventoryOnEscape()) {
dPlayer.applyRespawnInventory();
}
}
dPlayer.kill();
}
}

View File

@ -456,6 +456,20 @@ public class DGamePlayer extends DInstancePlayer {
}
}
public void kill() {
DPlayerKickEvent dPlayerKickEvent = new DPlayerKickEvent(this, DPlayerKickEvent.Cause.DEATH);
plugin.getServer().getPluginManager().callEvent(dPlayerKickEvent);
if (!dPlayerKickEvent.isCancelled()) {
MessageUtil.broadcastMessage(DMessages.PLAYER_DEATH_KICK.getMessage(player.getName()));
GameRules rules = Game.getByPlayer(player).getRules();
leave();
if (rules.getKeepInventoryOnEscape() && rules.getKeepInventoryOnDeath()) {
applyRespawnInventory();
}
}
}
public boolean checkRequirements(Game game) {
if (DPermissions.hasPermission(player, DPermissions.IGNORE_REQUIREMENTS)) {
return true;

View File

@ -113,6 +113,10 @@ public class LivesModifierSign extends DSign {
} else {
MessageUtil.sendMessage(dPlayer.getPlayer(), DMessages.PLAYER_LIVES_REMOVED.getMessage(String.valueOf(-1 * lives)));
}
if (dPlayer.getLives() <= 0) {
dPlayer.kill();
}
}
@Override