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.
MAUtils.tellAll(this, Msg.ARENA_END, true);
arenaPlayers.clear();
lobbyPlayers.clear();
readyPlayers.clear();
notifyPlayers.clear();
rewardedPlayers.clear();
classMap.clear();
@ -593,6 +595,7 @@ public class Arena
specPlayers.remove(p);
arenaPlayers.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 (WEAPONS_TYPE.contains(stack.getType()))
stack.setDurability((short) -32768);
stack.setDurability(Short.MIN_VALUE);
giveItem(inv, stack);
//inv.addItem(stack);
@ -600,17 +600,30 @@ public class MAUtils
public static void giveItem(PlayerInventory inv, ItemStack stack)
{
int id = stack.getTypeId();
int amount = stack.getAmount();
// If the stack isn't too big, just add it
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;
for (int i = 0; i < times; i++)
inv.addItem(new ItemStack(id, 64));
// Add a bunch of stacks of amount 64.
for (int i = 0; i < quotient; i++)
inv.addItem(new ItemStack(id, 64, durability, data));
// Add the rest.
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)