aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/commands
diff options
context:
space:
mode:
authorEmpa <42304516+ItsEmpa@users.noreply.github.com>2024-05-26 14:57:16 +0200
committerGitHub <noreply@github.com>2024-05-26 14:57:16 +0200
commit29657e24412baa7be9a1681593593368f92de26f (patch)
tree70d669a42b88fdc5df0fbad6313bcffdd1b9b5c0 /src/main/java/at/hannibal2/skyhanni/features/commands
parent0ddd9edc94bc0c872109acd0b845163b073ceb6a (diff)
downloadskyhanni-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/commands')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt34
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/commands/SendCoordinatedCommand.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/commands/WarpIsCommand.kt4
4 files changed, 31 insertions, 26 deletions
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()
}
}
}