mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 13:36:33 +01:00
Lives modifier sign: Added dying if no lives are left
This commit is contained in:
parent
882393a027
commit
101c821af6
@ -134,16 +134,7 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dPlayer.getLives() == 0 && dPlayer.isReady()) {
|
if (dPlayer.getLives() == 0 && dPlayer.isReady()) {
|
||||||
DPlayerKickEvent dPlayerKickEvent = new DPlayerKickEvent(dPlayer, DPlayerKickEvent.Cause.DEATH);
|
dPlayer.kill();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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) {
|
public boolean checkRequirements(Game game) {
|
||||||
if (DPermissions.hasPermission(player, DPermissions.IGNORE_REQUIREMENTS)) {
|
if (DPermissions.hasPermission(player, DPermissions.IGNORE_REQUIREMENTS)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -113,6 +113,10 @@ public class LivesModifierSign extends DSign {
|
|||||||
} else {
|
} else {
|
||||||
MessageUtil.sendMessage(dPlayer.getPlayer(), DMessages.PLAYER_LIVES_REMOVED.getMessage(String.valueOf(-1 * lives)));
|
MessageUtil.sendMessage(dPlayer.getPlayer(), DMessages.PLAYER_LIVES_REMOVED.getMessage(String.valueOf(-1 * lives)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dPlayer.getLives() <= 0) {
|
||||||
|
dPlayer.kill();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user