mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-12-14 15:26:54 +01:00
Fix a skin broken bug I hope while fixed the other previous bug
This commit is contained in:
parent
80dff148ff
commit
e0fffdaa14
@ -705,6 +705,8 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,8 +58,8 @@ public class ReflectionManager {
|
|||||||
static {
|
static {
|
||||||
for (Method method : getNmsClass("EntityLiving").getDeclaredMethods()) {
|
for (Method method : getNmsClass("EntityLiving").getDeclaredMethods()) {
|
||||||
try {
|
try {
|
||||||
if (method.getReturnType() == float.class && Modifier.isProtected(method.getModifiers())
|
if (method.getReturnType() == float.class && Modifier.isProtected(
|
||||||
&& method.getParameterTypes().length == 0) {
|
method.getModifiers()) && method.getParameterTypes().length == 0) {
|
||||||
Object entity = createEntityInstance("Cow");
|
Object entity = createEntityInstance("Cow");
|
||||||
|
|
||||||
method.setAccessible(true);
|
method.setAccessible(true);
|
||||||
@ -86,8 +86,8 @@ public class ReflectionManager {
|
|||||||
|
|
||||||
ihmGet = getNmsMethod("IntHashMap", "get", int.class);
|
ihmGet = getNmsMethod("IntHashMap", "get", int.class);
|
||||||
|
|
||||||
boundingBoxConstructor = getNmsConstructor("AxisAlignedBB", double.class, double.class, double.class, double.class,
|
boundingBoxConstructor = getNmsConstructor("AxisAlignedBB", double.class, double.class, double.class,
|
||||||
double.class, double.class);
|
double.class, double.class, double.class);
|
||||||
|
|
||||||
setBoundingBoxMethod = getNmsMethod("Entity", "a", getNmsClass("AxisAlignedBB"));
|
setBoundingBoxMethod = getNmsMethod("Entity", "a", getNmsClass("AxisAlignedBB"));
|
||||||
|
|
||||||
@ -102,8 +102,9 @@ public class ReflectionManager {
|
|||||||
String id = (String) response.get("id");
|
String id = (String) response.get("id");
|
||||||
|
|
||||||
if (!id.contains("-")) {
|
if (!id.contains("-")) {
|
||||||
id = Pattern.compile("([0-9a-fA-F]{8})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]+)").matcher(id)
|
id = Pattern.compile(
|
||||||
.replaceFirst("$1-$2-$3-$4-$5");
|
"([0-9a-fA-F]{8})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]+)").matcher(
|
||||||
|
id).replaceFirst("$1-$2-$3-$4-$5");
|
||||||
}
|
}
|
||||||
|
|
||||||
WrappedGameProfile gameProfile = new WrappedGameProfile(UUID.fromString(id), (String) response.get("name"));
|
WrappedGameProfile gameProfile = new WrappedGameProfile(UUID.fromString(id), (String) response.get("name"));
|
||||||
@ -139,36 +140,35 @@ public class ReflectionManager {
|
|||||||
Object world = getWorldServer(Bukkit.getWorlds().get(0));
|
Object world = getWorldServer(Bukkit.getWorlds().get(0));
|
||||||
|
|
||||||
switch (entityName) {
|
switch (entityName) {
|
||||||
case "Player":
|
case "Player":
|
||||||
Object minecraftServer = getNmsMethod("MinecraftServer", "getServer").invoke(null);
|
Object minecraftServer = getNmsMethod("MinecraftServer", "getServer").invoke(null);
|
||||||
|
|
||||||
Object playerinteractmanager = getNmsClass("PlayerInteractManager").getDeclaredConstructor(getNmsClass("World"))
|
Object playerinteractmanager = getNmsClass("PlayerInteractManager").getDeclaredConstructor(
|
||||||
.newInstance(world);
|
getNmsClass("World")).newInstance(world);
|
||||||
|
|
||||||
WrappedGameProfile gameProfile = getGameProfile(null, "Steve");
|
WrappedGameProfile gameProfile = getGameProfile(null, "Steve");
|
||||||
|
|
||||||
entityObject = entityClass
|
entityObject = entityClass.getDeclaredConstructor(getNmsClass("MinecraftServer"),
|
||||||
.getDeclaredConstructor(getNmsClass("MinecraftServer"), getNmsClass("WorldServer"),
|
getNmsClass("WorldServer"), gameProfile.getHandleType(),
|
||||||
gameProfile.getHandleType(), playerinteractmanager.getClass())
|
playerinteractmanager.getClass()).newInstance(minecraftServer, world,
|
||||||
.newInstance(minecraftServer, world, gameProfile.getHandle(), playerinteractmanager);
|
gameProfile.getHandle(), playerinteractmanager);
|
||||||
break;
|
break;
|
||||||
case "EnderPearl":
|
case "EnderPearl":
|
||||||
entityObject = entityClass.getDeclaredConstructor(getNmsClass("World"), getNmsClass("EntityLiving"))
|
entityObject = entityClass.getDeclaredConstructor(getNmsClass("World"),
|
||||||
.newInstance(world, createEntityInstance("Cow"));
|
getNmsClass("EntityLiving")).newInstance(world, createEntityInstance("Cow"));
|
||||||
break;
|
break;
|
||||||
case "Potion":
|
case "Potion":
|
||||||
entityObject = entityClass
|
entityObject = entityClass.getDeclaredConstructor(getNmsClass("World"), Double.TYPE, Double.TYPE,
|
||||||
.getDeclaredConstructor(getNmsClass("World"), Double.TYPE, Double.TYPE, Double.TYPE,
|
Double.TYPE, getNmsClass("ItemStack")).newInstance(world, 0d, 0d, 0d,
|
||||||
getNmsClass("ItemStack"))
|
getNmsItem(new ItemStack(Material.SPLASH_POTION)));
|
||||||
.newInstance(world, 0d, 0d, 0d, getNmsItem(new ItemStack(Material.SPLASH_POTION)));
|
break;
|
||||||
break;
|
case "FishingHook":
|
||||||
case "FishingHook":
|
entityObject = entityClass.getDeclaredConstructor(getNmsClass("World"),
|
||||||
entityObject = entityClass.getDeclaredConstructor(getNmsClass("World"), getNmsClass("EntityHuman"))
|
getNmsClass("EntityHuman")).newInstance(world, createEntityInstance("Player"));
|
||||||
.newInstance(world, createEntityInstance("Player"));
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
entityObject = entityClass.getDeclaredConstructor(getNmsClass("World")).newInstance(world);
|
||||||
entityObject = entityClass.getDeclaredConstructor(getNmsClass("World")).newInstance(world);
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return entityObject;
|
return entityObject;
|
||||||
@ -194,15 +194,15 @@ public class ReflectionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Object createMobEffect(PotionEffect effect) {
|
public static Object createMobEffect(PotionEffect effect) {
|
||||||
return createMobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(),
|
return createMobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(),
|
||||||
effect.hasParticles());
|
effect.isAmbient(), effect.hasParticles());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object createMobEffect(int id, int duration, int amplification, boolean ambient, boolean particles) {
|
public static Object createMobEffect(int id, int duration, int amplification, boolean ambient, boolean particles) {
|
||||||
try {
|
try {
|
||||||
return getNmsClass("MobEffect")
|
return getNmsClass("MobEffect").getDeclaredConstructor(getNmsClass("MobEffectList"), Integer.TYPE,
|
||||||
.getDeclaredConstructor(getNmsClass("MobEffectList"), Integer.TYPE, Integer.TYPE, Boolean.TYPE, Boolean.TYPE)
|
Integer.TYPE, Boolean.TYPE, Boolean.TYPE).newInstance(getMobEffectList(id), duration, amplification,
|
||||||
.newInstance(getMobEffectList(id), duration, amplification, ambient, particles);
|
ambient, particles);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -223,26 +223,26 @@ public class ReflectionManager {
|
|||||||
stage++;
|
stage++;
|
||||||
|
|
||||||
switch (stage) {
|
switch (stage) {
|
||||||
case 1:
|
case 1:
|
||||||
x -= field.getDouble(boundingBox);
|
x -= field.getDouble(boundingBox);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
y -= field.getDouble(boundingBox);
|
y -= field.getDouble(boundingBox);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
z -= field.getDouble(boundingBox);
|
z -= field.getDouble(boundingBox);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
x += field.getDouble(boundingBox);
|
x += field.getDouble(boundingBox);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
y += field.getDouble(boundingBox);
|
y += field.getDouble(boundingBox);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
z += field.getDouble(boundingBox);
|
z += field.getDouble(boundingBox);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Exception("Error while setting the bounding box, more doubles than I thought??");
|
throw new Exception("Error while setting the bounding box, more doubles than I thought??");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -357,7 +357,8 @@ public class ReflectionManager {
|
|||||||
|
|
||||||
public static Object getBlockPosition(int x, int y, int z) {
|
public static Object getBlockPosition(int x, int y, int z) {
|
||||||
try {
|
try {
|
||||||
return getNmsClass("BlockPosition").getDeclaredConstructor(int.class, int.class, int.class).newInstance(x, y, z);
|
return getNmsClass("BlockPosition").getDeclaredConstructor(int.class, int.class, int.class).newInstance(x,
|
||||||
|
y, z);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -390,14 +391,13 @@ public class ReflectionManager {
|
|||||||
|
|
||||||
public static Object getPlayerInfoData(Object playerInfoPacket, WrappedGameProfile gameProfile) {
|
public static Object getPlayerInfoData(Object playerInfoPacket, WrappedGameProfile gameProfile) {
|
||||||
try {
|
try {
|
||||||
Object playerListName = getNmsClass("ChatComponentText").getDeclaredConstructor(String.class)
|
Object playerListName = getNmsClass("ChatComponentText").getDeclaredConstructor(String.class).newInstance(
|
||||||
.newInstance(gameProfile.getName());
|
gameProfile.getName());
|
||||||
|
|
||||||
return getNmsClass("PacketPlayOutPlayerInfo$PlayerInfoData")
|
return getNmsClass("PacketPlayOutPlayerInfo$PlayerInfoData").getDeclaredConstructor(
|
||||||
.getDeclaredConstructor(getNmsClass("PacketPlayOutPlayerInfo"), gameProfile.getHandleType(), int.class,
|
getNmsClass("PacketPlayOutPlayerInfo"), gameProfile.getHandleType(), int.class,
|
||||||
getNmsClass("EnumGamemode"), getNmsClass("IChatBaseComponent"))
|
getNmsClass("EnumGamemode"), getNmsClass("IChatBaseComponent")).newInstance(playerInfoPacket,
|
||||||
.newInstance(playerInfoPacket, gameProfile.getHandle(), 0, getNmsClass("EnumGamemode").getEnumConstants()[1],
|
gameProfile.getHandle(), 0, getNmsClass("EnumGamemode").getEnumConstants()[1], playerListName);
|
||||||
playerListName);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -427,9 +427,11 @@ public class ReflectionManager {
|
|||||||
public static WrappedGameProfile getGameProfileWithThisSkin(UUID uuid, String playerName,
|
public static WrappedGameProfile getGameProfileWithThisSkin(UUID uuid, String playerName,
|
||||||
WrappedGameProfile profileWithSkin) {
|
WrappedGameProfile profileWithSkin) {
|
||||||
try {
|
try {
|
||||||
WrappedGameProfile gameProfile = new WrappedGameProfile(uuid != null ? uuid : UUID.randomUUID(), playerName);
|
WrappedGameProfile gameProfile = new WrappedGameProfile(uuid != null ? uuid : UUID.randomUUID(),
|
||||||
|
playerName);
|
||||||
|
|
||||||
gameProfile.getProperties().putAll(profileWithSkin.getProperties());
|
if (profileWithSkin != null)
|
||||||
|
gameProfile.getProperties().putAll(profileWithSkin.getProperties());
|
||||||
|
|
||||||
return gameProfile;
|
return gameProfile;
|
||||||
}
|
}
|
||||||
@ -561,9 +563,7 @@ public class ReflectionManager {
|
|||||||
float width = getNmsField("Entity", "width").getFloat(getNmsEntity(entity));
|
float width = getNmsField("Entity", "width").getFloat(getNmsEntity(entity));
|
||||||
|
|
||||||
float height = (Float) getNmsMethod("Entity", "getHeadHeight").invoke(getNmsEntity(entity));
|
float height = (Float) getNmsMethod("Entity", "getHeadHeight").invoke(getNmsEntity(entity));
|
||||||
return new float[] {
|
return new float[]{length, width, height};
|
||||||
length, width, height
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -580,9 +580,9 @@ public class ReflectionManager {
|
|||||||
if (method.getReturnType().getSimpleName().equals("MinecraftSessionService")) {
|
if (method.getReturnType().getSimpleName().equals("MinecraftSessionService")) {
|
||||||
Object session = method.invoke(minecraftServer);
|
Object session = method.invoke(minecraftServer);
|
||||||
|
|
||||||
return WrappedGameProfile.fromHandle(session.getClass()
|
return WrappedGameProfile.fromHandle(
|
||||||
.getDeclaredMethod("fillProfileProperties", gameProfile.getHandleType(), boolean.class)
|
session.getClass().getDeclaredMethod("fillProfileProperties", gameProfile.getHandleType(),
|
||||||
.invoke(session, gameProfile.getHandle(), true));
|
boolean.class).invoke(session, gameProfile.getHandle(), true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -616,12 +616,9 @@ public class ReflectionManager {
|
|||||||
|
|
||||||
LibsProfileLookupCaller callback = new LibsProfileLookupCaller();
|
LibsProfileLookupCaller callback = new LibsProfileLookupCaller();
|
||||||
|
|
||||||
profileRepo.getClass()
|
profileRepo.getClass().getDeclaredMethod("findProfilesByNames", String[].class, agent.getClass(),
|
||||||
.getDeclaredMethod("findProfilesByNames", String[].class, agent.getClass(),
|
Class.forName("com.mojang.authlib.ProfileLookupCallback")).invoke(profileRepo,
|
||||||
Class.forName("com.mojang.authlib.ProfileLookupCallback"))
|
new String[]{playername}, agent, callback);
|
||||||
.invoke(profileRepo, new String[] {
|
|
||||||
playername
|
|
||||||
}, agent, callback);
|
|
||||||
|
|
||||||
if (callback.getGameProfile() != null) {
|
if (callback.getGameProfile() != null) {
|
||||||
return callback.getGameProfile();
|
return callback.getGameProfile();
|
||||||
@ -646,9 +643,9 @@ public class ReflectionManager {
|
|||||||
try {
|
try {
|
||||||
Location loc = entity.getLocation();
|
Location loc = entity.getLocation();
|
||||||
|
|
||||||
Object boundingBox = boundingBoxConstructor.newInstance(loc.getX() - newBox.getX(), loc.getY() - newBox.getY(),
|
Object boundingBox = boundingBoxConstructor.newInstance(loc.getX() - newBox.getX(),
|
||||||
loc.getZ() - newBox.getZ(), loc.getX() + newBox.getX(), loc.getY() + newBox.getY(),
|
loc.getY() - newBox.getY(), loc.getZ() - newBox.getZ(), loc.getX() + newBox.getX(),
|
||||||
loc.getZ() + newBox.getZ());
|
loc.getY() + newBox.getY(), loc.getZ() + newBox.getZ());
|
||||||
|
|
||||||
setBoundingBoxMethod.invoke(getNmsEntity(entity), boundingBox);
|
setBoundingBoxMethod.invoke(getNmsEntity(entity), boundingBox);
|
||||||
}
|
}
|
||||||
@ -712,20 +709,20 @@ public class ReflectionManager {
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
switch (slot) {
|
switch (slot) {
|
||||||
case HAND:
|
case HAND:
|
||||||
return (Enum) enums[0];
|
return (Enum) enums[0];
|
||||||
case OFF_HAND:
|
case OFF_HAND:
|
||||||
return (Enum) enums[1];
|
return (Enum) enums[1];
|
||||||
case FEET:
|
case FEET:
|
||||||
return (Enum) enums[2];
|
return (Enum) enums[2];
|
||||||
case LEGS:
|
case LEGS:
|
||||||
return (Enum) enums[3];
|
return (Enum) enums[3];
|
||||||
case CHEST:
|
case CHEST:
|
||||||
return (Enum) enums[4];
|
return (Enum) enums[4];
|
||||||
case HEAD:
|
case HEAD:
|
||||||
return (Enum) enums[5];
|
return (Enum) enums[5];
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -739,18 +736,18 @@ public class ReflectionManager {
|
|||||||
Enum nmsSlot = (Enum) enumItemSlot;
|
Enum nmsSlot = (Enum) enumItemSlot;
|
||||||
|
|
||||||
switch (nmsSlot.name()) {
|
switch (nmsSlot.name()) {
|
||||||
case "MAINHAND":
|
case "MAINHAND":
|
||||||
return EquipmentSlot.HAND;
|
return EquipmentSlot.HAND;
|
||||||
case "OFFHAND":
|
case "OFFHAND":
|
||||||
return EquipmentSlot.OFF_HAND;
|
return EquipmentSlot.OFF_HAND;
|
||||||
case "FEET":
|
case "FEET":
|
||||||
return EquipmentSlot.FEET;
|
return EquipmentSlot.FEET;
|
||||||
case "LEGS":
|
case "LEGS":
|
||||||
return EquipmentSlot.LEGS;
|
return EquipmentSlot.LEGS;
|
||||||
case "CHEST":
|
case "CHEST":
|
||||||
return EquipmentSlot.CHEST;
|
return EquipmentSlot.CHEST;
|
||||||
case "HEAD":
|
case "HEAD":
|
||||||
return EquipmentSlot.HEAD;
|
return EquipmentSlot.HEAD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
@ -770,20 +767,20 @@ public class ReflectionManager {
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
switch (slot) {
|
switch (slot) {
|
||||||
case HAND:
|
case HAND:
|
||||||
return ((LivingEntity) disguisedEntity).getEquipment().getItemInMainHand();
|
return ((LivingEntity) disguisedEntity).getEquipment().getItemInMainHand();
|
||||||
case OFF_HAND:
|
case OFF_HAND:
|
||||||
return ((LivingEntity) disguisedEntity).getEquipment().getItemInOffHand();
|
return ((LivingEntity) disguisedEntity).getEquipment().getItemInOffHand();
|
||||||
case FEET:
|
case FEET:
|
||||||
return ((LivingEntity) disguisedEntity).getEquipment().getBoots();
|
return ((LivingEntity) disguisedEntity).getEquipment().getBoots();
|
||||||
case LEGS:
|
case LEGS:
|
||||||
return ((LivingEntity) disguisedEntity).getEquipment().getLeggings();
|
return ((LivingEntity) disguisedEntity).getEquipment().getLeggings();
|
||||||
case CHEST:
|
case CHEST:
|
||||||
return ((LivingEntity) disguisedEntity).getEquipment().getChestplate();
|
return ((LivingEntity) disguisedEntity).getEquipment().getChestplate();
|
||||||
case HEAD:
|
case HEAD:
|
||||||
return ((LivingEntity) disguisedEntity).getEquipment().getHelmet();
|
return ((LivingEntity) disguisedEntity).getEquipment().getHelmet();
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -831,14 +828,14 @@ public class ReflectionManager {
|
|||||||
BlockPosition pos = (BlockPosition) val;
|
BlockPosition pos = (BlockPosition) val;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return Optional.of(getNmsConstructor("BlockPosition", int.class, int.class, int.class).newInstance(pos.getX(),
|
return Optional.of(
|
||||||
pos.getY(), pos.getZ()));
|
getNmsConstructor("BlockPosition", int.class, int.class, int.class).newInstance(pos.getX(),
|
||||||
|
pos.getY(), pos.getZ()));
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
} else if (val instanceof WrappedBlockData) {
|
||||||
else if (val instanceof WrappedBlockData) {
|
|
||||||
try {
|
try {
|
||||||
return Optional.of(((WrappedBlockData) val).getHandle());
|
return Optional.of(((WrappedBlockData) val).getHandle());
|
||||||
}
|
}
|
||||||
@ -846,8 +843,7 @@ public class ReflectionManager {
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (value instanceof Vector3F) {
|
||||||
else if (value instanceof Vector3F) {
|
|
||||||
Vector3F angle = (Vector3F) value;
|
Vector3F angle = (Vector3F) value;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -857,27 +853,25 @@ public class ReflectionManager {
|
|||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
} else if (value instanceof Direction) {
|
||||||
else if (value instanceof Direction) {
|
|
||||||
try {
|
try {
|
||||||
return (Enum) getNmsMethod("EnumDirection", "fromType1", int.class).invoke(null, ((Direction) value).ordinal());
|
return (Enum) getNmsMethod("EnumDirection", "fromType1", int.class).invoke(null,
|
||||||
|
((Direction) value).ordinal());
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
} else if (value instanceof BlockPosition) {
|
||||||
else if (value instanceof BlockPosition) {
|
|
||||||
BlockPosition pos = (BlockPosition) value;
|
BlockPosition pos = (BlockPosition) value;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return getNmsConstructor("BlockPosition", int.class, int.class, int.class).newInstance(pos.getX(), pos.getY(),
|
return getNmsConstructor("BlockPosition", int.class, int.class, int.class).newInstance(pos.getX(),
|
||||||
pos.getZ());
|
pos.getY(), pos.getZ());
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
} else if (value instanceof ItemStack) {
|
||||||
else if (value instanceof ItemStack) {
|
|
||||||
return getNmsItem((ItemStack) value);
|
return getNmsItem((ItemStack) value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -902,19 +896,15 @@ public class ReflectionManager {
|
|||||||
if (value instanceof Optional) {
|
if (value instanceof Optional) {
|
||||||
Optional opt = (Optional) value;
|
Optional opt = (Optional) value;
|
||||||
|
|
||||||
serializer = Registry.get((opt.isPresent()
|
serializer = Registry.get((opt.isPresent() ? getNmsClass("IBlockData").isInstance(opt.get()) ? getNmsClass(
|
||||||
? getNmsClass("IBlockData").isInstance(opt.get()) ? getNmsClass("IBlockData") : opt.get().getClass()
|
"IBlockData") : opt.get().getClass() : UUID.class), true);
|
||||||
: UUID.class), true);
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
serializer = Registry.get(value.getClass());
|
serializer = Registry.get(value.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serializer == null) {
|
if (serializer == null) {
|
||||||
throw new IllegalArgumentException("Unable to find Serializer for " + value
|
throw new IllegalArgumentException(
|
||||||
+ (value instanceof Optional && ((Optional) value).isPresent()
|
"Unable to find Serializer for " + value + (value instanceof Optional && ((Optional) value).isPresent() ? " (" + ((Optional) value).get().getClass().getName() + ")" : "") + "! Are you running the latest version of ProtocolLib?");
|
||||||
? " (" + ((Optional) value).get().getClass().getName() + ")" : "")
|
|
||||||
+ "! Are you running the latest version of ProtocolLib?");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WrappedDataWatcherObject watcherObject = new WrappedDataWatcherObject(id, serializer);
|
WrappedDataWatcherObject watcherObject = new WrappedDataWatcherObject(id, serializer);
|
||||||
@ -969,5 +959,4 @@ public class ReflectionManager {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user