mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-18 09:54:59 +01:00
Enable script in big world (#884)
* add docs for tower * fix: LEAK: ByteBuf.release() was not called * enableScriptInBigWorld * not print log when loaded scripts from cache * revert the change of server tick * revert the change of server tick * fix * optimize the performance: lazy load & cache * fix the refresh group * fix NPE Co-authored-by: Melledy <52122272+Melledy@users.noreply.github.com>
This commit is contained in:
@@ -76,8 +76,11 @@ public class LuaSerializer implements Serializer {
|
||||
LuaValue[] keys = table.keys();
|
||||
for (LuaValue k : keys) {
|
||||
try {
|
||||
Field field = object.getClass().getDeclaredField(k.checkjstring());
|
||||
|
||||
Field field = getField(object.getClass(), k.checkjstring());
|
||||
if (field == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
field.setAccessible(true);
|
||||
LuaValue keyValue = table.get(k);
|
||||
|
||||
@@ -103,4 +106,17 @@ public class LuaSerializer implements Serializer {
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
public <T> Field getField(Class<T> clazz, String name){
|
||||
try{
|
||||
return clazz.getField(name);
|
||||
} catch (NoSuchFieldException ex) {
|
||||
try {
|
||||
return clazz.getDeclaredField(name);
|
||||
} catch (NoSuchFieldException e) {
|
||||
// ignore
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user