Support generic equipping

This commit is contained in:
fullwall 2012-12-11 10:17:09 +08:00
parent af81d49565
commit 6ee3c65614
2 changed files with 2 additions and 4 deletions

View File

@ -51,7 +51,7 @@ public class EquipmentEditor extends Editor {
Equipper equipper = EQUIPPERS.get(npc.getBukkitEntity().getType());
if (equipper == null)
return;
equipper = new GenericEquipper();
ItemStack hand = event.getPlayer().getItemInHand();
equipper.equip(event.getPlayer(), npc);
event.getPlayer().setItemInHand(hand.getAmount() > 0 ? hand : null);
@ -60,7 +60,6 @@ public class EquipmentEditor extends Editor {
private static final Map<EntityType, Equipper> EQUIPPERS = Maps.newEnumMap(EntityType.class);
static {
EQUIPPERS.put(EntityType.PIG, new PigEquipper());
EQUIPPERS.put(EntityType.PLAYER, new HumanEquipper());
EQUIPPERS.put(EntityType.SHEEP, new SheepEquipper());
EQUIPPERS.put(EntityType.ENDERMAN, new EndermanEquipper());
}

View File

@ -9,8 +9,7 @@ import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class HumanEquipper implements Equipper {
public class GenericEquipper implements Equipper {
@Override
public void equip(Player equipper, NPC toEquip) {
ItemStack hand = equipper.getItemInHand();