StorageAlert: Add click event to create waypoint

This commit is contained in:
noil 2020-12-23 14:13:38 -05:00
parent c4a3cf6148
commit 71d1919bf2
1 changed files with 16 additions and 1 deletions

View File

@ -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<Boolean> stands = new Value<Boolean>("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);