diff --git a/MobArena.jar b/MobArena.jar index d3c5572..e2616b5 100644 Binary files a/MobArena.jar and b/MobArena.jar differ diff --git a/src/com/garbagemule/MobArena/Arena.java b/src/com/garbagemule/MobArena/Arena.java index c0ff9d0..34b0d00 100644 --- a/src/com/garbagemule/MobArena/Arena.java +++ b/src/com/garbagemule/MobArena/Arena.java @@ -249,7 +249,6 @@ public class Arena notifyPlayers.clear(); rewardedPlayers.clear(); classMap.clear(); - spawnThread = null; // Notify listeners. for (MobArenaListener listener : plugin.getAM().listeners) @@ -327,7 +326,7 @@ public class Arena public void playerLeave(Player p) { - finishArenaPlayer(p); + finishArenaPlayer(p, false); movePlayerToEntry(p); discardPlayer(p); @@ -341,7 +340,7 @@ public class Arena public void playerDeath(Player p) { - finishArenaPlayer(p); + finishArenaPlayer(p, true); if (specOnDeath) { @@ -482,7 +481,7 @@ public class Arena log.players.get(p).kills++; } - public void restoreInvAndGiveRewards(final Player p) + public void restoreInvAndGiveRewardsDelayed(final Player p) { final List rewards = log != null && log.players.get(p) != null ? log.players.get(p).rewards : new LinkedList(); final boolean hadRewards = rewardedPlayers.contains(p); @@ -505,20 +504,22 @@ public class Arena }); } - public void restoreInvAndGiveRewardz(final Player p, List rewards, boolean hadRewards) + public void restoreInvAndGiveRewards(final Player p) { - if (!p.isOnline()) - return; - if (!emptyInvJoin) MAUtils.restoreInventory(p); - if (hadRewards) + if (rewardedPlayers.contains(p)) return; + final List rewards = (log != null && log.players.get(p) != null) ? + log.players.get(p).rewards : + new LinkedList(); + MAUtils.giveRewards(p, rewards, plugin); if (running) - rewardedPlayers.add(p);} + rewardedPlayers.add(p); + } public void storePlayerData(Player p, Location loc) { @@ -617,9 +618,9 @@ public class Arena /** * Give the player back his inventory and record his last wave. * Called when a player dies or leaves prematurely. - * @param p + * @param p A player */ - private void finishArenaPlayer(Player p) + /*private void finishArenaPlayer(Player p) { if (!arenaPlayers.contains(p) && !lobbyPlayers.contains(p)) return; @@ -628,6 +629,22 @@ public class Arena MAUtils.clearInventory(p); restoreInvAndGiveRewards(p); + if (log != null && spawnThread != null) + log.players.get(p).lastWave = spawnThread.getWave() - 1; + }*/ + + private void finishArenaPlayer(Player p, boolean dead) + { + System.out.println(p.getName() + " in finishArenaPlayer"); + if (!arenaPlayers.contains(p) && !lobbyPlayers.contains(p)) + return; + + removeClassPermissions(p); + MAUtils.clearInventory(p); + + if (dead) restoreInvAndGiveRewardsDelayed(p); + else restoreInvAndGiveRewards(p); + if (log != null && spawnThread != null) log.players.get(p).lastWave = spawnThread.getWave() - 1; } diff --git a/src/com/garbagemule/MobArena/MAUtils.java b/src/com/garbagemule/MobArena/MAUtils.java index 6912551..a9edd17 100644 --- a/src/com/garbagemule/MobArena/MAUtils.java +++ b/src/com/garbagemule/MobArena/MAUtils.java @@ -386,7 +386,7 @@ public class MAUtils // If the player isn't online, hack the playerName.dat file if (!p.isOnline()) - return writeInventoryData(p, stacks); + System.out.println("FUCKKKKKKKKKKKKKKKKKKKKKKKKKK!");//return writeInventoryData(p, stacks); // Otherwise, restore the inventory directly ItemStack[] items = new ItemStack[stacks.length-4]; diff --git a/src/com/garbagemule/MobArena/waves/BossWave.java b/src/com/garbagemule/MobArena/waves/BossWave.java index df0a86a..d839d54 100644 --- a/src/com/garbagemule/MobArena/waves/BossWave.java +++ b/src/com/garbagemule/MobArena/waves/BossWave.java @@ -101,6 +101,13 @@ public class BossWave extends AbstractWave public void run() { + // Check to see if the boss is still alive. If not, end this boss wave. + if (bossCreature.isDead()) + { + clear(); + return; + } + // Grab the next ability BossAbility ability = abilities.get(counter % abilityCount);