Make horse equipper more general

This commit is contained in:
fullwall 2018-02-03 08:56:09 +08:00
parent c767b6fdc3
commit 476debfcd7
6 changed files with 15 additions and 18 deletions

View File

@ -1,11 +1,11 @@
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;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.util.NMS;
public class HorseEquipper implements Equipper {
@Override
public void equip(Player equipper, NPC toEquip) {

View File

@ -10,7 +10,6 @@ import org.bukkit.block.Block;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FishHook;
import org.bukkit.entity.Horse;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Shulker;
@ -189,7 +188,7 @@ public class NMS {
BRIDGE.mount(entity, passenger);
}
public static void openHorseScreen(Horse horse, Player equipper) {
public static void openHorseScreen(Tameable horse, Player equipper) {
BRIDGE.openHorseScreen(horse, equipper);
}

View File

@ -9,7 +9,6 @@ import org.bukkit.block.Block;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FishHook;
import org.bukkit.entity.Horse;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Shulker;
@ -90,7 +89,7 @@ public interface NMSBridge {
public void mount(Entity entity, Entity passenger);
public void openHorseScreen(Horse horse, Player equipper);
public void openHorseScreen(Tameable horse, Player equipper);
public void playAnimation(PlayerAnimation animation, Player player, int radius);

View File

@ -32,7 +32,6 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftWither;
import org.bukkit.craftbukkit.v1_10_R1.event.CraftEventFactory;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.FishHook;
import org.bukkit.entity.Horse;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Shulker;
@ -689,8 +688,8 @@ public class NMSImpl implements NMSBridge {
}
@Override
public void openHorseScreen(Horse horse, Player equipper) {
EntityLiving handle = NMSImpl.getHandle(horse);
public void openHorseScreen(Tameable horse, Player equipper) {
EntityLiving handle = NMSImpl.getHandle((LivingEntity) horse);
EntityLiving equipperHandle = NMSImpl.getHandle(equipper);
if (handle == null || equipperHandle == null)
return;

View File

@ -32,7 +32,6 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftWither;
import org.bukkit.craftbukkit.v1_11_R1.event.CraftEventFactory;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.FishHook;
import org.bukkit.entity.Horse;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Shulker;
@ -182,6 +181,7 @@ import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityEnderDragon;
import net.minecraft.server.v1_11_R1.EntityFishingHook;
import net.minecraft.server.v1_11_R1.EntityHorse;
import net.minecraft.server.v1_11_R1.EntityHorseAbstract;
import net.minecraft.server.v1_11_R1.EntityHuman;
import net.minecraft.server.v1_11_R1.EntityInsentient;
import net.minecraft.server.v1_11_R1.EntityLiving;
@ -748,14 +748,14 @@ public class NMSImpl implements NMSBridge {
}
@Override
public void openHorseScreen(Horse horse, Player equipper) {
EntityLiving handle = NMSImpl.getHandle(horse);
public void openHorseScreen(Tameable horse, Player equipper) {
EntityLiving handle = NMSImpl.getHandle((LivingEntity) horse);
EntityLiving equipperHandle = NMSImpl.getHandle(equipper);
if (handle == null || equipperHandle == null)
return;
boolean wasTamed = horse.isTamed();
horse.setTamed(true);
((EntityHorse) handle).a((EntityHuman) equipperHandle);
((EntityHorseAbstract) handle).a((EntityHuman) equipperHandle);
horse.setTamed(wasTamed);
}

View File

@ -32,7 +32,6 @@ import org.bukkit.craftbukkit.v1_12_R1.entity.CraftWither;
import org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.FishHook;
import org.bukkit.entity.Horse;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Shulker;
@ -186,6 +185,7 @@ import net.minecraft.server.v1_12_R1.EntityBird;
import net.minecraft.server.v1_12_R1.EntityEnderDragon;
import net.minecraft.server.v1_12_R1.EntityFishingHook;
import net.minecraft.server.v1_12_R1.EntityHorse;
import net.minecraft.server.v1_12_R1.EntityHorseAbstract;
import net.minecraft.server.v1_12_R1.EntityHuman;
import net.minecraft.server.v1_12_R1.EntityInsentient;
import net.minecraft.server.v1_12_R1.EntityLiving;
@ -755,14 +755,14 @@ public class NMSImpl implements NMSBridge {
}
@Override
public void openHorseScreen(Horse horse, Player equipper) {
EntityLiving handle = NMSImpl.getHandle(horse);
public void openHorseScreen(Tameable horse, Player equipper) {
EntityLiving handle = NMSImpl.getHandle((LivingEntity) horse);
EntityLiving equipperHandle = NMSImpl.getHandle(equipper);
if (handle == null || equipperHandle == null)
return;
boolean wasTamed = horse.isTamed();
horse.setTamed(true);
((EntityHorse) handle).a((EntityHuman) equipperHandle);
((EntityHorseAbstract) handle).a((EntityHuman) equipperHandle);
horse.setTamed(wasTamed);
}