From 3fa63a114636aa0c6305faed35458a67c98d5c5b Mon Sep 17 00:00:00 2001 From: Andreas Troelsen Date: Thu, 2 May 2013 15:55:53 +0200 Subject: [PATCH] Only weapons should auto-repair. --- src/com/garbagemule/MobArena/ArenaListener.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/com/garbagemule/MobArena/ArenaListener.java b/src/com/garbagemule/MobArena/ArenaListener.java index 374559f..6be54c4 100644 --- a/src/com/garbagemule/MobArena/ArenaListener.java +++ b/src/com/garbagemule/MobArena/ArenaListener.java @@ -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());