diff options
author | HackOS <63157139+HackedOS@users.noreply.github.com> | 2022-05-12 22:11:18 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-12 18:41:18 +0200 |
commit | ae12206958a0ba848594beeb2f804720d1a89d4f (patch) | |
tree | d18cb3b3a7f7214548a679ec58adbac4c3f3c849 /src/main/java/de/torui/coflsky/CoflSky.java | |
parent | a7d7277bfa5274c816b93e4493447989c3d562da (diff) | |
download | COFL-ae12206958a0ba848594beeb2f804720d1a89d4f.tar.gz COFL-ae12206958a0ba848594beeb2f804720d1a89d4f.tar.bz2 COFL-ae12206958a0ba848594beeb2f804720d1a89d4f.zip |
Add Auto-Toggle and Send Scoreboard/Tab Menu Data (#58)
* Add Auto-Toggle
* Send Scoreboard data to the Server
* Fix Privacy settings and respect collect scoreboard
* Move code to EventHandlers.java and collect Tab Manu data
* Remove unused import
* Refactor for Readability
* Bug Fix
* Fix bug
* Add LocalConfig and Respect AutoStart
* Add chat msg when leaving skyblock
* Add ChatRegex
* Fix bug where purse doesnt update with pigyy bank
* Improve Performance
* Fix chatregex always being null
Diffstat (limited to 'src/main/java/de/torui/coflsky/CoflSky.java')
-rw-r--r-- | src/main/java/de/torui/coflsky/CoflSky.java | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/src/main/java/de/torui/coflsky/CoflSky.java b/src/main/java/de/torui/coflsky/CoflSky.java index 6e7fde7..7ecccf0 100644 --- a/src/main/java/de/torui/coflsky/CoflSky.java +++ b/src/main/java/de/torui/coflsky/CoflSky.java @@ -1,12 +1,18 @@ package de.torui.coflsky; +import java.io.File; +import java.io.IOException; import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Paths; +import com.google.gson.Gson; +import de.torui.coflsky.configuration.LocalConfig; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import org.lwjgl.input.Keyboard; -import de.torui.coflsky.configuration.ConfigurationManager; import de.torui.coflsky.network.WSClientWrapper; import net.minecraft.client.settings.KeyBinding; import net.minecraftforge.client.ClientCommandHandler; @@ -27,6 +33,9 @@ public class CoflSky public static KeyBinding[] keyBindings; public static EventRegistry Events; + public static File configFile; + private File coflDir; + public static LocalConfig config; public static final String[] webSocketURIPrefix = new String [] { "wss://sky.coflnet.com/modsocket", @@ -36,7 +45,25 @@ public class CoflSky }; public static String CommandUri = "https://sky-commands.coflnet.com/api/mod/commands"; - + @EventHandler + public void preInit(FMLPreInitializationEvent event) { + String configString = null; + Gson gson = new Gson(); + coflDir = new File(event.getModConfigurationDirectory(), "CoflSky"); + coflDir.mkdirs(); + configFile = new File(coflDir, "config.json"); + try { + if (configFile.isFile()) { + configString = new String(Files.readAllBytes(Paths.get(configFile.getPath()))); + config = gson.fromJson(configString, LocalConfig.class); + } + } catch (IOException e) { + e.printStackTrace(); + } + if (configString == null) { + config = LocalConfig.createDefaultConfig(); + } + } @EventHandler public void init(FMLInitializationEvent event) throws URISyntaxException { @@ -62,7 +89,11 @@ public class CoflSky } Events = new EventRegistry(); - MinecraftForge.EVENT_BUS.register(Events); + MinecraftForge.EVENT_BUS.register(Events); + Runtime.getRuntime() + .addShutdownHook( + new Thread( + () -> config.saveConfig(configFile , config))); } |