mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2026-02-07 02:26:43 +01:00
28 lines
725 B
Java
28 lines
725 B
Java
package emu.grasscutter.scripts;
|
|
|
|
import emu.grasscutter.Grasscutter;
|
|
import org.luaj.vm2.LuaTable;
|
|
import org.luaj.vm2.LuaValue;
|
|
|
|
import java.util.HashMap;
|
|
|
|
public class ScriptUtils {
|
|
|
|
public static HashMap<Object, Object> toMap(LuaTable table) {
|
|
HashMap<Object, Object> map = new HashMap<>();
|
|
LuaValue[] rootKeys = table.keys();
|
|
for (LuaValue k : rootKeys) {
|
|
if (table.get(k).istable()) {
|
|
map.put(k, toMap(table.get(k).checktable()));
|
|
} else {
|
|
map.put(k, table.get(k));
|
|
}
|
|
}
|
|
return map;
|
|
}
|
|
|
|
public static void print(LuaTable table) {
|
|
Grasscutter.getLogger().info(toMap(table).toString());
|
|
}
|
|
}
|