Add HorseEquipper

This commit is contained in:
fullwall 2013-08-03 18:33:32 +08:00
parent 5ed44829a8
commit d568dfb886
3 changed files with 21 additions and 0 deletions

View File

@ -52,6 +52,7 @@ public class EquipmentEditor extends Editor {
if (equipper == null)
equipper = new GenericEquipper();
equipper.equip(event.getPlayer(), npc);
event.setCancelled(true);
}
private static final Map<EntityType, Equipper> EQUIPPERS = Maps.newEnumMap(EntityType.class);
@ -59,5 +60,6 @@ public class EquipmentEditor extends Editor {
EQUIPPERS.put(EntityType.PIG, new PigEquipper());
EQUIPPERS.put(EntityType.SHEEP, new SheepEquipper());
EQUIPPERS.put(EntityType.ENDERMAN, new EndermanEquipper());
EQUIPPERS.put(EntityType.HORSE, new HorseEquipper());
}
}

View File

@ -0,0 +1,15 @@
package net.citizensnpcs.editor;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.util.NMS;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Player;
public class HorseEquipper implements Equipper {
@Override
public void equip(Player equipper, NPC toEquip) {
Horse horse = (Horse) toEquip.getBukkitEntity();
NMS.equip(horse, equipper);
}
}

View File

@ -116,6 +116,10 @@ public class NMS {
}
}
public static void equip(LivingEntity entity, Player equipper) {
getHandle(entity).a(NMS.getHandle(equipper));
}
private static Constructor<?> getCustomEntityConstructor(Class<?> clazz, EntityType type) throws SecurityException,
NoSuchMethodException {
Constructor<?> constructor = ENTITY_CONSTRUCTOR_CACHE.get(clazz);