More changes, fixed armor
This commit is contained in:
		@@ -3,7 +3,6 @@ package me.libraryaddict.disguise.commands;
 | 
			
		||||
import java.lang.reflect.InvocationTargetException;
 | 
			
		||||
import java.lang.reflect.Method;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.Collections;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
@@ -39,6 +38,7 @@ import me.libraryaddict.disguise.disguisetypes.MobDisguise;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.RabbitType;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author libraryaddict
 | 
			
		||||
@@ -157,26 +157,6 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected Method[] getDisguiseWatcherMethods(Class<? extends FlagWatcher> watcherClass) {
 | 
			
		||||
        Method[] methods = watcherClass.getMethods();
 | 
			
		||||
 | 
			
		||||
        methods = Arrays.copyOf(methods, methods.length + 4);
 | 
			
		||||
        int i = 4;
 | 
			
		||||
 | 
			
		||||
        for (String methodName : new String[] {
 | 
			
		||||
                "setViewSelfDisguise", "setHideHeldItemFromSelf", "setHideArmorFromSelf", "setHearSelfDisguise"
 | 
			
		||||
        }) {
 | 
			
		||||
            try {
 | 
			
		||||
                methods[methods.length - i--] = Disguise.class.getMethod(methodName, boolean.class);
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex) {
 | 
			
		||||
                ex.printStackTrace();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return methods;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private Entry<Method, Integer> getMethod(Method[] methods, String methodName, int toStart) {
 | 
			
		||||
        for (int i = toStart; i < methods.length; i++) {
 | 
			
		||||
            Method method = methods[i];
 | 
			
		||||
@@ -665,7 +645,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
 | 
			
		||||
        System.arraycopy(args, toSkip, newArgs, 0, args.length - toSkip);
 | 
			
		||||
        args = newArgs;
 | 
			
		||||
 | 
			
		||||
        Method[] methods = this.getDisguiseWatcherMethods(disguise.getWatcher().getClass());
 | 
			
		||||
        Method[] methods = ReflectionFlagWatchers.getDisguiseWatcherMethods(disguise.getWatcher().getClass());
 | 
			
		||||
 | 
			
		||||
        for (int i = 0; i < args.length; i += 2) {
 | 
			
		||||
            String methodName = args[i];
 | 
			
		||||
@@ -985,9 +965,23 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
 | 
			
		||||
 | 
			
		||||
    private ItemStack parseToItemstack(String string) throws Exception {
 | 
			
		||||
        String[] split = string.split(":", -1);
 | 
			
		||||
 | 
			
		||||
        int itemId = -1;
 | 
			
		||||
 | 
			
		||||
        if (isNumeric(split[0])) {
 | 
			
		||||
            int itemId = Integer.parseInt(split[0]);
 | 
			
		||||
            itemId = Integer.parseInt(split[0]);
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            try {
 | 
			
		||||
                itemId = Material.valueOf(split[0].toUpperCase()).getId();
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex) {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (itemId != -1) {
 | 
			
		||||
            short itemDura = 0;
 | 
			
		||||
 | 
			
		||||
            if (split.length > 1) {
 | 
			
		||||
                if (isNumeric(split[1])) {
 | 
			
		||||
                    itemDura = Short.parseShort(split[1]);
 | 
			
		||||
@@ -996,6 +990,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
 | 
			
		||||
                    throw parseToException("item ID:Durability combo", string, "%s");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return new ItemStack(itemId, 1, itemDura);
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
 
 | 
			
		||||
@@ -123,7 +123,7 @@ public class DisguiseCommand extends BaseDisguiseCommand implements TabCompleter
 | 
			
		||||
                                addMethods = false;
 | 
			
		||||
 | 
			
		||||
                            if (info.isEnums()) {
 | 
			
		||||
                                for (String e : info.getEnums()) {
 | 
			
		||||
                                for (String e : info.getEnums(origArgs[origArgs.length - 1])) {
 | 
			
		||||
                                    tabs.add(e);
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
 
 | 
			
		||||
@@ -46,7 +46,7 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand implements TabCompl
 | 
			
		||||
 | 
			
		||||
                    if (help != null) {
 | 
			
		||||
                        sender.sendMessage(ChatColor.RED + help.getName() + ": " + ChatColor.GREEN
 | 
			
		||||
                                + StringUtils.join(help.getEnums(), ChatColor.RED + ", " + ChatColor.GREEN));
 | 
			
		||||
                                + StringUtils.join(help.getEnums(""), ChatColor.RED + ", " + ChatColor.GREEN));
 | 
			
		||||
                        return true;
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -108,7 +108,7 @@ public class EntityDisguiseCommand extends BaseDisguiseCommand implements TabCom
 | 
			
		||||
                                addMethods = false;
 | 
			
		||||
 | 
			
		||||
                            if (info.isEnums()) {
 | 
			
		||||
                                for (String e : info.getEnums()) {
 | 
			
		||||
                                for (String e : info.getEnums(origArgs[origArgs.length - 1])) {
 | 
			
		||||
                                    tabs.add(e);
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
 
 | 
			
		||||
@@ -159,7 +159,7 @@ public class PlayerDisguiseCommand extends BaseDisguiseCommand implements TabCom
 | 
			
		||||
                                addMethods = false;
 | 
			
		||||
 | 
			
		||||
                            if (info.isEnums()) {
 | 
			
		||||
                                for (String e : info.getEnums()) {
 | 
			
		||||
                                for (String e : info.getEnums(origArgs[origArgs.length - 1])) {
 | 
			
		||||
                                    tabs.add(e);
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
 
 | 
			
		||||
@@ -269,7 +269,7 @@ public class RadiusDisguiseCommand extends BaseDisguiseCommand implements TabCom
 | 
			
		||||
                                addMethods = false;
 | 
			
		||||
 | 
			
		||||
                            if (info.isEnums()) {
 | 
			
		||||
                                for (String e : info.getEnums()) {
 | 
			
		||||
                                for (String e : info.getEnums(origArgs[origArgs.length - 1])) {
 | 
			
		||||
                                    tabs.add(e);
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
 
 | 
			
		||||
@@ -34,16 +34,15 @@ public class FlagWatcher {
 | 
			
		||||
    private HashMap<Integer, Object> backupEntityValues = new HashMap<>();
 | 
			
		||||
    private TargetedDisguise disguise;
 | 
			
		||||
    private HashMap<Integer, Object> entityValues = new HashMap<>();
 | 
			
		||||
    private EntityEquipment equipment;
 | 
			
		||||
    private LibsEquipment equipment;
 | 
			
		||||
    private boolean hasDied;
 | 
			
		||||
    private HashSet<Integer> modifiedEntityAnimations = new HashSet<>();
 | 
			
		||||
    private List<WrappedWatchableObject> watchableObjects;
 | 
			
		||||
 | 
			
		||||
    public FlagWatcher(Disguise disguise) {
 | 
			
		||||
        this.disguise = (TargetedDisguise) disguise;
 | 
			
		||||
        equipment = ReflectionManager.createEntityEquipment(disguise.getEntity());
 | 
			
		||||
 | 
			
		||||
        this.setData(FlagType.ENTITY_AIR_TICKS, 0);
 | 
			
		||||
        equipment = new LibsEquipment(this);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private byte addEntityAnimations(byte originalValue, byte entityValue) {
 | 
			
		||||
@@ -72,7 +71,7 @@ public class FlagWatcher {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        cloned.entityValues = (HashMap<Integer, Object>) entityValues.clone();
 | 
			
		||||
        cloned.equipment = ReflectionManager.createEntityEquipment(cloned.getDisguise().getEntity());
 | 
			
		||||
        cloned.equipment = equipment.clone(cloned);
 | 
			
		||||
        cloned.modifiedEntityAnimations = (HashSet<Integer>) modifiedEntityAnimations.clone();
 | 
			
		||||
        cloned.addEntityAnimations = addEntityAnimations;
 | 
			
		||||
 | 
			
		||||
@@ -202,10 +201,7 @@ public class FlagWatcher {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public ItemStack[] getArmor() {
 | 
			
		||||
        ItemStack[] armor = new ItemStack[4];
 | 
			
		||||
        System.arraycopy(armor, 0, armor, 0, 4);
 | 
			
		||||
 | 
			
		||||
        return armor;
 | 
			
		||||
        return getEquipment().getArmorContents();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getCustomName() {
 | 
			
		||||
@@ -225,39 +221,15 @@ public class FlagWatcher {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public ItemStack getItemInMainHand() {
 | 
			
		||||
        if (equipment == null)
 | 
			
		||||
            return null;
 | 
			
		||||
 | 
			
		||||
        return equipment.getItemInMainHand();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public ItemStack getItemInOffHand() {
 | 
			
		||||
        if (equipment == null)
 | 
			
		||||
            return null;
 | 
			
		||||
 | 
			
		||||
        return equipment.getItemInOffHand();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public ItemStack getItemStack(EquipmentSlot slot) {
 | 
			
		||||
        if (equipment == null)
 | 
			
		||||
            return null;
 | 
			
		||||
 | 
			
		||||
        switch (slot) {
 | 
			
		||||
        case CHEST:
 | 
			
		||||
            return equipment.getChestplate();
 | 
			
		||||
        case FEET:
 | 
			
		||||
            return equipment.getBoots();
 | 
			
		||||
        case HAND:
 | 
			
		||||
            return equipment.getItemInMainHand();
 | 
			
		||||
        case HEAD:
 | 
			
		||||
            return equipment.getHelmet();
 | 
			
		||||
        case LEGS:
 | 
			
		||||
            return equipment.getLeggings();
 | 
			
		||||
        case OFF_HAND:
 | 
			
		||||
            return equipment.getItemInOffHand();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
        return equipment.getItem(slot);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected <Y> Y getData(FlagType<Y> flagType) {
 | 
			
		||||
@@ -407,11 +379,8 @@ public class FlagWatcher {
 | 
			
		||||
        addEntityAnimations = isEntityAnimationsAdded;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setArmor(ItemStack[] itemstack) {
 | 
			
		||||
        setItemStack(EquipmentSlot.HEAD, itemstack[0]);
 | 
			
		||||
        setItemStack(EquipmentSlot.CHEST, itemstack[1]);
 | 
			
		||||
        setItemStack(EquipmentSlot.LEGS, itemstack[2]);
 | 
			
		||||
        setItemStack(EquipmentSlot.FEET, itemstack[3]);
 | 
			
		||||
    public void setArmor(ItemStack[] items) {
 | 
			
		||||
        getEquipment().setArmorContents(items);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void setBackupValue(FlagType no, Object value) {
 | 
			
		||||
@@ -484,69 +453,61 @@ public class FlagWatcher {
 | 
			
		||||
        setItemStack(EquipmentSlot.OFF_HAND, itemstack);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void setItemStack(EntityEquipment equipment, EquipmentSlot slot, ItemStack itemStack) {
 | 
			
		||||
        if (equipment == null)
 | 
			
		||||
            return;
 | 
			
		||||
    public void setItemStack(EquipmentSlot slot, ItemStack itemStack) {
 | 
			
		||||
        setItemStack(slot, itemStack);
 | 
			
		||||
 | 
			
		||||
        switch (slot) {
 | 
			
		||||
        case CHEST:
 | 
			
		||||
            equipment.setChestplate(itemStack);
 | 
			
		||||
            break;
 | 
			
		||||
        case FEET:
 | 
			
		||||
            equipment.setBoots(itemStack);
 | 
			
		||||
            break;
 | 
			
		||||
        case HAND:
 | 
			
		||||
            equipment.setItemInMainHand(itemStack);
 | 
			
		||||
            break;
 | 
			
		||||
        case HEAD:
 | 
			
		||||
            equipment.setHelmet(itemStack);
 | 
			
		||||
            break;
 | 
			
		||||
        case LEGS:
 | 
			
		||||
            equipment.setLeggings(itemStack);
 | 
			
		||||
            break;
 | 
			
		||||
        case OFF_HAND:
 | 
			
		||||
            equipment.setItemInOffHand(itemStack);
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        sendItemStack(slot, itemStack);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setItemStack(EquipmentSlot slot, ItemStack itemStack) {
 | 
			
		||||
        if (equipment == null)
 | 
			
		||||
    protected void sendItemStack(EquipmentSlot slot, ItemStack itemStack) {
 | 
			
		||||
        if (!DisguiseAPI.isDisguiseInUse(getDisguise()) || getDisguise().getWatcher() != this
 | 
			
		||||
                || getDisguise().getEntity() == null)
 | 
			
		||||
            return;
 | 
			
		||||
 | 
			
		||||
        // Itemstack which is null means that its not replacing the disguises itemstack.
 | 
			
		||||
        if (itemStack == null) {
 | 
			
		||||
            // Find the item to replace it with
 | 
			
		||||
            if (getDisguise().getEntity() instanceof LivingEntity) {
 | 
			
		||||
                EntityEquipment equipment = ((LivingEntity) getDisguise().getEntity()).getEquipment();
 | 
			
		||||
                setItemStack(equipment, slot, itemStack);
 | 
			
		||||
        if (itemStack == null && getDisguise().getEntity() instanceof LivingEntity) {
 | 
			
		||||
            EntityEquipment equip = ((LivingEntity) getDisguise().getEntity()).getEquipment();
 | 
			
		||||
 | 
			
		||||
            switch (slot) {
 | 
			
		||||
            case HAND:
 | 
			
		||||
                itemStack = equip.getItemInMainHand();
 | 
			
		||||
                break;
 | 
			
		||||
            case OFF_HAND:
 | 
			
		||||
                itemStack = equip.getItemInOffHand();
 | 
			
		||||
                break;
 | 
			
		||||
            case HEAD:
 | 
			
		||||
                itemStack = equip.getHelmet();
 | 
			
		||||
                break;
 | 
			
		||||
            case CHEST:
 | 
			
		||||
                itemStack = equip.getChestplate();
 | 
			
		||||
                break;
 | 
			
		||||
            case LEGS:
 | 
			
		||||
                itemStack = equip.getLeggings();
 | 
			
		||||
                break;
 | 
			
		||||
            case FEET:
 | 
			
		||||
                itemStack = equip.getBoots();
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Object itemToSend = null;
 | 
			
		||||
        Object itemToSend = ReflectionManager.getNmsItem(itemStack);
 | 
			
		||||
 | 
			
		||||
        if (itemStack != null && itemStack.getTypeId() != 0) {
 | 
			
		||||
            itemToSend = ReflectionManager.getNmsItem(itemStack);
 | 
			
		||||
        }
 | 
			
		||||
        PacketContainer packet = new PacketContainer(Server.ENTITY_EQUIPMENT);
 | 
			
		||||
 | 
			
		||||
        setItemStack(equipment, slot, itemStack);
 | 
			
		||||
        StructureModifier<Object> mods = packet.getModifier();
 | 
			
		||||
 | 
			
		||||
        if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) {
 | 
			
		||||
            PacketContainer packet = new PacketContainer(Server.ENTITY_EQUIPMENT);
 | 
			
		||||
        mods.write(0, getDisguise().getEntity().getEntityId());
 | 
			
		||||
        mods.write(1, ReflectionManager.createEnumItemSlot(slot));
 | 
			
		||||
        mods.write(2, itemToSend);
 | 
			
		||||
 | 
			
		||||
            StructureModifier<Object> mods = packet.getModifier();
 | 
			
		||||
        for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
 | 
			
		||||
 | 
			
		||||
            mods.write(0, getDisguise().getEntity().getEntityId());
 | 
			
		||||
            mods.write(1, ReflectionManager.createEnumItemSlot(slot));
 | 
			
		||||
            mods.write(2, itemToSend);
 | 
			
		||||
 | 
			
		||||
            for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
 | 
			
		||||
                try {
 | 
			
		||||
                    ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
 | 
			
		||||
                }
 | 
			
		||||
                catch (InvocationTargetException e) {
 | 
			
		||||
                    e.printStackTrace();
 | 
			
		||||
                }
 | 
			
		||||
            try {
 | 
			
		||||
                ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
 | 
			
		||||
            }
 | 
			
		||||
            catch (InvocationTargetException e) {
 | 
			
		||||
                e.printStackTrace();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										211
									
								
								src/me/libraryaddict/disguise/disguisetypes/LibsEquipment.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										211
									
								
								src/me/libraryaddict/disguise/disguisetypes/LibsEquipment.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,211 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes; // Its here so I can make use of flagWatcher.sendItemStack() which is protected
 | 
			
		||||
 | 
			
		||||
import org.bukkit.entity.Entity;
 | 
			
		||||
import org.bukkit.inventory.EntityEquipment;
 | 
			
		||||
import org.bukkit.inventory.EquipmentSlot;
 | 
			
		||||
import org.bukkit.inventory.ItemStack;
 | 
			
		||||
 | 
			
		||||
public class LibsEquipment implements EntityEquipment {
 | 
			
		||||
    private ItemStack[] equipment = new ItemStack[6];
 | 
			
		||||
    private FlagWatcher flagWatcher;
 | 
			
		||||
 | 
			
		||||
    public LibsEquipment(FlagWatcher flagWatcher) {
 | 
			
		||||
        this.flagWatcher = flagWatcher;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public LibsEquipment clone(FlagWatcher flagWatcher) {
 | 
			
		||||
        LibsEquipment newEquip = new LibsEquipment(flagWatcher);
 | 
			
		||||
 | 
			
		||||
        for (int i = 0; i < equipment.length; i++) {
 | 
			
		||||
            ItemStack item = equipment[i];
 | 
			
		||||
 | 
			
		||||
            if (item == null)
 | 
			
		||||
                continue;
 | 
			
		||||
 | 
			
		||||
            newEquip.equipment[i] = item.clone();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return newEquip;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public ItemStack getItem(EquipmentSlot slot) {
 | 
			
		||||
        return equipment[slot.ordinal()];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setItem(EquipmentSlot slot, ItemStack item) {
 | 
			
		||||
        if (getItem(slot) == item)
 | 
			
		||||
            return;
 | 
			
		||||
 | 
			
		||||
        equipment[slot.ordinal()] = item;
 | 
			
		||||
        flagWatcher.sendItemStack(slot, item);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack getItemInMainHand() {
 | 
			
		||||
        return getItem(EquipmentSlot.HAND);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setItemInMainHand(ItemStack item) {
 | 
			
		||||
        setItem(EquipmentSlot.HAND, item);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack getItemInOffHand() {
 | 
			
		||||
        return getItem(EquipmentSlot.OFF_HAND);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setItemInOffHand(ItemStack item) {
 | 
			
		||||
        setItem(EquipmentSlot.OFF_HAND, item);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack getItemInHand() {
 | 
			
		||||
        return getItem(EquipmentSlot.HAND);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setItemInHand(ItemStack stack) {
 | 
			
		||||
        setItem(EquipmentSlot.HAND, stack);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack getHelmet() {
 | 
			
		||||
        return getItem(EquipmentSlot.HEAD);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setHelmet(ItemStack helmet) {
 | 
			
		||||
        setItem(EquipmentSlot.HEAD, helmet);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack getChestplate() {
 | 
			
		||||
        return getItem(EquipmentSlot.CHEST);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setChestplate(ItemStack chestplate) {
 | 
			
		||||
        setItem(EquipmentSlot.CHEST, chestplate);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack getLeggings() {
 | 
			
		||||
        return getItem(EquipmentSlot.LEGS);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setLeggings(ItemStack leggings) {
 | 
			
		||||
        setItem(EquipmentSlot.LEGS, leggings);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack getBoots() {
 | 
			
		||||
        return getItem(EquipmentSlot.FEET);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setBoots(ItemStack boots) {
 | 
			
		||||
        setItem(EquipmentSlot.FEET, boots);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack[] getArmorContents() {
 | 
			
		||||
        return new ItemStack[] {
 | 
			
		||||
                getBoots(), getLeggings(), getChestplate(), getHelmet()
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setArmorContents(ItemStack[] items) {
 | 
			
		||||
        setBoots(items[0]);
 | 
			
		||||
        setLeggings(items[1]);
 | 
			
		||||
        setChestplate(items[2]);
 | 
			
		||||
        setHelmet(items[3]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void clear() {
 | 
			
		||||
        setBoots(null);
 | 
			
		||||
        setLeggings(null);
 | 
			
		||||
        setChestplate(null);
 | 
			
		||||
        setHelmet(null);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public float getItemInHandDropChance() {
 | 
			
		||||
        throw new UnsupportedOperationException("This is not supported on a disguise");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setItemInHandDropChance(float chance) {
 | 
			
		||||
        throw new UnsupportedOperationException("This is not supported on a disguise");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public float getItemInMainHandDropChance() {
 | 
			
		||||
        throw new UnsupportedOperationException("This is not supported on a disguise");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setItemInMainHandDropChance(float chance) {
 | 
			
		||||
        throw new UnsupportedOperationException("This is not supported on a disguise");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public float getItemInOffHandDropChance() {
 | 
			
		||||
        throw new UnsupportedOperationException("This is not supported on a disguise");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setItemInOffHandDropChance(float chance) {
 | 
			
		||||
        throw new UnsupportedOperationException("This is not supported on a disguise");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public float getHelmetDropChance() {
 | 
			
		||||
        throw new UnsupportedOperationException("This is not supported on a disguise");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setHelmetDropChance(float chance) {
 | 
			
		||||
        throw new UnsupportedOperationException("This is not supported on a disguise");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public float getChestplateDropChance() {
 | 
			
		||||
        throw new UnsupportedOperationException("This is not supported on a disguise");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setChestplateDropChance(float chance) {
 | 
			
		||||
        throw new UnsupportedOperationException("This is not supported on a disguise");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public float getLeggingsDropChance() {
 | 
			
		||||
        throw new UnsupportedOperationException("This is not supported on a disguise");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setLeggingsDropChance(float chance) {
 | 
			
		||||
        throw new UnsupportedOperationException("This is not supported on a disguise");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public float getBootsDropChance() {
 | 
			
		||||
        throw new UnsupportedOperationException("This is not supported on a disguise");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setBootsDropChance(float chance) {
 | 
			
		||||
        throw new UnsupportedOperationException("This is not supported on a disguise");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Entity getHolder() {
 | 
			
		||||
        throw new UnsupportedOperationException("This is not supported on a disguise");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -25,26 +25,21 @@ import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
 | 
			
		||||
 | 
			
		||||
public class LivingWatcher extends FlagWatcher
 | 
			
		||||
{
 | 
			
		||||
public class LivingWatcher extends FlagWatcher {
 | 
			
		||||
    static Map<Integer, Object> list = new HashMap<>();
 | 
			
		||||
    static Method getId;
 | 
			
		||||
 | 
			
		||||
    static
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
    static {
 | 
			
		||||
        try {
 | 
			
		||||
            getId = ReflectionManager.getNmsMethod("MobEffectList", "getId", ReflectionManager.getNmsClass("MobEffectList"));
 | 
			
		||||
            Object REGISTRY = ReflectionManager.getNmsField("MobEffectList", "REGISTRY").get(null);
 | 
			
		||||
 | 
			
		||||
            for (Object next : ((Iterable) REGISTRY))
 | 
			
		||||
            {
 | 
			
		||||
            for (Object next : ((Iterable) REGISTRY)) {
 | 
			
		||||
                int id = (int) getId.invoke(null, next);
 | 
			
		||||
                list.put(id, next);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception ex)
 | 
			
		||||
        {
 | 
			
		||||
        catch (Exception ex) {
 | 
			
		||||
            ex.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -53,15 +48,12 @@ public class LivingWatcher extends FlagWatcher
 | 
			
		||||
    private boolean maxHealthSet;
 | 
			
		||||
    private HashSet<Integer> potionEffects = new HashSet<>();
 | 
			
		||||
 | 
			
		||||
    public LivingWatcher(Disguise disguise)
 | 
			
		||||
    {
 | 
			
		||||
    public LivingWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void addPotionEffect(PotionEffectType potionEffect)
 | 
			
		||||
    {
 | 
			
		||||
        if (!hasPotionEffect(potionEffect))
 | 
			
		||||
        {
 | 
			
		||||
    public void addPotionEffect(PotionEffectType potionEffect) {
 | 
			
		||||
        if (!hasPotionEffect(potionEffect)) {
 | 
			
		||||
            removePotionEffect(potionEffect);
 | 
			
		||||
            potionEffects.add(potionEffect.getId());
 | 
			
		||||
 | 
			
		||||
@@ -70,8 +62,7 @@ public class LivingWatcher extends FlagWatcher
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public LivingWatcher clone(Disguise disguise)
 | 
			
		||||
    {
 | 
			
		||||
    public LivingWatcher clone(Disguise disguise) {
 | 
			
		||||
        LivingWatcher clone = (LivingWatcher) super.clone(disguise);
 | 
			
		||||
        clone.potionEffects = (HashSet<Integer>) potionEffects.clone();
 | 
			
		||||
        clone.maxHealth = maxHealth;
 | 
			
		||||
@@ -80,27 +71,22 @@ public class LivingWatcher extends FlagWatcher
 | 
			
		||||
        return clone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public float getHealth()
 | 
			
		||||
    {
 | 
			
		||||
    public float getHealth() {
 | 
			
		||||
        return (float) getData(FlagType.LIVING_HEALTH);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public double getMaxHealth()
 | 
			
		||||
    {
 | 
			
		||||
    public double getMaxHealth() {
 | 
			
		||||
        return maxHealth;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isPotionParticlesAmbient()
 | 
			
		||||
    {
 | 
			
		||||
    public boolean isPotionParticlesAmbient() {
 | 
			
		||||
        return (boolean) getData(FlagType.LIVING_POTION_AMBIENT);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private int getPotions()
 | 
			
		||||
    {
 | 
			
		||||
    private int getPotions() {
 | 
			
		||||
        int m = 3694022;
 | 
			
		||||
 | 
			
		||||
        if (potionEffects.isEmpty())
 | 
			
		||||
        {
 | 
			
		||||
        if (potionEffects.isEmpty()) {
 | 
			
		||||
            return m;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -108,10 +94,8 @@ public class LivingWatcher extends FlagWatcher
 | 
			
		||||
        float f2 = 0.0F;
 | 
			
		||||
        float f3 = 0.0F;
 | 
			
		||||
        float f4 = 0.0F;
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            for (int localMobEffect : potionEffects)
 | 
			
		||||
            {
 | 
			
		||||
        try {
 | 
			
		||||
            for (int localMobEffect : potionEffects) {
 | 
			
		||||
                int n = (Integer) getId.invoke(list.get(localMobEffect));
 | 
			
		||||
                f1 += (n >> 16 & 0xFF) / 255.0F;
 | 
			
		||||
                f2 += (n >> 8 & 0xFF) / 255.0F;
 | 
			
		||||
@@ -119,8 +103,7 @@ public class LivingWatcher extends FlagWatcher
 | 
			
		||||
                f4 += 1.0F;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception ex)
 | 
			
		||||
        {
 | 
			
		||||
        catch (Exception ex) {
 | 
			
		||||
            ex.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -131,61 +114,50 @@ public class LivingWatcher extends FlagWatcher
 | 
			
		||||
        return (int) f1 << 16 | (int) f2 << 8 | (int) f3;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean hasPotionEffect(PotionEffectType type)
 | 
			
		||||
    {
 | 
			
		||||
    public boolean hasPotionEffect(PotionEffectType type) {
 | 
			
		||||
        return potionEffects.contains(type.getId());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isMaxHealthSet()
 | 
			
		||||
    {
 | 
			
		||||
    public boolean isMaxHealthSet() {
 | 
			
		||||
        return maxHealthSet;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void removePotionEffect(PotionEffectType type)
 | 
			
		||||
    {
 | 
			
		||||
        if (potionEffects.contains(type.getId()))
 | 
			
		||||
        {
 | 
			
		||||
    public void removePotionEffect(PotionEffectType type) {
 | 
			
		||||
        if (potionEffects.contains(type.getId())) {
 | 
			
		||||
            potionEffects.remove(type.getId());
 | 
			
		||||
            sendPotionEffects();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPotionParticlesAmbient(boolean particles)
 | 
			
		||||
    {
 | 
			
		||||
    public void setPotionParticlesAmbient(boolean particles) {
 | 
			
		||||
        setData(FlagType.LIVING_POTION_AMBIENT, particles);
 | 
			
		||||
        sendData(FlagType.LIVING_POTION_AMBIENT);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void sendPotionEffects()
 | 
			
		||||
    {
 | 
			
		||||
    private void sendPotionEffects() {
 | 
			
		||||
        setData(FlagType.LIVING_POTIONS, getPotions());
 | 
			
		||||
        sendData(FlagType.LIVING_POTIONS);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setHealth(float health)
 | 
			
		||||
    {
 | 
			
		||||
    public void setHealth(float health) {
 | 
			
		||||
        setData(FlagType.LIVING_HEALTH, health);
 | 
			
		||||
        sendData(FlagType.LIVING_HEALTH);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getArrowsSticking()
 | 
			
		||||
    {
 | 
			
		||||
    public int getArrowsSticking() {
 | 
			
		||||
        return (int) getData(FlagType.LIVING_ARROWS);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setArrowsSticking(int arrowsNo)
 | 
			
		||||
    {
 | 
			
		||||
    public void setArrowsSticking(int arrowsNo) {
 | 
			
		||||
        setData(FlagType.LIVING_ARROWS, arrowsNo);
 | 
			
		||||
        sendData(FlagType.LIVING_ARROWS);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setMaxHealth(double newHealth)
 | 
			
		||||
    {
 | 
			
		||||
    public void setMaxHealth(double newHealth) {
 | 
			
		||||
        this.maxHealth = newHealth;
 | 
			
		||||
        this.maxHealthSet = true;
 | 
			
		||||
 | 
			
		||||
        if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this)
 | 
			
		||||
        {
 | 
			
		||||
        if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) {
 | 
			
		||||
            PacketContainer packet = new PacketContainer(Server.UPDATE_ATTRIBUTES);
 | 
			
		||||
 | 
			
		||||
            List<WrappedAttribute> attributes = new ArrayList<>();
 | 
			
		||||
@@ -203,18 +175,14 @@ public class LivingWatcher extends FlagWatcher
 | 
			
		||||
            packet.getIntegers().write(0, entity.getEntityId());
 | 
			
		||||
            packet.getAttributeCollectionModifier().write(0, attributes);
 | 
			
		||||
 | 
			
		||||
            for (Player player : DisguiseUtilities.getPerverts(getDisguise()))
 | 
			
		||||
            {
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
            for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
 | 
			
		||||
                try {
 | 
			
		||||
                    ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false);
 | 
			
		||||
                }
 | 
			
		||||
                catch (InvocationTargetException e)
 | 
			
		||||
                {
 | 
			
		||||
                catch (InvocationTargetException e) {
 | 
			
		||||
                    e.printStackTrace();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -186,6 +186,7 @@ public class PacketsManager {
 | 
			
		||||
                ItemStack itemstack = disguise.getWatcher().getItemStack(slot);
 | 
			
		||||
 | 
			
		||||
                if (itemstack == null || itemstack.getType() == Material.AIR) {
 | 
			
		||||
                    System.out.println("Not wearing anything for " + slot.name());
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -3,10 +3,13 @@ package me.libraryaddict.disguise.utilities;
 | 
			
		||||
import java.lang.reflect.Method;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.Collections;
 | 
			
		||||
import java.util.Comparator;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
 | 
			
		||||
import org.apache.commons.lang.StringUtils;
 | 
			
		||||
import org.bukkit.Art;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.block.BlockFace;
 | 
			
		||||
import org.bukkit.entity.Horse;
 | 
			
		||||
import org.bukkit.entity.Llama;
 | 
			
		||||
@@ -82,7 +85,7 @@ public class ReflectionFlagWatchers {
 | 
			
		||||
            return description;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public String[] getEnums() {
 | 
			
		||||
        public String[] getEnums(String tabComplete) {
 | 
			
		||||
            return enums;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -141,6 +144,34 @@ public class ReflectionFlagWatchers {
 | 
			
		||||
 | 
			
		||||
            potionEnums.add(toReadable(effectType.getName()));
 | 
			
		||||
        }
 | 
			
		||||
        String[] materials = new String[Material.values().length];
 | 
			
		||||
 | 
			
		||||
        for (int i = 0; i < Material.values().length; i++) {
 | 
			
		||||
            materials[i] = Material.values()[i].name();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        paramList.add(new ParamInfo(ItemStack.class, "Item (id:damage)", "An ItemStack compromised of ID:Durability", materials));
 | 
			
		||||
 | 
			
		||||
        paramList.add(new ParamInfo(ItemStack[].class, "Four ItemStacks (id:damage,id:damage..)",
 | 
			
		||||
                "Four ItemStacks seperated by an ,", materials) {
 | 
			
		||||
            @Override
 | 
			
		||||
            public String[] getEnums(String tabComplete) {
 | 
			
		||||
                String beginning = tabComplete.substring(0, tabComplete.contains(",") ? tabComplete.lastIndexOf(",") + 1 : 0);
 | 
			
		||||
                String end = tabComplete.substring(tabComplete.contains(",") ? tabComplete.lastIndexOf(",") + 1 : 0);
 | 
			
		||||
 | 
			
		||||
                ArrayList<String> toReturn = new ArrayList<String>();
 | 
			
		||||
 | 
			
		||||
                for (String material : super.getEnums("")) {
 | 
			
		||||
                    if (!material.toLowerCase().startsWith(end.toLowerCase()))
 | 
			
		||||
                        continue;
 | 
			
		||||
 | 
			
		||||
                    toReturn.add(beginning + material);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                return toReturn.toArray(new String[0]);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        paramList.add(new ParamInfo(PotionEffectType.class, "Potion Effect", "View all the potion effects you can add",
 | 
			
		||||
                potionEnums.toArray(new String[0])));
 | 
			
		||||
@@ -151,14 +182,18 @@ public class ReflectionFlagWatchers {
 | 
			
		||||
        paramList.add(new ParamInfo(int.class, "Number", "A whole number, no decimcals"));
 | 
			
		||||
        paramList.add(new ParamInfo(double.class, "Number", "A number which can have decimals"));
 | 
			
		||||
        paramList.add(new ParamInfo(float.class, "Number", "A number which can have decimals"));
 | 
			
		||||
        paramList.add(new ParamInfo(ItemStack.class, "Item (id:damage)", "An ItemStack compromised of ID:Durability"));
 | 
			
		||||
        paramList.add(
 | 
			
		||||
                new ParamInfo(ItemStack[].class, "Four ItemStacks (id:damage,id:damage..)", "Four ItemStacks seperated by an ,"));
 | 
			
		||||
        paramList.add(new ParamInfo(Horse.Style.class, "Horse Style", "Horse style which is the patterns on the horse"));
 | 
			
		||||
        paramList.add(new ParamInfo(int[].class, "number,number,number...", "Numbers seperated by an ,"));
 | 
			
		||||
        paramList.add(new ParamInfo(BlockPosition.class, "Block Position (num,num,num)", "Three numbers seperated by an ,"));
 | 
			
		||||
        paramList.add(new ParamInfo(GameProfile.class, "GameProfile",
 | 
			
		||||
                "Get the gameprofile here https://sessionserver.mojang.com/session/minecraft/profile/PLAYER_UUID_GOES_HERE?unsigned=false"));
 | 
			
		||||
 | 
			
		||||
        Collections.sort(paramList, new Comparator<ParamInfo>() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public int compare(ParamInfo o1, ParamInfo o2) {
 | 
			
		||||
                return String.CASE_INSENSITIVE_ORDER.compare(o1.getName(), o2.getName());
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Method[] getDisguiseWatcherMethods(Class<? extends FlagWatcher> watcherClass) {
 | 
			
		||||
@@ -184,6 +219,9 @@ public class ReflectionFlagWatchers {
 | 
			
		||||
            else if (!method.getReturnType().equals(Void.TYPE)) {
 | 
			
		||||
                itel.remove();
 | 
			
		||||
            }
 | 
			
		||||
            else if (method.getName().equals("removePotionEffect")) {
 | 
			
		||||
                itel.remove();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        for (String methodName : new String[] {
 | 
			
		||||
 
 | 
			
		||||
@@ -20,7 +20,6 @@ import org.bukkit.entity.Entity;
 | 
			
		||||
import org.bukkit.entity.LivingEntity;
 | 
			
		||||
import org.bukkit.entity.Monster;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.bukkit.inventory.EntityEquipment;
 | 
			
		||||
import org.bukkit.inventory.EquipmentSlot;
 | 
			
		||||
import org.bukkit.inventory.ItemStack;
 | 
			
		||||
import org.bukkit.potion.PotionEffect;
 | 
			
		||||
@@ -895,22 +894,6 @@ public class ReflectionManager {
 | 
			
		||||
        return new WrappedWatchableObject(createDataWatcherItem(index, obj));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static EntityEquipment createEntityEquipment(Entity entity) {
 | 
			
		||||
        if (!(entity instanceof LivingEntity))
 | 
			
		||||
            return null;
 | 
			
		||||
 | 
			
		||||
        Constructor construct = getCraftConstructor("inventory.CraftEntityEquipment", getCraftClass("entity.CraftLivingEntity"));
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            return (EntityEquipment) construct.newInstance((LivingEntity) entity);
 | 
			
		||||
        }
 | 
			
		||||
        catch (InstantiationException | IllegalAccessException | InvocationTargetException | ClassCastException e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static int getCombinedId(int id, int data) {
 | 
			
		||||
        return id + (data << 12);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user