mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-23 16:16:46 +00:00
Remove the extra slash while loading resources. (#893)
* Remove the extra slash * Update src/main/java/emu/grasscutter/Configuration.java Co-authored-by: HotaruYS <105128850+HotaruYS@users.noreply.github.com> * Update src/main/java/emu/grasscutter/Configuration.java Co-authored-by: HotaruYS <105128850+HotaruYS@users.noreply.github.com> * Update src/main/java/emu/grasscutter/Configuration.java Co-authored-by: HotaruYS <105128850+HotaruYS@users.noreply.github.com> * Import java.nio.file.Paths to use Paths.get * Mark fields as private to prevent use *FOLDER directly * Remove unnecessary slash Co-authored-by: HotaruYS <105128850+HotaruYS@users.noreply.github.com>
This commit is contained in:
parent
82775b4ff9
commit
58df221c6d
@ -4,9 +4,11 @@ import emu.grasscutter.utils.ConfigContainer;
|
||||
import emu.grasscutter.utils.ConfigContainer.*;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static emu.grasscutter.Grasscutter.config;
|
||||
|
||||
|
||||
/**
|
||||
* A data container for the server's configuration.
|
||||
*
|
||||
@ -24,12 +26,12 @@ public final class Configuration extends ConfigContainer {
|
||||
|
||||
public static final Locale LANGUAGE = config.language.language;
|
||||
public static final Locale FALLBACK_LANGUAGE = config.language.fallback;
|
||||
public static final String DATA_FOLDER = config.folderStructure.data;
|
||||
public static final String RESOURCES_FOLDER = config.folderStructure.resources;
|
||||
public static final String KEYS_FOLDER = config.folderStructure.keys;
|
||||
public static final String PLUGINS_FOLDER = config.folderStructure.plugins;
|
||||
public static final String SCRIPTS_FOLDER = config.folderStructure.scripts;
|
||||
public static final String PACKETS_FOLDER = config.folderStructure.packets;
|
||||
private static final String DATA_FOLDER = config.folderStructure.data;
|
||||
private static final String RESOURCES_FOLDER = config.folderStructure.resources;
|
||||
private static final String KEYS_FOLDER = config.folderStructure.keys;
|
||||
private static final String PLUGINS_FOLDER = config.folderStructure.plugins;
|
||||
private static final String SCRIPTS_FOLDER = config.folderStructure.scripts;
|
||||
private static final String PACKETS_FOLDER = config.folderStructure.packets;
|
||||
|
||||
public static final Server SERVER = config.server;
|
||||
public static final Database DATABASE = config.databaseInfo;
|
||||
@ -49,17 +51,36 @@ public final class Configuration extends ConfigContainer {
|
||||
/*
|
||||
* Utilities
|
||||
*/
|
||||
|
||||
public static String DATA() {
|
||||
return DATA_FOLDER;
|
||||
}
|
||||
|
||||
public static String DATA(String path) {
|
||||
return DATA_FOLDER + "/" + path;
|
||||
return Paths.get(DATA_FOLDER, path).toString();
|
||||
}
|
||||
|
||||
public static String RESOURCE(String path) {
|
||||
return RESOURCES_FOLDER + "/" + path;
|
||||
return Paths.get(RESOURCES_FOLDER, path).toString();
|
||||
}
|
||||
|
||||
public static String KEY(String path) {
|
||||
return Paths.get(KEYS_FOLDER, path).toString();
|
||||
}
|
||||
|
||||
public static String PLUGIN() {
|
||||
return PLUGINS_FOLDER;
|
||||
}
|
||||
|
||||
public static String PLUGIN(String path) {
|
||||
return Paths.get(PLUGINS_FOLDER, path).toString();
|
||||
}
|
||||
|
||||
public static String SCRIPT(String path) {
|
||||
return SCRIPTS_FOLDER + "/" + path;
|
||||
return Paths.get(SCRIPTS_FOLDER, path).toString();
|
||||
}
|
||||
|
||||
public static String PACKET(String path) {
|
||||
return Paths.get(PACKETS_FOLDER, path).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -91,4 +112,4 @@ public final class Configuration extends ConfigContainer {
|
||||
public static int lr(int left, int right) {
|
||||
return left == 0 ? right : left;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -358,7 +358,7 @@ public class GachaManager {
|
||||
if(this.watchService == null) {
|
||||
try {
|
||||
this.watchService = FileSystems.getDefault().newWatchService();
|
||||
Path path = new File(DATA_FOLDER).toPath();
|
||||
Path path = new File(DATA()).toPath();
|
||||
path.register(watchService, new WatchEvent.Kind[]{StandardWatchEventKinds.ENTRY_MODIFY}, SensitivityWatchEventModifier.HIGH);
|
||||
} catch (Exception e) {
|
||||
Grasscutter.getLogger().error("Unable to load the Gacha Manager Watch Service. If ServerOptions.watchGacha is true it will not auto-reload");
|
||||
|
@ -37,7 +37,7 @@ public abstract class Plugin {
|
||||
|
||||
this.identifier = identifier;
|
||||
this.classLoader = classLoader;
|
||||
this.dataFolder = new File(PLUGINS_FOLDER, identifier.name);
|
||||
this.dataFolder = new File(PLUGIN(), identifier.name);
|
||||
this.logger = LoggerFactory.getLogger(identifier.name);
|
||||
|
||||
if(!this.dataFolder.exists() && !this.dataFolder.mkdirs()) {
|
||||
|
@ -34,7 +34,7 @@ public final class PluginManager {
|
||||
* Loads plugins from the config-specified directory.
|
||||
*/
|
||||
private void loadPlugins() {
|
||||
File pluginsDir = new File(Utils.toFilePath(PLUGINS_FOLDER));
|
||||
File pluginsDir = new File(Utils.toFilePath(PLUGIN()));
|
||||
if(!pluginsDir.exists() && !pluginsDir.mkdirs()) {
|
||||
Grasscutter.getLogger().error("Failed to create plugins directory: " + pluginsDir.getAbsolutePath());
|
||||
return;
|
||||
|
@ -236,7 +236,7 @@ public class SceneScriptManager {
|
||||
group.setLoaded(true);
|
||||
|
||||
CompiledScript cs = ScriptLoader.getScriptByPath(
|
||||
SCRIPTS_FOLDER + "Scene/" + getScene().getId() + "/scene" + getScene().getId() + "_group" + group.id + "." + ScriptLoader.getScriptType());
|
||||
SCRIPT("Scene/" + getScene().getId() + "/scene" + getScene().getId() + "_group" + group.id + "." + ScriptLoader.getScriptType()));
|
||||
|
||||
if (cs == null) {
|
||||
return;
|
||||
|
@ -140,7 +140,7 @@ public class GameSession extends KcpChannel {
|
||||
}
|
||||
|
||||
public void replayPacket(int opcode, String name) {
|
||||
String filePath = PACKETS_FOLDER + name;
|
||||
String filePath = PACKET(name);
|
||||
File p = new File(filePath);
|
||||
|
||||
if (!p.exists()) return;
|
||||
|
@ -20,11 +20,11 @@ public final class Crypto {
|
||||
public static byte[] ENCRYPT_SEED_BUFFER = new byte[0];
|
||||
|
||||
public static void loadKeys() {
|
||||
DISPATCH_KEY = FileUtils.read(KEYS_FOLDER + "/dispatchKey.bin");
|
||||
DISPATCH_SEED = FileUtils.read(KEYS_FOLDER + "/dispatchSeed.bin");
|
||||
DISPATCH_KEY = FileUtils.read(KEY("dispatchKey.bin"));
|
||||
DISPATCH_SEED = FileUtils.read(KEY("dispatchSeed.bin"));
|
||||
|
||||
ENCRYPT_KEY = FileUtils.read(KEYS_FOLDER + "/secretKey.bin");
|
||||
ENCRYPT_SEED_BUFFER = FileUtils.read(KEYS_FOLDER + "/secretKeyBuffer.bin");
|
||||
ENCRYPT_KEY = FileUtils.read(KEY("secretKey.bin"));
|
||||
ENCRYPT_SEED_BUFFER = FileUtils.read(KEY("secretKeyBuffer.bin"));
|
||||
}
|
||||
|
||||
public static void xor(byte[] packet, byte[] key) {
|
||||
@ -40,7 +40,7 @@ public final class Crypto {
|
||||
public static void extractSecretKeyBuffer(byte[] data) {
|
||||
try {
|
||||
GetPlayerTokenRsp p = GetPlayerTokenRsp.parseFrom(data);
|
||||
FileUtils.write(KEYS_FOLDER + "/secretKeyBuffer.bin", p.getSecretKeyBytes().toByteArray());
|
||||
FileUtils.write(KEY("/secretKeyBuffer.bin"), p.getSecretKeyBytes().toByteArray());
|
||||
Grasscutter.getLogger().info("Secret Key: " + p.getSecretKey());
|
||||
} catch (Exception e) {
|
||||
Grasscutter.getLogger().error("Crypto error.", e);
|
||||
@ -50,7 +50,7 @@ public final class Crypto {
|
||||
public static void extractDispatchSeed(String data) {
|
||||
try {
|
||||
QueryCurrRegionHttpRsp p = QueryCurrRegionHttpRsp.parseFrom(Base64.getDecoder().decode(data));
|
||||
FileUtils.write(KEYS_FOLDER + "/dispatchSeed.bin", p.getRegionInfo().getSecretKey().toByteArray());
|
||||
FileUtils.write(KEY("/dispatchSeed.bin"), p.getRegionInfo().getSecretKey().toByteArray());
|
||||
} catch (Exception e) {
|
||||
Grasscutter.getLogger().error("Crypto error.", e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user