diff --git a/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java b/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java index 8c14b82a6..d7ebee8e2 100644 --- a/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java +++ b/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java @@ -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 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()); } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/editor/HorseEquipper.java b/src/main/java/net/citizensnpcs/editor/HorseEquipper.java new file mode 100644 index 000000000..ae6680a2b --- /dev/null +++ b/src/main/java/net/citizensnpcs/editor/HorseEquipper.java @@ -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); + } +} diff --git a/src/main/java/net/citizensnpcs/util/NMS.java b/src/main/java/net/citizensnpcs/util/NMS.java index e7bba5537..7aa74dd8a 100644 --- a/src/main/java/net/citizensnpcs/util/NMS.java +++ b/src/main/java/net/citizensnpcs/util/NMS.java @@ -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);