Allow disguises in 1.7.6 - 1.7.8 but no skins for players!!

This commit is contained in:
libraryaddict 2014-04-12 16:22:47 +12:00
parent c3c6a5c1c4
commit 8c2261798e
3 changed files with 11 additions and 20 deletions

View File

@ -299,20 +299,8 @@ public class DisguiseUtilities {
return selfDisguisesIds;
}
public static UUID getUUID(final Disguise disguise, final String playerName) {
public static UUID getUUID() {
if (LibVersion.getGameVersion() == LibVersion.V1_7) {
Player p = Bukkit.getPlayerExact(playerName);
if (p != null) {
try {
Field field = ReflectionManager.getNmsClass("PlayerConnection").getDeclaredField("processedDisconnect");
field.setAccessible(true);
if (!field.getBoolean(ReflectionManager.getNmsClass("EntityPlayer").getField("playerConnection")
.get(p.getClass().getDeclaredMethod("getHandle").invoke(p))))
return p.getUniqueId();
} catch (Exception e) {
e.printStackTrace();
}
}
EthernetAddress addr = EthernetAddress.fromInterface();
TimeBasedGenerator uuidGenerator = Generators.timeBasedGenerator(addr);
return uuidGenerator.generate();

View File

@ -200,11 +200,8 @@ public class PacketsManager {
stringMods.write(i, ((PlayerDisguise) disguise).getName());
}
} else {
spawnPackets[0].getModifier().write(
1,
ReflectionManager.getGameProfile(
DisguiseUtilities.getUUID(disguise, ((PlayerDisguise) disguise).getName()),
((PlayerDisguise) disguise).getName()));
spawnPackets[0].getModifier().write(1,
ReflectionManager.getGameProfile(DisguiseUtilities.getUUID(), ((PlayerDisguise) disguise).getName()));
}
StructureModifier<Integer> intMods = spawnPackets[0].getIntegers();
intMods.write(0, disguisedEntity.getEntityId());

View File

@ -208,8 +208,14 @@ public class ReflectionManager {
public static Object getGameProfile(UUID uuid, String playerName) {
try {
return Class.forName("net.minecraft.util.com.mojang.authlib.GameProfile").getConstructor(String.class, String.class)
.newInstance(uuid != null ? uuid.toString() : "", playerName);
try {
return Class.forName("net.minecraft.util.com.mojang.authlib.GameProfile")
.getConstructor(UUID.class, String.class)
.newInstance(uuid != null ? uuid : DisguiseUtilities.getUUID(), playerName);
} catch (NoSuchMethodException ex) {
return Class.forName("net.minecraft.util.com.mojang.authlib.GameProfile")
.getConstructor(String.class, String.class).newInstance(uuid != null ? uuid.toString() : "", playerName);
}
} catch (Exception ex) {
ex.printStackTrace();
}