Fix onDeath

This commit is contained in:
Daniel Saukel 2015-09-20 17:18:57 +02:00
parent 56c3e982ba
commit c98e52a925

View File

@ -24,9 +24,12 @@ public class PlayerDeathListener implements Listener {
Player player = event.getEntity(); Player player = event.getEntity();
DPlayer dPlayer = DPlayer.get(player); DPlayer dPlayer = DPlayer.get(player);
DConfig dConfig = GameWorld.get(player.getLocation().getWorld()).config; GameWorld gameWorld = GameWorld.get(player.getLocation().getWorld());
if (gameWorld != null) {
DConfig dConfig = gameWorld.config;
if (dPlayer != null) { if (dPlayer != null) {
if (dConfig != null) {
if (dConfig.getKeepInventoryOnDeath()) { if (dConfig.getKeepInventoryOnDeath()) {
dPlayer.respawnInventory = event.getEntity().getInventory().getContents(); dPlayer.respawnInventory = event.getEntity().getInventory().getContents();
dPlayer.respawnArmor = event.getEntity().getInventory().getArmorContents(); dPlayer.respawnArmor = event.getEntity().getInventory().getArmorContents();
@ -35,6 +38,7 @@ public class PlayerDeathListener implements Listener {
istack.setType(Material.AIR); istack.setType(Material.AIR);
} }
} }
}
if (p.lives.containsKey(player)) { if (p.lives.containsKey(player)) {
lives = p.lives.get(player) - 1; lives = p.lives.get(player) - 1;
@ -44,11 +48,13 @@ public class PlayerDeathListener implements Listener {
if (lives == 0 && dPlayer.isReady) { if (lives == 0 && dPlayer.isReady) {
Bukkit.broadcastMessage(p.language.get("Player_DeathKick").replaceAll("v1", player.getName()).replaceAll("&", "\u00a7")); Bukkit.broadcastMessage(p.language.get("Player_DeathKick").replaceAll("v1", player.getName()).replaceAll("&", "\u00a7"));
player.performCommand("dxl leave"); player.performCommand("dxl leave");
} else if (!(lives == -1)) { } else if ( !(lives == -1)) {
p.msg(player, p.language.get("Player_Death").replaceAll("v1", String.valueOf(lives))); p.msg(player, p.language.get("Player_Death").replaceAll("v1", String.valueOf(lives)));
} }
} }
} }
}
} }