Add backwards support for 1.11.2, bugfixes, update to 1.12
This commit is contained in:
@@ -10,11 +10,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Llama;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
@@ -23,7 +19,6 @@ import com.comphenix.protocol.wrappers.BlockPosition;
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
|
||||
import me.libraryaddict.disguise.disguisetypes.AnimalColor;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
@@ -444,7 +439,7 @@ public class DisguiseParser {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isNumeric(String string) {
|
||||
private static boolean isInteger(String string) {
|
||||
try {
|
||||
Integer.parseInt(string);
|
||||
return true;
|
||||
@@ -463,7 +458,6 @@ public class DisguiseParser {
|
||||
* @param args
|
||||
* @param permissionMap
|
||||
* @return
|
||||
* @throws DisguiseBaseCommand.DisguiseParseException
|
||||
* @throws java.lang.IllegalAccessException
|
||||
* @throws java.lang.reflect.InvocationTargetException
|
||||
*/
|
||||
@@ -576,13 +570,13 @@ public class DisguiseParser {
|
||||
// If the first arg is a number
|
||||
if (args[1].contains(":")) {
|
||||
String[] split = args[1].split(":");
|
||||
if (isNumeric(split[1])) {
|
||||
if (isInteger(split[1])) {
|
||||
secondArg = split[1];
|
||||
}
|
||||
args[1] = split[0];
|
||||
}
|
||||
|
||||
if (isNumeric(args[1])) {
|
||||
if (isInteger(args[1])) {
|
||||
miscId = Integer.parseInt(args[1]);
|
||||
} else {
|
||||
if (disguisePerm.getType() == DisguiseType.FALLING_BLOCK || disguisePerm.getType() == DisguiseType.DROPPED_ITEM) {
|
||||
@@ -614,7 +608,7 @@ public class DisguiseParser {
|
||||
}
|
||||
toSkip++;
|
||||
// If they also defined a data value
|
||||
if (args.length > 2 && secondArg == null && isNumeric(args[2])) {
|
||||
if (args.length > 2 && secondArg == null && isInteger(args[2])) {
|
||||
secondArg = args[2];
|
||||
toSkip++;
|
||||
}
|
||||
@@ -706,7 +700,7 @@ public class DisguiseParser {
|
||||
if (valueString != null) {
|
||||
if (int.class == param) {
|
||||
// Parse to integer
|
||||
if (isNumeric(valueString)) {
|
||||
if (isInteger(valueString)) {
|
||||
value = Integer.parseInt(valueString);
|
||||
} else {
|
||||
throw parseToException("number", valueString, methodName);
|
||||
@@ -806,7 +800,8 @@ public class DisguiseParser {
|
||||
// Parse to potion effect
|
||||
try {
|
||||
PotionEffectType potionType = PotionEffectType.getByName(valueString.toUpperCase());
|
||||
if (potionType == null && isNumeric(valueString)) {
|
||||
|
||||
if (potionType == null && isInteger(valueString)) {
|
||||
potionType = PotionEffectType.getById(Integer.parseInt(valueString));
|
||||
}
|
||||
|
||||
@@ -878,6 +873,8 @@ public class DisguiseParser {
|
||||
catch (Exception ex) {
|
||||
throw parseToException("three numbers Number,Number,Number", valueString, methodName);
|
||||
}
|
||||
} else if (param.getName().equals("org.bukkit.entity.Parrot$Variant")) {
|
||||
value = callValueOf(param, valueString, methodName, "a parrot color");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -949,7 +946,7 @@ public class DisguiseParser {
|
||||
|
||||
int itemId = -1;
|
||||
|
||||
if (isNumeric(split[0])) {
|
||||
if (isInteger(split[0])) {
|
||||
itemId = Integer.parseInt(split[0]);
|
||||
} else {
|
||||
try {
|
||||
@@ -963,7 +960,7 @@ public class DisguiseParser {
|
||||
short itemDura = 0;
|
||||
|
||||
if (split.length > 1) {
|
||||
if (isNumeric(split[1])) {
|
||||
if (isInteger(split[1])) {
|
||||
itemDura = Short.parseShort(split[1]);
|
||||
} else {
|
||||
throw parseToException("item ID:Durability combo", string, "%s");
|
||||
|
@@ -69,6 +69,10 @@ public enum DisguiseSound {
|
||||
Sound.ENTITY_HORSE_STEP_WOOD, Sound.ENTITY_HORSE_ARMOR, Sound.ENTITY_HORSE_LAND, Sound.ENTITY_HORSE_JUMP,
|
||||
Sound.ENTITY_HORSE_ANGRY),
|
||||
|
||||
ILLUSIONER("entity.illusion_illager.hurt", null, "entity.illusion_illager.death", "entity.illusion_illager.ambient",
|
||||
"entity.illusion_illager.cast_spell", "entity.illusion_illager" + ".prepare_blindness",
|
||||
"entity.illusion_illager.prepare_mirror", "entity.illusion_illager.mirror_move"),
|
||||
|
||||
IRON_GOLEM(Sound.ENTITY_IRONGOLEM_HURT, Sound.ENTITY_IRONGOLEM_STEP, Sound.ENTITY_IRONGOLEM_DEATH,
|
||||
Sound.ENTITY_IRONGOLEM_ATTACK),
|
||||
|
||||
@@ -84,13 +88,28 @@ public enum DisguiseSound {
|
||||
OCELOT(Sound.ENTITY_CAT_HURT, Sound.BLOCK_GRASS_STEP, Sound.ENTITY_CAT_HURT, Sound.ENTITY_CAT_AMBIENT,
|
||||
Sound.ENTITY_CAT_PURR, Sound.ENTITY_CAT_PURREOW),
|
||||
|
||||
PARROT("entity.parrot.hurt", "entity.parrot.step", "entity.parrot.death", "entity.parrot.ambient",
|
||||
"entity.parrot.eat", "entity.parrot.fly", "entity.parrot.imitate.blaze", "entity.parrot.imitate.creeper",
|
||||
"entity.parrot.imitate.elder_guardian", "entity.parrot.imitate.enderdragon",
|
||||
"entity.parrot.imitate.enderman", "entity.parrot.imitate.endermite",
|
||||
"entity.parrot.imitate.evocation_illager", "entity.parrot.imitate.ghast", "entity.parrot.imitate.husk",
|
||||
"entity.parrot.imitate.illusion_illager", "entity.parrot.imitate.magmacube",
|
||||
"entity.parrot.imitate.polar_bear", "entity.parrot.imitate.shulker", "entity.parrot.imitate.silverfish",
|
||||
"entity.parrot.imitate.skeleton", "entity.parrot.imitate.slime", "entity.parrot.imitate.spider",
|
||||
"entity.parrot.imitate.stray", "entity.parrot.imitate.vex", "entity.parrot.imitate.vindication_illager",
|
||||
"entity.parrot.imitate.witch", "entity.parrot.imitate.wither", "entity.parrot.imitate.wither_skeleton",
|
||||
"entity.parrot.imitate.wolf", "entity.parrot.imitate.zombie", "entity.parrot.imitate.zombie_pigman",
|
||||
"entity.parrot.imitate.zombie_villager"),
|
||||
|
||||
PIG(Sound.ENTITY_PIG_HURT, Sound.ENTITY_PIG_STEP, Sound.ENTITY_PIG_DEATH, Sound.ENTITY_PIG_AMBIENT),
|
||||
|
||||
PIG_ZOMBIE(Sound.ENTITY_ZOMBIE_PIG_HURT, null, Sound.ENTITY_ZOMBIE_PIG_DEATH, Sound.ENTITY_ZOMBIE_PIG_AMBIENT,
|
||||
Sound.ENTITY_ZOMBIE_PIG_ANGRY),
|
||||
|
||||
PLAYER(Sound.ENTITY_PLAYER_HURT,
|
||||
new Sound[]{Sound.BLOCK_STONE_STEP, Sound.BLOCK_GRASS_STEP, Sound.BLOCK_ANVIL_STEP, Sound.BLOCK_CLOTH_STEP, Sound.BLOCK_GLASS_STEP, Sound.BLOCK_GRAVEL_STEP, Sound.BLOCK_LADDER_STEP, Sound.BLOCK_METAL_STEP, Sound.BLOCK_SAND_STEP, Sound.BLOCK_SLIME_STEP, Sound.BLOCK_SNOW_STEP, Sound.BLOCK_WOOD_STEP},
|
||||
new Sound[]{Sound.BLOCK_STONE_STEP, Sound.BLOCK_GRASS_STEP, Sound.BLOCK_ANVIL_STEP, Sound.BLOCK_CLOTH_STEP,
|
||||
Sound.BLOCK_GLASS_STEP, Sound.BLOCK_GRAVEL_STEP, Sound.BLOCK_LADDER_STEP, Sound.BLOCK_METAL_STEP,
|
||||
Sound.BLOCK_SAND_STEP, Sound.BLOCK_SLIME_STEP, Sound.BLOCK_SNOW_STEP, Sound.BLOCK_WOOD_STEP},
|
||||
Sound.ENTITY_PLAYER_DEATH, null),
|
||||
|
||||
RABBIT(Sound.ENTITY_RABBIT_HURT, Sound.ENTITY_RABBIT_JUMP, Sound.ENTITY_RABBIT_DEATH, Sound.ENTITY_RABBIT_AMBIENT),
|
||||
|
@@ -12,7 +12,6 @@ import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
@@ -24,6 +23,8 @@ import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
|
||||
import me.libraryaddict.disguise.utilities.PacketsManager.LibsPackets;
|
||||
import me.libraryaddict.disguise.utilities.backwards.BackwardMethods;
|
||||
import me.libraryaddict.disguise.utilities.backwards.BackwardsSupport;
|
||||
import me.libraryaddict.disguise.utilities.json.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@@ -46,8 +47,6 @@ import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.reflect.*;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -74,6 +73,7 @@ public class DisguiseUtilities {
|
||||
private static File profileCache = new File("plugins/LibsDisguises/GameProfiles"), savedDisguises = new File(
|
||||
"plugins/LibsDisguises/SavedDisguises");
|
||||
private static Gson gson;
|
||||
private static BackwardMethods methods;
|
||||
|
||||
public static void saveDisguises() {
|
||||
Iterator<HashSet<TargetedDisguise>> itel = disguisesInUse.values().iterator();
|
||||
@@ -132,7 +132,7 @@ public class DisguiseUtilities {
|
||||
}
|
||||
|
||||
public static void saveDisguises(UUID owningEntity, Disguise[] disguise) {
|
||||
if (!LibVersion.isPremium())
|
||||
if (!LibsVersion.isPremium())
|
||||
return;
|
||||
|
||||
try {
|
||||
@@ -171,7 +171,7 @@ public class DisguiseUtilities {
|
||||
}
|
||||
|
||||
public static Disguise[] getSavedDisguises(UUID entityUUID, boolean remove) {
|
||||
if (!isSavedDisguise(entityUUID) || !LibVersion.isPremium())
|
||||
if (!isSavedDisguise(entityUUID) || !LibsVersion.isPremium())
|
||||
return new Disguise[0];
|
||||
|
||||
File disguiseFile = new File(savedDisguises, entityUUID.toString());
|
||||
@@ -773,6 +773,7 @@ public class DisguiseUtilities {
|
||||
|
||||
public static void init(LibsDisguises disguises) {
|
||||
libsDisguises = disguises;
|
||||
methods = BackwardsSupport.getMethods();
|
||||
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(MetaIndex.class, new SerializerMetaIndex());
|
||||
@@ -848,7 +849,7 @@ public class DisguiseUtilities {
|
||||
savedDisguiseList.add(UUID.fromString(key));
|
||||
}
|
||||
|
||||
LibVersion.check(libsDisguises);
|
||||
LibsVersion.check(libsDisguises);
|
||||
}
|
||||
|
||||
public static boolean isDisguiseInUse(Disguise disguise) {
|
||||
|
@@ -10,7 +10,7 @@ import java.net.URLClassLoader;
|
||||
/**
|
||||
* Created by libraryaddict on 2/06/2017.
|
||||
*/
|
||||
public class LibVersion {
|
||||
public class LibsVersion {
|
||||
/**
|
||||
* If you're seriously going to modify this to get the premium stuff for free, can you at least not
|
||||
* distribute it? You didn't pay for it despite how cheap it is. You spend $8 on a trip to McDonalds
|
||||
@@ -39,7 +39,12 @@ public class LibVersion {
|
||||
thisPluginIsPaidFor = isPremium();
|
||||
|
||||
if (!isPremium() && disguises.getDescription().getVersion().contains("SNAPSHOT")) {
|
||||
for (File file : new File("plugins/LibsDisguises/").listFiles()) {
|
||||
File[] files = new File("plugins/LibsDisguises/").listFiles();
|
||||
|
||||
if (files == null)
|
||||
return;
|
||||
|
||||
for (File file : files) {
|
||||
if (!file.isFile())
|
||||
continue;
|
||||
|
||||
@@ -48,7 +53,7 @@ public class LibVersion {
|
||||
|
||||
try {
|
||||
ClassLoader cl = new URLClassLoader(new URL[]{file.toURI().toURL()});
|
||||
Class c = cl.loadClass(LibVersion.class.getName());
|
||||
Class c = cl.loadClass(LibsVersion.class.getName());
|
||||
|
||||
Method m = c.getMethod("isPremium");
|
||||
thisPluginIsPaidFor = (Boolean) m.invoke(null);
|
||||
@@ -56,10 +61,6 @@ public class LibVersion {
|
||||
if (isPremium())
|
||||
break;
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
if (disguises.getDescription().getVersion().contains("9.3.0-SNAPSHOT"))
|
||||
thisPluginIsPaidFor = true;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// Don't print off errors
|
||||
}
|
@@ -7,16 +7,13 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.mysql.fabric.xmlrpc.base.Param;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Art;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.TreeSpecies;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Llama;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
import org.bukkit.entity.Rabbit;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
@@ -37,9 +34,7 @@ public class ReflectionFlagWatchers {
|
||||
private String description;
|
||||
|
||||
public ParamInfo(Class paramClass, String name, String description) {
|
||||
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this(name, description);
|
||||
this.paramClass = paramClass;
|
||||
|
||||
Enum[] enums = (Enum[]) paramClass.getEnumConstants();
|
||||
@@ -51,24 +46,37 @@ public class ReflectionFlagWatchers {
|
||||
this.enums[i] = enums[i].name();
|
||||
}
|
||||
}
|
||||
|
||||
paramList.add(this);
|
||||
}
|
||||
|
||||
private ParamInfo(String name, String description) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public ParamInfo(String className, String name, String description) throws ClassNotFoundException {
|
||||
this(Class.forName(className), name, description);
|
||||
}
|
||||
|
||||
public ParamInfo(Class paramClass, Enum[] enums, String name, String description) {
|
||||
this.name = name;
|
||||
this(name, description);
|
||||
this.enums = new String[enums.length];
|
||||
this.description = description;
|
||||
this.paramClass = paramClass;
|
||||
|
||||
for (int i = 0; i < enums.length; i++) {
|
||||
this.enums[i] = enums[i].name();
|
||||
}
|
||||
|
||||
paramList.add(this);
|
||||
}
|
||||
|
||||
public ParamInfo(Class paramClass, String name, String description, String[] enums) {
|
||||
this.name = name;
|
||||
this(name, description);
|
||||
this.enums = enums;
|
||||
this.description = description;
|
||||
this.paramClass = paramClass;
|
||||
|
||||
paramList.add(this);
|
||||
}
|
||||
|
||||
public boolean isEnums() {
|
||||
@@ -92,7 +100,7 @@ public class ReflectionFlagWatchers {
|
||||
}
|
||||
}
|
||||
|
||||
private static ArrayList<ParamInfo> paramList = new ArrayList<ParamInfo>();
|
||||
private static ArrayList<ParamInfo> paramList = new ArrayList<>();
|
||||
|
||||
public static ArrayList<ParamInfo> getParamInfos() {
|
||||
return paramList;
|
||||
@@ -131,19 +139,29 @@ public class ReflectionFlagWatchers {
|
||||
}
|
||||
|
||||
static {
|
||||
paramList.add(new ParamInfo(AnimalColor.class, "Animal Color", "View all the colors you can use for an animal color"));
|
||||
paramList.add(new ParamInfo(Art.class, "Art", "View all the paintings you can use for a painting disguise"));
|
||||
paramList.add(new ParamInfo(Llama.Color.class, "Llama Color", "View all the colors you can use for a llama color"));
|
||||
paramList.add(new ParamInfo(Horse.Color.class, "Horse Color", "View all the colors you can use for a horses color"));
|
||||
paramList.add(new ParamInfo(Ocelot.Type.class, "Ocelot Type", "View all the ocelot types you can use for ocelots"));
|
||||
paramList.add(new ParamInfo(Villager.Profession.class, "Villager Profession",
|
||||
"View all the professions you can set on a villager"));
|
||||
paramList.add(new ParamInfo(BlockFace.class, Arrays.copyOf(BlockFace.values(), 5), "Direction",
|
||||
"View the five directions usable on player setSleeping disguise"));
|
||||
paramList.add(new ParamInfo(Rabbit.Type.class, "Rabbit Type", "View the kinds of rabbits you can turn into"));
|
||||
paramList.add(new ParamInfo(TreeSpecies.class, "Tree Species", "View the different types of tree species"));
|
||||
new ParamInfo(AnimalColor.class, "Animal Color", "View all the colors you can use for an animal color");
|
||||
new ParamInfo(Art.class, "Art", "View all the paintings you can use for a painting disguise");
|
||||
|
||||
ArrayList<String> potionEnums = new ArrayList<String>();
|
||||
new ParamInfo(Llama.Color.class, "Llama Color", "View all the colors you can use for a llama color");
|
||||
|
||||
new ParamInfo(Horse.Color.class, "Horse Color", "View all the colors you can use for a horses color");
|
||||
|
||||
new ParamInfo(Ocelot.Type.class, "Ocelot Type", "View all the ocelot types you can use for ocelots");
|
||||
new ParamInfo(Villager.Profession.class, "Villager Profession",
|
||||
"View all the professions you can set on a villager");
|
||||
new ParamInfo(BlockFace.class, Arrays.copyOf(BlockFace.values(), 5), "Direction",
|
||||
"View the five directions usable on player setSleeping disguise");
|
||||
new ParamInfo(Rabbit.Type.class, "Rabbit Type", "View the kinds of rabbits you can turn into");
|
||||
new ParamInfo(TreeSpecies.class, "Tree Species", "View the different types of tree species");
|
||||
|
||||
try {
|
||||
new ParamInfo("org.bukkit.entity.Parrot$Variant", "Parrot Variant",
|
||||
"View the different colors a parrot can be");
|
||||
}
|
||||
catch (ClassNotFoundException ex) {// Dont handle
|
||||
}
|
||||
|
||||
ArrayList<String> potionEnums = new ArrayList<>();
|
||||
|
||||
for (PotionEffectType effectType : PotionEffectType.values()) {
|
||||
if (effectType == null)
|
||||
@@ -157,16 +175,17 @@ public class ReflectionFlagWatchers {
|
||||
materials[i] = Material.values()[i].name();
|
||||
}
|
||||
|
||||
paramList.add(new ParamInfo(ItemStack.class, "Item (id:damage)", "An ItemStack compromised of ID:Durability", materials));
|
||||
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) {
|
||||
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 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>();
|
||||
ArrayList<String> toReturn = new ArrayList<>();
|
||||
|
||||
for (String material : super.getEnums("")) {
|
||||
if (!material.toLowerCase().startsWith(end.toLowerCase()))
|
||||
@@ -177,23 +196,22 @@ public class ReflectionFlagWatchers {
|
||||
|
||||
return toReturn.toArray(new String[0]);
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
new ParamInfo(PotionEffectType.class, "Potion Effect", "View all the potion effects you can add",
|
||||
potionEnums.toArray(new String[0]));
|
||||
new ParamInfo(String.class, "Text", "A line of text");
|
||||
new ParamInfo(boolean.class, "True/False", "True or False", new String[]{"true", "false"});
|
||||
new ParamInfo(int.class, "Number", "A whole number, no decimcals");
|
||||
new ParamInfo(double.class, "Number", "A number which can have decimals");
|
||||
new ParamInfo(float.class, "Number", "A number which can have decimals");
|
||||
|
||||
paramList.add(new ParamInfo(PotionEffectType.class, "Potion Effect", "View all the potion effects you can add",
|
||||
potionEnums.toArray(new String[0])));
|
||||
paramList.add(new ParamInfo(String.class, "Text", "A line of text"));
|
||||
paramList.add(new ParamInfo(boolean.class, "True/False", "True or False", new String[] {
|
||||
"true", "false"
|
||||
}));
|
||||
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(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"));
|
||||
new ParamInfo(Horse.Style.class, "Horse Style", "Horse style which is the patterns on the horse");
|
||||
new ParamInfo(int[].class, "number,number,number...", "Numbers seperated by an ,");
|
||||
|
||||
new ParamInfo(BlockPosition.class, "Block Position (num,num,num)", "Three numbers seperated by an ,");
|
||||
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
|
||||
@@ -213,27 +231,21 @@ public class ReflectionFlagWatchers {
|
||||
|
||||
if (method.getParameterTypes().length != 1) {
|
||||
itel.remove();
|
||||
}
|
||||
else if (method.getName().startsWith("get")) {
|
||||
} else if (method.getName().startsWith("get")) {
|
||||
itel.remove();
|
||||
}
|
||||
else if (method.getAnnotation(Deprecated.class) != null) {
|
||||
} else if (method.getAnnotation(Deprecated.class) != null) {
|
||||
itel.remove();
|
||||
}
|
||||
else if (getParamInfo(method.getParameterTypes()[0]) == null) {
|
||||
} else if (getParamInfo(method.getParameterTypes()[0]) == null) {
|
||||
itel.remove();
|
||||
}
|
||||
else if (!method.getReturnType().equals(Void.TYPE)) {
|
||||
} else if (!method.getReturnType().equals(Void.TYPE)) {
|
||||
itel.remove();
|
||||
}
|
||||
else if (method.getName().equals("removePotionEffect")) {
|
||||
} else if (method.getName().equals("removePotionEffect")) {
|
||||
itel.remove();
|
||||
}
|
||||
}
|
||||
|
||||
for (String methodName : new String[] {
|
||||
"setViewSelfDisguise", "setHideHeldItemFromSelf", "setHideArmorFromSelf", "setHearSelfDisguise", "setHidePlayer"
|
||||
}) {
|
||||
for (String methodName : new String[]{"setViewSelfDisguise", "setHideHeldItemFromSelf", "setHideArmorFromSelf",
|
||||
"setHearSelfDisguise", "setHidePlayer"}) {
|
||||
try {
|
||||
methods.add(Disguise.class.getMethod(methodName, boolean.class));
|
||||
}
|
||||
|
@@ -1,47 +1,30 @@
|
||||
package me.libraryaddict.disguise.utilities;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.comphenix.protocol.wrappers.*;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Registry;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Serializer;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtBase;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtWrapper;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.gson.Gson;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.bukkit.Art;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Ambient;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
||||
import com.comphenix.protocol.wrappers.MinecraftKey;
|
||||
import com.comphenix.protocol.wrappers.Vector3F;
|
||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Registry;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Serializer;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
import com.comphenix.protocol.wrappers.WrappedSignedProperty;
|
||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ReflectionManager {
|
||||
private static final String bukkitVersion = Bukkit.getServer().getClass().getName().split("\\.")[3];
|
||||
@@ -863,6 +846,8 @@ public class ReflectionManager {
|
||||
return getNmsItem((ItemStack) value);
|
||||
} else if (value instanceof Double)
|
||||
return ((Double) value).floatValue();
|
||||
else if (value instanceof NbtCompound)
|
||||
return ((NbtWrapper)value).getHandle();
|
||||
|
||||
return value;
|
||||
}
|
||||
|
@@ -0,0 +1,11 @@
|
||||
package me.libraryaddict.disguise.utilities.backwards;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 8/06/2017.
|
||||
*/
|
||||
public class BackwardMethods {
|
||||
|
||||
public boolean isOrderedIndexes() {
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
package me.libraryaddict.disguise.utilities.backwards;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||
import me.libraryaddict.disguise.utilities.backwards.metadata.Version_1_1;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 8/06/2017.
|
||||
*/
|
||||
public class BackwardsSupport {
|
||||
public static BackwardMethods getMethods() {
|
||||
try {
|
||||
String version = ReflectionManager.getBukkitVersion();
|
||||
|
||||
if (version.equals("v1_11_R1")) {
|
||||
return setupMetadata(Version_1_1.class);
|
||||
}
|
||||
|
||||
return setupMetadata(BackwardMethods.class);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static BackwardMethods setupMetadata(Class<? extends BackwardMethods> backwardsClass) {
|
||||
try {
|
||||
BackwardMethods backwards = backwardsClass.newInstance();
|
||||
|
||||
for (Field field : backwards.getClass().getFields()) {
|
||||
if (field.getType() != MetaIndex.class)
|
||||
continue;
|
||||
|
||||
MetaIndex.setMetaIndex(field.getName(), (MetaIndex) field.get(backwards));
|
||||
}
|
||||
|
||||
MetaIndex.setValues();
|
||||
|
||||
if (backwards.isOrderedIndexes()) {
|
||||
MetaIndex.fillInBlankIndexes();
|
||||
MetaIndex.orderMetaIndexes();
|
||||
}
|
||||
|
||||
return backwards;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package me.libraryaddict.disguise.utilities.backwards.metadata;
|
||||
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
||||
import me.libraryaddict.disguise.utilities.backwards.BackwardMethods;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 8/06/2017.
|
||||
* Supports 1.11.0 1.11.1 and 1.11.2
|
||||
*/
|
||||
public class Version_1_1 extends BackwardMethods {
|
||||
private MetaIndex ILLAGER_META;
|
||||
private MetaIndex PARROT_VARIANT;
|
||||
private MetaIndex PLAYER_LEFT_SHOULDER_ENTITY;
|
||||
private MetaIndex PLAYER_RIGHT_SHOULDER_ENTITY;
|
||||
}
|
@@ -27,29 +27,24 @@ import me.libraryaddict.disguise.utilities.DisguiseSound.SoundType;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||
|
||||
public class PacketListenerSounds extends PacketAdapter
|
||||
{
|
||||
public class PacketListenerSounds extends PacketAdapter {
|
||||
/**
|
||||
* This is a fix for the stupidity that is
|
||||
* "I can't separate the sounds from the sounds the player heard, and the sounds of the entity tracker heard"
|
||||
*/
|
||||
private static boolean cancelSound;
|
||||
|
||||
public PacketListenerSounds(LibsDisguises plugin)
|
||||
{
|
||||
public PacketListenerSounds(LibsDisguises plugin) {
|
||||
super(plugin, ListenerPriority.NORMAL, Server.NAMED_SOUND_EFFECT, Server.ENTITY_STATUS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.isAsync())
|
||||
{
|
||||
if (event.isAsync()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -62,20 +57,15 @@ public class PacketListenerSounds extends PacketAdapter
|
||||
|
||||
Player observer = event.getPlayer();
|
||||
|
||||
if (event.getPacketType() == Server.NAMED_SOUND_EFFECT)
|
||||
{
|
||||
if (event.getPacketType() == Server.NAMED_SOUND_EFFECT) {
|
||||
SoundType soundType = null;
|
||||
|
||||
int[] soundCords = new int[]
|
||||
{
|
||||
(Integer) mods.read(2), (Integer) mods.read(3), (Integer) mods.read(4)
|
||||
};
|
||||
int[] soundCords = new int[]{(Integer) mods.read(2), (Integer) mods.read(3), (Integer) mods.read(4)};
|
||||
|
||||
int chunkX = (int) Math.floor((soundCords[0] / 8D) / 16D);
|
||||
int chunkZ = (int) Math.floor((soundCords[2] / 8D) / 16D);
|
||||
|
||||
if (!observer.getWorld().isChunkLoaded(chunkX, chunkZ))
|
||||
{
|
||||
if (!observer.getWorld().isChunkLoaded(chunkX, chunkZ)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -87,87 +77,68 @@ public class PacketListenerSounds extends PacketAdapter
|
||||
String soundEffect = ReflectionManager.convertSoundEffectToString(mods.read(0));
|
||||
Entity[] entities = observer.getWorld().getChunkAt(chunkX, chunkZ).getEntities();
|
||||
|
||||
for (Entity entity : entities)
|
||||
{
|
||||
for (Entity entity : entities) {
|
||||
Disguise entityDisguise = DisguiseAPI.getDisguise(observer, entity);
|
||||
|
||||
if (entityDisguise != null)
|
||||
{
|
||||
if (entityDisguise != null) {
|
||||
Location loc = entity.getLocation();
|
||||
|
||||
int[] entCords = new int[]
|
||||
{
|
||||
(int) (loc.getX() * 8), (int) (loc.getY() * 8), (int) (loc.getZ() * 8)
|
||||
};
|
||||
int[] entCords = new int[]{(int) (loc.getX() * 8), (int) (loc.getY() * 8), (int) (loc.getZ() * 8)};
|
||||
|
||||
if (soundCords[0] != entCords[0] || soundCords[1] != entCords[1] || soundCords[2] != entCords[2])
|
||||
{
|
||||
if (soundCords[0] != entCords[0] || soundCords[1] != entCords[1] || soundCords[2] != entCords[2]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
entitySound = DisguiseSound.getType(entity.getType().name());
|
||||
|
||||
if (entitySound == null)
|
||||
{
|
||||
if (entitySound == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Object obj = null;
|
||||
|
||||
if (entity instanceof LivingEntity)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (entity instanceof LivingEntity) {
|
||||
try {
|
||||
// Use reflection so that this works for either int or double methods
|
||||
obj = LivingEntity.class.getMethod("getHealth").invoke(entity);
|
||||
|
||||
if (obj instanceof Double ? (Double) obj == 0 : (Integer) obj == 0)
|
||||
{
|
||||
if (obj instanceof Double ? (Double) obj == 0 : (Integer) obj == 0) {
|
||||
soundType = SoundType.DEATH;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
obj = null;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (obj == null)
|
||||
{
|
||||
if (obj == null) {
|
||||
boolean hasInvun = false;
|
||||
|
||||
Object nmsEntity = ReflectionManager.getNmsEntity(entity);
|
||||
|
||||
try
|
||||
{
|
||||
if (entity instanceof LivingEntity)
|
||||
{
|
||||
hasInvun = ReflectionManager.getNmsField("Entity", "noDamageTicks")
|
||||
.getInt(nmsEntity) == ReflectionManager.getNmsField("EntityLiving", "maxNoDamageTicks")
|
||||
.getInt(nmsEntity);
|
||||
}
|
||||
else
|
||||
{
|
||||
try {
|
||||
if (entity instanceof LivingEntity) {
|
||||
hasInvun = ReflectionManager.getNmsField("Entity", "noDamageTicks").getInt(
|
||||
nmsEntity) == ReflectionManager.getNmsField("EntityLiving",
|
||||
"maxNoDamageTicks").getInt(nmsEntity);
|
||||
} else {
|
||||
Class clazz = ReflectionManager.getNmsClass("DamageSource");
|
||||
|
||||
hasInvun = (Boolean) ReflectionManager.getNmsMethod("Entity", "isInvulnerable", clazz)
|
||||
.invoke(nmsEntity, ReflectionManager.getNmsField(clazz, "GENERIC").get(null));
|
||||
hasInvun = (Boolean) ReflectionManager.getNmsMethod("Entity", "isInvulnerable",
|
||||
clazz).invoke(nmsEntity,
|
||||
ReflectionManager.getNmsField(clazz, "GENERIC").get(null));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
soundType = entitySound.getType(soundEffect, !hasInvun);
|
||||
}
|
||||
|
||||
if (soundType != null)
|
||||
{
|
||||
if (soundType != null) {
|
||||
disguise = entityDisguise;
|
||||
disguisedEntity = entity;
|
||||
break;
|
||||
@@ -175,9 +146,7 @@ public class PacketListenerSounds extends PacketAdapter
|
||||
}
|
||||
}
|
||||
|
||||
if (disguise != null && disguise.isSoundsReplaced()
|
||||
&& (disguise.isSelfDisguiseSoundsReplaced() || disguisedEntity != observer))
|
||||
{
|
||||
if (disguise != null && disguise.isSoundsReplaced() && (disguise.isSelfDisguiseSoundsReplaced() || disguisedEntity != observer)) {
|
||||
String sound = null;
|
||||
|
||||
DisguiseSound dSound = DisguiseSound.getType(disguise.getType().name());
|
||||
@@ -185,92 +154,71 @@ public class PacketListenerSounds extends PacketAdapter
|
||||
if (dSound != null)
|
||||
sound = dSound.getSound(soundType);
|
||||
|
||||
if (sound == null)
|
||||
{
|
||||
if (sound == null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sound.equals("step.grass"))
|
||||
{
|
||||
try
|
||||
{
|
||||
} else {
|
||||
if (sound.equals("step.grass")) {
|
||||
try {
|
||||
int typeId = observer.getWorld().getBlockTypeIdAt((int) Math.floor(soundCords[0] / 8D),
|
||||
(int) Math.floor(soundCords[1] / 8D), (int) Math.floor(soundCords[2] / 8D));
|
||||
|
||||
Object block = ReflectionManager.getNmsMethod("RegistryMaterials", "getId", int.class)
|
||||
.invoke(ReflectionManager.getNmsField("Block", "REGISTRY").get(null), typeId);
|
||||
Object block = ReflectionManager.getNmsMethod("RegistryMaterials", "getId",
|
||||
int.class).invoke(ReflectionManager.getNmsField("Block", "REGISTRY").get(null),
|
||||
typeId);
|
||||
|
||||
if (block != null)
|
||||
{
|
||||
if (block != null) {
|
||||
Object step = ReflectionManager.getNmsField("Block", "stepSound").get(block);
|
||||
|
||||
mods.write(0, ReflectionManager.getNmsMethod(step.getClass(), "d").invoke(step));
|
||||
mods.write(1, ReflectionManager.getSoundCategory(disguise.getType()));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
// There is no else statement. Because seriously. This should never be null. Unless
|
||||
// someone is
|
||||
// sending fake sounds. In which case. Why cancel it.
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
mods.write(0, ReflectionManager.getCraftSoundEffect(sound));
|
||||
mods.write(1, ReflectionManager.getSoundCategory(disguise.getType()));
|
||||
|
||||
// Time to change the pitch and volume
|
||||
if (soundType == SoundType.HURT || soundType == SoundType.DEATH || soundType == SoundType.IDLE)
|
||||
{
|
||||
if (soundType == SoundType.HURT || soundType == SoundType.DEATH || soundType == SoundType.IDLE) {
|
||||
// If the volume is the default
|
||||
if (mods.read(5).equals(entitySound.getDamageAndIdleSoundVolume()))
|
||||
{
|
||||
if (mods.read(5).equals(entitySound.getDamageAndIdleSoundVolume())) {
|
||||
mods.write(5, dSound.getDamageAndIdleSoundVolume());
|
||||
}
|
||||
|
||||
// Here I assume its the default pitch as I can't calculate if its real.
|
||||
if (disguise instanceof MobDisguise && disguisedEntity instanceof LivingEntity
|
||||
&& ((MobDisguise) disguise).doesDisguiseAge())
|
||||
{
|
||||
if (disguise instanceof MobDisguise && disguisedEntity instanceof LivingEntity && ((MobDisguise) disguise).doesDisguiseAge()) {
|
||||
boolean baby = false;
|
||||
|
||||
if (disguisedEntity instanceof Zombie)
|
||||
{
|
||||
if (disguisedEntity instanceof Zombie) {
|
||||
baby = ((Zombie) disguisedEntity).isBaby();
|
||||
}
|
||||
else if (disguisedEntity instanceof Ageable)
|
||||
{
|
||||
} else if (disguisedEntity instanceof Ageable) {
|
||||
baby = !((Ageable) disguisedEntity).isAdult();
|
||||
}
|
||||
|
||||
if (((MobDisguise) disguise).isAdult() == baby)
|
||||
{
|
||||
if (((MobDisguise) disguise).isAdult() == baby) {
|
||||
float pitch = (Float) mods.read(6);
|
||||
|
||||
if (baby)
|
||||
{
|
||||
if (baby) {
|
||||
// If the pitch is not the expected
|
||||
if (pitch > 97 || pitch < 111)
|
||||
return;
|
||||
|
||||
pitch = (DisguiseUtilities.random.nextFloat() - DisguiseUtilities.random.nextFloat())
|
||||
* 0.2F + 1.5F;
|
||||
pitch = (DisguiseUtilities.random.nextFloat() - DisguiseUtilities.random.nextFloat()) * 0.2F + 1.5F;
|
||||
// Min = 1.5
|
||||
// Cap = 97.5
|
||||
// Max = 1.7
|
||||
// Cap = 110.5
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// If the pitch is not the expected
|
||||
if (pitch >= 63 || pitch <= 76)
|
||||
return;
|
||||
|
||||
pitch = (DisguiseUtilities.random.nextFloat() - DisguiseUtilities.random.nextFloat())
|
||||
* 0.2F + 1.0F;
|
||||
pitch = (DisguiseUtilities.random.nextFloat() - DisguiseUtilities.random.nextFloat()) * 0.2F + 1.0F;
|
||||
// Min = 1
|
||||
// Cap = 63
|
||||
// Max = 1.2
|
||||
@@ -292,11 +240,8 @@ public class PacketListenerSounds extends PacketAdapter
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (event.getPacketType() == Server.ENTITY_STATUS)
|
||||
{
|
||||
if ((byte) mods.read(1) != 2)
|
||||
{
|
||||
} else if (event.getPacketType() == Server.ENTITY_STATUS) {
|
||||
if ((byte) mods.read(1) != 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -305,9 +250,7 @@ public class PacketListenerSounds extends PacketAdapter
|
||||
|
||||
Disguise disguise = DisguiseAPI.getDisguise(observer, entity);
|
||||
|
||||
if (disguise != null && !disguise.getType().isPlayer()
|
||||
&& (disguise.isSelfDisguiseSoundsReplaced() || entity != event.getPlayer()))
|
||||
{
|
||||
if (disguise != null && !disguise.getType().isPlayer() && (disguise.isSelfDisguiseSoundsReplaced() || entity != event.getPlayer())) {
|
||||
DisguiseSound disSound = DisguiseSound.getType(entity.getType().name());
|
||||
|
||||
if (disSound == null)
|
||||
@@ -316,37 +259,28 @@ public class PacketListenerSounds extends PacketAdapter
|
||||
SoundType soundType = null;
|
||||
Object obj = null;
|
||||
|
||||
if (entity instanceof LivingEntity)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (entity instanceof LivingEntity) {
|
||||
try {
|
||||
obj = LivingEntity.class.getMethod("getHealth").invoke(entity);
|
||||
|
||||
if (obj instanceof Double ? (Double) obj == 0 : (Integer) obj == 0)
|
||||
{
|
||||
if (obj instanceof Double ? (Double) obj == 0 : (Integer) obj == 0) {
|
||||
soundType = SoundType.DEATH;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
obj = null;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (obj == null)
|
||||
{
|
||||
if (obj == null) {
|
||||
soundType = SoundType.HURT;
|
||||
}
|
||||
|
||||
if (disSound.getSound(soundType) == null
|
||||
|| (disguise.isSelfDisguiseSoundsReplaced() && entity == event.getPlayer()))
|
||||
{
|
||||
if (disguise.isSelfDisguiseSoundsReplaced() && entity == event.getPlayer())
|
||||
{
|
||||
if (disSound.getSound(
|
||||
soundType) == null || (disguise.isSelfDisguiseSoundsReplaced() && entity == event.getPlayer())) {
|
||||
if (disguise.isSelfDisguiseSoundsReplaced() && entity == event.getPlayer()) {
|
||||
cancelSound = !cancelSound;
|
||||
|
||||
if (cancelSound)
|
||||
@@ -355,12 +289,10 @@ public class PacketListenerSounds extends PacketAdapter
|
||||
|
||||
disSound = DisguiseSound.getType(disguise.getType().name());
|
||||
|
||||
if (disSound != null)
|
||||
{
|
||||
if (disSound != null) {
|
||||
String sound = disSound.getSound(soundType);
|
||||
|
||||
if (sound != null)
|
||||
{
|
||||
if (sound != null) {
|
||||
Location loc = entity.getLocation();
|
||||
|
||||
PacketContainer packet = new PacketContainer(Server.NAMED_SOUND_EFFECT);
|
||||
@@ -378,14 +310,10 @@ public class PacketListenerSounds extends PacketAdapter
|
||||
|
||||
float pitch;
|
||||
|
||||
if (disguise instanceof MobDisguise && !((MobDisguise) disguise).isAdult())
|
||||
{
|
||||
pitch = (DisguiseUtilities.random.nextFloat() - DisguiseUtilities.random.nextFloat()) * 0.2F
|
||||
+ 1.5F;
|
||||
}
|
||||
else
|
||||
pitch = (DisguiseUtilities.random.nextFloat() - DisguiseUtilities.random.nextFloat()) * 0.2F
|
||||
+ 1.0F;
|
||||
if (disguise instanceof MobDisguise && !((MobDisguise) disguise).isAdult()) {
|
||||
pitch = (DisguiseUtilities.random.nextFloat() - DisguiseUtilities.random.nextFloat()) * 0.2F + 1.5F;
|
||||
} else
|
||||
pitch = (DisguiseUtilities.random.nextFloat() - DisguiseUtilities.random.nextFloat()) * 0.2F + 1.0F;
|
||||
|
||||
if (disguise.getType() == DisguiseType.BAT)
|
||||
pitch *= 95F;
|
||||
@@ -400,12 +328,10 @@ public class PacketListenerSounds extends PacketAdapter
|
||||
|
||||
mods.write(6, (int) pitch);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet, false);
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user