aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data
diff options
context:
space:
mode:
authorBrady <thatgravyboat@gmail.com>2024-05-08 08:30:59 -0230
committerGitHub <noreply@github.com>2024-05-08 13:00:59 +0200
commitf9ce2fa19a1178fd9f2e2728d09ac5acd299d69f (patch)
treec344555d1a09f27b74347413f828df71fe95767b /src/main/java/at/hannibal2/skyhanni/data
parent49d918a5d01f102796c2ef52a26e69a41892eb8f (diff)
downloadskyhanni-f9ce2fa19a1178fd9f2e2728d09ac5acd299d69f.tar.gz
skyhanni-f9ce2fa19a1178fd9f2e2728d09ac5acd299d69f.tar.bz2
skyhanni-f9ce2fa19a1178fd9f2e2728d09ac5acd299d69f.zip
Backend: Text API (#1718)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ChatClickActionManager.kt49
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerNameFormatter.kt12
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,