diff options
author | Empa <42304516+ItsEmpa@users.noreply.github.com> | 2024-05-26 14:57:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-26 14:57:16 +0200 |
commit | 29657e24412baa7be9a1681593593368f92de26f (patch) | |
tree | 70d669a42b88fdc5df0fbad6313bcffdd1b9b5c0 /src/main/java/at/hannibal2/skyhanni/features | |
parent | 0ddd9edc94bc0c872109acd0b845163b073ceb6a (diff) | |
download | skyhanni-29657e24412baa7be9a1681593593368f92de26f.tar.gz skyhanni-29657e24412baa7be9a1681593593368f92de26f.tar.bz2 skyhanni-29657e24412baa7be9a1681593593368f92de26f.zip |
Backend: Use HypixelCommands (#1769)
Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
13 files changed, 50 insertions, 43 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardDisplay.kt index 1140379b6..b00b88569 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardDisplay.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.features.bingo.card.goals.BingoGoal import at.hannibal2.skyhanni.features.bingo.card.nextstephelper.BingoNextStepHelper import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle +import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.LorenzUtils @@ -87,7 +88,7 @@ class BingoCardDisplay { newList.add(Renderable.clickAndHover("§cOpen the §e/bingo §ccard.", listOf("Click to run §e/bingo"), onClick = { - ChatUtils.sendCommandToServer("bingo") + HypixelCommands.bingo() } )) } else { diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt index b323bb73d..3f2580465 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt @@ -6,8 +6,8 @@ import at.hannibal2.skyhanni.data.FriendAPI import at.hannibal2.skyhanni.data.PartyAPI import at.hannibal2.skyhanni.events.MessageSendToServerEvent import at.hannibal2.skyhanni.features.misc.limbo.LimboTimeTracker -import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.EntityUtils +import at.hannibal2.skyhanni.utils.HypixelCommands import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object PartyCommands { @@ -17,29 +17,31 @@ object PartyCommands { fun kickOffline() { if (!config.shortCommands) return if (PartyAPI.partyMembers.isEmpty()) return - ChatUtils.sendCommandToServer("party kickoffline") + HypixelCommands.partyKickOffline() } fun disband() { if (!config.shortCommands) return if (PartyAPI.partyMembers.isEmpty()) return - ChatUtils.sendCommandToServer("party disband") + HypixelCommands.partyDisband() } fun warp() { if (!config.shortCommands) return if (PartyAPI.partyMembers.isEmpty()) return - ChatUtils.sendCommandToServer("party warp") + HypixelCommands.partyWarp() } fun kick(args: Array<String>) { if (!config.shortCommands) return if (PartyAPI.partyMembers.isEmpty()) return if (args.isEmpty()) return - if (args.size > 1 && config.partyKickReason) { - ChatUtils.sendCommandToServer("pc Kicking ${args[0]}: ${args.drop(1).joinToString(" ").trim()}") + val kickedPlayer = args[0] + val kickedReason = args.drop(1).joinToString(" ").trim() + if (kickedReason.isNotEmpty() && config.partyKickReason) { + HypixelCommands.partyChat("Kicking $kickedPlayer: $kickedReason") } - ChatUtils.sendCommandToServer("party kick ${args[0]}") + HypixelCommands.partyKick(kickedPlayer) } fun transfer(args: Array<String>) { @@ -48,19 +50,19 @@ object PartyCommands { LimboTimeTracker.printStats(true) return } - ChatUtils.sendCommandToServer("pt") + HypixelCommands.playtime() return } if (!config.shortCommands) return if (PartyAPI.partyMembers.isEmpty()) return - ChatUtils.sendCommandToServer("party transfer ${args[0]}") + HypixelCommands.partyTransfer(args[0]) } fun promote(args: Array<String>) { if (!config.shortCommands) return if (PartyAPI.partyMembers.isEmpty()) return if (args.isEmpty()) return - ChatUtils.sendCommandToServer("party promote ${args[0]}") + HypixelCommands.partyPromote(args[0]) } @SubscribeEvent @@ -73,14 +75,14 @@ object PartyCommands { ) { return } - val args = event.message.split(" ") - if (args.size < 3) return - val kickedPlayer = args[2] - val kickReason = args.drop(3).joinToString(" ").trim() + val args = event.message.substringAfter("kick").trim().split(" ") + if (args.isEmpty()) return + val kickedPlayer = args[0] + val kickReason = args.drop(1).joinToString(" ").trim() if (kickReason.isEmpty()) return event.cancel() - ChatUtils.sendCommandToServer("pc Kicking $kickedPlayer: $kickReason") - ChatUtils.sendCommandToServer("p kick $kickedPlayer") + HypixelCommands.partyChat("Kicking $kickedPlayer: $kickReason") + HypixelCommands.partyKick(kickedPlayer) } fun customTabComplete(command: String): List<String>? { diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/SendCoordinatedCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/SendCoordinatedCommand.kt index 555ed38ee..70b94c795 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/SendCoordinatedCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/SendCoordinatedCommand.kt @@ -10,16 +10,17 @@ class SendCoordinatedCommand { @SubscribeEvent fun onMessageSendToServer(event: MessageSendToServerEvent) { val message = event.message - if (message == "/sendcoords") { + if (message.startsWith("/sendcoords")) { event.isCanceled = true - ChatUtils.sendMessageToServer(getCoordinates()) - } else if (message.startsWith("/sendcoords ")) { - event.isCanceled = true - val description = message.split(" ").drop(1).joinToString(" ") - ChatUtils.sendMessageToServer("${getCoordinates()} $description") + val description = message.substringAfter("/sendcoords").trim() + sendCoordinates(description) } } + private fun sendCoordinates(description: String) { + ChatUtils.sendMessageToServer(getCoordinates() + " $description") + } + private fun getCoordinates(): String { val location = LocationUtils.playerLocation() val x = location.x.toInt() diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt index 204c39eaa..fbfb1a640 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt @@ -2,7 +2,7 @@ package at.hannibal2.skyhanni.features.commands import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.MessageSendToServerEvent -import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.NEUItems import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -17,8 +17,10 @@ object ViewRecipeCommand { if (!message.startsWith("/viewrecipe ", ignoreCase = true)) return if (message == message.uppercase()) return + val item = message.uppercase().substringAfter("viewrecipe").trim() + if (item.isEmpty()) return event.isCanceled = true - ChatUtils.sendCommandToServer(message.uppercase().drop(1)) + HypixelCommands.viewRecipe(item) } val list by lazy { diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/WarpIsCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/WarpIsCommand.kt index 7d46dbec5..0401c0edb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/WarpIsCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/WarpIsCommand.kt @@ -2,7 +2,7 @@ package at.hannibal2.skyhanni.features.commands import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.MessageSendToServerEvent -import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -15,7 +15,7 @@ class WarpIsCommand { if (event.message.lowercase() == "/warp is") { event.isCanceled = true - ChatUtils.sendCommandToServer("is") + HypixelCommands.island() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt index 5a30c763e..c8f7fc240 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.EntityUtils +import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.KeyboardManager import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzUtils @@ -211,7 +212,7 @@ object InquisitorWaypointShare { return } inquisitor = -1 - ChatUtils.sendCommandToServer("pc Inquisitor dead!") + HypixelCommands.partyChat("Inquisitor dead!") } fun sendInquisitor() { @@ -238,7 +239,7 @@ object InquisitorWaypointShare { val x = location.x.toInt() val y = location.y.toInt() val z = location.z.toInt() - ChatUtils.sendCommandToServer("pc x: $x, y: $y, z: $z ") + HypixelCommands.partyChat("x: $x, y: $y, z: $z ") } @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) 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 26490ff8e..54804cf06 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenWarpCommands.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenWarpCommands.kt @@ -65,7 +65,7 @@ class GardenWarpCommands { } config.sethomeHotkey -> { - ChatUtils.sendCommandToServer("sethome") + HypixelCommands.setHome() } config.barnHotkey -> { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt index 1ac97f080..d60ed737b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt @@ -16,6 +16,7 @@ import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.renderPlot import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.sendTeleportTo 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.LorenzVec import at.hannibal2.skyhanni.utils.NEUItems @@ -81,7 +82,7 @@ object PestFinder { "Runs /desk." ), onClick = { - ChatUtils.sendCommandToServer("desk") + HypixelCommands.gardenDesk() } )) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorSupercraft.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorSupercraft.kt index e64e0c76b..8fe8bee3c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorSupercraft.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorSupercraft.kt @@ -5,7 +5,7 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorOpenEvent import at.hannibal2.skyhanni.test.command.ErrorManager -import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.ItemUtils.itemName import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName @@ -107,7 +107,7 @@ class GardenVisitorSupercraft { if (event.slotId != 31) return event.isCanceled = true if (lastClick.passedSince() > 0.3.seconds) { - ChatUtils.sendCommandToServer("recipe $lastSuperCraftMaterial") + HypixelCommands.recipe(lastSuperCraftMaterial) lastClick = SimpleTimeMark.now() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt index 0fd4f60ad..e06e7975c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt @@ -5,7 +5,7 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent -import at.hannibal2.skyhanni.utils.ChatUtils +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.ItemUtils.name @@ -142,7 +142,7 @@ class SkyblockGuideHighlightFeature private constructor( private val openWikiOnClick: (GuiContainerEvent.SlotClickEvent) -> Unit = { event -> val internalName = event.item?.getInternalName() if (internalName != null) { - ChatUtils.sendCommandToServer("wiki ${internalName.asString()}") + HypixelCommands.wiki(internalName.asString()) } } @@ -172,7 +172,7 @@ class SkyblockGuideHighlightFeature private constructor( "travel", "Core ➜ Fast Travels Unlocked", taskOnlyCompleteOncePattern, - { ChatUtils.sendCommandToServer("wiki MUSEUM_TRAVEL_SCROLL") }, // The items do not have proper internal names and using the fact that all travel scrolls lead to the same wiki page + { HypixelCommands.wiki("MUSEUM_TRAVEL_SCROLL") }, // The items do not have proper internal names and using the fact that all travel scrolls lead to the same wiki page openWikiTooltip ) SkyblockGuideHighlightFeature( diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/TunnelsMaps.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/TunnelsMaps.kt index 546c5a7d8..3a9f26cf0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/TunnelsMaps.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/TunnelsMaps.kt @@ -17,12 +17,12 @@ import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.events.LorenzWarpEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.test.command.ErrorManager -import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.filterNotNullKeys import at.hannibal2.skyhanni.utils.ColorUtils.getFirstColorCode import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle import at.hannibal2.skyhanni.utils.DelayedRun +import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.itemName import at.hannibal2.skyhanni.utils.LocationUtils @@ -421,7 +421,7 @@ class TunnelsMaps { private fun campfireKey(event: LorenzKeyPressEvent) { if (event.keyCode != config.campfireKey) return if (config.travelScroll) { - ChatUtils.sendMessageToServer("/warp basecamp") + HypixelCommands.warp("basecamp") } else { campfireOverride() } 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 27ea2bb4c..86ce497fe 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 @@ -15,7 +15,6 @@ import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled -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 @@ -174,7 +173,7 @@ object TrevorFeatures { event.chatComponent.siblings.forEach { sibling -> if (sibling.chatStyle.chatClickEvent != null && sibling.chatStyle.chatClickEvent.value.contains("YES")) { lastChatPromptTime = SimpleTimeMark.now() - lastChatPrompt = sibling.chatStyle.chatClickEvent.value.drop(1) + lastChatPrompt = sibling.chatStyle.chatClickEvent.value.substringAfter(" ") } } } @@ -293,7 +292,7 @@ object TrevorFeatures { val timeSince = lastChatPromptTime.passedSince() if (timeSince > 200.milliseconds && timeSince < 5.seconds) { lastChatPromptTime = SimpleTimeMark.farPast() - ChatUtils.sendCommandToServer(lastChatPrompt) + HypixelCommands.chatPrompt(lastChatPrompt) lastChatPrompt = "" timeLastWarped = SimpleTimeMark.now() return diff --git a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt index adf2e1099..fe6d3e4a1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt @@ -15,9 +15,9 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.SkillOverflowLevelupEvent import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.XP_NEEDED_FOR_60 -import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ChatUtils.chat import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle +import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble @@ -287,7 +287,7 @@ object SkillProgress { Renderable.clickAndHover( "§cOpen your skills menu!", listOf("§eClick here to execute §6/skills"), - onClick = { ChatUtils.sendCommandToServer("skills") } + onClick = { HypixelCommands.skills() } ) } else { val tips = buildList { |