aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-04-24 11:00:06 +0200
committerGitHub <noreply@github.com>2024-04-24 11:00:06 +0200
commit9f7ef2b05adaf526300018bf8fb4f42ca081c483 (patch)
tree6335a960b4cb606cf2ee6067682cc76cd4b375d6
parentd4c635abdc2db495659b0a64b3e035cd5f0aa222 (diff)
downloadskyhanni-9f7ef2b05adaf526300018bf8fb4f42ca081c483.tar.gz
skyhanni-9f7ef2b05adaf526300018bf8fb4f42ca081c483.tar.bz2
skyhanni-9f7ef2b05adaf526300018bf8fb4f42ca081c483.zip
Backend: HypixelCommands (#1525)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
-rw-r--r--src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ChatClickActionManager.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/ChocolateFactoryBarnManager.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/winter/NewYearCakeReminder.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenWarpCommands.kt31
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestSpawn.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/tiarelay/TiaRelayHelper.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/JoinCrystalHollows.kt10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/NoBitsWarning.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/PabloHelper.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/HypixelCommands.kt54
21 files changed, 165 insertions, 51 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt
index ad5ea7b6e..d3034d003 100644
--- a/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt
@@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.ChatUtils.isCommand
import at.hannibal2.skyhanni.utils.ChatUtils.senderIsSkyhanni
+import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
@@ -54,9 +55,11 @@ object GetFromSackAPI {
fun getFromChatMessageSackItems(
item: PrimitiveItemStack,
- text: String = "§lCLICK HERE§r§e to grab §ax${item.amount} §9${item.itemName}§e from sacks!"
+ text: String = "§lCLICK HERE§r§e to grab §ax${item.amount} §9${item.itemName}§e from sacks!",
) =
- ChatUtils.clickableChat(text, "${commands.first()} ${item.internalName.asString()} ${item.amount}")
+ ChatUtils.clickableChat(text, onClick = {
+ HypixelCommands.getFromSacks(item.internalName.asString(), item.amount)
+ })
fun getFromSlotClickedSackItems(items: List<PrimitiveItemStack>, slotIndex: Int) = addToInventory(items, slotIndex)
@@ -86,7 +89,7 @@ object GetFromSackAPI {
if (!LorenzUtils.inSkyBlock) return
if (queue.isNotEmpty() && lastTimeOfCommand.passedSince() >= minimumDelay) {
val item = queue.poll()
- ChatUtils.sendCommandToServer("gfs ${item.internalName.asString().replace('-', ':')} ${item.amount}")
+ HypixelCommands.getFromSacks(item.internalName.asString().replace('-', ':'), item.amount)
lastTimeOfCommand = ChatUtils.getTimeWhenNewlyQueuedMessageGetsExecuted()
}
}
@@ -158,7 +161,7 @@ object GetFromSackAPI {
private fun bazaarMessage(item: String, amount: Int, isRemaining: Boolean = false) = ChatUtils.clickableChat(
"§lCLICK §r§eto get the ${if (isRemaining) "remaining " else ""}§ax${amount} §9$item §efrom bazaar",
- "bz ${item.removeColor()}"
+ onClick = { HypixelCommands.bazaar(item.removeColor()) }
)
private fun commandValidator(args: List<String>): Pair<CommandResult, PrimitiveItemStack?> {
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ChatClickActionManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ChatClickActionManager.kt
index 3dc03c5f9..140615e08 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ChatClickActionManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ChatClickActionManager.kt
@@ -15,6 +15,8 @@ object ChatClickActionManager {
}
private fun ClickableAction.sendToChat() {
+ @Suppress("DEPRECATION")
+ // TODO rename function
ChatUtils.clickableChat(message, "shaction $token", prefix = false)
}
@@ -42,6 +44,6 @@ object ChatClickActionManager {
val message: String,
val onClick: () -> Any,
val oneTime: Boolean = true,
- val expiresAt: SimpleTimeMark = SimpleTimeMark.farFuture()
+ val expiresAt: SimpleTimeMark = SimpleTimeMark.farFuture(),
)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt
index 2e42bb002..97cab2c33 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt
@@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.ProfileJoinEvent
import at.hannibal2.skyhanni.events.TabListUpdateEvent
import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.matchFirst
@@ -71,7 +72,9 @@ object ProfileStorageData {
ChatUtils.clickableChat(
"§cCan not read profile name from tab list! Open /widget and enable Profile Widget. " +
"This is needed for the mod to function! And therefore this warning cannot be disabled",
- command = "widget"
+ onClick = {
+ HypixelCommands.widget()
+ }
)
} else {
ChatUtils.chat(
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/ChocolateFactoryBarnManager.kt b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/ChocolateFactoryBarnManager.kt
index 353e0dfe3..e403415d2 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/ChocolateFactoryBarnManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/ChocolateFactoryBarnManager.kt
@@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.event.chocolatefactory
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.SimpleTimeMark
import at.hannibal2.skyhanni.utils.SoundUtils
@@ -56,15 +57,18 @@ object ChocolateFactoryBarnManager {
if (profileStorage.maxRabbits == -1) {
ChatUtils.clickableChat(
"Open your chocolate factory to see your barn's capacity status!",
- "cf"
+ onClick = {
+ HypixelCommands.chocolateFactory()
+ }
)
return
}
ChatUtils.clickableChat(
- "§cYour barn is almost full! " +
- "§7(${barnStatus()}). §cUpgrade it so they don't get crushed",
- "cf"
+ "§cYour barn is almost full! §7(${barnStatus()}). §cUpgrade it so they don't get crushed",
+ onClick = {
+ HypixelCommands.chocolateFactory()
+ }
)
SoundUtils.playBeepSound()
lastBarnFullWarning = SimpleTimeMark.now()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt
index bb5c1271b..11973f2c7 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt
@@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.LorenzKeyPressEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.CollectionUtils.sorted
+import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.round
@@ -33,7 +34,7 @@ class BurrowWarpHelper {
currentWarp?.let {
if (lastWarpTime.passedSince() > 5.seconds) {
lastWarpTime = SimpleTimeMark.now()
- ChatUtils.sendCommandToServer("warp " + currentWarp?.name)
+ HypixelCommands.warp(it.name)
lastWarp = currentWarp
GriffinBurrowHelper.lastTitleSentTime = SimpleTimeMark.now() + 2.seconds
TitleManager.optionalResetTitle {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/winter/NewYearCakeReminder.kt b/src/main/java/at/hannibal2/skyhanni/features/event/winter/NewYearCakeReminder.kt
index 9a68947dc..4e53e92bb 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/winter/NewYearCakeReminder.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/winter/NewYearCakeReminder.kt
@@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.SecondPassedEvent
import at.hannibal2.skyhanni.features.fame.ReminderUtils
import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.matches
@@ -63,7 +64,9 @@ class NewYearCakeReminder {
ChatUtils.clickableChat(
"Reminding you to grab the free New Year Cake. Click here to open the baker menu!",
- "openbaker"
+ onClick = {
+ HypixelCommands.openBaker()
+ }
)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
index 586829185..92ebceccd 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
@@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.features.garden.CropType.Companion.getTurboCrop
import at.hannibal2.skyhanni.features.garden.pests.PestAPI
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter
+import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzUtils.round
@@ -190,7 +191,7 @@ object FarmingFortuneDisplay {
"§cshowing latest Crop Fortune."
),
onClick = {
- ChatUtils.sendCommandToServer("widget")
+ HypixelCommands.widget()
}
))
} else {
@@ -201,7 +202,7 @@ object FarmingFortuneDisplay {
"§cshowing the Farming Fortune stat."
),
onClick = {
- ChatUtils.sendCommandToServer("widget")
+ HypixelCommands.widget()
}
))
}
@@ -216,7 +217,9 @@ object FarmingFortuneDisplay {
ChatUtils.clickableChat(
"§cCan not read Farming Fortune from tab list! Open /widget and enable the Stats Widget " +
"and showing the Farming Fortune stat.",
- command = "widget"
+ onClick = {
+ HypixelCommands.widget()
+ }
)
lastUniversalFortuneMissingError = SimpleTimeMark.now()
}
@@ -225,7 +228,9 @@ object FarmingFortuneDisplay {
ChatUtils.clickableChat(
"§cCan not read Crop Fortune from tab list! Open /widget and enable the Stats Widget " +
"and showing latest Crop Fortune.",
- command = "widget"
+ onClick = {
+ HypixelCommands.widget()
+ }
)
lastCropFortuneMissingError = SimpleTimeMark.now()
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt
index e39387c97..1196c82e1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt
@@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.events.ProfileJoinEvent
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.ConditionalUtils
+import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
@@ -94,9 +95,12 @@ class GardenLevelDisplay {
ChatUtils.clickableChat(
" \n§b§lGARDEN LEVEL UP §8$oldLevel ➜ §b$newLevel\n" +
" §8+§aRespect from Elite Farmers and SkyHanni members :)\n ",
- "gardenlevels",
- false
+ onClick = {
+ HypixelCommands.gardenLevels()
+ },
+ prefix = false
)
+
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
index 82ccc9a93..7b898f3f0 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
@@ -17,6 +17,7 @@ import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.APIUtil
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.ConfigUtils
+import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
@@ -556,7 +557,9 @@ object GardenNextJacobContest {
}
} else {
ChatUtils.chat("This year's contests aren't available to fetch automatically yet, please load them from your calendar or wait 10 minutes.")
- ChatUtils.clickableChat("Click here to open your calendar!", "calendar")
+ ChatUtils.clickableChat("Click here to open your calendar!", onClick = {
+ HypixelCommands.calendar()
+ })
}
if (newContests.count() == MAX_CONTESTS_PER_YEAR) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt
index f71b6dbb0..400767704 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt
@@ -5,7 +5,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.features.garden.pests.SprayType
import at.hannibal2.skyhanni.features.misc.LockMouseLook
-import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LocationUtils.isInside
@@ -210,8 +210,8 @@ object GardenPlotAPI {
fun closestCenterPlot(location: LorenzVec) = plots.find { it.box.isInside(location) }?.middle
fun Plot.sendTeleportTo() {
- if (isBarn()) ChatUtils.sendCommandToServer("tptoplot barn")
- else ChatUtils.sendCommandToServer("tptoplot $name")
+ if (isBarn()) HypixelCommands.teleportToPlot("barn")
+ else HypixelCommands.teleportToPlot(name)
LockMouseLook.autoDisable()
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenWarpCommands.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenWarpCommands.kt
index e0abfa77f..220c7a757 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenWarpCommands.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenWarpCommands.kt
@@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.events.LorenzKeyPressEvent
import at.hannibal2.skyhanni.events.MessageSendToServerEvent
import at.hannibal2.skyhanni.features.misc.LockMouseLook
import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
@@ -32,20 +33,20 @@ class GardenWarpCommands {
if (message == "/home") {
event.isCanceled = true
- ChatUtils.sendCommandToServer("warp garden")
+ HypixelCommands.warp("garden")
ChatUtils.chat("§aTeleported you to the spawn location!", prefix = false)
}
if (message == "/barn") {
event.isCanceled = true
- ChatUtils.sendCommandToServer("tptoplot barn")
+ HypixelCommands.teleportToPlot("barn")
LockMouseLook.autoDisable()
}
tpPlotPattern.matchMatcher(event.message) {
event.isCanceled = true
val plotName = group("plot")
- ChatUtils.sendCommandToServer("tptoplot $plotName")
+ HypixelCommands.teleportToPlot(plotName)
LockMouseLook.autoDisable()
}
}
@@ -56,18 +57,24 @@ class GardenWarpCommands {
if (Minecraft.getMinecraft().currentScreen != null) return
if (NEUItems.neuHasFocus()) return
- val command = when (event.keyCode) {
- config.homeHotkey -> "warp garden"
- config.sethomeHotkey -> "sethome"
- config.barnHotkey -> "tptoplot barn"
+ if (lastWarpTime.passedSince() < 2.seconds) return
+
+ when (event.keyCode) {
+ config.homeHotkey -> {
+ HypixelCommands.warp("garden")
+ }
+
+ config.sethomeHotkey -> {
+ ChatUtils.sendCommandToServer("sethome")
+ }
+
+ config.barnHotkey -> {
+ LockMouseLook.autoDisable()
+ HypixelCommands.teleportToPlot("barn")
+ }
else -> return
}
- if (lastWarpTime.passedSince() < 2.seconds) return
lastWarpTime = SimpleTimeMark.now()
- if (command == "tptoplot barn") {
- LockMouseLook.autoDisable()
- }
- ChatUtils.sendCommandToServer(command)
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt
index 0d0494bf9..6516d9a2e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt
@@ -24,6 +24,7 @@ import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList
import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc
import at.hannibal2.skyhanni.utils.ConfigUtils
+import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.InventoryUtils.getAmountInInventory
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.KeyboardManager
@@ -490,7 +491,7 @@ object ComposterOverlay {
}
val havingInSacks = internalName.getAmountInSacksOrNull() ?: run {
- ChatUtils.sendCommandToServer("gfs ${internalName.asString()} ${itemsNeeded - havingInInventory}")
+ HypixelCommands.getFromSacks(internalName.asString(), itemsNeeded - havingInInventory)
// TODO Add sack type repo data
val isDwarvenMineable =
@@ -498,7 +499,9 @@ object ComposterOverlay {
val sackType = if (isDwarvenMineable) "Mining §eor §9Dwarven" else "Enchanted Agronomy"
ChatUtils.clickableChat(
"Sacks could not be loaded. Click here and open your §9$sackType Sack §eto update the data!",
- "sax"
+ onClick = {
+ HypixelCommands.sacks()
+ }
)
return
}
@@ -513,14 +516,16 @@ object ComposterOverlay {
return
}
- ChatUtils.sendCommandToServer("gfs ${internalName.asString()} ${itemsNeeded - havingInInventory}")
+ HypixelCommands.getFromSacks(internalName.asString(), itemsNeeded - havingInInventory)
if (itemsNeeded > havingInInventory - havingInSacks) {
if (LorenzUtils.noTradeMode) {
ChatUtils.chat("You're out of $itemName §ein your sacks!")
} else {
ChatUtils.clickableChat(
"You're out of $itemName §ein your sacks! Click here to buy more on the Bazaar!",
- "bz ${itemName.removeColor()}"
+ onClick = {
+ HypixelCommands.bazaar(itemName.removeColor())
+ }
)
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestSpawn.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestSpawn.kt
index b8ef8a2d7..acf23f51b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestSpawn.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestSpawn.kt
@@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.garden.pests.PestSpawnEvent
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.ConfigUtils
+import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
@@ -119,7 +120,7 @@ class PestSpawn {
PestSpawnEvent(amount, plotNames, unknownAmount).postAndCatch()
if (unknownAmount) return // todo make this work with offline pest spawn messages
- val plotName = plotNames.firstOrNull()
+ val plotName = plotNames.firstOrNull() ?: error("first plot name is null")
val pestName = StringUtils.pluralize(amount, "Pest")
val message = "§e$amount §a$pestName Spawned in §b$plotName§a!"
@@ -128,7 +129,9 @@ class PestSpawn {
}
if (config.chatMessageFormat == PestSpawnConfig.ChatMessageFormatEntry.COMPACT) {
- ChatUtils.clickableChat(message, "tptoplot $plotName")
+ ChatUtils.clickableChat(message, onClick = {
+ HypixelCommands.teleportToPlot(plotName)
+ })
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt
index 24b073d30..5d976a7dd 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt
@@ -10,7 +10,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.features.dungeon.DungeonAPI
import at.hannibal2.skyhanni.test.command.ErrorManager
-import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.InventoryUtils.getAllItems
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
@@ -61,7 +61,7 @@ class BazaarApi {
if (NEUItems.neuHasFocus()) return
if (LorenzUtils.noTradeMode) return
if (DungeonAPI.inDungeon() || LorenzUtils.inKuudraFight) return
- ChatUtils.sendCommandToServer("bz ${displayName.removeColor()}")
+ HypixelCommands.bazaar(displayName.removeColor())
if (amount != -1) OSUtils.copyToClipboard(amount.toString())
currentSearchedItem = displayName.removeColor()
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/tiarelay/TiaRelayHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/tiarelay/TiaRelayHelper.kt
index fd4240f10..cdd5163b5 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/tiarelay/TiaRelayHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/tiarelay/TiaRelayHelper.kt
@@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.PlaySoundEvent
import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.CollectionUtils.sorted
+import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzUtils
@@ -74,7 +75,9 @@ class TiaRelayHelper {
for (sound in sounds.toMutableMap()) {
if (sound.value.name != name) {
ChatUtils.error("Tia Relay Helper error: Too much background noise! Try turning off the music and then try again.")
- ChatUtils.clickableChat("Click here to run /togglemusic", "togglemusic")
+ ChatUtils.clickableChat("Click here to run /togglemusic", onClick = {
+ HypixelCommands.toggleMusic()
+ })
sounds.clear()
return
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/JoinCrystalHollows.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/JoinCrystalHollows.kt
index c1bbb347a..f0cf94264 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/JoinCrystalHollows.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/JoinCrystalHollows.kt
@@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.LorenzVec
@@ -25,13 +26,18 @@ class JoinCrystalHollows {
if (message == "§cYou do not have an active Crystal Hollows pass!") {
lastWrongPassTime = System.currentTimeMillis()
if (!IslandType.DWARVEN_MINES.isInIsland()) {
- ChatUtils.clickableChat("Click here to warp to Dwarven Mines!", "warp mines")
+ ChatUtils.clickableChat("Click here to warp to Dwarven Mines!",
+ onClick = {
+ HypixelCommands.warp("mines")
+ })
} else {
ChatUtils.chat("Buy a §2Crystal Hollows Pass §efrom §5Gwendolyn")
}
}
if (message == "§e[NPC] §5Gwendolyn§f: §rGreat! Now hop on into the Minecart and I'll get you on your way!" && inTime()) {
- ChatUtils.clickableChat("Click here to warp to Crystal Hollows!", "warp ch")
+ ChatUtils.clickableChat("Click here to warp to Crystal Hollows!", onClick = {
+ HypixelCommands.warp("ch")
+ })
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/NoBitsWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/NoBitsWarning.kt
index fbaba9095..66ac97792 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/NoBitsWarning.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NoBitsWarning.kt
@@ -1,10 +1,10 @@
package at.hannibal2.skyhanni.features.misc
-import akka.event.NoLogging.isWarningEnabled
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.events.BitsUpdateEvent
import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.SoundUtils
@@ -22,7 +22,9 @@ object NoBitsWarning {
ChatUtils.clickableChat(
"§bNo Bits Available! §eClick to run /bz booster cookie.",
- "bz booster cookie"
+ onClick = {
+ HypixelCommands.bazaar("booster cookie")
+ }
)
LorenzUtils.sendTitle("§bNo Bits Available", 5.seconds)
if (config.notificationSound) SoundUtils.repeatSound(100, 10, createSound("note.pling", 0.6f))
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt
index 0e3bb13ba..b855a49c8 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt
@@ -19,6 +19,7 @@ import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha
import at.hannibal2.skyhanni.utils.ConfigUtils
import at.hannibal2.skyhanni.utils.EntityUtils
+import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzColor
@@ -294,7 +295,7 @@ object TrevorFeatures {
}
if (config.warpToTrapper && timeLastWarped.passedSince() > 3.seconds && teleportBlock.passedSince() > 5.seconds) {
- ChatUtils.sendCommandToServer("warp trapper")
+ HypixelCommands.warp("trapper")
timeLastWarped = SimpleTimeMark.now()
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/PabloHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/PabloHelper.kt
index a65d5d030..fb876278c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/nether/PabloHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/PabloHelper.kt
@@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
@@ -34,7 +35,9 @@ class PabloHelper {
if (InventoryUtils.countItemsInLowerInventory { it.name.contains(itemName) } > 0) return
- ChatUtils.clickableChat("Click here to grab an $itemName from sacks!", "gfs $itemName 1")
+ ChatUtils.clickableChat("Click here to grab an $itemName from sacks!", onClick = {
+ HypixelCommands.getFromSacks(itemName, 1)
+ })
lastSentMessage = SimpleTimeMark.now()
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt
index 88d90c381..30ad1b728 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt
@@ -139,6 +139,7 @@ object ChatUtils {
* @see CHAT_PREFIX
*/
//TODO rename to runHypixelCommand
+ @Deprecated("Use clickableChat with onClick or use HypixelCommands", ReplaceWith(""))
fun clickableChat(message: String, command: String, prefix: Boolean = true, prefixColor: String = "§e") {
val msgPrefix = if (prefix) prefixColor + CHAT_PREFIX else ""
val fullMessage = msgPrefix + message
@@ -146,7 +147,7 @@ object ChatUtils {
internalChat(createClickableChat(fullMessage, command))
}
- fun createClickableChat(message: String, command: String): ChatComponentText {
+ private fun createClickableChat(message: String, command: String): ChatComponentText {
val text = ChatComponentText(message)
val fullCommand = "/" + command.removePrefix("/")
text.chatStyle.chatClickEvent = ClickEvent(ClickEvent.Action.RUN_COMMAND, fullCommand)
@@ -171,7 +172,7 @@ object ChatUtils {
onClick: () -> Any,
expireAt: SimpleTimeMark = SimpleTimeMark.farFuture(),
prefix: Boolean = true,
- prefixColor: String = "§e"
+ prefixColor: String = "§e",
) {
val msgPrefix = if (prefix) prefixColor + CHAT_PREFIX else ""
ChatClickActionManager.oneTimeClick(msgPrefix + message, onClick, expireAt)
@@ -290,6 +291,7 @@ object ChatUtils {
sendQueue.add(message)
}
+ @Deprecated("use HypixelCommands instead", ReplaceWith(""))
fun sendCommandToServer(command: String) {
if (command.startsWith("/")) {
debug("Sending wrong command to server? ($command)")
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/HypixelCommands.kt b/src/main/java/at/hannibal2/skyhanni/utils/HypixelCommands.kt
new file mode 100644
index 000000000..5507f4b99
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/utils/HypixelCommands.kt
@@ -0,0 +1,54 @@
+package at.hannibal2.skyhanni.utils
+
+object HypixelCommands {
+
+ fun bazaar(searchTerm: String) {
+ send("bz $searchTerm")
+ }
+
+ fun warp(warp: String) {
+ send("warp $warp")
+ }
+
+ fun teleportToPlot(plotName: String) {
+ send("tptoplot $plotName")
+ }
+
+ fun getFromSacks(itemName: String, amount: Int) {
+ send("gfs $itemName $amount")
+ }
+
+ fun widget() {
+ send("widget")
+ }
+
+ fun chocolateFactory() {
+ send("cf")
+ }
+
+ fun openBaker() {
+ send("openbaker")
+ }
+
+ fun gardenLevels() {
+ send("gardenlevels")
+ }
+
+ fun calendar() {
+ send("calendar")
+ }
+
+ fun sacks() {
+ send("sax")
+ }
+
+ fun toggleMusic() {
+ send("togglemusic")
+ }
+
+ private fun send(command: String) {
+ @Suppress("DEPRECATION")
+ // TODO rename function
+ ChatUtils.sendCommandToServer(command)
+ }
+}