diff options
| author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-03 23:36:44 +0200 |
|---|---|---|
| committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-03 23:36:44 +0200 |
| commit | a4c61672d93aaf7418568ca6b3704289d890f48b (patch) | |
| tree | 7418d0531f9f35ddef449fb44ec272a14ad9bc8a /src/main/java/at/hannibal2/skyhanni/data | |
| parent | 75ad1cd4a13487932750913b7c3054146adfd50e (diff) | |
| download | skyhanni-a4c61672d93aaf7418568ca6b3704289d890f48b.tar.gz skyhanni-a4c61672d93aaf7418568ca6b3704289d890f48b.tar.bz2 skyhanni-a4c61672d93aaf7418568ca6b3704289d890f48b.zip | |
code cleanup
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt index 167efdb3b..8b6330f6d 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt @@ -23,7 +23,6 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.relauncher.ReflectionHelper import java.lang.invoke.MethodHandles -import java.util.LinkedHashMap object ChatManager { @@ -39,9 +38,7 @@ object ChatManager { } } - fun getRecentMessageHistory(): List<MessageFilteringResult> { - return messageHistory.toList().map { it.second } - } + fun getRecentMessageHistory(): List<MessageFilteringResult> = messageHistory.toList().map { it.second } enum class ActionKind(format: Any) { BLOCKED(EnumChatFormatting.RED.toString() + EnumChatFormatting.BOLD), @@ -154,7 +151,7 @@ object ChatManager { } fun openChatFilterGUI() { - SkyHanniMod.screenToOpen = (ChatFilterGui(getRecentMessageHistory())) + SkyHanniMod.screenToOpen = ChatFilterGui(getRecentMessageHistory()) } val chatLinesField by lazy { @@ -167,12 +164,13 @@ object ChatManager { fun retractMessage(message: IChatComponent?, reason: String) { if (message == null) return val chatGUI = Minecraft.getMinecraft().ingameGUI.chatGUI + @Suppress("UNCHECKED_CAST") val chatLines = chatLinesField.invokeExact(chatGUI) as MutableList<ChatLine> - if (chatLines.removeIf { it.chatComponent === message }) { - val history = messageHistory[IdentityCharacteristics(message)] - history?.actionKind = ActionKind.RETRACTED - history?.actionReason = reason.uppercase() - } + if (!chatLines.removeIf { it.chatComponent === message }) return chatGUI.refreshChat() + + val history = messageHistory[IdentityCharacteristics(message)] ?: return + history.actionKind = ActionKind.RETRACTED + history.actionReason = reason.uppercase() } }
\ No newline at end of file |
