diff --git a/Makefile b/Makefile index 1993574..00cc461 100644 --- a/Makefile +++ b/Makefile @@ -3,10 +3,10 @@ all: releasejar RUST_SOURCE_FILES := $(shell find lib/src -type f) -# Release - Linux x86_64 Xenial +# Release - Linux x86_64 centos7 lib/target/x86_64-unknown-linux-gnu/release/libskinfixer.so: ${RUST_SOURCE_FILES} mkdir -p lib/target/x86_64-unknown-linux-gnu/release - docker run -v "${CURDIR}/lib/:/code/" docker-registry.k8s.array21.dev/rust-amd64-xenial release + docker run -v "${CURDIR}/lib/:/code/" docker-registry.k8s.array21.dev/rust-amd64-centos7 release # Release - Linux aarch64 lib/target/aarch64-unknown-linux-gnu/release/libskinfixer.so: ${RUST_SOURCE_FILES} diff --git a/build.gradle b/build.gradle index b0ff4bf..4dd6558 100644 --- a/build.gradle +++ b/build.gradle @@ -37,7 +37,7 @@ dependencies { implementation 'dev.array21:httplib:1.2.2' implementation 'dev.array21:classvalidator:1.0.0' - implementation 'dev.array21:bukkit-reflection-util:1.1.1' + implementation 'dev.array21:bukkit-reflection-util:1.1.2' // JDA and related dependencies implementation 'org.slf4j:slf4j-log4j12:1.7.29' diff --git a/gradle.properties b/gradle.properties index 80a3c94..a1a4715 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -pluginVersion = 1.7.4 +pluginVersion = 1.7.5 diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 009bc56..59d74d5 100755 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -15,6 +15,14 @@ postgres = "0.19.1" bincode = "1.3.3" lazy_static = "1.4.0" +[dependencies.mysql] +version = "22.0.0" +default-features = false + +[dependencies.flate2] +version = "1.0.22" +features = ["zlib"] + [dependencies.rusqlite] version = "0.25.1" features = ["bundled"] @@ -27,13 +35,6 @@ features = ["derive"] version = "1.14.0" features = ["no_std"] -[dependencies.mysql] -version = "21.0.2" -default-features = false - -[patch.crates-io.mysql] -git = "https://github.com/TheDutchMC/rust-mysql-simple" - [profile.release] lto = true panic = "abort" \ No newline at end of file diff --git a/src/main/java/dev/array21/skinfixer/SkinChangeHandler.java b/src/main/java/dev/array21/skinfixer/SkinChangeHandler.java index ecf7eb3..05241f4 100644 --- a/src/main/java/dev/array21/skinfixer/SkinChangeHandler.java +++ b/src/main/java/dev/array21/skinfixer/SkinChangeHandler.java @@ -222,7 +222,14 @@ private void applySkin1_18(Player player, String skinValue, String skinSignature Object entityPlayer = ReflectionUtil.invokeMethod(craftPlayerClass, player, "getHandle"); Class entityHumanClass = ReflectionUtil.getMinecraftClass("world.entity.player.EntityHuman"); - Object gameProfile = ReflectionUtil.invokeMethod(entityHumanClass, entityPlayer, "fp"); + + Object gameProfile; + if(ReflectionUtil.getMinorVersion() >= 2) { + gameProfile = ReflectionUtil.invokeMethod(entityHumanClass, entityPlayer, "fq"); + } else { + gameProfile = ReflectionUtil.invokeMethod(entityHumanClass, entityPlayer, "fp"); + } + Object propertyMap = ReflectionUtil.invokeMethod(gameProfile, "getProperties"); //Check if the PropertyMap contains the 'textures' property @@ -413,10 +420,40 @@ public void run() { dimensionManager = ReflectionUtil.invokeMethod(worldServer.getClass().getSuperclass(), worldServer, "getDimensionManager"); dimensionKey = ReflectionUtil.invokeMethod(worldServer.getClass().getSuperclass(), worldServer, "getDimensionKey"); } - - /* PacketPlayOutRespawn: + + Class argumentAClass; + Object argumentAValue; + if((ReflectionUtil.getMajorVersion() == 18 && ReflectionUtil.getMinorVersion() >= 2) || ReflectionUtil.getMajorVersion() > 18) { + Class holderClass = ReflectionUtil.getMinecraftClass("core.Holder"); + Object dimensionManagerHolder = ReflectionUtil.invokeMethod(holderClass, null, "a", new Class[] { Object.class }, new Object[] { dimensionManager }); + + argumentAClass = holderClass; + argumentAValue = holderClass.cast(dimensionManagerHolder); + } else { + argumentAClass = dimensionManager.getClass(); + argumentAValue = dimensionManager; + } + + boolean isDebugWorld; + if(ReflectionUtil.getMajorVersion() >= 18) { + isDebugWorld = (boolean) ReflectionUtil.invokeMethod(worldServer.getClass().getSuperclass(), worldServer, "ad"); + } else { + isDebugWorld = (boolean) ReflectionUtil.invokeMethod(worldServer.getClass().getSuperclass(), worldServer, "isDebugWorld"); + } + + // I hate obfuscations + boolean isFlatWorld; + if((ReflectionUtil.getMajorVersion() == 18 && ReflectionUtil.getMinorVersion() >= 2) || ReflectionUtil.getMajorVersion() > 18) { + isFlatWorld = (boolean) ReflectionUtil.invokeMethod(worldServer, "C"); + } else if(ReflectionUtil.getMajorVersion() == 18) { + isFlatWorld = (boolean) ReflectionUtil.invokeMethod(worldServer, "D"); + } else { + isFlatWorld = (boolean) ReflectionUtil.invokeMethod(worldServer, "isFlatWorld"); + } + + /* PacketPlayOutRespawn: * Mojang's variable names to their 'I know what this is'-name - * a: (DimensionManager) DimensionManager + * a: 1.18.1- (DimensionManager) DimensionManager ; 1.18.2+ (Holder) * b: (ResourceKey) ResourceKey * c: (long) Sha256 of the seed * d: (GameType) PlayerGameType @@ -427,7 +464,7 @@ public void run() { * */ packetPlayOutRespawn = ReflectionUtil.invokeConstructor(playPacketOutRespawnClass, new Class[] { - dimensionManager.getClass(), + argumentAClass, dimensionKey.getClass(), long.class, enumGamemode.getClass(), @@ -436,21 +473,13 @@ public void run() { boolean.class, boolean.class }, new Object[] { - dimensionManager, + argumentAValue, dimensionKey, seedHashed, gamemodeEnumConst, gamemodeEnumConst, - - //isDebugWorld is in the nms class World, which WorldServer extends - (ReflectionUtil.getMajorVersion() >= 18) ? - ReflectionUtil.invokeMethod(worldServer.getClass().getSuperclass(), worldServer, "ad") - : ReflectionUtil.invokeMethod(worldServer.getClass().getSuperclass(), worldServer, "isDebugWorld"), - - //isFlatWorld is in the nms class WorldServer for some reason (I expected it in the nms class World) - (ReflectionUtil.getMajorVersion() >= 18) ? - ReflectionUtil.invokeMethod(worldServer, "D") - : ReflectionUtil.invokeMethod(worldServer, "isFlatWorld"), + isDebugWorld, + isFlatWorld, true }); }