More changes, fixed armor

This commit is contained in:
libraryaddict
2016-11-29 07:30:25 +13:00
parent cfdd7bbecf
commit e5799d7a5e
12 changed files with 357 additions and 200 deletions

View File

@@ -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;
}

View File

@@ -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[] {

View File

@@ -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);
}