aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/config
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/config')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt54
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Minions.java35
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Misc.java2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/gui/commands/Commands.java10
5 files changed, 102 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
new file mode 100644
index 000000000..66a9f67c6
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
@@ -0,0 +1,54 @@
+package at.hannibal2.skyhanni.config
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.ConfigLoadEvent
+import com.google.gson.GsonBuilder
+import java.io.*
+import java.nio.charset.StandardCharsets
+
+class ConfigManager(val mod: SkyHanniMod) {
+ companion object {
+ val gson = GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create()
+ }
+
+ var configDirectory = File("config/skyhanni")
+ private var configFile: File? = null
+
+
+ fun firstLoad() {
+ try {
+ configDirectory.mkdir()
+ } catch (ignored: Exception) {
+ }
+
+ configFile = File(configDirectory, "config.json")
+
+ if (configFile!!.exists()) {
+ try {
+ BufferedReader(InputStreamReader(FileInputStream(configFile!!), StandardCharsets.UTF_8)).use { reader ->
+ SkyHanniMod.feature = gson.fromJson(reader,
+ Features::class.java)
+ }
+ ConfigLoadEvent().postAndCatch()
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+
+ if (SkyHanniMod.feature == null) {
+ SkyHanniMod.feature = Features()
+ saveConfig()
+ }
+ }
+
+ fun saveConfig() {
+ try {
+ configFile!!.createNewFile()
+ BufferedWriter(OutputStreamWriter(FileOutputStream(configFile!!), StandardCharsets.UTF_8)).use { writer ->
+ writer.write(gson.toJson(SkyHanniMod.feature))
+ }
+ } catch (e: IOException) {
+ e.printStackTrace()
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java
index 2c2472917..eef96aa56 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java
@@ -2,6 +2,9 @@ package at.hannibal2.skyhanni.config.features;
import com.google.gson.annotations.Expose;
+import java.util.HashMap;
+import java.util.Map;
+
public class Hidden {
@Expose
@@ -9,4 +12,7 @@ public class Hidden {
@Expose
public String currentPet = "";
+
+ @Expose
+ public Map<String, Long> minions = new HashMap<>();
}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Minions.java b/src/main/java/at/hannibal2/skyhanni/config/features/Minions.java
index d851c7436..7ce23a260 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Minions.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Minions.java
@@ -1,16 +1,18 @@
package at.hannibal2.skyhanni.config.features;
-import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigEditorBoolean;
-import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigEditorColour;
-import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigEditorSlider;
-import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigOption;
+import at.hannibal2.skyhanni.config.gui.core.config.annotations.*;
import com.google.gson.annotations.Expose;
public class Minions {
+ @ConfigOption(name = "Last Clicked", desc = "")
+ @ConfigEditorAccordion(id = 0)
+ public boolean lastMinion = false;
+
@Expose
@ConfigOption(name = "Last Minion Display", desc = "Show the last opened minion on your island")
@ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
public boolean lastOpenedMinionDisplay = false;
@Expose
@@ -19,6 +21,7 @@ public class Minions {
desc = "The colour in which the last minion should be displayed"
)
@ConfigEditorColour
+ @ConfigAccordionId(id = 0)
public String lastOpenedMinionColor = "0:245:85:255:85";
@Expose
@@ -31,5 +34,29 @@ public class Minions {
maxValue = 120,
minStep = 1
)
+ @ConfigAccordionId(id = 0)
public int lastOpenedMinionTime = 20;
+
+ @ConfigOption(name = "Emptied Time", desc = "")
+ @ConfigEditorAccordion(id = 1)
+ public boolean emptiedTime = false;
+
+ @Expose
+ @ConfigOption(name = "Emptied Time Display", desc = "Show the time when the hopper in the minion was last empties")
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 1)
+ public boolean emptiedTimeDisplay = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Emptied Time Distance",
+ desc = "At what distance is this text displayed"
+ )
+ @ConfigEditorSlider(
+ minValue = 3,
+ maxValue = 30,
+ minStep = 1
+ )
+ @ConfigAccordionId(id = 1)
+ public int emptiedTimeDistance = 10;
}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
index 50e99729c..f04d6db26 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
@@ -44,7 +44,7 @@ public class Misc {
public boolean realTime = false;
@Expose
- @ConfigOption(name = "Ashfang Freeze Position", desc = "")
+ @ConfigOption(name = "Real Time Position", desc = "")
@ConfigEditorButton(runnableId = "realTime", buttonText = "Edit")
public Position realTimePos = new Position(10, 10, false, true);
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/config/gui/commands/Commands.java b/src/main/java/at/hannibal2/skyhanni/config/gui/commands/Commands.java
index 17609296e..9aca72ec3 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/gui/commands/Commands.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/gui/commands/Commands.java
@@ -77,5 +77,15 @@ public class Commands {
}
)
);
+ ClientCommandHandler.instance.registerCommand(
+ new SimpleCommand(
+ "shconfigsave",
+ new SimpleCommand.ProcessCommandRunnable() {
+ public void processCommand(ICommandSender sender, String[] args) {
+ SkyHanniMod.configManager.saveConfig();
+ }
+ }
+ )
+ );
}
}