Skip to content

Commit 01e1374

Browse files
committed
feat: add support for 1.21.2/1.21.3
1 parent db58aa3 commit 01e1374

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Join the [Discord](https://discord.gg/v7nmTDTW8W) or create an issue for support
2323

2424
## Available Packet Adapters
2525

26-
- **modern.** Supports 1.17-1.21.1. Can take advantage of [Paper](https://papermc.io)'s native adventure support to be more efficient.
26+
- **modern.** Supports 1.17-1.21.3. Can take advantage of [Paper](https://papermc.io)'s native adventure support to be more efficient.
2727
- **legacy.** Supports 1.7.10-1.12.2.
2828
- **PacketEvents.** Supports 1.8+. Requires [PacketEvents 2.0](https://github.com/retrooper/packetevents/tree/2.0) to be shaded or installed as a plugin.
2929

gradle/libs.versions.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[versions]
22
adventure = "4.17.0"
3-
junitJupiter = "5.11.2"
4-
devBundle = "1.21-R0.1-20240810.100446-132" # find latest here: https://repo.papermc.io/repository/maven-snapshots/io/papermc/paper/dev-bundle/1.21-R0.1-SNAPSHOT/maven-metadata.xml
3+
junitJupiter = "5.11.3"
4+
devBundle = "1.21.3-R0.1-20241101.150401-13" # find latest here: https://repo.papermc.io/repository/maven-snapshots/io/papermc/paper/dev-bundle/1.21.3-R0.1-SNAPSHOT/maven-metadata.xml
55

66
[libraries]
77
spigotApi = "org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT" # do not update
@@ -18,7 +18,7 @@ junitJupiterEngine = { module = "org.junit.jupiter:junit-jupiter-engine", versio
1818

1919
[plugins]
2020
kotlin = "org.jetbrains.kotlin.jvm:2.0.21"
21-
paperweight = "io.papermc.paperweight.userdev:1.7.3"
21+
paperweight = "io.papermc.paperweight.userdev:1.7.4"
2222

2323
[bundles]
2424
adventure = [ "adventureApi", "adventureTextSerializerGson", "adventureTextSerializerLegacy" ]

implementation/src/main/java/net/megavex/scoreboardlibrary/implementation/PacketAdapterLoader.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ private PacketAdapterLoader() {
8787
case "1.20.6":
8888
case "1.21":
8989
case "1.21.1":
90+
case "1.21.2":
91+
case "1.21.3":
9092
return tryLoadImplementationClass(MODERN);
9193
default:
9294
// Hide from relocation checkers

versions/modern/src/main/java/net/megavex/scoreboardlibrary/implementation/packetAdapter/modern/util/PacketUtil.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.lang.invoke.MethodHandle;
1010
import java.lang.invoke.MethodHandles;
1111
import java.lang.invoke.MethodType;
12+
import java.lang.reflect.Field;
1213

1314
public final class PacketUtil {
1415
private static final MethodHandle GET_HANDLE;
@@ -36,19 +37,20 @@ private PacketUtil() {
3637
throw new ExceptionInInitializerError(e);
3738
}
3839

39-
MethodHandle playerConnection;
40-
try {
41-
playerConnection = lookup.findGetter(ServerPlayer.class, "c", ServerGamePacketListenerImpl.class);
42-
} catch (NoSuchFieldException e) {
43-
try {
44-
playerConnection = lookup.findGetter(ServerPlayer.class, "b", ServerGamePacketListenerImpl.class);
45-
} catch (NoSuchFieldException | IllegalAccessException ex) {
46-
throw new ExceptionInInitializerError(ex);
40+
MethodHandle playerConnection = null;
41+
for (Field field : ServerPlayer.class.getFields()) {
42+
if (field.getType() == ServerGamePacketListenerImpl.class) {
43+
try {
44+
playerConnection = lookup.unreflectGetter(field);
45+
} catch (IllegalAccessException e) {
46+
throw new ExceptionInInitializerError(e);
47+
}
4748
}
48-
} catch (IllegalAccessException e) {
49-
throw new ExceptionInInitializerError(e);
5049
}
51-
50+
51+
if (playerConnection == null) {
52+
throw new ExceptionInInitializerError("failed to find player connection field");
53+
}
5254
PLAYER_CONNECTION = playerConnection;
5355

5456
MethodType sendMethodType = MethodType.methodType(void.class, Packet.class);

0 commit comments

Comments
 (0)