Fixed item sub-types not working and players not being removed from classMap upon /ma leave

This commit is contained in:
Garbage Mule 2011-08-22 19:24:47 +02:00
parent 6079c8828e
commit d164e43c05
3 changed files with 24 additions and 8 deletions

Binary file not shown.

View File

@ -239,6 +239,8 @@ public class Arena
// Announce and clear sets. // Announce and clear sets.
MAUtils.tellAll(this, Msg.ARENA_END, true); MAUtils.tellAll(this, Msg.ARENA_END, true);
arenaPlayers.clear(); arenaPlayers.clear();
lobbyPlayers.clear();
readyPlayers.clear();
notifyPlayers.clear(); notifyPlayers.clear();
rewardedPlayers.clear(); rewardedPlayers.clear();
classMap.clear(); classMap.clear();
@ -593,6 +595,7 @@ public class Arena
specPlayers.remove(p); specPlayers.remove(p);
arenaPlayers.remove(p); arenaPlayers.remove(p);
lobbyPlayers.remove(p); lobbyPlayers.remove(p);
classMap.remove(p);
} }
/** /**

View File

@ -586,7 +586,7 @@ public class MAUtils
// If this is a weapon, set its durability to "unlimited". // If this is a weapon, set its durability to "unlimited".
if (WEAPONS_TYPE.contains(stack.getType())) if (WEAPONS_TYPE.contains(stack.getType()))
stack.setDurability((short) -32768); stack.setDurability(Short.MIN_VALUE);
giveItem(inv, stack); giveItem(inv, stack);
//inv.addItem(stack); //inv.addItem(stack);
@ -600,17 +600,30 @@ public class MAUtils
public static void giveItem(PlayerInventory inv, ItemStack stack) public static void giveItem(PlayerInventory inv, ItemStack stack)
{ {
int id = stack.getTypeId(); // If the stack isn't too big, just add it
int amount = stack.getAmount(); if (stack.getAmount() <= 64)
{
inv.addItem(stack);
return;
}
int times = amount / 64; // Otherwise, grab the id, durability and data.
int id = stack.getTypeId();
int amount = stack.getAmount();
short durability = stack.getDurability();
Byte data = stack.getData() != null ? stack.getData().getData() : null;
// Initialize the quotient and remainder.
int quotient = amount / 64;
int remainder = amount % 64; int remainder = amount % 64;
for (int i = 0; i < times; i++) // Add a bunch of stacks of amount 64.
inv.addItem(new ItemStack(id, 64)); for (int i = 0; i < quotient; i++)
inv.addItem(new ItemStack(id, 64, durability, data));
// Add the rest.
if (remainder > 0) if (remainder > 0)
inv.addItem(new ItemStack(id, remainder)); inv.addItem(new ItemStack(id, remainder, durability, data));
} }
public static void giveRewards(Player p, List<ItemStack> stacks, MobArena plugin) public static void giveRewards(Player p, List<ItemStack> stacks, MobArena plugin)