Start the road to a 1.7 update

This commit is contained in:
libraryaddict 2013-12-05 20:38:41 +13:00
parent 3299d97495
commit d415f6340e
3 changed files with 37 additions and 6 deletions

View File

@ -56,7 +56,7 @@
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>2.7.0</version>
<version>3.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<version>7.7.5-SNAPSHOT</version>

View File

@ -196,9 +196,13 @@ public class PacketsManager {
spawnPackets[0] = new PacketContainer(Packets.Server.NAMED_ENTITY_SPAWN);
StructureModifier<String> stringMods = spawnPackets[0].getStrings();
if (stringMods.size() > 0) {
for (int i = 0; i < stringMods.size(); i++) {
stringMods.write(i, ((PlayerDisguise) disguise).getName());
}
} else {
spawnPackets[0].getModifier().write(1, ReflectionManager.getGameProfile(((PlayerDisguise) disguise).getName()));
}
StructureModifier<Integer> intMods = spawnPackets[0].getIntegers();
intMods.write(0, disguisedEntity.getEntityId());
intMods.write(1, (int) Math.floor(loc.getX() * 32));

View File

@ -51,12 +51,29 @@ public class ReflectionManager {
Object entityObject;
Object world = getWorld(Bukkit.getWorlds().get(0));
if (entityName.equals("Player")) {
boolean useOld = false;
if (bukkitVersion.startsWith("1.")) {
try {
if (Integer.parseInt(bukkitVersion.split("\\.")[1]) < 7) {
useOld = true;
}
} catch (Exception ex) {
}
}
Object minecraftServer = getNmsClass("MinecraftServer").getMethod("getServer").invoke(null);
Object playerinteractmanager = getNmsClass("PlayerInteractManager").getConstructor(getNmsClass("World"))
.newInstance(world);
if (useOld) {
entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("World"), String.class,
playerinteractmanager.getClass()).newInstance(minecraftServer, world, "LibsDisguises",
playerinteractmanager);
} else {
Object gameProfile = getGameProfile("LibsDisguises");
entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("WorldServer"),
gameProfile.getClass(), playerinteractmanager.getClass()).newInstance(minecraftServer, world,
gameProfile, playerinteractmanager);
}
} else {
entityObject = entityClass.getConstructor(getNmsClass("World")).newInstance(world);
}
@ -67,6 +84,16 @@ public class ReflectionManager {
return null;
}
public static Object getGameProfile(String playerName) {
try {
return Class.forName("net.minecraft.util.com.mojang.authlib.GameProfile").getConstructor(String.class, String.class)
.newInstance(playerName, playerName);
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
public static Entity getBukkitEntity(Object nmsEntity) {
try {
Entity bukkitEntity = (Entity) ReflectionManager.getNmsClass("Entity").getMethod("getBukkitEntity").invoke(nmsEntity);