Use unbreakable item meta flag for unbreakable weapons and armor.
This changes how unbreakable items work in MobArena. It removes the legacy "repair logic" and replaces it with the item meta unbreakable flag. This approach should work all the same, except now if weapons and armor in class chests have special durability values, these are preserved in the cloning. This should make MobArena compatible with plugins that depend on special durability values, such as QualityArmory.
This commit is contained in:
parent
d9b9b2493c
commit
399b228999
|
@ -1139,6 +1139,23 @@ public class ArenaImpl implements Arena
|
|||
arenaClass.grantPotionEffects(p);
|
||||
arenaClass.grantLobbyPermissions(p);
|
||||
|
||||
if (arenaClass.hasUnbreakableWeapons()) {
|
||||
PlayerInventory inv = p.getInventory();
|
||||
for (ItemStack stack : inv.getContents()) {
|
||||
if (ArenaClass.isWeapon(stack)) {
|
||||
makeUnbreakable(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (arenaClass.hasUnbreakableArmor()) {
|
||||
PlayerInventory inv = p.getInventory();
|
||||
for (ItemStack stack : inv.getArmorContents()) {
|
||||
if (stack != null && ArmorType.getType(stack) != null) {
|
||||
makeUnbreakable(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
autoReady(p);
|
||||
}
|
||||
|
||||
|
@ -1186,9 +1203,9 @@ public class ArenaImpl implements Arena
|
|||
makeUnbreakable(stack);
|
||||
}
|
||||
switch (type) {
|
||||
case CHESTPLATE: chestplate = contents[i].clone(); break;
|
||||
case LEGGINGS: leggings = contents[i].clone(); break;
|
||||
case BOOTS: boots = contents[i].clone(); break;
|
||||
case CHESTPLATE: chestplate = stack; break;
|
||||
case LEGGINGS: leggings = stack; break;
|
||||
case BOOTS: boots = stack; break;
|
||||
default: break;
|
||||
}
|
||||
contents[i] = null;
|
||||
|
|
Loading…
Reference in New Issue