Start the road to a 1.7 update
This commit is contained in:
parent
3299d97495
commit
d415f6340e
2
pom.xml
2
pom.xml
@ -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>
|
||||
|
@ -196,8 +196,12 @@ public class PacketsManager {
|
||||
|
||||
spawnPackets[0] = new PacketContainer(Packets.Server.NAMED_ENTITY_SPAWN);
|
||||
StructureModifier<String> stringMods = spawnPackets[0].getStrings();
|
||||
for (int i = 0; i < stringMods.size(); i++) {
|
||||
stringMods.write(i, ((PlayerDisguise) disguise).getName());
|
||||
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());
|
||||
|
@ -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);
|
||||
entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("World"), String.class,
|
||||
playerinteractmanager.getClass()).newInstance(minecraftServer, world, "LibsDisguises",
|
||||
playerinteractmanager);
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user