3.2.0 update, fixes multi-config system
This commit is contained in:
parent
62a3c1f5d0
commit
31ba59f7a8
|
@ -18,7 +18,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
|
|||
|
||||
apply plugin: "com.github.johnrengelman.shadow"
|
||||
|
||||
version = "3.1.8"
|
||||
version = "3.2.0"
|
||||
group = "me.rigamortis"
|
||||
archivesBaseName = "seppuku"
|
||||
def buildmode = "IDE"
|
||||
|
|
|
@ -86,7 +86,7 @@ public final class Seppuku {
|
|||
public void init() {
|
||||
this.eventManager = new AnnotatedEventManager();
|
||||
this.apiManager = new APIManager();
|
||||
this.configManager = new ConfigManager("Default");
|
||||
this.configManager = new ConfigManager();
|
||||
this.ignoredManager = new IgnoredManager();
|
||||
this.friendManager = new FriendManager();
|
||||
this.rotationManager = new RotationManager();
|
||||
|
@ -203,7 +203,7 @@ public final class Seppuku {
|
|||
this.capeManager = new CapeManager();
|
||||
|
||||
this.configManager.getConfigurableList().clear();
|
||||
this.configManager = new ConfigManager(this.configManager.activeConfig);
|
||||
this.configManager = new ConfigManager();
|
||||
this.configManager.init();
|
||||
|
||||
this.getEventManager().dispatchEvent(new EventReload());
|
||||
|
@ -266,7 +266,7 @@ public final class Seppuku {
|
|||
|
||||
public ConfigManager getConfigManager() {
|
||||
if (this.configManager == null) {
|
||||
this.configManager = new ConfigManager("Default");
|
||||
this.configManager = new ConfigManager();
|
||||
}
|
||||
return this.configManager;
|
||||
}
|
||||
|
|
|
@ -5,14 +5,14 @@ import net.minecraftforge.fml.common.Mod;
|
|||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
|
||||
/**
|
||||
* @author Seth
|
||||
* @author Seth/riga
|
||||
* @author noil
|
||||
* @author the entire github & discordcommunity
|
||||
* @author GitHub's contributors & our Discord plugin developers
|
||||
*/
|
||||
@Mod(modid = "seppukumod", name = "Seppuku", version = SeppukuMod.VERSION, certificateFingerprint = "7979b1d0446af2675fcb5e888851a7f32637fdb9")
|
||||
@Mod(modid = "seppukumod", name = "Seppuku", version = SeppukuMod.VERSION)
|
||||
public final class SeppukuMod {
|
||||
|
||||
public static final String VERSION = "3.1.8";
|
||||
public static final String VERSION = "3.2.0";
|
||||
|
||||
/**
|
||||
* Our mods entry point
|
||||
|
|
|
@ -7,6 +7,11 @@ import me.rigamortis.seppuku.api.event.client.EventSaveConfig;
|
|||
import me.rigamortis.seppuku.impl.config.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -24,8 +29,8 @@ public final class ConfigManager {
|
|||
private boolean customMainMenuHidden = false;
|
||||
private List<Configurable> configurableList = new ArrayList<>();
|
||||
|
||||
public ConfigManager(final String config) {
|
||||
this.activeConfig = config;
|
||||
public ConfigManager() {
|
||||
this.activeConfig = readActiveConfig();
|
||||
this.generateDirectories();
|
||||
}
|
||||
|
||||
|
@ -33,10 +38,31 @@ public final class ConfigManager {
|
|||
this.saveAll();
|
||||
|
||||
this.activeConfig = config;
|
||||
this.writeActiveConfig(config);
|
||||
|
||||
Seppuku.INSTANCE.unloadSimple();
|
||||
Seppuku.INSTANCE.init();
|
||||
}
|
||||
|
||||
public String readActiveConfig() {
|
||||
try {
|
||||
final byte[] bytes = Files.readAllBytes(Paths.get("Seppuku/Config/active.txt"));
|
||||
return new String(bytes, StandardCharsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
return "Default";
|
||||
}
|
||||
}
|
||||
|
||||
public void writeActiveConfig(final String config) {
|
||||
try {
|
||||
final FileOutputStream fos = new FileOutputStream("Seppuku/Config/active.txt");
|
||||
fos.write(config.getBytes());
|
||||
fos.close();
|
||||
} catch (IOException e) {
|
||||
System.err.println("Could not create file active.txt in config directory.");
|
||||
}
|
||||
}
|
||||
|
||||
private void generateDirectories() {
|
||||
this.configDir = new File(String.format(CONFIG_PATH, activeConfig));
|
||||
if (!this.configDir.exists()) {
|
||||
|
|
Loading…
Reference in New Issue