diff options
author | Abhiram555 <63419731+abhithedev200@users.noreply.github.com> | 2023-01-26 21:34:15 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-26 17:04:15 +0100 |
commit | 19f6d6eacf3df61c3079d342482df3ae4a2c3e15 (patch) | |
tree | 30c8c309e46ecfc9d96d505322523178a53c1549 /src/main/java/de/torui/coflsky/CoflSky.java | |
parent | 7cfe4c326b668683cccc9c250d58b7ef9c3e9083 (diff) | |
download | COFL-19f6d6eacf3df61c3079d342482df3ae4a2c3e15.tar.gz COFL-19f6d6eacf3df61c3079d342482df3ae4a2c3e15.tar.bz2 COFL-19f6d6eacf3df61c3079d342482df3ae4a2c3e15.zip |
Add Proxy support to the cofl mod (#85)
* Implement basic proxy functionality
* Finish the api key management
* Finished the hypixel api key support
* Fixed a check, for some reason intelij didn't update my code
* Only upload request if the upload is enabled, else just do the request
Co-authored-by: Äkwav <16632490+Ekwav@users.noreply.github.com>
Co-authored-by: Äkwav <16632490+Ekwav@users.noreply.github.com>
Diffstat (limited to 'src/main/java/de/torui/coflsky/CoflSky.java')
-rw-r--r-- | src/main/java/de/torui/coflsky/CoflSky.java | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/src/main/java/de/torui/coflsky/CoflSky.java b/src/main/java/de/torui/coflsky/CoflSky.java index 7ab2448..0127859 100644 --- a/src/main/java/de/torui/coflsky/CoflSky.java +++ b/src/main/java/de/torui/coflsky/CoflSky.java @@ -2,7 +2,6 @@ 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; @@ -11,6 +10,8 @@ import java.nio.file.Paths; import com.google.gson.Gson; import de.torui.coflsky.configuration.LocalConfig; import de.torui.coflsky.handlers.EventRegistry; +import de.torui.coflsky.listeners.ChatListener; +import de.torui.coflsky.proxy.APIKeyManager; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import org.lwjgl.input.Keyboard; @@ -46,6 +47,9 @@ public class CoflSky }; public static String CommandUri = Config.BaseUrl + "/api/mod/commands"; + private final static APIKeyManager apiKeyManager = new APIKeyManager(); + + @EventHandler public void preInit(FMLPreInitializationEvent event) { String configString = null; @@ -64,9 +68,19 @@ public class CoflSky if (config == null) { config = LocalConfig.createDefaultConfig(); } + + try { + this.apiKeyManager.loadIfExists(); + }catch (Exception exception){ + exception.printStackTrace(); + } + + MinecraftForge.EVENT_BUS.register(new ChatListener()); + // Cache all the mods on load WSCommandHandler.cacheMods(); } + @EventHandler public void init(FMLInitializationEvent event) throws URISyntaxException { @@ -93,12 +107,21 @@ public class CoflSky } Events = new EventRegistry(); MinecraftForge.EVENT_BUS.register(Events); - Runtime.getRuntime() - .addShutdownHook( - new Thread( - () -> config.saveConfig(configFile , config))); + + Runtime.getRuntime().addShutdownHook(new Thread(() -> { + config.saveConfig(configFile , config); + try { + apiKeyManager.saveKey(); + }catch (Exception exception){ + exception.printStackTrace(); + } + })); } - + + public static APIKeyManager getAPIKeyManager(){ + return apiKeyManager; + } + } |