Fix shutdown registry setting

This commit is contained in:
fullwall 2018-08-18 13:19:16 +08:00
parent 505ef8a926
commit 0603c3f17e

View File

@ -2,7 +2,6 @@ package net.citizensnpcs.nms.v1_13_R1.util;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
@ -1017,10 +1016,8 @@ public class NMSImpl implements NMSBridge {
public void shutdown() { public void shutdown() {
if (ENTITY_REGISTRY == null) if (ENTITY_REGISTRY == null)
return; return;
Field field = NMS.getField(EntityTypes.class, "b"); Field field = NMS.getFinalField(EntityTypes.class, "REGISTRY");
Field modifiersField = NMS.getField(Field.class, "modifiers");
try { try {
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(null, ENTITY_REGISTRY.getWrapped()); field.set(null, ENTITY_REGISTRY.getWrapped());
} catch (Exception e) { } catch (Exception e) {
} }