aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/handlers
diff options
context:
space:
mode:
authorbowser0000 <bowser0000@gmail.com>2021-11-24 21:58:26 -0500
committerbowser0000 <bowser0000@gmail.com>2021-11-24 21:58:26 -0500
commitc466240003b130b43c17da9e585b80380154e4c4 (patch)
treeba6a03498dac85027d853e535aea0c71542d1f2f /src/main/java/me/Danker/handlers
parentb733d88cb79942d4a260293d1bb1f2d27fcc61e2 (diff)
downloadSkyblockMod-c466240003b130b43c17da9e585b80380154e4c4.tar.gz
SkyblockMod-c466240003b130b43c17da9e585b80380154e4c4.tar.bz2
SkyblockMod-c466240003b130b43c17da9e585b80380154e4c4.zip
Add custom alerts based on chat
Also move some other stuff around
Diffstat (limited to 'src/main/java/me/Danker/handlers')
-rw-r--r--src/main/java/me/Danker/handlers/ConfigHandler.java42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/main/java/me/Danker/handlers/ConfigHandler.java b/src/main/java/me/Danker/handlers/ConfigHandler.java
index 2a765ad..28f22fe 100644
--- a/src/main/java/me/Danker/handlers/ConfigHandler.java
+++ b/src/main/java/me/Danker/handlers/ConfigHandler.java
@@ -1,5 +1,8 @@
package me.Danker.handlers;
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
import me.Danker.DankersSkyblockMod;
import me.Danker.commands.MoveCommand;
import me.Danker.commands.ScaleCommand;
@@ -13,7 +16,9 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.common.config.ConfigCategory;
import net.minecraftforge.common.config.Configuration;
-import java.io.File;
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Arrays;
public class ConfigHandler {
public static Configuration config;
@@ -220,15 +225,6 @@ public class ConfigHandler {
ToggleCommand.crystalAutoWaypoints = initBoolean("toggles", "CrystalAutoWaypoints", true); // enabled by default
ToggleCommand.autoAcceptReparty = initBoolean("toggles", "AutoAcceptReparty", false);
ToggleCommand.abilityCooldowns = initBoolean("toggles", "AbilityCooldowns", false);
- // Chat Messages
- ToggleCommand.sceptreMessages = initBoolean("toggles", "SceptreMessages", true);
- ToggleCommand.midasStaffMessages = initBoolean("toggles", "MidasStaffMessages", true);
- ToggleCommand.implosionMessages = initBoolean("toggles", "ImplosionMessages", true);
- ToggleCommand.healMessages = initBoolean("toggles", "HealMessages", true);
- ToggleCommand.cooldownMessages = initBoolean("toggles", "CooldownMessages", true);
- ToggleCommand.manaMessages = initBoolean("toggles", "ManaMessages", true);
- ToggleCommand.killComboMessages = initBoolean("toggles", "KillComboMessages", true);
- // Dungeons
ToggleCommand.dungeonTimerToggled = initBoolean("toggles", "DungeonTimer", false);
ToggleCommand.lowHealthNotifyToggled = initBoolean("toggles", "LowHealthNotify", false);
ToggleCommand.lividSolverToggled = initBoolean("toggles", "LividSolver", false);
@@ -239,7 +235,16 @@ public class ConfigHandler {
ToggleCommand.bonzoTimerToggled = initBoolean("toggles", "BonzoTimer", false);
ToggleCommand.swapToPickBlockToggled = initBoolean("toggles", "PickBlock", false);
ToggleCommand.flowerWeaponsToggled = initBoolean("toggles", "FlowerWeapons", false);
- ToggleCommand.autoSkillTrackerToggled = initBoolean("toggles", "AutoSkillTracker", false);
+ ToggleCommand.autoSkillTrackerToggled = initBoolean("toggles", "AutoSkillTracker", false);
+ ToggleCommand.alerts = initBoolean("toggles", "Alerts", false);
+ // Chat Messages
+ ToggleCommand.sceptreMessages = initBoolean("toggles", "SceptreMessages", true);
+ ToggleCommand.midasStaffMessages = initBoolean("toggles", "MidasStaffMessages", true);
+ ToggleCommand.implosionMessages = initBoolean("toggles", "ImplosionMessages", true);
+ ToggleCommand.healMessages = initBoolean("toggles", "HealMessages", true);
+ ToggleCommand.cooldownMessages = initBoolean("toggles", "CooldownMessages", true);
+ ToggleCommand.manaMessages = initBoolean("toggles", "ManaMessages", true);
+ ToggleCommand.killComboMessages = initBoolean("toggles", "KillComboMessages", true);
// Puzzle Solvers
ToggleCommand.threeManToggled = initBoolean("toggles", "ThreeManPuzzle", false);
ToggleCommand.oruoToggled = initBoolean("toggles", "OruoPuzzle", false);
@@ -616,6 +621,21 @@ public class ConfigHandler {
// Commands
if (!hasKey("commands", "reparty")) writeBooleanConfig("commands", "reparty", false);
+
+ // JSON
+ Gson gson = new Gson();
+
+ try {
+ if (!(new File(Alerts.configFile).exists())) {
+ FileWriter file = new FileWriter(Alerts.configFile);
+ file.write(new JsonArray().toString());
+ file.close();
+ }
+ Alerts.Alert[] alerts = gson.fromJson(new FileReader(Alerts.configFile), Alerts.Alert[].class);
+ if (alerts != null) Alerts.alerts = new ArrayList<>(Arrays.asList(alerts));
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
}
}