mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2026-02-07 10:36:41 +01:00
Run spotlessApply
also set line endings to native, no more line conflict errors!
This commit is contained in:
@@ -41,11 +41,7 @@ public final class GridPosition implements Serializable {
|
||||
|
||||
@SneakyThrows
|
||||
public GridPosition(String str) {
|
||||
var listOfParams = str
|
||||
.replace(" ", "")
|
||||
.replace("(", "")
|
||||
.replace(")", "")
|
||||
.split(",");
|
||||
var listOfParams = str.replace(" ", "").replace("(", "").replace(")", "").split(",");
|
||||
if (listOfParams.length != 3)
|
||||
throw new IOException("invalid size on GridPosition definition - ");
|
||||
try {
|
||||
|
||||
@@ -90,20 +90,14 @@ public class JsonAdapters {
|
||||
|
||||
// GridPosition follows the format of: (x, y, z).
|
||||
// Flatten to (x,y,z) for easier parsing.
|
||||
var str = in.nextString()
|
||||
.replace("(", "")
|
||||
.replace(")", "")
|
||||
.replace(" ", "");
|
||||
var str = in.nextString().replace("(", "").replace(")", "").replace(" ", "");
|
||||
var split = str.split(",");
|
||||
|
||||
if (split.length != 3)
|
||||
throw new IOException("Invalid GridPosition definition - " + in.peek().name());
|
||||
|
||||
return new GridPosition(
|
||||
Integer.parseInt(split[0]),
|
||||
Integer.parseInt(split[1]),
|
||||
Integer.parseInt(split[2])
|
||||
);
|
||||
Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,13 +22,13 @@ import java.util.Map;
|
||||
public final class JsonUtils {
|
||||
static final Gson gson =
|
||||
new GsonBuilder()
|
||||
.setPrettyPrinting()
|
||||
.registerTypeAdapter(DynamicFloat.class, new DynamicFloatAdapter())
|
||||
.registerTypeAdapter(IntList.class, new IntListAdapter())
|
||||
.registerTypeAdapter(Position.class, new PositionAdapter())
|
||||
.registerTypeAdapter(GridPosition.class, new GridPositionAdapter())
|
||||
.registerTypeAdapterFactory(new EnumTypeAdapterFactory())
|
||||
.create();
|
||||
.setPrettyPrinting()
|
||||
.registerTypeAdapter(DynamicFloat.class, new DynamicFloatAdapter())
|
||||
.registerTypeAdapter(IntList.class, new IntListAdapter())
|
||||
.registerTypeAdapter(Position.class, new PositionAdapter())
|
||||
.registerTypeAdapter(GridPosition.class, new GridPositionAdapter())
|
||||
.registerTypeAdapterFactory(new EnumTypeAdapterFactory())
|
||||
.create();
|
||||
|
||||
/*
|
||||
* Encode an object to a JSON string
|
||||
|
||||
@@ -314,9 +314,7 @@ public final class Language {
|
||||
return getTextMapKey((int) hash);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads game text maps with caching.
|
||||
*/
|
||||
/** Loads game text maps with caching. */
|
||||
public static void loadTextMaps() {
|
||||
Language.loadTextMaps(false);
|
||||
}
|
||||
@@ -328,36 +326,38 @@ public final class Language {
|
||||
*/
|
||||
public static void loadTextMaps(boolean bypassCache) {
|
||||
// Check system timestamps on cache and resources
|
||||
if (!bypassCache) try {
|
||||
long cacheModified = Files.getLastModifiedTime(TEXTMAP_CACHE_PATH).toMillis();
|
||||
long textmapsModified =
|
||||
Files.list(getResourcePath("TextMap"))
|
||||
.filter(path -> path.toString().endsWith(".json"))
|
||||
.map(
|
||||
path -> {
|
||||
try {
|
||||
return Files.getLastModifiedTime(path).toMillis();
|
||||
} catch (Exception ignored) {
|
||||
Grasscutter.getLogger()
|
||||
.debug("Exception while checking modified time: ", path);
|
||||
return Long.MAX_VALUE; // Don't use cache, something has gone wrong
|
||||
}
|
||||
})
|
||||
.max(Long::compare)
|
||||
.get();
|
||||
if (!bypassCache)
|
||||
try {
|
||||
long cacheModified = Files.getLastModifiedTime(TEXTMAP_CACHE_PATH).toMillis();
|
||||
long textmapsModified =
|
||||
Files.list(getResourcePath("TextMap"))
|
||||
.filter(path -> path.toString().endsWith(".json"))
|
||||
.map(
|
||||
path -> {
|
||||
try {
|
||||
return Files.getLastModifiedTime(path).toMillis();
|
||||
} catch (Exception ignored) {
|
||||
Grasscutter.getLogger()
|
||||
.debug("Exception while checking modified time: ", path);
|
||||
return Long.MAX_VALUE; // Don't use cache, something has gone wrong
|
||||
}
|
||||
})
|
||||
.max(Long::compare)
|
||||
.get();
|
||||
|
||||
Grasscutter.getLogger()
|
||||
.debug(
|
||||
"Cache modified %d, textmap modified %d".formatted(cacheModified, textmapsModified));
|
||||
if (textmapsModified < cacheModified) {
|
||||
// Try loading from cache
|
||||
Grasscutter.getLogger().debug("Loading cached 'TextMaps'...");
|
||||
textMapStrings = loadTextMapsCache();
|
||||
return;
|
||||
Grasscutter.getLogger()
|
||||
.debug(
|
||||
"Cache modified %d, textmap modified %d"
|
||||
.formatted(cacheModified, textmapsModified));
|
||||
if (textmapsModified < cacheModified) {
|
||||
// Try loading from cache
|
||||
Grasscutter.getLogger().debug("Loading cached 'TextMaps'...");
|
||||
textMapStrings = loadTextMapsCache();
|
||||
return;
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
Grasscutter.getLogger().error("Error loading textmaps cache: " + exception.toString());
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
Grasscutter.getLogger().error("Error loading textmaps cache: " + exception.toString());
|
||||
}
|
||||
|
||||
// Regenerate cache
|
||||
Grasscutter.getLogger().debug("Generating TextMaps cache");
|
||||
|
||||
@@ -57,7 +57,7 @@ public class TsvUtils {
|
||||
private static final Function<String, Object> parseLong =
|
||||
value -> (long) Double.parseDouble(value); // Long::parseLong;
|
||||
private static final Map<Class<?>, Function<String, Object>> enumTypeParsers = new HashMap<>();
|
||||
private final static Map<Type, Function<String, Object>> primitiveTypeParsers =
|
||||
private static final Map<Type, Function<String, Object>> primitiveTypeParsers =
|
||||
Map.ofEntries(
|
||||
Map.entry(String.class, parseString),
|
||||
Map.entry(Integer.class, parseInt),
|
||||
@@ -72,7 +72,7 @@ public class TsvUtils {
|
||||
Map.entry(boolean.class, Boolean::parseBoolean));
|
||||
private static final Map<Type, Function<String, Object>> typeParsers =
|
||||
new HashMap<>(primitiveTypeParsers);
|
||||
private final static Map<Class<?>, Map<String, FieldParser>> cachedClassFieldMaps =
|
||||
private static final Map<Class<?>, Map<String, FieldParser>> cachedClassFieldMaps =
|
||||
new HashMap<>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
Reference in New Issue
Block a user