2525import org .bukkit .permissions .Permission ;
2626
2727import javax .annotation .Nonnull ;
28+ import java .lang .reflect .Field ;
29+ import java .lang .reflect .InvocationTargetException ;
30+ import java .lang .reflect .Method ;
2831import java .util .ArrayList ;
2932import java .util .Arrays ;
3033import java .util .HashMap ;
3639
3740public class PsrUser {
3841
42+ private static Method getLocaleLegacy = getLegacyMethod ();
43+
44+ private static Method getLegacyMethod () {
45+ try {
46+ return Player .Spigot .class .getDeclaredMethod ("getLocale" );
47+ } catch (NoSuchMethodException ignored ) {}
48+ return null ;
49+ }
50+
3951 private UUID uuid ;
4052 private Player player ;
4153 private CommandSender sender ;
@@ -65,7 +77,10 @@ public PsrUser(Player player) {
6577 if (ProtocolStringReplacer .getInstance ().getServerMajorVersion () >= 12 ) {
6678 setClientLocale (getPlayer ().getLocale ());
6779 } else {
68- setClientLocale (((Player ) getPlayer ().spigot ()).getLocale ());
80+ Player .Spigot spigot = getPlayer ().spigot ();
81+ try {
82+ setClientLocale ((String ) getLocaleLegacy .invoke (spigot ));
83+ } catch (IllegalAccessException | InvocationTargetException ignored ) {}
6984 }
7085 }
7186
@@ -76,7 +91,10 @@ public PsrUser(UUID uuid) {
7691 if (ProtocolStringReplacer .getInstance ().getServerMajorVersion () >= 12 ) {
7792 setClientLocale (getPlayer ().getLocale ());
7893 } else {
79- setClientLocale (((Player ) getPlayer ().spigot ()).getLocale ());
94+ Player .Spigot spigot = getPlayer ().spigot ();
95+ try {
96+ setClientLocale ((String ) getLocaleLegacy .invoke (spigot ));
97+ } catch (IllegalAccessException | InvocationTargetException ignored ) {}
8098 }
8199 }
82100
0 commit comments