aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-08-03 21:55:06 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-08-03 21:55:06 +0200
commit5dee3f298497dae472e80235091b659e4042fd49 (patch)
tree1f56f4f292d81c0fb8a3605cb50268d2bd8c6662 /src/main
parentd28deb42cf69ba3a56e1117e373a0a3514a45e31 (diff)
downloadskyhanni-5dee3f298497dae472e80235091b659e4042fd49.tar.gz
skyhanni-5dee3f298497dae472e80235091b659e4042fd49.tar.bz2
skyhanni-5dee3f298497dae472e80235091b659e4042fd49.zip
Shorten the bestiary level-up message
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Features.java27
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/ChatConfig.java (renamed from src/main/java/at/hannibal2/skyhanni/config/features/Chat.java)13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/CompactBestiaryChatMessage.kt87
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt22
5 files changed, 145 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index e19b4b49b..14650eff9 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -15,6 +15,7 @@ import at.hannibal2.skyhanni.features.bazaar.BazaarOrderHelper
import at.hannibal2.skyhanni.features.bingo.*
import at.hannibal2.skyhanni.features.chat.ArachneChatMessageHider
import at.hannibal2.skyhanni.features.chat.ChatFilter
+import at.hannibal2.skyhanni.features.chat.CompactBestiaryChatMessage
import at.hannibal2.skyhanni.features.chat.PlayerDeathMessages
import at.hannibal2.skyhanni.features.chat.playerchat.PlayerChatFilter
import at.hannibal2.skyhanni.features.chat.playerchat.PlayerChatModifier
@@ -373,7 +374,7 @@ class SkyHanniMod {
loadModule(KingTalismanHelper())
loadModule(HarpKeybinds())
loadModule(EnderNodeTracker())
- //
+ loadModule(CompactBestiaryChatMessage())
init()
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java
index c8bfc3d1f..2f2de9fc5 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/Features.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java
@@ -1,7 +1,30 @@
package at.hannibal2.skyhanni.config;
import at.hannibal2.skyhanni.SkyHanniMod;
-import at.hannibal2.skyhanni.config.features.*;
+import at.hannibal2.skyhanni.config.features.About;
+import at.hannibal2.skyhanni.config.features.Ashfang;
+import at.hannibal2.skyhanni.config.features.Bazaar;
+import at.hannibal2.skyhanni.config.features.Bingo;
+import at.hannibal2.skyhanni.config.features.ChatConfig;
+import at.hannibal2.skyhanni.config.features.CommandsFeatures;
+import at.hannibal2.skyhanni.config.features.DamageIndicatorConfig;
+import at.hannibal2.skyhanni.config.features.DevConfig;
+import at.hannibal2.skyhanni.config.features.DianaConfig;
+import at.hannibal2.skyhanni.config.features.Dungeon;
+import at.hannibal2.skyhanni.config.features.Fishing;
+import at.hannibal2.skyhanni.config.features.GUI;
+import at.hannibal2.skyhanni.config.features.Garden;
+import at.hannibal2.skyhanni.config.features.GhostCounterConfig;
+import at.hannibal2.skyhanni.config.features.Inventory;
+import at.hannibal2.skyhanni.config.features.ItemAbilities;
+import at.hannibal2.skyhanni.config.features.MarkedPlayers;
+import at.hannibal2.skyhanni.config.features.Minions;
+import at.hannibal2.skyhanni.config.features.MiscConfig;
+import at.hannibal2.skyhanni.config.features.Mobs;
+import at.hannibal2.skyhanni.config.features.OldHidden;
+import at.hannibal2.skyhanni.config.features.RiftConfig;
+import at.hannibal2.skyhanni.config.features.SlayerConfig;
+import at.hannibal2.skyhanni.config.features.Summonings;
import com.google.gson.annotations.Expose;
import io.github.moulberry.moulconfig.Config;
import io.github.moulberry.moulconfig.Social;
@@ -49,7 +72,7 @@ public class Features extends Config {
@Expose
@Category(name = "Chat", desc = "Change how the chat looks.")
- public Chat chat = new Chat();
+ public ChatConfig chat = new ChatConfig();
@Expose
@Category(name = "Dungeon", desc = "Features that change the dungeon experience in catacombs.")
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Chat.java b/src/main/java/at/hannibal2/skyhanni/config/features/ChatConfig.java
index f149fc624..1723db1be 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Chat.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/ChatConfig.java
@@ -1,10 +1,14 @@
package at.hannibal2.skyhanni.config.features;
import com.google.gson.annotations.Expose;
-import io.github.moulberry.moulconfig.annotations.*;
+import io.github.moulberry.moulconfig.annotations.ConfigAccordionId;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorKeybind;
+import io.github.moulberry.moulconfig.annotations.ConfigOption;
import org.lwjgl.input.Keyboard;
-public class Chat {
+public class ChatConfig {
@Expose
@ConfigOption(name = "Peek Chat", desc = "Hold this key to keep the chat open.")
@@ -130,6 +134,11 @@ public class Chat {
public boolean compactPotionMessage = true;
@Expose
+ @ConfigOption(name = "Compact Bestiary Message", desc = "Shorten the bestiary level up message, showing additional information when hovering.")
+ @ConfigEditorBoolean
+ public boolean compactBestiaryMessage = true;
+
+ @Expose
@ConfigOption(name = "Arachne Hider", desc = "Hide chat messages about the Arachne Fight while outside of §eArachne's Sanctuary§7.")
@ConfigEditorBoolean
public boolean hideArachneMessages = false;
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/CompactBestiaryChatMessage.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/CompactBestiaryChatMessage.kt
new file mode 100644
index 000000000..7b893afcf
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/CompactBestiaryChatMessage.kt
@@ -0,0 +1,87 @@
+package at.hannibal2.skyhanni.features.chat
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.makeAccessible
+import net.minecraft.client.Minecraft
+import net.minecraft.client.gui.ChatLine
+import net.minecraft.util.IChatComponent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.relauncher.ReflectionHelper
+
+class CompactBestiaryChatMessage {
+
+ var inBestiary = false
+ var bestiaryDescription = mutableListOf<String>()
+ var acceptMoreDescription = true
+ var command = ""
+
+ var lastBorder: IChatComponent? = null
+ var lastEmpty: IChatComponent? = null
+
+ var milestoneMessage: String? = null
+
+ @SubscribeEvent
+ fun onChatMessage(event: LorenzChatEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+ if (!SkyHanniMod.feature.chat.compactBestiaryMessage) return
+
+ val titleMessage = " §6§lBESTIARY"
+ val border = "§3§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬"
+
+ val message = event.message
+
+ if (message == border) {
+ lastBorder = event.chatComponent
+ }
+ if (message == " ") {
+ lastEmpty = event.chatComponent
+ }
+
+ if (message == titleMessage) {
+ event.blockedReason = "bestiary"
+ val chatGUI = Minecraft.getMinecraft().ingameGUI.chatGUI
+ val chatLinesField = ReflectionHelper.findField(chatGUI.javaClass, "chatLines")
+ val chatLines = chatLinesField.makeAccessible().get(chatGUI) as MutableList<ChatLine>
+
+ lastBorder?.let { chat -> chatLines.removeIf { it.chatComponent === chat } }
+ lastEmpty?.let { chat -> chatLines.removeIf { it.chatComponent === chat } }
+ chatGUI.refreshChat()
+
+ lastBorder = null
+ lastEmpty = null
+
+ for (sibling in event.chatComponent.siblings) {
+ sibling.chatStyle?.chatClickEvent?.let {
+ command = it.value
+ }
+ }
+ inBestiary = true
+ bestiaryDescription.add(message.trim())
+ } else if (inBestiary) {
+ event.blockedReason = "bestiary"
+ if (message == border) {
+ inBestiary = false
+
+ val title = bestiaryDescription[1]
+ LorenzUtils.hoverableChat("§6§lBESTIARY §r$title", bestiaryDescription.dropLast(1), command)
+ bestiaryDescription.clear()
+ acceptMoreDescription = true
+
+ } else {
+ milestoneMessage?.let {
+ LorenzUtils.chat("§6§lBESTIARY MILESTONE $it")
+ milestoneMessage = null
+ }
+ if (message.endsWith("§6§lBESTIARY MILESTONE")) {
+ acceptMoreDescription = false
+ milestoneMessage = message
+ }
+ if (acceptMoreDescription) {
+ bestiaryDescription.add(message.trim())
+ }
+ }
+ }
+ }
+}
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