mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-12-28 11:04:21 +00:00
Fix IllegalAccessException with advancement listener on 1.12.2 (#4826)
Fixes #4809.
This commit is contained in:
parent
c5253bc5e2
commit
1a5526867c
1 changed files with 6 additions and 3 deletions
|
@ -11,6 +11,7 @@ import org.bukkit.event.player.PlayerAdvancementDoneEvent;
|
||||||
import java.lang.invoke.MethodHandle;
|
import java.lang.invoke.MethodHandle;
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.lang.invoke.MethodType;
|
import java.lang.invoke.MethodType;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
public class AdvancementListenerProvider implements Listener {
|
public class AdvancementListenerProvider implements Listener {
|
||||||
private final Object language;
|
private final Object language;
|
||||||
|
@ -25,10 +26,12 @@ public class AdvancementListenerProvider implements Listener {
|
||||||
} else {
|
} else {
|
||||||
languageClass = ReflUtil.getNMSClass("LocaleLanguage");
|
languageClass = ReflUtil.getNMSClass("LocaleLanguage");
|
||||||
}
|
}
|
||||||
final MethodHandles.Lookup lookup = MethodHandles.lookup();
|
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
language = lookup.findStatic(languageClass, ReflUtil.isMojMap() ? "getInstance" : "a", MethodType.methodType(languageClass)).invoke();
|
final Method iWishICouldUseMethodHandles = languageClass.getDeclaredMethod(ReflUtil.isMojMap() ? "getInstance" : "a");
|
||||||
languageGetOrDefault = lookup.findVirtual(languageClass, ReflUtil.isMojMap() ? "getOrDefault" : "a", MethodType.methodType(String.class, String.class));
|
iWishICouldUseMethodHandles.setAccessible(true);
|
||||||
|
language = iWishICouldUseMethodHandles.invoke(null);
|
||||||
|
languageGetOrDefault = MethodHandles.lookup().findVirtual(languageClass, ReflUtil.isMojMap() ? "getOrDefault" : "a", MethodType.methodType(String.class, String.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
|
Loading…
Reference in a new issue