More changes, fixed armor
This commit is contained in:
parent
cfdd7bbecf
commit
e5799d7a5e
@ -3,7 +3,6 @@ package me.libraryaddict.disguise.commands;
|
|||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
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.PlayerDisguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.RabbitType;
|
import me.libraryaddict.disguise.disguisetypes.RabbitType;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
|
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author libraryaddict
|
* @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) {
|
private Entry<Method, Integer> getMethod(Method[] methods, String methodName, int toStart) {
|
||||||
for (int i = toStart; i < methods.length; i++) {
|
for (int i = toStart; i < methods.length; i++) {
|
||||||
Method method = methods[i];
|
Method method = methods[i];
|
||||||
@ -665,7 +645,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
|||||||
System.arraycopy(args, toSkip, newArgs, 0, args.length - toSkip);
|
System.arraycopy(args, toSkip, newArgs, 0, args.length - toSkip);
|
||||||
args = newArgs;
|
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) {
|
for (int i = 0; i < args.length; i += 2) {
|
||||||
String methodName = args[i];
|
String methodName = args[i];
|
||||||
@ -985,9 +965,23 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
|||||||
|
|
||||||
private ItemStack parseToItemstack(String string) throws Exception {
|
private ItemStack parseToItemstack(String string) throws Exception {
|
||||||
String[] split = string.split(":", -1);
|
String[] split = string.split(":", -1);
|
||||||
|
|
||||||
|
int itemId = -1;
|
||||||
|
|
||||||
if (isNumeric(split[0])) {
|
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;
|
short itemDura = 0;
|
||||||
|
|
||||||
if (split.length > 1) {
|
if (split.length > 1) {
|
||||||
if (isNumeric(split[1])) {
|
if (isNumeric(split[1])) {
|
||||||
itemDura = Short.parseShort(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");
|
throw parseToException("item ID:Durability combo", string, "%s");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ItemStack(itemId, 1, itemDura);
|
return new ItemStack(itemId, 1, itemDura);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -123,7 +123,7 @@ public class DisguiseCommand extends BaseDisguiseCommand implements TabCompleter
|
|||||||
addMethods = false;
|
addMethods = false;
|
||||||
|
|
||||||
if (info.isEnums()) {
|
if (info.isEnums()) {
|
||||||
for (String e : info.getEnums()) {
|
for (String e : info.getEnums(origArgs[origArgs.length - 1])) {
|
||||||
tabs.add(e);
|
tabs.add(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand implements TabCompl
|
|||||||
|
|
||||||
if (help != null) {
|
if (help != null) {
|
||||||
sender.sendMessage(ChatColor.RED + help.getName() + ": " + ChatColor.GREEN
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ public class EntityDisguiseCommand extends BaseDisguiseCommand implements TabCom
|
|||||||
addMethods = false;
|
addMethods = false;
|
||||||
|
|
||||||
if (info.isEnums()) {
|
if (info.isEnums()) {
|
||||||
for (String e : info.getEnums()) {
|
for (String e : info.getEnums(origArgs[origArgs.length - 1])) {
|
||||||
tabs.add(e);
|
tabs.add(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ public class PlayerDisguiseCommand extends BaseDisguiseCommand implements TabCom
|
|||||||
addMethods = false;
|
addMethods = false;
|
||||||
|
|
||||||
if (info.isEnums()) {
|
if (info.isEnums()) {
|
||||||
for (String e : info.getEnums()) {
|
for (String e : info.getEnums(origArgs[origArgs.length - 1])) {
|
||||||
tabs.add(e);
|
tabs.add(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,7 +269,7 @@ public class RadiusDisguiseCommand extends BaseDisguiseCommand implements TabCom
|
|||||||
addMethods = false;
|
addMethods = false;
|
||||||
|
|
||||||
if (info.isEnums()) {
|
if (info.isEnums()) {
|
||||||
for (String e : info.getEnums()) {
|
for (String e : info.getEnums(origArgs[origArgs.length - 1])) {
|
||||||
tabs.add(e);
|
tabs.add(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,16 +34,15 @@ public class FlagWatcher {
|
|||||||
private HashMap<Integer, Object> backupEntityValues = new HashMap<>();
|
private HashMap<Integer, Object> backupEntityValues = new HashMap<>();
|
||||||
private TargetedDisguise disguise;
|
private TargetedDisguise disguise;
|
||||||
private HashMap<Integer, Object> entityValues = new HashMap<>();
|
private HashMap<Integer, Object> entityValues = new HashMap<>();
|
||||||
private EntityEquipment equipment;
|
private LibsEquipment equipment;
|
||||||
private boolean hasDied;
|
private boolean hasDied;
|
||||||
private HashSet<Integer> modifiedEntityAnimations = new HashSet<>();
|
private HashSet<Integer> modifiedEntityAnimations = new HashSet<>();
|
||||||
private List<WrappedWatchableObject> watchableObjects;
|
private List<WrappedWatchableObject> watchableObjects;
|
||||||
|
|
||||||
public FlagWatcher(Disguise disguise) {
|
public FlagWatcher(Disguise disguise) {
|
||||||
this.disguise = (TargetedDisguise) disguise;
|
this.disguise = (TargetedDisguise) disguise;
|
||||||
equipment = ReflectionManager.createEntityEquipment(disguise.getEntity());
|
|
||||||
|
|
||||||
this.setData(FlagType.ENTITY_AIR_TICKS, 0);
|
this.setData(FlagType.ENTITY_AIR_TICKS, 0);
|
||||||
|
equipment = new LibsEquipment(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte addEntityAnimations(byte originalValue, byte entityValue) {
|
private byte addEntityAnimations(byte originalValue, byte entityValue) {
|
||||||
@ -72,7 +71,7 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cloned.entityValues = (HashMap<Integer, Object>) entityValues.clone();
|
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.modifiedEntityAnimations = (HashSet<Integer>) modifiedEntityAnimations.clone();
|
||||||
cloned.addEntityAnimations = addEntityAnimations;
|
cloned.addEntityAnimations = addEntityAnimations;
|
||||||
|
|
||||||
@ -202,10 +201,7 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack[] getArmor() {
|
public ItemStack[] getArmor() {
|
||||||
ItemStack[] armor = new ItemStack[4];
|
return getEquipment().getArmorContents();
|
||||||
System.arraycopy(armor, 0, armor, 0, 4);
|
|
||||||
|
|
||||||
return armor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCustomName() {
|
public String getCustomName() {
|
||||||
@ -225,39 +221,15 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItemInMainHand() {
|
public ItemStack getItemInMainHand() {
|
||||||
if (equipment == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return equipment.getItemInMainHand();
|
return equipment.getItemInMainHand();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItemInOffHand() {
|
public ItemStack getItemInOffHand() {
|
||||||
if (equipment == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return equipment.getItemInOffHand();
|
return equipment.getItemInOffHand();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItemStack(EquipmentSlot slot) {
|
public ItemStack getItemStack(EquipmentSlot slot) {
|
||||||
if (equipment == null)
|
return equipment.getItem(slot);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <Y> Y getData(FlagType<Y> flagType) {
|
protected <Y> Y getData(FlagType<Y> flagType) {
|
||||||
@ -407,11 +379,8 @@ public class FlagWatcher {
|
|||||||
addEntityAnimations = isEntityAnimationsAdded;
|
addEntityAnimations = isEntityAnimationsAdded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArmor(ItemStack[] itemstack) {
|
public void setArmor(ItemStack[] items) {
|
||||||
setItemStack(EquipmentSlot.HEAD, itemstack[0]);
|
getEquipment().setArmorContents(items);
|
||||||
setItemStack(EquipmentSlot.CHEST, itemstack[1]);
|
|
||||||
setItemStack(EquipmentSlot.LEGS, itemstack[2]);
|
|
||||||
setItemStack(EquipmentSlot.FEET, itemstack[3]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setBackupValue(FlagType no, Object value) {
|
protected void setBackupValue(FlagType no, Object value) {
|
||||||
@ -484,69 +453,61 @@ public class FlagWatcher {
|
|||||||
setItemStack(EquipmentSlot.OFF_HAND, itemstack);
|
setItemStack(EquipmentSlot.OFF_HAND, itemstack);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setItemStack(EntityEquipment equipment, EquipmentSlot slot, ItemStack itemStack) {
|
public void setItemStack(EquipmentSlot slot, ItemStack itemStack) {
|
||||||
if (equipment == null)
|
setItemStack(slot, itemStack);
|
||||||
return;
|
|
||||||
|
|
||||||
switch (slot) {
|
sendItemStack(slot, itemStack);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItemStack(EquipmentSlot slot, ItemStack itemStack) {
|
protected void sendItemStack(EquipmentSlot slot, ItemStack itemStack) {
|
||||||
if (equipment == null)
|
if (!DisguiseAPI.isDisguiseInUse(getDisguise()) || getDisguise().getWatcher() != this
|
||||||
|
|| getDisguise().getEntity() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Itemstack which is null means that its not replacing the disguises itemstack.
|
if (itemStack == null && getDisguise().getEntity() instanceof LivingEntity) {
|
||||||
if (itemStack == null) {
|
EntityEquipment equip = ((LivingEntity) getDisguise().getEntity()).getEquipment();
|
||||||
// Find the item to replace it with
|
|
||||||
if (getDisguise().getEntity() instanceof LivingEntity) {
|
switch (slot) {
|
||||||
EntityEquipment equipment = ((LivingEntity) getDisguise().getEntity()).getEquipment();
|
case HAND:
|
||||||
setItemStack(equipment, slot, itemStack);
|
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) {
|
PacketContainer packet = new PacketContainer(Server.ENTITY_EQUIPMENT);
|
||||||
itemToSend = ReflectionManager.getNmsItem(itemStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
setItemStack(equipment, slot, itemStack);
|
StructureModifier<Object> mods = packet.getModifier();
|
||||||
|
|
||||||
if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) {
|
mods.write(0, getDisguise().getEntity().getEntityId());
|
||||||
PacketContainer packet = new PacketContainer(Server.ENTITY_EQUIPMENT);
|
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());
|
try {
|
||||||
mods.write(1, ReflectionManager.createEnumItemSlot(slot));
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
||||||
mods.write(2, itemToSend);
|
}
|
||||||
|
catch (InvocationTargetException e) {
|
||||||
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
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.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||||
|
|
||||||
public class LivingWatcher extends FlagWatcher
|
public class LivingWatcher extends FlagWatcher {
|
||||||
{
|
|
||||||
static Map<Integer, Object> list = new HashMap<>();
|
static Map<Integer, Object> list = new HashMap<>();
|
||||||
static Method getId;
|
static Method getId;
|
||||||
|
|
||||||
static
|
static {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
getId = ReflectionManager.getNmsMethod("MobEffectList", "getId", ReflectionManager.getNmsClass("MobEffectList"));
|
getId = ReflectionManager.getNmsMethod("MobEffectList", "getId", ReflectionManager.getNmsClass("MobEffectList"));
|
||||||
Object REGISTRY = ReflectionManager.getNmsField("MobEffectList", "REGISTRY").get(null);
|
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);
|
int id = (int) getId.invoke(null, next);
|
||||||
list.put(id, next);
|
list.put(id, next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex) {
|
||||||
{
|
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -53,15 +48,12 @@ public class LivingWatcher extends FlagWatcher
|
|||||||
private boolean maxHealthSet;
|
private boolean maxHealthSet;
|
||||||
private HashSet<Integer> potionEffects = new HashSet<>();
|
private HashSet<Integer> potionEffects = new HashSet<>();
|
||||||
|
|
||||||
public LivingWatcher(Disguise disguise)
|
public LivingWatcher(Disguise disguise) {
|
||||||
{
|
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPotionEffect(PotionEffectType potionEffect)
|
public void addPotionEffect(PotionEffectType potionEffect) {
|
||||||
{
|
if (!hasPotionEffect(potionEffect)) {
|
||||||
if (!hasPotionEffect(potionEffect))
|
|
||||||
{
|
|
||||||
removePotionEffect(potionEffect);
|
removePotionEffect(potionEffect);
|
||||||
potionEffects.add(potionEffect.getId());
|
potionEffects.add(potionEffect.getId());
|
||||||
|
|
||||||
@ -70,8 +62,7 @@ public class LivingWatcher extends FlagWatcher
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LivingWatcher clone(Disguise disguise)
|
public LivingWatcher clone(Disguise disguise) {
|
||||||
{
|
|
||||||
LivingWatcher clone = (LivingWatcher) super.clone(disguise);
|
LivingWatcher clone = (LivingWatcher) super.clone(disguise);
|
||||||
clone.potionEffects = (HashSet<Integer>) potionEffects.clone();
|
clone.potionEffects = (HashSet<Integer>) potionEffects.clone();
|
||||||
clone.maxHealth = maxHealth;
|
clone.maxHealth = maxHealth;
|
||||||
@ -80,27 +71,22 @@ public class LivingWatcher extends FlagWatcher
|
|||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getHealth()
|
public float getHealth() {
|
||||||
{
|
|
||||||
return (float) getData(FlagType.LIVING_HEALTH);
|
return (float) getData(FlagType.LIVING_HEALTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMaxHealth()
|
public double getMaxHealth() {
|
||||||
{
|
|
||||||
return maxHealth;
|
return maxHealth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPotionParticlesAmbient()
|
public boolean isPotionParticlesAmbient() {
|
||||||
{
|
|
||||||
return (boolean) getData(FlagType.LIVING_POTION_AMBIENT);
|
return (boolean) getData(FlagType.LIVING_POTION_AMBIENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getPotions()
|
private int getPotions() {
|
||||||
{
|
|
||||||
int m = 3694022;
|
int m = 3694022;
|
||||||
|
|
||||||
if (potionEffects.isEmpty())
|
if (potionEffects.isEmpty()) {
|
||||||
{
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,10 +94,8 @@ public class LivingWatcher extends FlagWatcher
|
|||||||
float f2 = 0.0F;
|
float f2 = 0.0F;
|
||||||
float f3 = 0.0F;
|
float f3 = 0.0F;
|
||||||
float f4 = 0.0F;
|
float f4 = 0.0F;
|
||||||
try
|
try {
|
||||||
{
|
for (int localMobEffect : potionEffects) {
|
||||||
for (int localMobEffect : potionEffects)
|
|
||||||
{
|
|
||||||
int n = (Integer) getId.invoke(list.get(localMobEffect));
|
int n = (Integer) getId.invoke(list.get(localMobEffect));
|
||||||
f1 += (n >> 16 & 0xFF) / 255.0F;
|
f1 += (n >> 16 & 0xFF) / 255.0F;
|
||||||
f2 += (n >> 8 & 0xFF) / 255.0F;
|
f2 += (n >> 8 & 0xFF) / 255.0F;
|
||||||
@ -119,8 +103,7 @@ public class LivingWatcher extends FlagWatcher
|
|||||||
f4 += 1.0F;
|
f4 += 1.0F;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex) {
|
||||||
{
|
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,61 +114,50 @@ public class LivingWatcher extends FlagWatcher
|
|||||||
return (int) f1 << 16 | (int) f2 << 8 | (int) f3;
|
return (int) f1 << 16 | (int) f2 << 8 | (int) f3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPotionEffect(PotionEffectType type)
|
public boolean hasPotionEffect(PotionEffectType type) {
|
||||||
{
|
|
||||||
return potionEffects.contains(type.getId());
|
return potionEffects.contains(type.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMaxHealthSet()
|
public boolean isMaxHealthSet() {
|
||||||
{
|
|
||||||
return maxHealthSet;
|
return maxHealthSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePotionEffect(PotionEffectType type)
|
public void removePotionEffect(PotionEffectType type) {
|
||||||
{
|
if (potionEffects.contains(type.getId())) {
|
||||||
if (potionEffects.contains(type.getId()))
|
|
||||||
{
|
|
||||||
potionEffects.remove(type.getId());
|
potionEffects.remove(type.getId());
|
||||||
sendPotionEffects();
|
sendPotionEffects();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPotionParticlesAmbient(boolean particles)
|
public void setPotionParticlesAmbient(boolean particles) {
|
||||||
{
|
|
||||||
setData(FlagType.LIVING_POTION_AMBIENT, particles);
|
setData(FlagType.LIVING_POTION_AMBIENT, particles);
|
||||||
sendData(FlagType.LIVING_POTION_AMBIENT);
|
sendData(FlagType.LIVING_POTION_AMBIENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendPotionEffects()
|
private void sendPotionEffects() {
|
||||||
{
|
|
||||||
setData(FlagType.LIVING_POTIONS, getPotions());
|
setData(FlagType.LIVING_POTIONS, getPotions());
|
||||||
sendData(FlagType.LIVING_POTIONS);
|
sendData(FlagType.LIVING_POTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHealth(float health)
|
public void setHealth(float health) {
|
||||||
{
|
|
||||||
setData(FlagType.LIVING_HEALTH, health);
|
setData(FlagType.LIVING_HEALTH, health);
|
||||||
sendData(FlagType.LIVING_HEALTH);
|
sendData(FlagType.LIVING_HEALTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getArrowsSticking()
|
public int getArrowsSticking() {
|
||||||
{
|
|
||||||
return (int) getData(FlagType.LIVING_ARROWS);
|
return (int) getData(FlagType.LIVING_ARROWS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArrowsSticking(int arrowsNo)
|
public void setArrowsSticking(int arrowsNo) {
|
||||||
{
|
|
||||||
setData(FlagType.LIVING_ARROWS, arrowsNo);
|
setData(FlagType.LIVING_ARROWS, arrowsNo);
|
||||||
sendData(FlagType.LIVING_ARROWS);
|
sendData(FlagType.LIVING_ARROWS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxHealth(double newHealth)
|
public void setMaxHealth(double newHealth) {
|
||||||
{
|
|
||||||
this.maxHealth = newHealth;
|
this.maxHealth = newHealth;
|
||||||
this.maxHealthSet = true;
|
this.maxHealthSet = true;
|
||||||
|
|
||||||
if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this)
|
if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) {
|
||||||
{
|
|
||||||
PacketContainer packet = new PacketContainer(Server.UPDATE_ATTRIBUTES);
|
PacketContainer packet = new PacketContainer(Server.UPDATE_ATTRIBUTES);
|
||||||
|
|
||||||
List<WrappedAttribute> attributes = new ArrayList<>();
|
List<WrappedAttribute> attributes = new ArrayList<>();
|
||||||
@ -203,18 +175,14 @@ public class LivingWatcher extends FlagWatcher
|
|||||||
packet.getIntegers().write(0, entity.getEntityId());
|
packet.getIntegers().write(0, entity.getEntityId());
|
||||||
packet.getAttributeCollectionModifier().write(0, attributes);
|
packet.getAttributeCollectionModifier().write(0, attributes);
|
||||||
|
|
||||||
for (Player player : DisguiseUtilities.getPerverts(getDisguise()))
|
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false);
|
||||||
}
|
}
|
||||||
catch (InvocationTargetException e)
|
catch (InvocationTargetException e) {
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -186,6 +186,7 @@ public class PacketsManager {
|
|||||||
ItemStack itemstack = disguise.getWatcher().getItemStack(slot);
|
ItemStack itemstack = disguise.getWatcher().getItemStack(slot);
|
||||||
|
|
||||||
if (itemstack == null || itemstack.getType() == Material.AIR) {
|
if (itemstack == null || itemstack.getType() == Material.AIR) {
|
||||||
|
System.out.println("Not wearing anything for " + slot.name());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,10 +3,13 @@ package me.libraryaddict.disguise.utilities;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Art;
|
import org.bukkit.Art;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Horse;
|
import org.bukkit.entity.Horse;
|
||||||
import org.bukkit.entity.Llama;
|
import org.bukkit.entity.Llama;
|
||||||
@ -82,7 +85,7 @@ public class ReflectionFlagWatchers {
|
|||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getEnums() {
|
public String[] getEnums(String tabComplete) {
|
||||||
return enums;
|
return enums;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,6 +144,34 @@ public class ReflectionFlagWatchers {
|
|||||||
|
|
||||||
potionEnums.add(toReadable(effectType.getName()));
|
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",
|
paramList.add(new ParamInfo(PotionEffectType.class, "Potion Effect", "View all the potion effects you can add",
|
||||||
potionEnums.toArray(new String[0])));
|
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(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(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(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(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(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(BlockPosition.class, "Block Position (num,num,num)", "Three numbers seperated by an ,"));
|
||||||
paramList.add(new ParamInfo(GameProfile.class, "GameProfile",
|
paramList.add(new ParamInfo(GameProfile.class, "GameProfile",
|
||||||
"Get the gameprofile here https://sessionserver.mojang.com/session/minecraft/profile/PLAYER_UUID_GOES_HERE?unsigned=false"));
|
"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) {
|
public static Method[] getDisguiseWatcherMethods(Class<? extends FlagWatcher> watcherClass) {
|
||||||
@ -184,6 +219,9 @@ public class ReflectionFlagWatchers {
|
|||||||
else if (!method.getReturnType().equals(Void.TYPE)) {
|
else if (!method.getReturnType().equals(Void.TYPE)) {
|
||||||
itel.remove();
|
itel.remove();
|
||||||
}
|
}
|
||||||
|
else if (method.getName().equals("removePotionEffect")) {
|
||||||
|
itel.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String methodName : new String[] {
|
for (String methodName : new String[] {
|
||||||
|
@ -20,7 +20,6 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Monster;
|
import org.bukkit.entity.Monster;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.EntityEquipment;
|
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
@ -895,22 +894,6 @@ public class ReflectionManager {
|
|||||||
return new WrappedWatchableObject(createDataWatcherItem(index, obj));
|
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) {
|
public static int getCombinedId(int id, int data) {
|
||||||
return id + (data << 12);
|
return id + (data << 12);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user