diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/ChatClickActionManager.kt | 49 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerNameFormatter.kt | 12 |
2 files changed, 6 insertions, 55 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ChatClickActionManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ChatClickActionManager.kt deleted file mode 100644 index 140615e08..000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/ChatClickActionManager.kt +++ /dev/null @@ -1,49 +0,0 @@ -package at.hannibal2.skyhanni.data - -import at.hannibal2.skyhanni.utils.ChatUtils -import at.hannibal2.skyhanni.utils.SimpleTimeMark -import at.hannibal2.skyhanni.utils.StringUtils - -object ChatClickActionManager { - - private val actions = mutableListOf<ClickableAction>() - - fun oneTimeClick(message: String, onClick: () -> Any, expiresAt: SimpleTimeMark) { - val action = ClickableAction(StringUtils.generateRandomId(), message, onClick, expiresAt = expiresAt) - actions.add(action) - action.sendToChat() - } - - private fun ClickableAction.sendToChat() { - @Suppress("DEPRECATION") - // TODO rename function - ChatUtils.clickableChat(message, "shaction $token", prefix = false) - } - - fun onCommand(args: Array<String>) { - if (args.size == 1) { - getActionByToken(args[0])?.runAction() - } - } - - private fun ClickableAction.runAction() { - if (expiresAt.isInPast()) { - actions.remove(this) - return - } - onClick() - if (oneTime) { - actions.remove(this) - } - } - - private fun getActionByToken(token: String) = actions.find { it.token == token } - - class ClickableAction( - val token: String, - val message: String, - val onClick: () -> Any, - val oneTime: Boolean = true, - val expiresAt: SimpleTimeMark = SimpleTimeMark.farFuture(), - ) -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerNameFormatter.kt b/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerNameFormatter.kt index 35c1e8cd1..4190b2e9d 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerNameFormatter.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerNameFormatter.kt @@ -13,7 +13,6 @@ import at.hannibal2.skyhanni.features.bingo.BingoAPI import at.hannibal2.skyhanni.features.chat.playerchat.PlayerChatFilter import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager import at.hannibal2.skyhanni.features.misc.compacttablist.AdvancedPlayerList -import at.hannibal2.skyhanni.utils.ChatComponentUtils import at.hannibal2.skyhanni.utils.ComponentMatcherUtils.matchStyledMatcher import at.hannibal2.skyhanni.utils.ComponentSpan import at.hannibal2.skyhanni.utils.LorenzUtils @@ -21,6 +20,7 @@ import at.hannibal2.skyhanni.utils.StringUtils import at.hannibal2.skyhanni.utils.StringUtils.applyFormattingFrom import at.hannibal2.skyhanni.utils.StringUtils.cleanPlayerName import at.hannibal2.skyhanni.utils.StringUtils.toCleanChatComponent +import at.hannibal2.skyhanni.utils.chat.Text import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import com.google.gson.JsonArray import com.google.gson.JsonNull @@ -85,7 +85,7 @@ class PlayerNameFormatter { if (!isEnabled()) return event.chatComponent = StringUtils.replaceIfNeeded( event.chatComponent, - ChatComponentUtils.text("§bCo-Op > ") { + Text.text("§bCo-Op > ") { appendSibling(nameFormat(event.authorComponent)) appendText("§f: ") appendSibling(event.messageComponent.intoComponent()) @@ -98,7 +98,7 @@ class PlayerNameFormatter { if (!isEnabled()) return event.chatComponent = StringUtils.replaceIfNeeded( event.chatComponent, - ChatComponentUtils.text("§2Guild > ") { + Text.text("§2Guild > ") { appendSibling(nameFormat(event.authorComponent, guildRank = event.guildRank)) appendText("§f: ") appendSibling(event.messageComponent.intoComponent()) @@ -111,7 +111,7 @@ class PlayerNameFormatter { if (!isEnabled()) return event.chatComponent = StringUtils.replaceIfNeeded( event.chatComponent, - ChatComponentUtils.text("§9Party §8> ") { + Text.text("§9Party §8> ") { appendSibling(nameFormat(event.authorComponent)) appendText("§f: ") appendSibling(event.messageComponent.intoComponent()) @@ -123,7 +123,7 @@ class PlayerNameFormatter { fun onPrivateChat(event: PrivateMessageChatEvent) { if (!isEnabled()) return event.chatComponent = - StringUtils.replaceIfNeeded(event.chatComponent, ChatComponentUtils.text("§d${event.direction}") { + StringUtils.replaceIfNeeded(event.chatComponent, Text.text("§d${event.direction}") { appendText(" ") appendSibling(nameFormat(event.authorComponent)) appendText("§f: ") @@ -135,7 +135,7 @@ class PlayerNameFormatter { @SubscribeEvent fun onPlayerShowItemChat(event: PlayerShowItemChatEvent) { if (!isEnabled()) return - event.chatComponent = StringUtils.replaceIfNeeded(event.chatComponent, ChatComponentUtils.text("") { + event.chatComponent = StringUtils.replaceIfNeeded(event.chatComponent, Text.text("") { appendSibling( nameFormat( event.authorComponent, |