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>
|
<dependency>
|
||||||
<groupId>com.comphenix.protocol</groupId>
|
<groupId>com.comphenix.protocol</groupId>
|
||||||
<artifactId>ProtocolLib</artifactId>
|
<artifactId>ProtocolLib</artifactId>
|
||||||
<version>2.7.0</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<version>7.7.5-SNAPSHOT</version>
|
<version>7.7.5-SNAPSHOT</version>
|
||||||
|
@ -196,8 +196,12 @@ public class PacketsManager {
|
|||||||
|
|
||||||
spawnPackets[0] = new PacketContainer(Packets.Server.NAMED_ENTITY_SPAWN);
|
spawnPackets[0] = new PacketContainer(Packets.Server.NAMED_ENTITY_SPAWN);
|
||||||
StructureModifier<String> stringMods = spawnPackets[0].getStrings();
|
StructureModifier<String> stringMods = spawnPackets[0].getStrings();
|
||||||
for (int i = 0; i < stringMods.size(); i++) {
|
if (stringMods.size() > 0) {
|
||||||
stringMods.write(i, ((PlayerDisguise) disguise).getName());
|
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();
|
StructureModifier<Integer> intMods = spawnPackets[0].getIntegers();
|
||||||
intMods.write(0, disguisedEntity.getEntityId());
|
intMods.write(0, disguisedEntity.getEntityId());
|
||||||
|
@ -51,12 +51,29 @@ public class ReflectionManager {
|
|||||||
Object entityObject;
|
Object entityObject;
|
||||||
Object world = getWorld(Bukkit.getWorlds().get(0));
|
Object world = getWorld(Bukkit.getWorlds().get(0));
|
||||||
if (entityName.equals("Player")) {
|
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 minecraftServer = getNmsClass("MinecraftServer").getMethod("getServer").invoke(null);
|
||||||
Object playerinteractmanager = getNmsClass("PlayerInteractManager").getConstructor(getNmsClass("World"))
|
Object playerinteractmanager = getNmsClass("PlayerInteractManager").getConstructor(getNmsClass("World"))
|
||||||
.newInstance(world);
|
.newInstance(world);
|
||||||
entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("World"), String.class,
|
if (useOld) {
|
||||||
playerinteractmanager.getClass()).newInstance(minecraftServer, world, "LibsDisguises",
|
entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("World"), String.class,
|
||||||
playerinteractmanager);
|
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 {
|
} else {
|
||||||
entityObject = entityClass.getConstructor(getNmsClass("World")).newInstance(world);
|
entityObject = entityClass.getConstructor(getNmsClass("World")).newInstance(world);
|
||||||
}
|
}
|
||||||
@ -67,6 +84,16 @@ public class ReflectionManager {
|
|||||||
return null;
|
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) {
|
public static Entity getBukkitEntity(Object nmsEntity) {
|
||||||
try {
|
try {
|
||||||
Entity bukkitEntity = (Entity) ReflectionManager.getNmsClass("Entity").getMethod("getBukkitEntity").invoke(nmsEntity);
|
Entity bukkitEntity = (Entity) ReflectionManager.getNmsClass("Entity").getMethod("getBukkitEntity").invoke(nmsEntity);
|
||||||
|
Loading…
Reference in New Issue
Block a user