Only weapons should auto-repair.

This commit is contained in:
Andreas Troelsen 2013-05-02 15:55:53 +02:00
parent 1497a46a77
commit 3fa63a1146

View File

@ -1,5 +1,6 @@
package com.garbagemule.MobArena;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@ -528,6 +529,12 @@ public class ArenaListener
private void onPetDamage(EntityDamageEvent event, Wolf pet, Entity damager) {
event.setCancelled(true);
}
// Array of weapon IDs (includes flint and steel, fishing pole)
private final int[] weapons = {
256, 257, 258, 259, 261, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
277, 278, 279, 283, 284, 285, 286, 290, 291, 292, 293, 294, 346, 398
};
private void onMonsterDamage(EntityDamageEvent event, Entity monster, Entity damager) {
if (damager instanceof Player) {
@ -539,11 +546,9 @@ public class ArenaListener
// Dirty hack for invincible weapons
ItemStack weapon = p.getInventory().getContents()[p.getInventory().getHeldItemSlot()];
if (weapon != null && // Avoid NPE
weapon.getTypeId() != 373 && // Prevent potion -> water bottle
weapon.getTypeId() != 35 && // Prevent wool -> white wool
weapon.getTypeId() != 322) // Prevent ench. apple -> normal apple
if (weapon != null && Arrays.binarySearch(weapons, weapon.getTypeId()) >= 0) {
weapon.setDurability((short) 0);
}
ArenaPlayerStatistics aps = arena.getArenaPlayer(p).getStats();
aps.add("dmgDone", event.getDamage());