mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-23 19:16:41 +01:00
Only weapons should auto-repair.
This commit is contained in:
parent
1497a46a77
commit
3fa63a1146
@ -1,5 +1,6 @@
|
||||
package com.garbagemule.MobArena;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -529,6 +530,12 @@ public class ArenaListener
|
||||
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) {
|
||||
Player p = (Player) damager;
|
||||
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user