Skip to content

Commit

Permalink
Fixes:
Browse files Browse the repository at this point in the history
- 1.18.2 Compat (#34)
- Mysql auth issue
  • Loading branch information
TobiasDeBruijn committed Mar 14, 2022
1 parent 198bdaa commit 9fa8e8c
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 27 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pluginVersion = 1.7.4
pluginVersion = 1.7.5
15 changes: 8 additions & 7 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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"
61 changes: 45 additions & 16 deletions src/main/java/dev/array21/skinfixer/SkinChangeHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<DimensionManager>)
* b: (ResourceKey) ResourceKey<World>
* c: (long) Sha256 of the seed
* d: (GameType) PlayerGameType
Expand All @@ -427,7 +464,7 @@ public void run() {
* */
packetPlayOutRespawn = ReflectionUtil.invokeConstructor(playPacketOutRespawnClass,
new Class<?>[] {
dimensionManager.getClass(),
argumentAClass,
dimensionKey.getClass(),
long.class,
enumGamemode.getClass(),
Expand All @@ -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
});
}
Expand Down

0 comments on commit 9fa8e8c

Please sign in to comment.