Fix deaths; resolves #210

This commit is contained in:
Daniel Saukel 2017-02-28 14:03:05 +01:00
parent 92ea016603
commit da049b4618
2 changed files with 22 additions and 18 deletions

View File

@ -178,6 +178,7 @@ public enum DMessages implements Messages {
LOG_WORLD_GENERATION_FINISHED("Log_WorldGenerationFinished", "&6World generation finished!"),
MISC_NO("Misc_No", "&4[ NO ]"),
MISC_OKAY("Misc_Okay", "&a[ OK ]"),
MISC_UNLIMITED("Misc_Unlimited", "unlimited"),
MISC_YES("Misc_Yes", "&a[ YES ]"),
PLAYER_BLOCK_INFO("Player_BlockInfo", "&6Block ID: &2&v1"),
PLAYER_CHECKPOINT_REACHED("Player_CheckpointReached", "&6Checkpoint reached!"),

View File

@ -817,28 +817,31 @@ public class DGamePlayer extends DInstancePlayer {
return;
}
if (lives != -1) {
lives = lives - dPlayerDeathEvent.getLostLives();
if (game.getRules().getKeepInventoryOnDeath()) {
setRespawnInventory(event.getEntity().getInventory().getContents());
setRespawnArmor(event.getEntity().getInventory().getArmorContents());
// Delete all drops
for (ItemStack item : event.getDrops()) {
item.setType(Material.AIR);
}
}
if (getDGroup() != null && dGroup.getLives() != -1) {
dGroup.setLives(dGroup.getLives() - 1);
MessageUtil.broadcastMessage(DMessages.GROUP_DEATH.getMessage(getName(), dGroup.getName(), String.valueOf(dGroup.getLives())));
} else {
if (lives != -1) {
lives = lives - dPlayerDeathEvent.getLostLives();
}
DGamePlayer killer = DGamePlayer.getByPlayer(player.getKiller());
String newLives = lives == -1 ? DMessages.MISC_UNLIMITED.getMessage() : String.valueOf(this.lives);
if (killer != null) {
gameWorld.sendMessage(DMessages.PLAYER_KILLED.getMessage(getName(), killer.getName(), String.valueOf(lives)));
gameWorld.sendMessage(DMessages.PLAYER_KILLED.getMessage(getName(), killer.getName(), newLives));
} else {
gameWorld.sendMessage(DMessages.PLAYER_DEATH.getMessage(getName(), String.valueOf(lives)));
gameWorld.sendMessage(DMessages.PLAYER_DEATH.getMessage(getName(), newLives));
}
if (game.getRules().getKeepInventoryOnDeath()) {
setRespawnInventory(event.getEntity().getInventory().getContents());
setRespawnArmor(event.getEntity().getInventory().getArmorContents());
// Delete all drops
for (ItemStack item : event.getDrops()) {
item.setType(Material.AIR);
}
}
} else if (getDGroup() != null && dGroup.getLives() != -1) {
dGroup.setLives(dGroup.getLives() - 1);
MessageUtil.broadcastMessage(DMessages.GROUP_DEATH.getMessage(player.getName(), String.valueOf(lives)));
}
if (isStealing()) {
@ -851,7 +854,7 @@ public class DGamePlayer extends DInstancePlayer {
}
}
if (lives == 0 && ready) {
if ((dGroup.getLives() == 0 || lives == 0) && ready) {
kill();
}