Compare commits
6 Commits
4ca81e4504
...
811a56f3fa
Author | SHA1 | Date |
---|---|---|
noil | 811a56f3fa | |
noil | e132ed7365 | |
noil | 6534eb32c5 | |
noil | 7af3a6f613 | |
noil | 2cd23c3632 | |
noil | 607fcb9b8d |
|
@ -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,29 +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(NukerFilterConfig.class)) {
|
|
||||||
final JsonObject nukerFilterJson = cfg.getJsonObject();
|
|
||||||
endJson.add("NukerFilter", nukerFilterJson);
|
|
||||||
}
|
|
||||||
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);
|
||||||
|
@ -64,7 +60,7 @@ public final class ExportCommand extends Command {
|
||||||
|
|
||||||
FileUtil.saveJsonFile(file, endJson);
|
FileUtil.saveJsonFile(file, endJson);
|
||||||
|
|
||||||
Seppuku.INSTANCE.logChat("\247c" + "Exported config " + configName + ".json into the Seppuku directory.");
|
Seppuku.INSTANCE.logChat("\247c" + "Exported config " + configName + ".json into the Seppuku directory");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package me.rigamortis.seppuku.impl.command;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import me.rigamortis.seppuku.Seppuku;
|
import me.rigamortis.seppuku.Seppuku;
|
||||||
import me.rigamortis.seppuku.api.cape.CapeUser;
|
|
||||||
import me.rigamortis.seppuku.api.command.Command;
|
import me.rigamortis.seppuku.api.command.Command;
|
||||||
import me.rigamortis.seppuku.impl.config.*;
|
import me.rigamortis.seppuku.impl.config.*;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
@ -19,7 +18,7 @@ import java.net.URL;
|
||||||
public final class LoadCommand extends Command {
|
public final class LoadCommand extends Command {
|
||||||
|
|
||||||
public LoadCommand() {
|
public LoadCommand() {
|
||||||
super("Load", new String[]{"Lode"}, "Load a config from your profile on Seppuku's website.", "Load <pin>");
|
super("Load", new String[]{"Lode"}, "Load a config from your profile on Seppuku's website", "Load <pin>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -52,7 +51,7 @@ public final class LoadCommand extends Command {
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Seppuku.INSTANCE.logChat("\247c" + "Error loading config from server.");
|
Seppuku.INSTANCE.logChat("\247c" + "Error loading config from server");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configJson != null) {
|
if (configJson != null) {
|
||||||
|
@ -65,10 +64,6 @@ public final class LoadCommand extends Command {
|
||||||
}
|
}
|
||||||
if (entry.getKey().equalsIgnoreCase("Search")) {
|
if (entry.getKey().equalsIgnoreCase("Search")) {
|
||||||
this.loadConfigForClass(SearchConfig.class, entry.getValue().getAsJsonObject());
|
this.loadConfigForClass(SearchConfig.class, entry.getValue().getAsJsonObject());
|
||||||
|
|
||||||
}
|
|
||||||
if (entry.getKey().equalsIgnoreCase("NukerFilter")) {
|
|
||||||
this.loadConfigForClass(NukerFilterConfig.class, entry.getValue().getAsJsonObject());
|
|
||||||
}
|
}
|
||||||
Seppuku.INSTANCE.getModuleManager().getModuleList().forEach(module -> {
|
Seppuku.INSTANCE.getModuleManager().getModuleList().forEach(module -> {
|
||||||
if (entry.getKey().equalsIgnoreCase("Module" + module.getDisplayName())) {
|
if (entry.getKey().equalsIgnoreCase("Module" + module.getDisplayName())) {
|
||||||
|
@ -82,7 +77,10 @@ public final class LoadCommand extends Command {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Seppuku.INSTANCE.logChat("\247c" + "Loaded config from server.");
|
// Seppuku.INSTANCE.getConfigManager().saveAll();
|
||||||
|
// Seppuku.INSTANCE.reload();
|
||||||
|
|
||||||
|
Seppuku.INSTANCE.logChat("\247c" + "Loaded config from server");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,8 +93,8 @@ public final class LoadCommand extends Command {
|
||||||
private void loadModuleConfigForClass(Class configClass, JsonObject jsonObject, String displayName) {
|
private void loadModuleConfigForClass(Class configClass, JsonObject jsonObject, String displayName) {
|
||||||
Seppuku.INSTANCE.getConfigManager().getConfigurableList().stream().filter(configurable -> configurable.getClass().equals(ModuleConfig.class)).forEach(configurable -> {
|
Seppuku.INSTANCE.getConfigManager().getConfigurableList().stream().filter(configurable -> configurable.getClass().equals(ModuleConfig.class)).forEach(configurable -> {
|
||||||
final ModuleConfig moduleConfig = (ModuleConfig) configurable;
|
final ModuleConfig moduleConfig = (ModuleConfig) configurable;
|
||||||
if (moduleConfig.getModule().getDisplayName().equals(displayName)) {
|
if (moduleConfig.getModule().getDisplayName().equalsIgnoreCase(displayName)) {
|
||||||
configurable.onLoad(jsonObject);
|
moduleConfig.onLoad(jsonObject);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -104,8 +102,8 @@ public final class LoadCommand extends Command {
|
||||||
private void loadHudConfigForClass(Class configClass, JsonObject jsonObject, String name) {
|
private void loadHudConfigForClass(Class configClass, JsonObject jsonObject, String name) {
|
||||||
Seppuku.INSTANCE.getConfigManager().getConfigurableList().stream().filter(configurable -> configurable.getClass().equals(HudConfig.class)).forEach(configurable -> {
|
Seppuku.INSTANCE.getConfigManager().getConfigurableList().stream().filter(configurable -> configurable.getClass().equals(HudConfig.class)).forEach(configurable -> {
|
||||||
final HudConfig hudConfig = (HudConfig) configurable;
|
final HudConfig hudConfig = (HudConfig) configurable;
|
||||||
if (hudConfig.getHudComponent().getName().equals(name)) {
|
if (hudConfig.getHudComponent().getName().equalsIgnoreCase(name)) {
|
||||||
configurable.onLoad(jsonObject);
|
hudConfig.onLoad(jsonObject);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package me.rigamortis.seppuku.impl.command;
|
||||||
|
|
||||||
|
import me.rigamortis.seppuku.Seppuku;
|
||||||
|
import me.rigamortis.seppuku.api.command.Command;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author noil
|
||||||
|
*/
|
||||||
|
public final class SaveCommand extends Command {
|
||||||
|
|
||||||
|
public SaveCommand() {
|
||||||
|
super("Save", new String[]{"SaveAll"}, "Saves all client settings to disk", "Save");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exec(String input) {
|
||||||
|
if (!this.clamp(input, 1, 1)) {
|
||||||
|
this.printUsage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Seppuku.INSTANCE.getConfigManager().saveAll();
|
||||||
|
Seppuku.INSTANCE.logChat("Saved current config");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class NukerFilterConfig extends Configurable {
|
||||||
|
|
||||||
public NukerFilterConfig(File dir) {
|
public NukerFilterConfig(File dir) {
|
||||||
super(FileUtil.createJsonFile(dir, "NukerFilter"));
|
super(FileUtil.createJsonFile(dir, "NukerFilter"));
|
||||||
this.nukerModule = (NukerModule) Seppuku.INSTANCE.getModuleManager().find("Nuker");
|
this.nukerModule = (NukerModule) Seppuku.INSTANCE.getModuleManager().find(NukerModule.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,6 +51,12 @@ public class NukerFilterConfig extends Configurable {
|
||||||
if (this.nukerModule == null)
|
if (this.nukerModule == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (this.nukerModule.getFilter().getValue() == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (this.nukerModule.getFilter().getValue().isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
JsonObject save = new JsonObject();
|
JsonObject save = new JsonObject();
|
||||||
|
|
||||||
JsonArray xrayIdsJsonArray = new JsonArray();
|
JsonArray xrayIdsJsonArray = new JsonArray();
|
||||||
|
|
|
@ -79,6 +79,7 @@ public final class CommandManager {
|
||||||
this.commandList.add(new NukerFilterCommand());
|
this.commandList.add(new NukerFilterCommand());
|
||||||
this.commandList.add(new ExportCommand());
|
this.commandList.add(new ExportCommand());
|
||||||
this.commandList.add(new LoadCommand());
|
this.commandList.add(new LoadCommand());
|
||||||
|
this.commandList.add(new SaveCommand());
|
||||||
|
|
||||||
//create commands for every value within every module
|
//create commands for every value within every module
|
||||||
loadValueCommands();
|
loadValueCommands();
|
||||||
|
|
|
@ -86,7 +86,7 @@ public final class ConfigManager {
|
||||||
this.configurableList.add(new ModuleConfig(this.moduleConfigDir, module));
|
this.configurableList.add(new ModuleConfig(this.moduleConfigDir, module));
|
||||||
});
|
});
|
||||||
|
|
||||||
Seppuku.INSTANCE.getHudManager().getComponentList().stream().forEach(hudComponent -> {
|
Seppuku.INSTANCE.getHudManager().getComponentList().forEach(hudComponent -> {
|
||||||
this.configurableList.add(new HudConfig(this.hudComponentConfigDir, hudComponent));
|
this.configurableList.add(new HudConfig(this.hudComponentConfigDir, hudComponent));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue