Seriously, wtf? Removed reflection on Bukkit API.

This commit is contained in:
riking 2014-06-14 18:05:13 -07:00
parent 48056c735f
commit 2b86c98fbb

View File

@ -27,9 +27,12 @@ import org.bukkit.Bukkit;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Horse;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.HorseInventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
@ -65,18 +68,14 @@ public class DisguiseAPI {
EntityEquipment enquip = ((LivingEntity) entity).getEquipment(); EntityEquipment enquip = ((LivingEntity) entity).getEquipment();
watcher.setArmor(enquip.getArmorContents()); watcher.setArmor(enquip.getArmorContents());
watcher.setItemInHand(enquip.getItemInHand()); watcher.setItemInHand(enquip.getItemInHand());
if (disguiseType.getEntityType().name().equals("HORSE")) { if (disguiseType.getEntityType() == EntityType.HORSE) {
try { Horse horse = (Horse) entity;
Object horseInv = entity.getClass().getMethod("getInventory").invoke(entity); HorseInventory horseInventory = horse.getInventory();
Object item = horseInv.getClass().getMethod("getSaddle").invoke(horseInv); ItemStack saddle = horseInventory.getSaddle();
if (item != null && ((ItemStack) item).getType() == Material.SADDLE) { if (saddle != null && saddle.getType() == Material.SADDLE) {
((HorseWatcher) watcher).setSaddled(true); ((HorseWatcher) watcher).setSaddled(true);
}
((HorseWatcher) watcher)
.setHorseArmor((ItemStack) horseInv.getClass().getMethod("getArmor").invoke(horseInv));
} catch (Exception ex) {
ex.printStackTrace();
} }
((HorseWatcher) watcher).setHorseArmor(horseInventory.getArmor());
} }
} }
for (Method method : entity.getClass().getMethods()) { for (Method method : entity.getClass().getMethods()) {