Final fixes to Load/Save/Export commands
This commit is contained in:
parent
7af3a6f613
commit
6534eb32c5
|
@ -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);
|
FileUtil.saveJsonFile(FileUtil.recreateFile(this.getFile()), object);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JsonObject convertJsonObjectFromFile() {
|
public JsonObject convertJsonObjectFromFile() {
|
||||||
if (!this.getFile().exists())
|
if (!this.getFile().exists())
|
||||||
return new JsonObject();
|
return new JsonObject();
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ import java.io.File;
|
||||||
*/
|
*/
|
||||||
public final class ExportCommand extends Command {
|
public final class ExportCommand extends Command {
|
||||||
public ExportCommand() {
|
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
|
@Override
|
||||||
|
@ -33,25 +33,25 @@ public final class ExportCommand extends Command {
|
||||||
JsonObject endJson = new JsonObject();
|
JsonObject endJson = new JsonObject();
|
||||||
for (Configurable cfg : Seppuku.INSTANCE.getConfigManager().getConfigurableList()) {
|
for (Configurable cfg : Seppuku.INSTANCE.getConfigManager().getConfigurableList()) {
|
||||||
if (cfg.getClass().equals(ClientConfig.class)) {
|
if (cfg.getClass().equals(ClientConfig.class)) {
|
||||||
final JsonObject clientJson = cfg.getJsonObject();
|
final JsonObject clientJson = cfg.convertJsonObjectFromFile();
|
||||||
endJson.add("Client", clientJson);
|
endJson.add("Client", clientJson);
|
||||||
}
|
}
|
||||||
if (cfg.getClass().equals(XrayConfig.class)) {
|
if (cfg.getClass().equals(XrayConfig.class)) {
|
||||||
final JsonObject xrayJson = cfg.getJsonObject();
|
final JsonObject xrayJson = cfg.convertJsonObjectFromFile();
|
||||||
endJson.add("Xray", xrayJson);
|
endJson.add("Xray", xrayJson);
|
||||||
}
|
}
|
||||||
if (cfg.getClass().equals(SearchConfig.class)) {
|
if (cfg.getClass().equals(SearchConfig.class)) {
|
||||||
final JsonObject searchJson = cfg.getJsonObject();
|
final JsonObject searchJson = cfg.convertJsonObjectFromFile();
|
||||||
endJson.add("Search", searchJson);
|
endJson.add("Search", searchJson);
|
||||||
}
|
}
|
||||||
if (cfg.getClass().equals(ModuleConfig.class)) {
|
if (cfg.getClass().equals(ModuleConfig.class)) {
|
||||||
final JsonObject moduleJson = cfg.getJsonObject();
|
final JsonObject moduleJson = cfg.convertJsonObjectFromFile();
|
||||||
final ModuleConfig moduleConfig = (ModuleConfig) cfg;
|
final ModuleConfig moduleConfig = (ModuleConfig) cfg;
|
||||||
final Module module = moduleConfig.getModule();
|
final Module module = moduleConfig.getModule();
|
||||||
endJson.add("Module" + module.getDisplayName(), moduleJson);
|
endJson.add("Module" + module.getDisplayName(), moduleJson);
|
||||||
}
|
}
|
||||||
if (cfg.getClass().equals(HudConfig.class)) {
|
if (cfg.getClass().equals(HudConfig.class)) {
|
||||||
final JsonObject hudJson = cfg.getJsonObject();
|
final JsonObject hudJson = cfg.convertJsonObjectFromFile();
|
||||||
final HudConfig hudConfig = (HudConfig) cfg;
|
final HudConfig hudConfig = (HudConfig) cfg;
|
||||||
final HudComponent hudComponent = hudConfig.getHudComponent();
|
final HudComponent hudComponent = hudConfig.getHudComponent();
|
||||||
endJson.add("HudComponent" + hudComponent.getName(), hudJson);
|
endJson.add("HudComponent" + hudComponent.getName(), hudJson);
|
||||||
|
|
|
@ -78,6 +78,9 @@ public final class LoadCommand extends Command {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Seppuku.INSTANCE.unloadSimple();
|
||||||
|
Seppuku.INSTANCE.init();
|
||||||
|
|
||||||
Seppuku.INSTANCE.logChat("\247c" + "Loaded config from server.");
|
Seppuku.INSTANCE.logChat("\247c" + "Loaded config from server.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import me.rigamortis.seppuku.api.command.Command;
|
||||||
public final class SaveCommand extends Command {
|
public final class SaveCommand extends Command {
|
||||||
|
|
||||||
public SaveCommand() {
|
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
|
@Override
|
||||||
|
@ -20,7 +20,7 @@ public final class SaveCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
Seppuku.INSTANCE.getConfigManager().saveAll();
|
Seppuku.INSTANCE.getConfigManager().saveAll();
|
||||||
Seppuku.INSTANCE.logChat("Saved current config.");
|
Seppuku.INSTANCE.logChat("Saved current config");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue