@@ -73,15 +73,18 @@ public class NMS {
7373 Class <?> playerConnectionClass = getClass ("net.minecraft.server.network" , "PlayerConnection" );
7474 Class <?> packetClass = getClass ("net.minecraft.network.protocol" , "Packet" );
7575
76-
7776 sbScore = scoreClass .getConstructor (sbClass , objClass , String .class );
78- sbScoreSet = scoreClass .getMethod ("setScore" , int .class );
79-
8077 packetObj = packetObjClass .getConstructor (objClass , int .class );
81-
8278 packetDisplay = packetDisplayClass .getConstructor (int .class , objClass );
8379
84- sendPacket = playerConnectionClass .getMethod ("sendPacket" , packetClass );
80+ if (VERSION .isBelow1_18 ()) {
81+ sbScoreSet = scoreClass .getMethod ("setScore" , int .class );
82+ sendPacket = playerConnectionClass .getMethod ("sendPacket" , packetClass );
83+ }
84+ else {
85+ sbScoreSet = scoreClass .getMethod ("a" , int .class );
86+ sendPacket = playerConnectionClass .getMethod ("a" , packetClass );
87+ }
8588
8689 if (VERSION .isBelow1_17 ()) {
8790 playerScores = sbClass .getDeclaredField ("playerScores" );
@@ -158,9 +161,7 @@ public static Object getHandle(Object obj) throws NoSuchMethodException,
158161
159162 if (!HANDLES .containsKey (clazz )) {
160163 Method method = clazz .getDeclaredMethod ("getHandle" );
161-
162- if (!method .isAccessible ())
163- method .setAccessible (true );
164+ method .setAccessible (true );
164165
165166 HANDLES .put (clazz , method );
166167 }
@@ -213,6 +214,10 @@ public boolean isBelow1_17() {
213214 major .equals ("1.16" );
214215 }
215216
217+ public boolean isBelow1_18 () {
218+ return major .equals ("1.17" ) || isBelow1_17 ();
219+ }
220+
216221 }
217222
218223}
0 commit comments