diff options
| author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-03 21:55:06 +0200 |
|---|---|---|
| committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-03 21:55:06 +0200 |
| commit | 5dee3f298497dae472e80235091b659e4042fd49 (patch) | |
| tree | 1f56f4f292d81c0fb8a3605cb50268d2bd8c6662 /src/main/java/at/hannibal2/skyhanni/utils | |
| parent | d28deb42cf69ba3a56e1117e373a0a3514a45e31 (diff) | |
| download | skyhanni-5dee3f298497dae472e80235091b659e4042fd49.tar.gz skyhanni-5dee3f298497dae472e80235091b659e4042fd49.tar.bz2 skyhanni-5dee3f298497dae472e80235091b659e4042fd49.zip | |
Shorten the bestiary level-up message
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 4528f7ee5..8ef5433e0 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -22,6 +22,7 @@ import net.minecraft.util.ChatComponentText import org.lwjgl.input.Keyboard import java.awt.Color import java.lang.reflect.Field +import java.lang.reflect.Modifier import java.text.DecimalFormat import java.text.NumberFormat import java.text.SimpleDateFormat @@ -222,9 +223,21 @@ object LorenzUtils { fun clickableChat(message: String, command: String) { val text = ChatComponentText(message) - text.chatStyle.chatClickEvent = ClickEvent(ClickEvent.Action.RUN_COMMAND, "/$command") + text.chatStyle.chatClickEvent = ClickEvent(ClickEvent.Action.RUN_COMMAND, "/${command.removePrefix("/")}") text.chatStyle.chatHoverEvent = - HoverEvent(HoverEvent.Action.SHOW_TEXT, ChatComponentText("§eExecute /$command")) + HoverEvent(HoverEvent.Action.SHOW_TEXT, ChatComponentText("§eExecute /${command.removePrefix("/")}")) + Minecraft.getMinecraft().thePlayer.addChatMessage(text) + } + + fun hoverableChat(message: String, hover: List<String>, command: String? = null) { + val text = ChatComponentText(message) + text.chatStyle.chatHoverEvent = + HoverEvent(HoverEvent.Action.SHOW_TEXT, ChatComponentText(hover.joinToString("\n"))) + + if (command != null) { + text.chatStyle.chatClickEvent = ClickEvent(ClickEvent.Action.RUN_COMMAND, "/${command.removePrefix("/")}") + } + Minecraft.getMinecraft().thePlayer.addChatMessage(text) } @@ -432,4 +445,9 @@ object LorenzUtils { infix fun <K, V> MutableMap<K, V>.put(pairs: Pair<K, V>) { this[pairs.first] = pairs.second } + + fun Field.removeFinal(): Field { + javaClass.getDeclaredField("modifiers").makeAccessible().set(this, modifiers and (Modifier.FINAL.inv())) + return this + } }
\ No newline at end of file |
