From ad53066846fb168255499a332a1ad4bca39f5935 Mon Sep 17 00:00:00 2001 From: bowser0000 Date: Sat, 27 Feb 2021 18:25:51 -0500 Subject: Move features into their own files --- .../me/Danker/features/FasterMaddoxCalling.java | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/main/java/me/Danker/features/FasterMaddoxCalling.java (limited to 'src/main/java/me/Danker/features/FasterMaddoxCalling.java') diff --git a/src/main/java/me/Danker/features/FasterMaddoxCalling.java b/src/main/java/me/Danker/features/FasterMaddoxCalling.java new file mode 100644 index 0000000..fa8bcb5 --- /dev/null +++ b/src/main/java/me/Danker/features/FasterMaddoxCalling.java @@ -0,0 +1,64 @@ +package me.Danker.features; + +import me.Danker.DankersSkyblockMod; +import me.Danker.commands.ToggleCommand; +import me.Danker.utils.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.gui.GuiChat; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.StringUtils; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.client.event.GuiScreenEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.InputEvent; +import org.lwjgl.input.Mouse; + +import java.util.List; + +public class FasterMaddoxCalling { + + static String lastMaddoxCommand = "/cb placeholder"; + static double lastMaddoxTime = 0; + + @SubscribeEvent + public void onChat(ClientChatReceivedEvent event) { + String message = StringUtils.stripControlCodes(event.message.getUnformattedText()); + + if (!Utils.inSkyblock) return; + if (message.contains(":")) return; + + if (message.contains("[OPEN MENU]")) { + List listOfSiblings = event.message.getSiblings(); + for (IChatComponent sibling : listOfSiblings) { + if (sibling.getUnformattedText().contains("[OPEN MENU]")) { + lastMaddoxCommand = sibling.getChatStyle().getChatClickEvent().getValue(); + lastMaddoxTime = System.currentTimeMillis() / 1000; + } + } + if (ToggleCommand.chatMaddoxToggled) Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Open chat then click anywhere on-screen to open Maddox")); + } + } + + @SubscribeEvent + public void onMouseInputPost(GuiScreenEvent.MouseInputEvent.Post event) { + if (!Utils.inSkyblock) return; + if (Mouse.getEventButton() == 0 && event.gui instanceof GuiChat) { + if (ToggleCommand.chatMaddoxToggled && System.currentTimeMillis() / 1000 - lastMaddoxTime < 10) { + Minecraft.getMinecraft().thePlayer.sendChatMessage(lastMaddoxCommand); + } + } + } + + @SubscribeEvent + public void onKey(InputEvent.KeyInputEvent event) { + if (!Utils.inSkyblock) return; + + EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + if (DankersSkyblockMod.keyBindings[0].isPressed()) { + player.sendChatMessage(lastMaddoxCommand); + } + } + +} -- cgit