mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-27 13:15:33 +01:00
Add HorseEquipper
This commit is contained in:
parent
5ed44829a8
commit
d568dfb886
@ -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());
|
||||
}
|
||||
}
|
15
src/main/java/net/citizensnpcs/editor/HorseEquipper.java
Normal file
15
src/main/java/net/citizensnpcs/editor/HorseEquipper.java
Normal 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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user