aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-01-18 16:50:17 +0100
committerGitHub <noreply@github.com>2024-01-18 16:50:17 +0100
commit9827e764ea8e686d8e0a7b1d5b320da7ce85c227 (patch)
tree8070b2e83b9e8bd88362c2bef0fa706802644f5e /src/main/java/at/hannibal2
parentff75f3d0da65a06e9bde3afccb898326186c5317 (diff)
downloadskyhanni-9827e764ea8e686d8e0a7b1d5b320da7ce85c227.tar.gz
skyhanni-9827e764ea8e686d8e0a7b1d5b320da7ce85c227.tar.bz2
skyhanni-9827e764ea8e686d8e0a7b1d5b320da7ce85c227.zip
feat: Party kick with reason (#874)
Party kick with reason #874
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/commands/CommandsConfig.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt22
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt27
4 files changed, 51 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 3685ba22f..c1ef48932 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -343,6 +343,7 @@ import at.hannibal2.skyhanni.test.WorldEdit
import at.hannibal2.skyhanni.test.command.CopyNearbyParticlesCommand
import at.hannibal2.skyhanni.utils.EntityOutlineRenderer
import at.hannibal2.skyhanni.utils.KeyboardManager
+import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.MinecraftConsoleFilter.Companion.initLogging
import at.hannibal2.skyhanni.utils.NEUVersionCheck.checkIfNeuIsLoaded
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils
@@ -445,6 +446,7 @@ class SkyHanniMod {
loadModule(SackAPI)
loadModule(BingoAPI)
loadModule(FishingAPI)
+ loadModule(LorenzUtils)
// features
loadModule(BazaarOrderHelper())
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/commands/CommandsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/commands/CommandsConfig.java
index 777d543a3..f6ff5ade2 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/commands/CommandsConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/commands/CommandsConfig.java
@@ -25,6 +25,12 @@ public class CommandsConfig {
@FeatureToggle
public boolean shortCommands = true;
+ @ConfigOption(name = "Party Kick Reason", desc = "Kick people while sending a reason when using §e/pk lrg89 Dupe Archer§7 or §e/party kick nea89o Low Cata Level§7.")
+ @Expose
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean partyKickReason = true;
+
@Expose
@ConfigOption(name = "Replace Warp Is", desc = "Adds §e/warp is §7alongside §e/is§7. Idk why. Ask §cKaeso")
@ConfigEditorBoolean
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 fea58deef..79df780db 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt
@@ -4,6 +4,7 @@ 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.events.MessageSendToServerEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -26,6 +27,8 @@ object PartyCommands {
if (!config.shortCommands) return
if (PartyAPI.partyMembers.isEmpty()) return
if (args.isEmpty()) return
+ if (args.size > 1 && config.partyKickReason)
+ LorenzUtils.sendCommandToServer("pc Kicking ${args[0]}: ${args.drop(1).joinToString(" ").trim()}")
LorenzUtils.sendCommandToServer("party kick ${args[0]}")
}
@@ -46,6 +49,25 @@ object PartyCommands {
LorenzUtils.sendCommandToServer("party promote ${args[0]}")
}
+ @SubscribeEvent
+ fun onSendCommand(event: MessageSendToServerEvent) {
+ if (!config.partyKickReason) {
+ return
+ }
+ if (!event.message.startsWith("/party kick ", ignoreCase = true)
+ && !event.message.startsWith("/p kick ", ignoreCase = true)) {
+ return
+ }
+ val args = event.message.split(" ")
+ if (args.size < 3) return
+ val kickedPlayer = args[2]
+ val kickReason = args.drop(3).joinToString(" ").trim()
+ if (kickReason.isEmpty()) return
+ event.cancel()
+ LorenzUtils.sendCommandToServer("pc Kicking $kickedPlayer: $kickReason")
+ LorenzUtils.sendCommandToServer("p kick $kickedPlayer")
+ }
+
fun customTabComplete(command: String): List<String>? {
if (command == "pk" || command == "pt" || command == "pp" && config.shortCommands) {
return PartyAPI.partyMembers
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index c86dd3688..9e8fc6b8e 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.HypixelData
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.MayorElection
import at.hannibal2.skyhanni.data.TitleManager
+import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.features.dungeon.DungeonAPI
import at.hannibal2.skyhanni.mixins.transformers.AccessorGuiEditSign
import at.hannibal2.skyhanni.test.TestBingo
@@ -26,6 +27,7 @@ import net.minecraft.event.HoverEvent
import net.minecraft.launchwrapper.Launch
import net.minecraft.util.ChatComponentText
import net.minecraftforge.fml.common.FMLCommonHandler
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.awt.Color
import java.lang.reflect.Constructor
import java.lang.reflect.Field
@@ -34,6 +36,8 @@ import java.text.DecimalFormat
import java.text.NumberFormat
import java.text.SimpleDateFormat
import java.util.Collections
+import java.util.LinkedList
+import java.util.Queue
import java.util.Timer
import java.util.TimerTask
import java.util.WeakHashMap
@@ -48,6 +52,7 @@ import kotlin.reflect.full.memberProperties
import kotlin.reflect.full.starProjectedType
import kotlin.reflect.jvm.isAccessible
import kotlin.time.Duration
+import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.seconds
object LorenzUtils {
@@ -371,18 +376,28 @@ object LorenzUtils {
return this
}
- private var lastMessageSent = 0L
+ private var lastMessageSent = SimpleTimeMark.farPast()
+ private val sendQueue: Queue<String> = LinkedList()
+
+ @SubscribeEvent
+ fun sendQueuedChatMessages(event: LorenzTickEvent) {
+ val player = Minecraft.getMinecraft().thePlayer
+ if (player == null) {
+ sendQueue.clear()
+ return
+ }
+ if (lastMessageSent.passedSince() > 300.milliseconds) {
+ player.sendChatMessage(sendQueue.poll() ?: return)
+ lastMessageSent = SimpleTimeMark.now()
+ }
+ }
fun sendCommandToServer(command: String) {
sendMessageToServer("/$command")
}
fun sendMessageToServer(message: String) {
- if (System.currentTimeMillis() > lastMessageSent + 1_000) {
- lastMessageSent = System.currentTimeMillis()
- val thePlayer = Minecraft.getMinecraft().thePlayer
- thePlayer.sendChatMessage(message)
- }
+ sendQueue.add(message)
}
// MoulConfig is in Java, I don't want to downgrade this logic