From 8f3bce7d6fe41e85f2654f7557bbb564305e58b5 Mon Sep 17 00:00:00 2001 From: matthias-luger <58751503+matthias-luger@users.noreply.github.com> Date: Fri, 17 Feb 2023 17:32:26 +0100 Subject: Add TFM Purchase UI to Mod (#78) * Add TFM Purchase UI to Mod * fix up opening flips by hotkey fix up flip message in tfm ui * readded check if the auction should be drawn mod doesnt crash anymore if a non flip auction is opened * added /cofl set gui command changed gui title * added /fc toggle command dont store toggle locally * rename purchaseOverlay config removed unused code renamed gui command to /cofl set ahbuygui * fix message not available if flip opened by mouse fix old message shown for non flip auctions * added /cofl setGui command added cofl purchase gui * Add sound on flip * Fixed new flip sound Optimized cofl gui Removed flickering of default mc gui Move mouse to middle on screen open * remove unused code * remove debug code * don't open guis if not in skyblock * fix sound being null * fix bed flips fix opening /cofl blocked * remove logging * Rewrote cofl gui to render before the chest gui opens * - fix bed flips - invalidate best flips after open * - fix scrolling * - fix description not updating - case insensitive commands - fix up , at the end of the message * - add gui if item was already bought - fix bug that invalidated too many flips - added missing "break" * fix merge error * add .vscode to gitignore formatting * fix formatting issue * - remove comment - remove emty line --- src/main/java/de/torui/coflsky/CoflSky.java | 82 ++++++++++++++--------------- 1 file changed, 40 insertions(+), 42 deletions(-) (limited to 'src/main/java/de/torui/coflsky/CoflSky.java') diff --git a/src/main/java/de/torui/coflsky/CoflSky.java b/src/main/java/de/torui/coflsky/CoflSky.java index 7eba195..a1498ba 100644 --- a/src/main/java/de/torui/coflsky/CoflSky.java +++ b/src/main/java/de/torui/coflsky/CoflSky.java @@ -6,15 +6,16 @@ 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 de.torui.coflsky.gui.GUIType; import de.torui.coflsky.handlers.EventRegistry; import de.torui.coflsky.listeners.ChatListener; import de.torui.coflsky.proxy.APIKeyManager; +import de.torui.coflsky.gui.tfm.ButtonRemapper; +import de.torui.coflsky.gui.tfm.ChatMessageSendHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import org.lwjgl.input.Keyboard; - import de.torui.coflsky.network.WSClientWrapper; import net.minecraft.client.settings.KeyBinding; import net.minecraftforge.client.ClientCommandHandler; @@ -26,11 +27,10 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.relauncher.Side; @Mod(modid = CoflSky.MODID, version = CoflSky.VERSION) -public class CoflSky -{ +public class CoflSky { public static final String MODID = "CoflSky"; - public static final String VERSION = "1.4.4-Alpha"; - + public static final String VERSION = "1.5.0-Alpha"; + public static WSClientWrapper Wrapper; public static KeyBinding[] keyBindings; @@ -38,14 +38,14 @@ public class CoflSky public static File configFile; private File coflDir; public static LocalConfig config; - - public static final String[] webSocketURIPrefix = new String [] { - "wss://sky.coflnet.com/modsocket", - "wss://sky-mod.coflnet.com/modsocket", - "ws://sky.coflnet.com/modsocket", - "ws://sky-mod.coflnet.com/modsocket", + + public static final String[] webSocketURIPrefix = new String[]{ + "wss://sky.coflnet.com/modsocket", + "wss://sky-mod.coflnet.com/modsocket", + "ws://sky.coflnet.com/modsocket", + "ws://sky-mod.coflnet.com/modsocket", }; - + public static String CommandUri = Config.BaseUrl + "/api/mod/commands"; private final static APIKeyManager apiKeyManager = new APIKeyManager(); @@ -66,12 +66,12 @@ public class CoflSky e.printStackTrace(); } if (config == null) { - config = LocalConfig.createDefaultConfig(); + config = LocalConfig.createDefaultConfig(); } try { this.apiKeyManager.loadIfExists(); - }catch (Exception exception){ + } catch (Exception exception) { exception.printStackTrace(); } @@ -82,44 +82,42 @@ public class CoflSky } @EventHandler - public void init(FMLInitializationEvent event) throws URISyntaxException - { - System.out.println(">>>Started"); - + public void init(FMLInitializationEvent event) { CoflSky.Wrapper = new WSClientWrapper(webSocketURIPrefix); - - keyBindings = new KeyBinding[] { - new KeyBinding("key.replay_last.onclick", Keyboard.KEY_NONE, "SkyCofl"), - new KeyBinding("key.start_highest_bid", Keyboard.KEY_NONE, "SkyCofl") + + keyBindings = new KeyBinding[]{ + new KeyBinding("key.replay_last.onclick", Keyboard.KEY_NONE, "SkyCofl"), + new KeyBinding("key.start_highest_bid", Keyboard.KEY_NONE, "SkyCofl") }; - - if(event.getSide() == Side.CLIENT) { - ClientCommandHandler.instance.registerCommand(new CoflSkyCommand()); - ClientCommandHandler.instance.registerCommand(new ColfCommand()); - ClientCommandHandler.instance.registerCommand(new FlipperChatCommand()); - - for (int i = 0; i < keyBindings.length; ++i) - { - ClientRegistry.registerKeyBinding(keyBindings[i]); - } - - - } + + if (event.getSide() == Side.CLIENT) { + ClientCommandHandler.instance.registerCommand(new CoflSkyCommand()); + ClientCommandHandler.instance.registerCommand(new ColfCommand()); + ClientCommandHandler.instance.registerCommand(new FlipperChatCommand()); + + for (int i = 0; i < keyBindings.length; ++i) { + ClientRegistry.registerKeyBinding(keyBindings[i]); + } + + + } Events = new EventRegistry(); MinecraftForge.EVENT_BUS.register(Events); - + if (config.purchaseOverlay == GUIType.TFM) { + MinecraftForge.EVENT_BUS.register(ButtonRemapper.getInstance()); + } + MinecraftForge.EVENT_BUS.register(new ChatMessageSendHandler()); Runtime.getRuntime().addShutdownHook(new Thread(() -> { - config.saveConfig(configFile , config); + config.saveConfig(configFile, config); try { apiKeyManager.saveKey(); - }catch (Exception exception){ + } catch (Exception exception) { exception.printStackTrace(); } })); - } - + } - public static APIKeyManager getAPIKeyManager(){ + public static APIKeyManager getAPIKeyManager() { return apiKeyManager; } -- cgit