Fixed some weird inventory bug...

This commit is contained in:
Garbage Mule 2011-08-25 20:40:17 +02:00
parent d71430435b
commit cd404a5ffa
4 changed files with 37 additions and 13 deletions

Binary file not shown.

View File

@ -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<ItemStack> rewards = log != null && log.players.get(p) != null ? log.players.get(p).rewards : new LinkedList<ItemStack>();
final boolean hadRewards = rewardedPlayers.contains(p);
@ -505,20 +504,22 @@ public class Arena
});
}
public void restoreInvAndGiveRewardz(final Player p, List<ItemStack> 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<ItemStack> rewards = (log != null && log.players.get(p) != null) ?
log.players.get(p).rewards :
new LinkedList<ItemStack>();
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;
}

View File

@ -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];

View File

@ -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);