Skip to content

Commit

Permalink
Fix deaths; resolves #210
Browse files Browse the repository at this point in the history
  • Loading branch information
Sataniel98 committed Feb 28, 2017
1 parent 92ea016 commit da049b4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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!"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -817,28 +817,31 @@ public void onDeath(PlayerDeathEvent event) {
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)));
}

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);
}
gameWorld.sendMessage(DMessages.PLAYER_DEATH.getMessage(getName(), newLives));
}

} 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()) {
Expand All @@ -851,7 +854,7 @@ public void onDeath(PlayerDeathEvent event) {
}
}

if (lives == 0 && ready) {
if ((dGroup.getLives() == 0 || lives == 0) && ready) {
kill();
}

Expand Down

0 comments on commit da049b4

Please sign in to comment.