Skip to content

Commit

Permalink
fix(SkinHandler): Fixed SkinHandlers on Spigot
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeV220 committed Mar 10, 2023
1 parent 7cbef7d commit a045ac6
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 4 deletions.
7 changes: 6 additions & 1 deletion build.gradle
Expand Up @@ -118,6 +118,7 @@ dependencies {
implementation "com.georgev22.library:utilities:${libraryVersion}:all"
implementation "com.georgev22.library:yaml:${libraryVersion}:all"
implementation "com.georgev22.library:minecraft:${libraryVersion}"
implementation 'com.georgev22.api:libraryloader:1.4.0'

implementation "org.bstats:bstats-bukkit:3.0.1"
implementation "org.bstats:bstats-bungeecord:3.0.1"
Expand All @@ -132,8 +133,11 @@ dependencies {
implementation 'co.aikar:acf-velocity:0.5.1-G-1.0-SNAPSHOT'
implementation 'co.aikar:acf-sponge:0.5.1-G-1.0-SNAPSHOT'
implementation 'co.aikar:acf-sponge8:0.5.1-G-1.0-SNAPSHOT'
implementation 'com.georgev22.api:libraryloader:1.4.0'

implementation 'com.google.code.gson:gson:2.10.1'

implementation "io.papermc:paperlib:1.0.7"

implementation project(path: ':core')
implementation project(path: ':bukkit')
implementation project(path: ':bungee')
Expand All @@ -155,6 +159,7 @@ shadowJar {
relocate 'org.bstats', "${packageName}.bstats"
relocate 'com.georgev22.api.libraryloader', "${packageName}.libraryloader"
relocate 'com.georgev22.library', "${packageName}.library"
relocate "io.papermc.lib", "${packageName}.paperlib"
}

jar {
Expand Down
Expand Up @@ -90,7 +90,7 @@ public GameProfile getGameProfile0(@NotNull PlayerObject playerObject) {
Player player = (Player) playerObject.player();
final CraftPlayer craftPlayer = (CraftPlayer) player;
final ServerPlayer entityPlayer = craftPlayer.getHandle();
return entityPlayer.gameProfile;
return entityPlayer.getGameProfile();
}

private void sendPacket(@NotNull ServerPlayer player, Packet<?> packet) {
Expand Down
Expand Up @@ -92,7 +92,7 @@ public GameProfile getGameProfile0(@NotNull PlayerObject playerObject) {
Player player = (Player) playerObject.player();
final CraftPlayer craftPlayer = (CraftPlayer) player;
final ServerPlayer entityPlayer = craftPlayer.getHandle();
return entityPlayer.gameProfile;
return entityPlayer.getGameProfile();
}

private void sendPacket(@NotNull ServerPlayer player, Packet<?> packet) {
Expand Down
2 changes: 2 additions & 0 deletions mc-1-19-3/build.gradle
Expand Up @@ -11,4 +11,6 @@ dependencies {
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.19.3-R0.1-SNAPSHOT")

implementation project(path: ':core')

compileOnly "io.papermc:paperlib:1.0.7"
}
Expand Up @@ -7,6 +7,7 @@
import com.georgev22.skinoverlay.utilities.player.PlayerObject;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import io.papermc.lib.PaperLib;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.*;
import net.minecraft.network.syncher.EntityDataAccessor;
Expand All @@ -21,6 +22,9 @@
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
import java.util.HashSet;
import java.util.List;

Expand Down Expand Up @@ -92,6 +96,16 @@ public GameProfile getGameProfile0(@NotNull PlayerObject playerObject) {
Player player = (Player) playerObject.player();
final CraftPlayer craftPlayer = (CraftPlayer) player;
final ServerPlayer entityPlayer = craftPlayer.getHandle();
if (PaperLib.isSpigot())
try {
Field field = entityPlayer.getClass().getDeclaredField("cs");
if (Modifier.isPrivate(field.getModifiers())) {
return (GameProfile) Utils.Reflection.fetchDeclaredField(entityPlayer.getClass().getSuperclass(), entityPlayer, "cs");
}
} catch (NoSuchFieldException | IllegalAccessException | NoSuchMethodException |
InvocationTargetException exception) {
exception.printStackTrace();
}
return entityPlayer.gameProfile;
}

Expand Down
2 changes: 2 additions & 0 deletions mc-1-19/build.gradle
Expand Up @@ -11,4 +11,6 @@ dependencies {
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.19-R0.1-SNAPSHOT")

implementation project(path: ':core')

compileOnly "io.papermc:paperlib:1.0.7"
}
Expand Up @@ -8,6 +8,7 @@
import com.google.common.collect.ImmutableList;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import io.papermc.lib.PaperLib;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.*;
import net.minecraft.network.syncher.EntityDataAccessor;
Expand All @@ -22,6 +23,9 @@
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
import java.util.HashSet;

public class SkinHandler_1_19 extends SkinHandler {
Expand Down Expand Up @@ -93,7 +97,17 @@ public GameProfile getGameProfile0(@NotNull PlayerObject playerObject) {
Player player = (Player) playerObject.player();
final CraftPlayer craftPlayer = (CraftPlayer) player;
final ServerPlayer entityPlayer = craftPlayer.getHandle();
return entityPlayer.gameProfile;
if (PaperLib.isSpigot())
try {
Field field = entityPlayer.getClass().getDeclaredField("ct");
if (Modifier.isPrivate(field.getModifiers())) {
return (GameProfile) Utils.Reflection.fetchDeclaredField(entityPlayer.getClass().getSuperclass(), entityPlayer, "ct");
}
} catch (NoSuchFieldException | IllegalAccessException | NoSuchMethodException |
InvocationTargetException exception) {
exception.printStackTrace();
}
return entityPlayer.getGameProfile();
}

private void sendPacket(@NotNull ServerPlayer player, Packet<?> packet) {
Expand Down

0 comments on commit a045ac6

Please sign in to comment.