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:
Akka
2022-05-15 19:19:24 +08:00
committed by GitHub
parent eb64b25f12
commit 6dc30e4def
21 changed files with 643 additions and 321 deletions

View File

@@ -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;
}
}
}
}