Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend: Text API #1718

Merged
merged 6 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import at.hannibal2.skyhanni.api.SkillAPI
import at.hannibal2.skyhanni.config.ConfigFileType
import at.hannibal2.skyhanni.config.ConfigGuiManager
import at.hannibal2.skyhanni.config.features.About.UpdateStream
import at.hannibal2.skyhanni.data.ChatClickActionManager
import at.hannibal2.skyhanni.utils.chat.ChatClickActionManager
import at.hannibal2.skyhanni.data.ChatManager
import at.hannibal2.skyhanni.data.GardenCropMilestonesCommunityFix
import at.hannibal2.skyhanni.data.GuiEditManager
Expand Down Expand Up @@ -82,6 +82,9 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.SoundUtils
import at.hannibal2.skyhanni.utils.StringUtils.splitLines
import at.hannibal2.skyhanni.utils.TabListData
import at.hannibal2.skyhanni.utils.chat.Text
import at.hannibal2.skyhanni.utils.chat.Text.hover
import at.hannibal2.skyhanni.utils.chat.Text.suggest
import at.hannibal2.skyhanni.utils.repopatterns.RepoPatternGui
import net.minecraft.command.ICommandSender
import net.minecraft.util.BlockPos
Expand Down Expand Up @@ -565,9 +568,10 @@ object Commands {
addDescription(category.description)
}

val commandInfo = ChatUtils.createHoverableChat("$color/$name", hoverText, "/$name", false)

components.add(commandInfo)
components.add(Text.text("$color/$name") {
this.hover = Text.multiline(hoverText)
this.suggest = "/$name"
})
components.add(ChatComponentText("§7, "))
}
components.add(ChatComponentText("\n "))
Expand Down Expand Up @@ -629,7 +633,8 @@ object Commands {
"Are you sure you want to switch to beta? These versions may be less stable.",
onClick = {
UpdateManager.checkUpdate(true, updateStream)
}
},
oneTimeClick = true
)
} else {
UpdateManager.checkUpdate(true, updateStream)
Expand Down
49 changes: 0 additions & 49 deletions src/main/java/at/hannibal2/skyhanni/data/ChatClickActionManager.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ 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
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
Expand Down Expand Up @@ -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())
Expand All @@ -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())
Expand All @@ -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())
Expand All @@ -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: ")
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ object GhostCounter {
GhostUtil.importCTGhostCounterData()
},
prefixColor = "§6",
oneTimeClick = true
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,14 @@ object PartyChatCommands {
}

"clear" -> {
ChatUtils.clickableChat("Are you sure you want to do this? Click here to confirm.",
ChatUtils.clickableChat(
"Are you sure you want to do this? Click here to confirm.",
onClick = {
storage.blacklistedUsers.clear()
ChatUtils.chat("Cleared your ignored players list!")
})
},
oneTimeClick = true
)
}

else -> blacklistModify(firstArg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.SackAPI.getAmountInSacks
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
Expand Down Expand Up @@ -43,12 +44,11 @@ class DungeonArchitectFeatures {
val architectItemAmount = architectsFirstDraftItem.getAmountInSacks()
if (architectItemAmount <= 0) return

// TODO use hypxel command class (once the pr is merged
ChatUtils.clickableChat(
"§c§lPUZZLE FAILED! §r§b$name §r§efailed a puzzle.\n" +
"§eClick here to get §5Architect's First Draft §7(§e${architectItemAmount}x left§7)",
"/gfs ARCHITECT_FIRST_DRAFT 1",
false
{ HypixelCommands.getFromSacks("ARCHITECT_FIRST_DRAFT", 1) },
prefix = false
)
LorenzUtils.sendTitle("§c§lPUZZLE FAILED!", 3.seconds)
event.blockedReason = "puzzle_fail"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,13 @@ object InquisitorWaypointShare {
sendInquisitor()
} else {
val keyName = KeyboardManager.getKeyName(config.keyBindShare)
val message =
"§l§bYou found a Inquisitor! Press §l§chere §l§bor §c$keyName to share the location!"
ChatUtils.clickableChat(message, onClick = {
sendInquisitor()
})
val message = "§l§bYou found a Inquisitor! Press §l§chere §l§bor §c$keyName to share the location!"
ChatUtils.clickableChat(
message, onClick = {
sendInquisitor()
},
oneTimeClick = true
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ object HoppityEggsManager {
ChatUtils.clickableChat(
"Click here to share the location of this chocolate egg with the server!",
onClick = { HoppityEggsShared.shareNearbyEggLocation(currentLocation, meal, note) },
expireAt = 30.seconds.fromNow()
expireAt = 30.seconds.fromNow(),
oneTimeClick = true
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class AccountUpgradeReminder {
"The §a$upgrade §eupgrade has completed! §c(Click to disable these reminders)",
onClick = {
disable()
}
},
oneTimeClick = true
)
}

Expand Down Expand Up @@ -113,6 +114,7 @@ class AccountUpgradeReminder {

fun disable() {
SkyHanniMod.feature.misc.accountUpgradeReminder = false
ChatUtils.chat("Disabled account upgrade reminder.")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class CityProjectFeatures {
"Daily City Project Reminder! (Click here to disable this reminder)",
onClick = {
disable()
}
},
oneTimeClick = true
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ object TrophyFishManager {
}
}
if (changed) {
ChatUtils.clickableChat("Click here to load data from NEU PV!", onClick = {
updateFromNeuPv(savedFishes, neuData)
})
ChatUtils.clickableChat(
"Click here to load data from NEU PV!", onClick = {
updateFromNeuPv(savedFishes, neuData)
},
oneTimeClick = true
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ object GardenNextJacobContest {
"§2Click here to submit this year's farming contests. Thank you for helping everyone out!",
onClick = {
shareContests()
}
},
oneTimeClick = true
)
}
}
Expand Down Expand Up @@ -303,7 +304,8 @@ object GardenNextJacobContest {
config.shareAutomatically = ShareContestsEntry.AUTO
SkyHanniMod.feature.storage.contestSendingAsked = true
ChatUtils.chat("§2Enabled automatic sharing of future contests!")
}
},
oneTimeClick = true
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ class SkyHanniDebugsAndTests {
onClick = {
resetConfig()
},
prefix = false
prefix = false,
oneTimeClick = true
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ object TestChatCommand {
if (finalMessage.formattedText.stripHypixelMessage() != message) {
ChatUtils.chat("§eChat modified!")
}
ChatUtils.chatComponent(finalMessage)
ChatUtils.chat(finalMessage)
}
}
}

This file was deleted.

Loading
Loading