Final fixes to Load/Save/Export commands

This commit is contained in:
noil 2023-05-17 01:43:05 -04:00
parent 7af3a6f613
commit 6534eb32c5
4 changed files with 13 additions and 10 deletions

View File

@ -37,11 +37,11 @@ public abstract class Configurable {
}
protected void saveJsonObjectToFile(JsonObject object) {
public void saveJsonObjectToFile(JsonObject object) {
FileUtil.saveJsonFile(FileUtil.recreateFile(this.getFile()), object);
}
protected JsonObject convertJsonObjectFromFile() {
public JsonObject convertJsonObjectFromFile() {
if (!this.getFile().exists())
return new JsonObject();

View File

@ -16,7 +16,7 @@ import java.io.File;
*/
public final class ExportCommand extends Command {
public ExportCommand() {
super("Export", new String[]{"Exprt"}, "Export all Module & HUD configs into a single json for upload on Seppuku's website.", "Export <config_name>");
super("Export", new String[]{"Exprt"}, "Export all Module & HUD configs into a single json for upload on Seppuku's website", "Export <config_name>");
}
@Override
@ -33,25 +33,25 @@ public final class ExportCommand extends Command {
JsonObject endJson = new JsonObject();
for (Configurable cfg : Seppuku.INSTANCE.getConfigManager().getConfigurableList()) {
if (cfg.getClass().equals(ClientConfig.class)) {
final JsonObject clientJson = cfg.getJsonObject();
final JsonObject clientJson = cfg.convertJsonObjectFromFile();
endJson.add("Client", clientJson);
}
if (cfg.getClass().equals(XrayConfig.class)) {
final JsonObject xrayJson = cfg.getJsonObject();
final JsonObject xrayJson = cfg.convertJsonObjectFromFile();
endJson.add("Xray", xrayJson);
}
if (cfg.getClass().equals(SearchConfig.class)) {
final JsonObject searchJson = cfg.getJsonObject();
final JsonObject searchJson = cfg.convertJsonObjectFromFile();
endJson.add("Search", searchJson);
}
if (cfg.getClass().equals(ModuleConfig.class)) {
final JsonObject moduleJson = cfg.getJsonObject();
final JsonObject moduleJson = cfg.convertJsonObjectFromFile();
final ModuleConfig moduleConfig = (ModuleConfig) cfg;
final Module module = moduleConfig.getModule();
endJson.add("Module" + module.getDisplayName(), moduleJson);
}
if (cfg.getClass().equals(HudConfig.class)) {
final JsonObject hudJson = cfg.getJsonObject();
final JsonObject hudJson = cfg.convertJsonObjectFromFile();
final HudConfig hudConfig = (HudConfig) cfg;
final HudComponent hudComponent = hudConfig.getHudComponent();
endJson.add("HudComponent" + hudComponent.getName(), hudJson);

View File

@ -78,6 +78,9 @@ public final class LoadCommand extends Command {
});
});
Seppuku.INSTANCE.unloadSimple();
Seppuku.INSTANCE.init();
Seppuku.INSTANCE.logChat("\247c" + "Loaded config from server.");
}
}

View File

@ -9,7 +9,7 @@ import me.rigamortis.seppuku.api.command.Command;
public final class SaveCommand extends Command {
public SaveCommand() {
super("Save", new String[]{"SaveAll"}, "Saves all client settings to disk.", "Save");
super("Save", new String[]{"SaveAll"}, "Saves all client settings to disk", "Save");
}
@Override
@ -20,7 +20,7 @@ public final class SaveCommand extends Command {
}
Seppuku.INSTANCE.getConfigManager().saveAll();
Seppuku.INSTANCE.logChat("Saved current config.");
Seppuku.INSTANCE.logChat("Saved current config");
}
}