diff options
| author | Linnea Gräf <nea@nea.moe> | 2024-04-27 10:15:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-27 10:15:43 +0200 |
| commit | cde33a4c83a2f2d781ff8bb740b7166691c04600 (patch) | |
| tree | 936882c427187a469d63b4f5142549054314f432 /src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java | |
| parent | 18ea34b92d6106afda3b662256a2dc36dd4d8ec0 (diff) | |
| download | notenoughupdates-cde33a4c83a2f2d781ff8bb740b7166691c04600.tar.gz notenoughupdates-cde33a4c83a2f2d781ff8bb740b7166691c04600.tar.bz2 notenoughupdates-cde33a4c83a2f2d781ff8bb740b7166691c04600.zip | |
Add hotm upgrade TODOs/warning (#1090)
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java')
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index fee8c594..f13462bc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -67,6 +67,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraftforge.fml.common.Loader; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.lwjgl.BufferUtils; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; @@ -1241,7 +1242,7 @@ public class Utils { var width = fr.getStringWidth(str); float scale = ((float) availableSpace) / width; GlStateManager.scale(scale, scale, 1f); - fr.drawString(str, -width / 2F, 0, colour, shadow); + fr.drawString(str, -width / 2F, 0, colour, shadow); GlStateManager.popMatrix(); } @@ -2342,10 +2343,27 @@ public class Utils { return username; } - public static void addChatMessage(String message) { + public static void addChatMessage(@NotNull String message) { + addChatMessage(new ChatComponentText(message)); + } + + public static void addClickableChatMessage( + @NotNull String message, + @NotNull String command, + @Nullable String hoverText + ) { + if (hoverText == null) + hoverText = "§eClick to run §a" + command; + addChatMessage(new ChatComponentText(message) + .setChatStyle(new ChatStyle() + .setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command)) + .setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(hoverText))))); + } + + public static void addChatMessage(@NotNull IChatComponent message) { EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; if (thePlayer != null) { - thePlayer.addChatMessage(new ChatComponentText(message)); + thePlayer.addChatMessage(message); } else { System.out.println(message); } |
