aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
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/skyhanni/utils
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/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt27
1 files changed, 21 insertions, 6 deletions
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