Fix class chest bones not giving pets.
This commit is contained in:
@@ -15,7 +15,6 @@ public class ArenaClass
|
|||||||
private ItemStack helmet, chestplate, leggings, boots;
|
private ItemStack helmet, chestplate, leggings, boots;
|
||||||
private List<ItemStack> items, armor;
|
private List<ItemStack> items, armor;
|
||||||
private Map<String,Boolean> perms;
|
private Map<String,Boolean> perms;
|
||||||
private int pets;
|
|
||||||
private boolean unbreakableWeapons;
|
private boolean unbreakableWeapons;
|
||||||
private boolean mount;
|
private boolean mount;
|
||||||
|
|
||||||
@@ -30,7 +29,6 @@ public class ArenaClass
|
|||||||
this.items = new ArrayList<ItemStack>();
|
this.items = new ArrayList<ItemStack>();
|
||||||
this.armor = new ArrayList<ItemStack>(4);
|
this.armor = new ArrayList<ItemStack>(4);
|
||||||
this.perms = new HashMap<String,Boolean>();
|
this.perms = new HashMap<String,Boolean>();
|
||||||
this.pets = 0;
|
|
||||||
|
|
||||||
this.unbreakableWeapons = unbreakableWeapons;
|
this.unbreakableWeapons = unbreakableWeapons;
|
||||||
}
|
}
|
||||||
@@ -107,9 +105,6 @@ public class ArenaClass
|
|||||||
if (unbreakableWeapons && isWeapon(stack)) {
|
if (unbreakableWeapons && isWeapon(stack)) {
|
||||||
stack.setDurability(Short.MIN_VALUE);
|
stack.setDurability(Short.MIN_VALUE);
|
||||||
}
|
}
|
||||||
else if (stack.getType() == Material.BONE) {
|
|
||||||
pets += stack.getAmount();
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (stack.getTypeId() == 170 && stack.getAmount() == 1) {
|
else if (stack.getTypeId() == 170 && stack.getAmount() == 1) {
|
||||||
if (mount) return;
|
if (mount) return;
|
||||||
@@ -239,14 +234,6 @@ public class ArenaClass
|
|||||||
return pa;
|
return pa;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the amount of pets this class is given upon starting the arena.
|
|
||||||
* @return the number of pets this class has
|
|
||||||
*/
|
|
||||||
public int getPetAmount() {
|
|
||||||
return pets;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasUnbreakableWeapons() {
|
public boolean hasUnbreakableWeapons() {
|
||||||
return unbreakableWeapons;
|
return unbreakableWeapons;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -700,19 +700,16 @@ public class ArenaImpl implements Arena
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void spawnPets() {
|
private void spawnPets() {
|
||||||
for (Map.Entry<Player,ArenaPlayer> entry : arenaPlayerMap.entrySet()) {
|
for (Player p : arenaPlayers) {
|
||||||
ArenaClass arenaClass = entry.getValue().getArenaClass();
|
// Find the first slot containing bones
|
||||||
int petAmount = arenaClass.getPetAmount();
|
int bone = p.getInventory().first(Material.BONE);
|
||||||
|
if (bone == -1) continue;
|
||||||
|
|
||||||
if (petAmount <= 0) {
|
// Get the amount of pets to spawn
|
||||||
continue;
|
int amount = p.getInventory().getItem(bone).getAmount();
|
||||||
}
|
|
||||||
|
|
||||||
// Remove the bones from the inventory.
|
// Spawn each pet
|
||||||
Player p = entry.getKey();
|
for (int i = 0; i < amount; i++) {
|
||||||
p.getInventory().removeItem(new ItemStack(Material.BONE, petAmount));
|
|
||||||
|
|
||||||
for (int i = 0; i < petAmount; i++) {
|
|
||||||
Wolf wolf = (Wolf) world.spawnEntity(p.getLocation(), EntityType.WOLF);
|
Wolf wolf = (Wolf) world.spawnEntity(p.getLocation(), EntityType.WOLF);
|
||||||
wolf.setTamed(true);
|
wolf.setTamed(true);
|
||||||
wolf.setOwner(p);
|
wolf.setOwner(p);
|
||||||
@@ -721,6 +718,9 @@ public class ArenaImpl implements Arena
|
|||||||
wolf.setFireTicks(32768);
|
wolf.setFireTicks(32768);
|
||||||
monsterManager.addPet(wolf);
|
monsterManager.addPet(wolf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove the bones
|
||||||
|
p.getInventory().setItem(bone, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user