mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-06-26 10:04:58 +08:00
Compare commits
No commits in common. "db8cbd4f839db2a0ab46ea8d69b6b14403d610b2" and "4ef3080c62d337a39ae2ea9e8351ba28230e1e39" have entirely different histories.
db8cbd4f83
...
4ef3080c62
@ -48,20 +48,18 @@ public class DataLoader {
|
||||
}
|
||||
|
||||
public static void CheckAllFiles() {
|
||||
String pathSplitter = "defaults" + Pattern.quote(FileSystems.getDefault().getSeparator()) + "data" + Pattern.quote(FileSystems.getDefault().getSeparator());
|
||||
|
||||
try {
|
||||
List<Path> filenames = FileUtils.getPathsFromResource("/defaults/data/");
|
||||
|
||||
if (filenames == null) {
|
||||
Grasscutter.getLogger().error("We were unable to locate your default data files.");
|
||||
}
|
||||
|
||||
for (Path file : filenames) {
|
||||
String relativePath = String.valueOf(file).split("defaults[\\\\\\/]data[\\\\\\/]")[1];
|
||||
String relativePath = String.valueOf(file).split(pathSplitter)[1];
|
||||
|
||||
CheckAndCopyData(relativePath);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Grasscutter.getLogger().error("An error occurred while trying to check the data folder.", e);
|
||||
Grasscutter.getLogger().error("An error occurred while trying to check the data folder. \n", e);
|
||||
}
|
||||
|
||||
GenerateGachaMappings();
|
||||
|
@ -587,10 +587,10 @@ public class Scene {
|
||||
// Load suites
|
||||
int suite = group.init_config.suite;
|
||||
|
||||
if (suite == 0 || group.suites == null || group.suites.size() == 0) {
|
||||
if (suite == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
do {
|
||||
var suiteData = group.getSuiteByIndex(suite);
|
||||
suiteData.sceneTriggers.forEach(getScriptManager()::registerTrigger);
|
||||
@ -599,7 +599,6 @@ public class Scene {
|
||||
.map(g -> scriptManager.createGadget(group.id, group.block_id, g)).toList());
|
||||
entities.addAll(suiteData.sceneMonsters.stream()
|
||||
.map(mob -> scriptManager.createMonster(group.id, group.block_id, mob)).toList());
|
||||
|
||||
suite++;
|
||||
} while (suite < group.init_config.end_suite);
|
||||
}
|
||||
|
@ -164,10 +164,7 @@ public class SceneScriptManager {
|
||||
public void loadGroupFromScript(SceneGroup group) {
|
||||
group.load(getScene().getId());
|
||||
|
||||
if (group.variables != null) {
|
||||
group.variables.forEach(var -> this.getVariables().put(var.name, var.value));
|
||||
}
|
||||
|
||||
group.variables.forEach(var -> this.getVariables().put(var.name, var.value));
|
||||
this.sceneGroups.put(group.id, group);
|
||||
|
||||
if(group.regions != null){
|
||||
|
@ -1,28 +0,0 @@
|
||||
package emu.grasscutter.scripts;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.luaj.vm2.LuaTable;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
@ -9,10 +9,6 @@ import lombok.ToString;
|
||||
import javax.script.Bindings;
|
||||
import javax.script.CompiledScript;
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import org.luaj.vm2.LuaTable;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -110,17 +106,9 @@ public class SceneGroup {
|
||||
|
||||
suites = ScriptLoader.getSerializer().toList(SceneSuite.class, bindings.get("suites"));
|
||||
regions = ScriptLoader.getSerializer().toList(SceneRegion.class, bindings.get("regions"));
|
||||
garbages = ScriptLoader.getSerializer().toObject(SceneGarbage.class, bindings.get("garbages"));
|
||||
init_config = ScriptLoader.getSerializer().toObject(SceneInitConfig.class, bindings.get("init_config"));
|
||||
|
||||
// Garbages TODO fix properly later
|
||||
Object garbagesValue = bindings.get("garbages");
|
||||
if (garbagesValue != null && garbagesValue instanceof LuaValue garbagesTable) {
|
||||
garbages = new SceneGarbage();
|
||||
if (garbagesTable.checktable().get("gadgets") != LuaValue.NIL) {
|
||||
garbages.gadgets = ScriptLoader.getSerializer().toList(SceneGadget.class, garbagesTable.checktable().get("gadgets").checktable());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add variables to suite
|
||||
variables = ScriptLoader.getSerializer().toList(SceneVar.class, bindings.get("variables"));
|
||||
|
||||
|
@ -9,7 +9,6 @@ import lombok.ToString;
|
||||
public class SceneObject {
|
||||
public int level;
|
||||
public int config_id;
|
||||
public int area_id;
|
||||
|
||||
public Position pos;
|
||||
public Position rot;
|
||||
|
@ -2,9 +2,6 @@ package emu.grasscutter.scripts.serializer;
|
||||
|
||||
import com.esotericsoftware.reflectasm.ConstructorAccess;
|
||||
import com.esotericsoftware.reflectasm.MethodAccess;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.scripts.ScriptUtils;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@ -12,8 +9,6 @@ import lombok.experimental.FieldDefaults;
|
||||
import org.luaj.vm2.LuaTable;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ -36,10 +31,6 @@ public class LuaSerializer implements Serializer {
|
||||
public <T> List<T> serializeList(Class<T> type, LuaTable table) {
|
||||
List<T> list = new ArrayList<>();
|
||||
|
||||
if (table == null) {
|
||||
return list;
|
||||
}
|
||||
|
||||
try {
|
||||
LuaValue[] keys = table.keys();
|
||||
for (LuaValue k : keys) {
|
||||
@ -88,7 +79,7 @@ public class LuaSerializer implements Serializer {
|
||||
}
|
||||
|
||||
try {
|
||||
if (!methodAccessCache.containsKey(type)) {
|
||||
if(!methodAccessCache.containsKey(type)){
|
||||
cacheType(type);
|
||||
}
|
||||
var methodAccess = methodAccessCache.get(type);
|
||||
@ -96,10 +87,9 @@ public class LuaSerializer implements Serializer {
|
||||
|
||||
object = (T) constructorCache.get(type).newInstance();
|
||||
|
||||
if (table == null) {
|
||||
if(table == null){
|
||||
return object;
|
||||
}
|
||||
|
||||
LuaValue[] keys = table.keys();
|
||||
for (LuaValue k : keys) {
|
||||
try {
|
||||
@ -127,7 +117,6 @@ public class LuaSerializer implements Serializer {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Grasscutter.getLogger().info(ScriptUtils.toMap(table).toString());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -98,11 +97,6 @@ public final class FileUtils {
|
||||
} catch (Exception e) {
|
||||
// Eclipse puts resources in its bin folder
|
||||
File f = new File(jarPath + "defaults/data/");
|
||||
|
||||
if (!f.exists() || f.listFiles().length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
result = Arrays.stream(f.listFiles()).map(File::toPath).toList();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user