Read for information...

Now using ASM manipulation to remove invalid methods on load
Fixed imports
Fixed Chat Components being used in 1.12
Fixed tab complete showing args for disguise options you can't use
Disguise option permissions now demand a parameter to be the method name
Falling block disguises are now only usable with blocks
LibsDisguises command now tab completes the new options
Libs Disguises command lets you create a vanilla compatible item string
If a vehicle is disguised as a vehicle, don't give no gravity
Fixed horse disguise using almost random values for its flagwatcher settings
Renamed horse disguise setMouthOpen to setEating
Slightly better string for premium info jar location
Skip attributes packets if using older ProtocolLib jar
Don't cancel entity death if entity is dead
Improved disguise permissions checking
Fixed time parameter not being attributed properly
This commit is contained in:
libraryaddict
2020-02-19 12:57:39 +13:00
parent 668eec641e
commit 897a6629ae
65 changed files with 1205 additions and 513 deletions

View File

@@ -10,15 +10,12 @@ import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.disguisetypes.*;
import me.libraryaddict.disguise.disguisetypes.watchers.*;
import me.libraryaddict.disguise.utilities.DisguiseSound;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.LibsPremium;
import me.libraryaddict.disguise.utilities.*;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.bukkit.*;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import org.bukkit.entity.*;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
@@ -1013,7 +1010,7 @@ public class ReflectionManager {
Object obj = ((WrappedChatComponent) val).getHandle();
return NmsVersion.v1_13.isSupported() ? Optional.of(obj) : com.google.common.base.Optional.of(obj);
}else if (!NmsVersion.v1_13.isSupported()) {
} else if (!NmsVersion.v1_13.isSupported()) {
return com.google.common.base.Optional.of(val);
}
} else if (value instanceof Vector3F) {
@@ -1063,6 +1060,71 @@ public class ReflectionManager {
return value;
}
public static Material getMaterial(String name) {
try {
if (!NmsVersion.v1_13.isSupported()) {
Method toMinecraft = getCraftMethod("util.CraftMagicNumbers", "getMaterialFromInternalName",
String.class);
return (Material) toMinecraft.invoke(null, name);
}
Object mcKey = getNmsConstructor("MinecraftKey", String.class).newInstance(name);
Object registry = getNmsField("IRegistry", "ITEM").get(null);
Method getMethod = getNmsMethod(getNmsClass("RegistryMaterials"), "get", mcKey.getClass());
Object item = getMethod.invoke(registry, mcKey);
if (item == null) {
return null;
}
Method getMaterial = getCraftMethod("util.CraftMagicNumbers", "getMaterial", getNmsClass("Item"));
return (Material) getMaterial.invoke(null, item);
}
catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
public static String getItemName(Material material) {
try {
Object item = getCraftMethod("util.CraftMagicNumbers", "getItem", Material.class).invoke(null, material);
if (item == null) {
return null;
}
Object registry;
if (NmsVersion.v1_13.isSupported()) {
registry = getNmsField("IRegistry", "ITEM").get(null);
} else {
registry = getNmsField("Item", "REGISTRY").get(null);
}
Method getMethod = getNmsMethod(registry.getClass(), NmsVersion.v1_13.isSupported() ? "getKey" : "b",
Object.class);
Object mcKey = getMethod.invoke(registry, item);
if (mcKey == null) {
return null;
}
return (String) getNmsMethod("MinecraftKey", "getKey").invoke(mcKey);
}
catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
public static Object getNmsVillagerData(VillagerData data) {
Object type = getVillagerType(data.getType());
Object profession = getVillagerProfession(data.getProfession());