From 71d1919bf282a5c075d081e8beebda2348aca0bd Mon Sep 17 00:00:00 2001 From: noil Date: Wed, 23 Dec 2020 14:13:38 -0500 Subject: [PATCH] StorageAlert: Add click event to create waypoint --- .../impl/module/misc/StorageAlertModule.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/misc/StorageAlertModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/misc/StorageAlertModule.java index ae6721b..e54af05 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/module/misc/StorageAlertModule.java +++ b/src/main/java/me/rigamortis/seppuku/impl/module/misc/StorageAlertModule.java @@ -11,11 +11,16 @@ import me.rigamortis.seppuku.api.event.network.EventReceivePacket; import me.rigamortis.seppuku.api.module.Module; import me.rigamortis.seppuku.api.util.FileUtil; import me.rigamortis.seppuku.api.value.Value; +import me.rigamortis.seppuku.impl.module.hidden.CommandsModule; import me.rigamortis.seppuku.impl.module.render.LogoutSpotsModule; import net.minecraft.client.Minecraft; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.play.server.SPacketChunkData; import net.minecraft.util.math.Vec2f; +import net.minecraft.util.text.Style; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.event.ClickEvent; +import net.minecraft.util.text.event.HoverEvent; import team.stiff.pomelo.impl.annotated.handler.annotation.Listener; import java.io.File; @@ -46,6 +51,7 @@ public final class StorageAlertModule extends Module { public final Value stands = new Value("BrewingStands", new String[]{"BrewingStands", "brew"}, "Count brewing stands.", false); private final File locationsFile; + private CommandsModule commandsModule; private enum Mode { CHAT, NOTIFICATION, BOTH @@ -89,7 +95,16 @@ public final class StorageAlertModule extends Module { if (foundStorage.size() > 0) { final String message = foundStorage.size() + " storage blocks located at X: " + position.x + " Z: " + position.y; if (this.mode.getValue() == Mode.CHAT || this.mode.getValue() == Mode.BOTH) { - Seppuku.INSTANCE.logChat(ChatFormatting.YELLOW + message); + if (this.commandsModule == null) { + this.commandsModule = (CommandsModule) Seppuku.INSTANCE.getModuleManager().find(CommandsModule.class); + } else { + final TextComponentString textComponent = new TextComponentString(ChatFormatting.YELLOW + message); + textComponent.appendSibling(new TextComponentString("(*)") + .setStyle(new Style() + .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("\2476" + "Create a waypoint for this position."))) + .setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, commandsModule.getPrefix().getValue() + "waypoint add " + String.format("x%s_z%s", position.x, position.y) + " " + position.x + " 120 " + position.y)))); + Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(textComponent); + } } if (this.mode.getValue() == Mode.NOTIFICATION || this.mode.getValue() == Mode.BOTH) { Seppuku.INSTANCE.getNotificationManager().addNotification("", message);