summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/commands
diff options
context:
space:
mode:
authorJordan <77755681+Jordyrat@users.noreply.github.com>2024-08-31 21:50:16 +0100
committerGitHub <noreply@github.com>2024-08-31 22:50:16 +0200
commit755a36d801e29a3c517e9c7abbf4ef6b016b026a (patch)
tree4840b326a24f8a0d9d957c0c0713930103548bba /src/main/java/at/hannibal2/skyhanni/features/commands
parent79d891d5a3e1bffd31491a921757ccf7ab66b5fe (diff)
downloadskyhanni-755a36d801e29a3c517e9c7abbf4ef6b016b026a.tar.gz
skyhanni-755a36d801e29a3c517e9c7abbf4ef6b016b026a.tar.bz2
skyhanni-755a36d801e29a3c517e9c7abbf4ef6b016b026a.zip
Feature: Reverse Party Transfer (#1712)
Co-authored-by: BuildTools <unconfigured@null.spigotmc.org> Co-authored-by: Cal <cwolfson58@gmail.com> Co-authored-by: hannibal2 <24389977+hannibal00212@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.kt48
1 files changed, 44 insertions, 4 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 c60c84ae5..e7b3333dd 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt
@@ -4,11 +4,20 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.data.FriendAPI
import at.hannibal2.skyhanni.data.PartyAPI
+import at.hannibal2.skyhanni.data.PartyAPI.partyLeader
+import at.hannibal2.skyhanni.data.PartyAPI.transferVoluntaryPattern
+import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.MessageSendToServerEvent
import at.hannibal2.skyhanni.features.misc.limbo.LimboTimeTracker
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
+import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.HypixelCommands
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.RegexUtils.matches
+import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import at.hannibal2.skyhanni.utils.StringUtils.trimWhiteSpace
+import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@SkyHanniModule
@@ -67,14 +76,29 @@ object PartyCommands {
HypixelCommands.partyPromote(args[0])
}
+ fun reverseTransfer() {
+ if (!config.reversePT.command) return
+ if (PartyAPI.partyMembers.isEmpty()) return
+ val prevPartyLeader = PartyAPI.prevPartyLeader ?: return
+
+ autoPartyTransfer(prevPartyLeader)
+ }
+
+ private fun autoPartyTransfer(prevPartyLeader: String) {
+ HypixelCommands.partyTransfer(prevPartyLeader)
+ config.reversePT.message?.let {
+ if (it.isNotBlank()) {
+ HypixelCommands.partyChat(it)
+ }
+ }
+ }
+
@SubscribeEvent
fun onMessageSendToServer(event: MessageSendToServerEvent) {
if (!config.partyKickReason) {
return
}
- if (!event.message.startsWith("/party kick ", ignoreCase = true)
- && !event.message.startsWith("/p kick ", ignoreCase = true)
- ) {
+ if (!event.message.startsWith("/party kick ", ignoreCase = true) && !event.message.startsWith("/p kick ", ignoreCase = true)) {
return
}
val args = event.message.substringAfter("kick").trim().split(" ")
@@ -116,6 +140,22 @@ object PartyCommands {
event.move(31, "commands", "misc.commands")
}
+
+ @SubscribeEvent(priority = EventPriority.LOW)
+ fun onChat(event: LorenzChatEvent) {
+ if (!config.reversePT.clickable) return
+ if (!transferVoluntaryPattern.matches(event.message.trimWhiteSpace().removeColor())) return
+ if (partyLeader != LorenzUtils.getPlayerName()) return
+
+ val prevPartyLeader = PartyAPI.prevPartyLeader ?: return
+ event.blockedReason = "replacing"
+
+ ChatUtils.clickableChat(
+ event.message,
+ onClick = { autoPartyTransfer(prevPartyLeader) },
+ prefix = false,
+ )
+ }
}
private val otherPartyCommands = listOf(
@@ -126,5 +166,5 @@ private val otherPartyCommands = listOf(
"Mute",
"Private",
"Warp",
- "Settings"
+ "Settings",
)