Merge pull request #57 from MinelinkNetwork/1.8
Merge 3rd party commit for 1.8 support
This commit is contained in:
commit
b63d855dd6
13
pom.xml
13
pom.xml
@ -64,14 +64,9 @@
|
||||
<url>http://repo.md-5.net/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>comphenix-rep</id>
|
||||
<name>Comphenix Repository</name>
|
||||
<url>http://repo.comphenix.net/content/groups/public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>comphenix-snapshot-rep</id>
|
||||
<name>Comphenix Snapshot Repository</name>
|
||||
<url>http://repo.comphenix.net/content/repositories/snapshots/</url>
|
||||
<id>shadowvolt-repo</id>
|
||||
<name>Shadowvolt Maven Repository</name>
|
||||
<url>http://ci.shadowvolt.com/plugin/repository/everything/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
@ -79,7 +74,7 @@
|
||||
<dependency>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<version>3.6.3-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
|
@ -34,8 +34,6 @@ public abstract class TargetedDisguise extends Disguise {
|
||||
}
|
||||
|
||||
public boolean canSee(Player player) {
|
||||
if (getType() != null && (getType().is1_8() && !ReflectionManager.is1_8(player)))
|
||||
return false;
|
||||
return canSee(player.getName());
|
||||
}
|
||||
|
||||
|
@ -81,12 +81,14 @@ public class DisguiseUtilities {
|
||||
|
||||
static {
|
||||
try {
|
||||
Object server = ReflectionManager.getNmsMethod("MinecraftServer", "getServer").invoke(null);
|
||||
Object world = ((List) server.getClass().getField("worlds").get(server)).get(0);
|
||||
bedChunk = ReflectionManager.getNmsClass("Chunk")
|
||||
.getConstructor(ReflectionManager.getNmsClass("World"), int.class, int.class).newInstance(null, 0, 0);
|
||||
.getConstructor(ReflectionManager.getNmsClass("World"), int.class, int.class).newInstance(world, 0, 0);
|
||||
Field cSection = bedChunk.getClass().getDeclaredField("sections");
|
||||
cSection.setAccessible(true);
|
||||
Object chunkSection = ReflectionManager.getNmsClass("ChunkSection").getConstructor(int.class, boolean.class)
|
||||
.newInstance(0, false);
|
||||
.newInstance(0, true);
|
||||
Object block;
|
||||
try {
|
||||
block = ReflectionManager.getNmsClass("Block").getMethod("getById", int.class)
|
||||
@ -95,23 +97,35 @@ public class DisguiseUtilities {
|
||||
block = ((Object[]) ReflectionManager.getNmsField(ReflectionManager.getNmsClass("Block"), "byId").get(null))[Material.BED_BLOCK
|
||||
.getId()];
|
||||
}
|
||||
Method setId = chunkSection.getClass().getMethod("setTypeId", int.class, int.class, int.class,
|
||||
ReflectionManager.getNmsClass("Block"));
|
||||
Method setData = chunkSection.getClass().getMethod("setData", int.class, int.class, int.class, int.class);
|
||||
Method setSky = chunkSection.getClass().getMethod("setSkyLight", int.class, int.class, int.class, int.class);
|
||||
Method setEmitted = chunkSection.getClass().getMethod("setEmittedLight", int.class, int.class, int.class, int.class);
|
||||
for (BlockFace face : new BlockFace[] { BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH }) {
|
||||
setId.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), block);
|
||||
setData.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), face.ordinal());
|
||||
setSky.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), 0);
|
||||
setEmitted.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), 0);
|
||||
|
||||
if (LibVersion.is1_8()) {
|
||||
Method fromLegacyData = block.getClass().getMethod("fromLegacyData", int.class);
|
||||
Method setType = chunkSection.getClass().getMethod("setType", int.class, int.class, int.class,
|
||||
ReflectionManager.getNmsClass("IBlockData"));
|
||||
Method setSky = chunkSection.getClass().getMethod("a", int.class, int.class, int.class, int.class);
|
||||
Method setEmitted = chunkSection.getClass().getMethod("b", int.class, int.class, int.class, int.class);
|
||||
for (BlockFace face : new BlockFace[] { BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH }) {
|
||||
setType.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), fromLegacyData.invoke(block, face.ordinal()));
|
||||
setSky.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), 0);
|
||||
setEmitted.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), 0);
|
||||
}
|
||||
} else {
|
||||
Method setId = chunkSection.getClass().getMethod("setTypeId", int.class, int.class, int.class,
|
||||
ReflectionManager.getNmsClass("Block"));
|
||||
Method setData = chunkSection.getClass().getMethod("setData", int.class, int.class, int.class, int.class);
|
||||
Method setSky = chunkSection.getClass().getMethod("setSkyLight", int.class, int.class, int.class, int.class);
|
||||
Method setEmitted = chunkSection.getClass().getMethod("setEmittedLight", int.class, int.class, int.class, int.class);
|
||||
for (BlockFace face : new BlockFace[] { BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH }) {
|
||||
setId.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), block);
|
||||
setData.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), face.ordinal());
|
||||
setSky.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), 0);
|
||||
setEmitted.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
Object[] array = (Object[]) Array.newInstance(chunkSection.getClass(), 16);
|
||||
array[0] = chunkSection;
|
||||
cSection.set(bedChunk, array);
|
||||
Object server = ReflectionManager.getNmsMethod("MinecraftServer", "getServer").invoke(null);
|
||||
Object world = ((List) server.getClass().getField("worlds").get(server)).get(0);
|
||||
bedChunk.getClass().getField("world").set(bedChunk, world);
|
||||
xChunk = bedChunk.getClass().getField("locX");
|
||||
xChunk.setAccessible(true);
|
||||
zChunk = bedChunk.getClass().getField("locZ");
|
||||
@ -327,7 +341,7 @@ public class DisguiseUtilities {
|
||||
try {
|
||||
packets[i] = ProtocolLibrary.getProtocolManager()
|
||||
.createPacketConstructor(PacketType.Play.Server.MAP_CHUNK, bedChunk, true, 0, 40)
|
||||
.createPacket(bedChunk, true, 0, ReflectionManager.is1_8(player) ? 48 : 0);
|
||||
.createPacket(bedChunk, true, 0, LibVersion.is1_8() ? 48 : 0);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
packets[i] = ProtocolLibrary.getProtocolManager()
|
||||
.createPacketConstructor(PacketType.Play.Server.MAP_CHUNK, bedChunk, true, 0)
|
||||
@ -339,10 +353,10 @@ public class DisguiseUtilities {
|
||||
try {
|
||||
packets[i] = ProtocolLibrary.getProtocolManager()
|
||||
.createPacketConstructor(PacketType.Play.Server.MAP_CHUNK_BULK, Arrays.asList(bedChunk), 40)
|
||||
.createPacket(Arrays.asList(bedChunk), ReflectionManager.is1_8(player) ? 48 : 0);
|
||||
.createPacket(Arrays.asList(bedChunk), LibVersion.is1_8() ? 48 : 0);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
packets[i] = ProtocolLibrary.getProtocolManager()
|
||||
.createPacketConstructor(PacketType.Play.Server.MAP_CHUNK_BULK, Arrays.asList(bedChunk))
|
||||
.createPacketConstructor(PacketType.Play.Server.MAP_CHUNK_BULK, List.class)
|
||||
.createPacket(Arrays.asList(bedChunk));
|
||||
}
|
||||
i++;
|
||||
@ -356,7 +370,7 @@ public class DisguiseUtilities {
|
||||
PacketContainer setBed = new PacketContainer(PacketType.Play.Server.BED);
|
||||
StructureModifier<Integer> bedInts = setBed.getIntegers();
|
||||
bedInts.write(0, entity.getEntityId());
|
||||
if (ReflectionManager.is1_8(player)) {
|
||||
if (LibVersion.is1_8()) {
|
||||
PlayerWatcher watcher = disguise.getWatcher();
|
||||
int chunkX = (int) Math.floor(playerLocation.getX() / 16D) - 17, chunkZ = (int) Math
|
||||
.floor(playerLocation.getZ() / 16D) - 17;
|
||||
@ -599,7 +613,7 @@ public class DisguiseUtilities {
|
||||
*/
|
||||
public static List<WrappedWatchableObject> rebuildForVersion(Player player, FlagWatcher watcher,
|
||||
List<WrappedWatchableObject> list) {
|
||||
if (!ReflectionManager.is1_8(player))
|
||||
if (!LibVersion.is1_8())
|
||||
return list;
|
||||
ArrayList<WrappedWatchableObject> rebuiltList = new ArrayList<WrappedWatchableObject>();
|
||||
ArrayList<WrappedWatchableObject> backups = new ArrayList<WrappedWatchableObject>();
|
||||
|
@ -266,7 +266,7 @@ public class PacketsManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (ReflectionManager.is1_8(player)) {
|
||||
if (LibVersion.is1_8()) {
|
||||
ArrayList<PacketContainer> newPackets = new ArrayList<PacketContainer>();
|
||||
newPackets.add(null);
|
||||
for (int i = 0; i < spawnPackets.length; i++) {
|
||||
|
@ -36,20 +36,16 @@ public class ReflectionManager {
|
||||
if (mcVersion.startsWith("1.")) {
|
||||
if (mcVersion.compareTo("1.7") < 0) {
|
||||
currentVersion = LibVersion.V1_6;
|
||||
} else {
|
||||
} else if (mcVersion.startsWith("1.7")) {
|
||||
if (mcVersion.equals("1.7.10")) {
|
||||
currentVersion = LibVersion.V1_7_10;
|
||||
} else {
|
||||
currentVersion = mcVersion.compareTo("1.7.6") < 0 ? LibVersion.V1_7 : LibVersion.V1_7_6;
|
||||
}
|
||||
} else {
|
||||
currentVersion = V1_8;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Class.forName("org.spigotmc.ProtocolData");
|
||||
currentVersion = V1_8;
|
||||
} catch (Exception ex) {
|
||||
// Its not 1.8
|
||||
}
|
||||
}
|
||||
|
||||
public static LibVersion getGameVersion() {
|
||||
@ -249,6 +245,9 @@ public class ReflectionManager {
|
||||
playerinteractmanager.getClass()).newInstance(minecraftServer, world, "LibsDisguises",
|
||||
playerinteractmanager);
|
||||
}
|
||||
} else if (LibVersion.is1_8() && entityName.equals("EnderPearl")) {
|
||||
entityObject = entityClass.getConstructor(getNmsClass("World"), getNmsClass("EntityLiving"))
|
||||
.newInstance(world, createEntityInstance("Sheep"));
|
||||
} else {
|
||||
entityObject = entityClass.getConstructor(getNmsClass("World")).newInstance(world);
|
||||
}
|
||||
@ -265,7 +264,12 @@ public class ReflectionManager {
|
||||
|
||||
public static FakeBoundingBox getBoundingBox(Entity entity) {
|
||||
try {
|
||||
Object boundingBox = getNmsField("Entity", "boundingBox").get(getNmsEntity(entity));
|
||||
Object boundingBox;
|
||||
if (LibVersion.is1_8()) {
|
||||
boundingBox = getNmsMethod("Entity", "getBoundingBox").invoke(getNmsEntity(entity));
|
||||
} else {
|
||||
boundingBox = getNmsField("Entity", "boundingBox").get(getNmsEntity(entity));
|
||||
}
|
||||
double x = 0, y = 0, z = 0;
|
||||
int stage = 0;
|
||||
for (Field field : boundingBox.getClass().getFields()) {
|
||||
@ -492,7 +496,12 @@ public class ReflectionManager {
|
||||
try {
|
||||
float length = getNmsField("Entity", "length").getFloat(getNmsEntity(entity));
|
||||
float width = getNmsField("Entity", "width").getFloat(getNmsEntity(entity));
|
||||
float height = getNmsField("Entity", "height").getFloat(getNmsEntity(entity));
|
||||
float height;
|
||||
if (LibVersion.is1_8()) {
|
||||
height = (Float) getNmsMethod("Entity", "getHeadHeight").invoke(getNmsEntity(entity));
|
||||
} else {
|
||||
height = getNmsField("Entity", "height").getFloat(getNmsEntity(entity));
|
||||
}
|
||||
return new float[] { length, width, height };
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
@ -611,7 +620,12 @@ public class ReflectionManager {
|
||||
|
||||
public static void setBoundingBox(Entity entity, FakeBoundingBox newBox) {
|
||||
try {
|
||||
Object boundingBox = getNmsField("Entity", "boundingBox").get(getNmsEntity(entity));
|
||||
Object boundingBox;
|
||||
if (LibVersion.is1_8()) {
|
||||
boundingBox = getNmsMethod("Entity", "getBoundingBox").invoke(getNmsEntity(entity));
|
||||
} else {
|
||||
boundingBox = getNmsField("Entity", "boundingBox").get(getNmsEntity(entity));
|
||||
}
|
||||
int stage = 0;
|
||||
Location loc = entity.getLocation();
|
||||
for (Field field : boundingBox.getClass().getFields()) {
|
||||
|
Loading…
Reference in New Issue
Block a user