@@ -514,7 +514,7 @@ public static Class<?> getEntityPlayerClass() {
514
514
.getMethodByName ("getHandle" );
515
515
516
516
// EntityPlayer is the return type
517
- return setMinecraftClass ("EntityPlayer" , getHandle .getReturnType ());
517
+ return setMinecraftClass ("server.level. EntityPlayer" , getHandle .getReturnType ());
518
518
} catch (IllegalArgumentException e1 ) {
519
519
throw new RuntimeException ("Could not find EntityPlayer class." , e1 );
520
520
}
@@ -584,7 +584,7 @@ public static Class<?> getNmsWorldClass() {
584
584
try {
585
585
return getMinecraftClass ("world.level.World" , "world.level.Level" , "World" );
586
586
} catch (RuntimeException e ) {
587
- return setMinecraftClass ("World" , getWorldServerClass ().getSuperclass ());
587
+ return setMinecraftClass ("world.level. World" , getWorldServerClass ().getSuperclass ());
588
588
}
589
589
}
590
590
@@ -644,7 +644,7 @@ public static boolean isBundlePacket(Class<?> packetClass) {
644
644
}
645
645
646
646
public static boolean isBundleDelimiter (Class <?> packetClass ) {
647
- Class <?> bundleDelimiterClass = getBundleDelimiterClass ().orElse (null );
647
+ Class <?> bundleDelimiterClass = getBundleDelimiterClass ().orElse (null );
648
648
return bundleDelimiterClass != null && (packetClass .equals (bundleDelimiterClass ) || bundleDelimiterClass .isAssignableFrom (packetClass ));
649
649
}
650
650
@@ -727,10 +727,10 @@ public static Class<?> getMinecraftServerClass() {
727
727
return getMinecraftClass ("server.MinecraftServer" , "MinecraftServer" );
728
728
} catch (RuntimeException e ) {
729
729
// Reset cache and try again
730
- setMinecraftClass ( " MinecraftServer", null );
730
+ resetCacheForNMSClass ( "server. MinecraftServer" );
731
731
732
732
useFallbackServer ();
733
- return getMinecraftClass ("MinecraftServer" );
733
+ return getMinecraftClass ("server. MinecraftServer" );
734
734
}
735
735
}
736
736
@@ -762,10 +762,10 @@ public static Class<?> getPlayerListClass() {
762
762
return getMinecraftClass ("server.players.PlayerList" , "PlayerList" );
763
763
} catch (RuntimeException e ) {
764
764
// Reset cache and try again
765
- setMinecraftClass ( " PlayerList", null );
765
+ resetCacheForNMSClass ( "server.players. PlayerList" );
766
766
767
767
useFallbackServer ();
768
- return getMinecraftClass ("PlayerList" );
768
+ return getMinecraftClass ("server.players. PlayerList" );
769
769
}
770
770
}
771
771
@@ -797,7 +797,7 @@ public static Class<?> getItemStackClass() {
797
797
return getMinecraftClass ("world.item.ItemStack" , "ItemStack" );
798
798
} catch (RuntimeException e ) {
799
799
// Use the handle reference
800
- return setMinecraftClass ("ItemStack" , FuzzyReflection .fromClass (getCraftItemStackClass (), true )
800
+ return setMinecraftClass ("world.item. ItemStack" , FuzzyReflection .fromClass (getCraftItemStackClass (), true )
801
801
.getFieldByName ("handle" )
802
802
.getType ());
803
803
}
@@ -1185,13 +1185,15 @@ public static Class<?> getCraftMessageClass() {
1185
1185
public static Class <?> getPlayerInfoDataClass () {
1186
1186
try {
1187
1187
return getMinecraftClass (
1188
- "network.protocol.game.PacketPlayOutPlayerInfo$PlayerInfoData" ,
1189
- "network.protocol.game.ClientboundPlayerInfoPacket$PlayerUpdate" ,
1190
- "PacketPlayOutPlayerInfo$PlayerInfoData" , "PlayerInfoData" );
1191
- } catch (Exception ex ) {
1192
- // todo: ClientboundPlayerInfoUpdatePacket$b, maybe get this via field type
1188
+ "network.protocol.game.ClientboundPlayerInfoUpdatePacket$Entry" ,
1189
+ "network.protocol.game.PacketPlayOutPlayerInfo$PlayerInfoData" ,
1190
+ "network.protocol.game.ClientboundPlayerInfoPacket$PlayerUpdate" ,
1191
+ "PacketPlayOutPlayerInfo$PlayerInfoData" ,
1192
+ "PlayerInfoData"
1193
+ );
1194
+ } catch (Exception ignored ) {
1193
1195
return setMinecraftClass (
1194
- "network.protocol.game.PacketPlayOutPlayerInfo$PlayerInfoData " ,
1196
+ "network.protocol.game.ClientboundPlayerInfoUpdatePacket$Entry " ,
1195
1197
PacketType .Play .Server .PLAYER_INFO .getPacketClass ().getClasses ()[0 ]);
1196
1198
}
1197
1199
}
@@ -1512,16 +1514,22 @@ public static Optional<Class<?>> getOptionalNMS(String className, String... alia
1512
1514
* Retrieves a nullable NMS (net.minecraft.server) class. We will attempt to
1513
1515
* look up the class and its aliases, but will return null if none is found.
1514
1516
*
1515
- * @deprecated - Use getOptionalNMS where possible
1516
1517
* @param className NMS class name
1517
1518
* @param aliases Potential aliases
1518
1519
* @return The class, or null if not found
1519
1520
*/
1520
- @ Deprecated
1521
1521
public static Class <?> getNullableNMS (String className , String ... aliases ) {
1522
1522
return getOptionalNMS (className , aliases ).orElse (null );
1523
1523
}
1524
1524
1525
+ private static void resetCacheForNMSClass (String className ) {
1526
+ if (minecraftPackage == null ) {
1527
+ minecraftPackage = new CachedPackage (getMinecraftPackage (), getClassSource ());
1528
+ }
1529
+
1530
+ minecraftPackage .removePackageClass (className );
1531
+ }
1532
+
1525
1533
/**
1526
1534
* Set the class object for the specific Minecraft class.
1527
1535
*
@@ -1838,7 +1846,7 @@ public static Class<?> getHolderClass() {
1838
1846
}
1839
1847
1840
1848
public static Class <?> getCraftServer () {
1841
- return getCraftBukkitClass ("CraftServer" );
1849
+ return getCraftBukkitClass ("CraftServer" );
1842
1850
}
1843
1851
1844
1852
public static Class <?> getHolderLookupProviderClass () {
@@ -1850,29 +1858,29 @@ public static Class<?> getRegistryAccessClass() {
1850
1858
}
1851
1859
1852
1860
public static Class <?> getProtocolInfoClass () {
1853
- return getMinecraftClass ("network.ProtocolInfo" );
1861
+ return getMinecraftClass ("network.ProtocolInfo" );
1854
1862
}
1855
1863
1856
1864
public static Class <?> getProtocolInfoUnboundClass () {
1857
- return getMinecraftClass ("network.ProtocolInfo$a" /* Spigot Mappings */ , "network.ProtocolInfo$Unbound" /* Mojang Mappings */ );
1865
+ return getMinecraftClass ("network.ProtocolInfo$a" /* Spigot Mappings */ , "network.ProtocolInfo$Unbound" /* Mojang Mappings */ );
1858
1866
}
1859
1867
1860
1868
public static Class <?> getPacketFlowClass () {
1861
- return getMinecraftClass ("network.protocol.EnumProtocolDirection" /* Spigot Mappings */ , "network.protocol.PacketFlow" /* Mojang Mappings */ );
1869
+ return getMinecraftClass ("network.protocol.EnumProtocolDirection" /* Spigot Mappings */ , "network.protocol.PacketFlow" /* Mojang Mappings */ );
1862
1870
}
1863
1871
1864
1872
public static Class <?> getStreamCodecClass () {
1865
- return getMinecraftClass ("network.codec.StreamCodec" );
1873
+ return getMinecraftClass ("network.codec.StreamCodec" );
1866
1874
}
1867
1875
1868
1876
public static Optional <Class <?>> getRegistryFriendlyByteBufClass () {
1869
- return getOptionalNMS ("network.RegistryFriendlyByteBuf" );
1877
+ return getOptionalNMS ("network.RegistryFriendlyByteBuf" );
1870
1878
}
1871
1879
1872
1880
public static boolean isMojangMapped () {
1873
1881
if (isMojangMapped == null ) {
1874
- String craftServerName = Bukkit . getServer (). getClass ().getName ();
1875
- isMojangMapped = ! craftServerName .contains (".v" ) && ! craftServerName . contains ( "_R " );
1882
+ String nmsWorldName = getWorldServerClass ().getName ();
1883
+ isMojangMapped = nmsWorldName .contains ("ServerLevel " );
1876
1884
}
1877
1885
1878
1886
return isMojangMapped ;
0 commit comments