aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/dulkirmod/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/dulkirmod/features')
-rw-r--r--src/main/kotlin/dulkirmod/features/ArachneTimer.kt11
-rw-r--r--src/main/kotlin/dulkirmod/features/MatchoAlert.kt8
-rw-r--r--src/main/kotlin/dulkirmod/features/chat/AbiphoneDND.kt72
-rw-r--r--src/main/kotlin/dulkirmod/features/chat/FakeMsg.kt15
-rw-r--r--src/main/kotlin/dulkirmod/features/chat/ThrottleNotif.kt11
-rw-r--r--src/main/kotlin/dulkirmod/features/chat/VanquisherTrigger.kt4
6 files changed, 51 insertions, 70 deletions
diff --git a/src/main/kotlin/dulkirmod/features/ArachneTimer.kt b/src/main/kotlin/dulkirmod/features/ArachneTimer.kt
index 9089f5c..a4cfa1a 100644
--- a/src/main/kotlin/dulkirmod/features/ArachneTimer.kt
+++ b/src/main/kotlin/dulkirmod/features/ArachneTimer.kt
@@ -1,11 +1,9 @@
package dulkirmod.features
-import dulkirmod.DulkirMod
-import dulkirmod.DulkirMod.Companion.mc
import dulkirmod.config.Config
+import dulkirmod.utils.TextUtils
import dulkirmod.utils.Utils
import dulkirmod.utils.WorldRenderUtils
-import net.minecraft.util.ChatComponentText
import net.minecraft.util.Vec3
import net.minecraftforge.client.event.ClientChatReceivedEvent
import net.minecraftforge.client.event.RenderWorldLastEvent
@@ -22,7 +20,7 @@ class ArachneTimer {
fun onChat(event: ClientChatReceivedEvent) {
if (!Config.arachneKillTimer) return
- var killtime: Float = -1f;
+ var killtime: Float = -1f
if (event.type == 2.toByte()) {
return
@@ -41,10 +39,7 @@ class ArachneTimer {
endmillis = System.currentTimeMillis()
if (startmillis > -1) {
killtime = (endmillis - startmillis).toFloat() / 1000
-
- mc.thePlayer.addChatMessage(
- ChatComponentText(" ${DulkirMod.CHAT_PREFIX} §6Arachne took §7$killtime §6seconds to kill.")
- )
+ TextUtils.info("§6Arachne took §7$killtime §6seconds to kill.")
}
}
}
diff --git a/src/main/kotlin/dulkirmod/features/MatchoAlert.kt b/src/main/kotlin/dulkirmod/features/MatchoAlert.kt
index f713372..c140036 100644
--- a/src/main/kotlin/dulkirmod/features/MatchoAlert.kt
+++ b/src/main/kotlin/dulkirmod/features/MatchoAlert.kt
@@ -5,7 +5,7 @@ import dulkirmod.config.Config
import dulkirmod.utils.TabListUtils
import dulkirmod.utils.Utils
-class MatchoAlert() {
+class MatchoAlert {
var hasSentAlert = false
@@ -26,16 +26,16 @@ class MatchoAlert() {
DulkirMod.titleUtils.drawStringForTime("${color}Matcho", 5000)
if (Config.bestiaryAlertSounds)
DulkirMod.mc.thePlayer.playSound("mob.villager.yes", 1f * Config.bestiaryNotifVol, 0f)
- hasSentAlert = true;
+ hasSentAlert = true
} else if (s == " INACTIVE") hasSentAlert = false
- break;
+ break
}
if (s == "Volcano Explosivity:")
explo = true
if (s != null) {
if (s.contains("Area:") && !s.contains("Crimson Isle")) {
hasSentAlert = false
- break;
+ break
}
}
}
diff --git a/src/main/kotlin/dulkirmod/features/chat/AbiphoneDND.kt b/src/main/kotlin/dulkirmod/features/chat/AbiphoneDND.kt
index 9212bbd..a6a0ab6 100644
--- a/src/main/kotlin/dulkirmod/features/chat/AbiphoneDND.kt
+++ b/src/main/kotlin/dulkirmod/features/chat/AbiphoneDND.kt
@@ -1,8 +1,7 @@
package dulkirmod.features.chat
-import dulkirmod.DulkirMod
import dulkirmod.config.Config
-import net.minecraft.util.ChatComponentText
+import dulkirmod.utils.TextUtils
import net.minecraftforge.client.event.ClientChatReceivedEvent
import net.minecraftforge.client.event.sound.PlaySoundEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
@@ -12,44 +11,35 @@ private val abiphoneFormat = "✆ (\\w+) ✆ ".toRegex()
private var lastRing: Long = 0
class AbiphoneDND {
- //BLOCK ABIPHONE SOUNDS
- @SubscribeEvent(receiveCanceled = false, priority = EventPriority.LOW)
- fun onSound(event: PlaySoundEvent) {
- if (!Config.abiDND) return
- if (System.currentTimeMillis() - lastRing < 5000) {
- if (event.name == "note.pling" && event.sound.volume == 0.69f && event.sound.pitch == 1.6666666f) {
- // This throws an error but still blocks the sound. Not a great solution, but it works for now
- try {
- event.isCanceled = true
- } catch (ignored: IllegalArgumentException) {
- }
- }
- }
- }
+ //BLOCK ABIPHONE SOUNDS
+ @SubscribeEvent(receiveCanceled = false, priority = EventPriority.LOW)
+ fun onSound(event: PlaySoundEvent) {
+ if (!Config.abiDND) return
+ if (System.currentTimeMillis() - lastRing < 5000) {
+ if (event.name == "note.pling" && event.sound.volume == 0.69f && event.sound.pitch == 1.6666666f) {
+ event.result = null
+ }
+ }
+ }
- companion object {
- fun handle(event: ClientChatReceivedEvent, unformatted: String) {
- if (!Config.abiDND) return
- if (unformatted matches abiphoneFormat) {
- val matchResult = abiphoneFormat.find(unformatted)
- event.isCanceled = true;
- lastRing = System.currentTimeMillis()
- if (Config.abiCallerID) {
- DulkirMod.mc.thePlayer.addChatMessage(
- ChatComponentText(
- "${DulkirMod.CHAT_PREFIX} §6Call blocked from ${
- if (Math.random() < .001) "Breefing"
- else matchResult?.groups?.get(1)?.value
- }!"
- )
- )
- }
- }
- if (unformatted.startsWith("✆ Ring...") && unformatted.endsWith("[PICK UP]")
- && System.currentTimeMillis() - lastRing < 5000
- ) {
- event.isCanceled = true;
- }
- }
- }
+ companion object {
+ fun handle(event: ClientChatReceivedEvent, unformatted: String) {
+ if (!Config.abiDND) return
+ if (unformatted matches abiphoneFormat) {
+ val matchResult = abiphoneFormat.find(unformatted)
+ event.isCanceled = true
+ lastRing = System.currentTimeMillis()
+ if (Config.abiCallerID) {
+ val blocked = if (Math.random() < .001) "Breefing"
+ else matchResult?.groups?.get(1)?.value
+ TextUtils.info("§6Call blocked from $blocked!")
+ }
+ }
+ if (unformatted.startsWith("✆ Ring...") && unformatted.endsWith("[PICK UP]")
+ && System.currentTimeMillis() - lastRing < 5000
+ ) {
+ event.isCanceled = true
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/src/main/kotlin/dulkirmod/features/chat/FakeMsg.kt b/src/main/kotlin/dulkirmod/features/chat/FakeMsg.kt
index f73572e..e1b618f 100644
--- a/src/main/kotlin/dulkirmod/features/chat/FakeMsg.kt
+++ b/src/main/kotlin/dulkirmod/features/chat/FakeMsg.kt
@@ -1,20 +1,15 @@
package dulkirmod.features.chat
-import net.minecraft.client.Minecraft
-import net.minecraft.util.ChatComponentText
+import dulkirmod.utils.TextUtils
import net.minecraftforge.client.event.ClientChatReceivedEvent
object FakeMsg {
+ private val dulkirRegex = "From \\[MVP(\\+|\\+\\+)] Dulkir: c:".toRegex()
fun handle(event: ClientChatReceivedEvent, unformatted: String) {
- if (unformatted.startsWith("From [MVP++] Dulkir: c:")) {
+ if (dulkirRegex.matches(unformatted)) {
event.isCanceled = true
- val newst = unformatted.substring("From [MVP++] Dulkir: c:".length)
- Minecraft.getMinecraft().thePlayer.addChatMessage(ChatComponentText(newst.replace("&", "§")))
- }
- if (unformatted.startsWith("From [MVP+] Dulkir: c:")) {
- event.isCanceled = true
- val newst = unformatted.substring("From [MVP+] Dulkir: c:".length)
- Minecraft.getMinecraft().thePlayer.addChatMessage(ChatComponentText(newst.replace("&", "§")))
+ val message = unformatted.replace(dulkirRegex, "").replace("&", "§")
+ TextUtils.info(message, false)
}
}
} \ No newline at end of file
diff --git a/src/main/kotlin/dulkirmod/features/chat/ThrottleNotif.kt b/src/main/kotlin/dulkirmod/features/chat/ThrottleNotif.kt
index c572db0..f6a90eb 100644
--- a/src/main/kotlin/dulkirmod/features/chat/ThrottleNotif.kt
+++ b/src/main/kotlin/dulkirmod/features/chat/ThrottleNotif.kt
@@ -2,6 +2,7 @@ package dulkirmod.features.chat
import dulkirmod.DulkirMod
import dulkirmod.config.Config
+import dulkirmod.utils.TextUtils
import dulkirmod.utils.Utils
import net.minecraftforge.client.event.ClientChatReceivedEvent
@@ -11,11 +12,11 @@ object ThrottleNotif {
if (unformatted == "This menu has been throttled! Please slow down..." && DulkirMod.config.throttleNotifier
&& Utils.isInDungeons()
) {
- event.isCanceled = true;
- if (!Config.throttleNotifierSpam && System.currentTimeMillis() - lastThrottle > 8000) {
- DulkirMod.mc.thePlayer.sendChatMessage("/pc " + DulkirMod.config.customMessage)
- } else {
- DulkirMod.mc.thePlayer.sendChatMessage("/pc " + DulkirMod.config.customMessage)
+ event.isCanceled = true
+ if (!Config.throttleNotifierSpam && System.currentTimeMillis() - lastThrottle > 8000) {
+ TextUtils.sendPartyChatMessage(DulkirMod.config.customMessage)
+ } else if (Config.throttleNotifierSpam) {
+ TextUtils.sendPartyChatMessage(DulkirMod.config.customMessage)
}
lastThrottle = System.currentTimeMillis()
}
diff --git a/src/main/kotlin/dulkirmod/features/chat/VanquisherTrigger.kt b/src/main/kotlin/dulkirmod/features/chat/VanquisherTrigger.kt
index c7d4349..d607df2 100644
--- a/src/main/kotlin/dulkirmod/features/chat/VanquisherTrigger.kt
+++ b/src/main/kotlin/dulkirmod/features/chat/VanquisherTrigger.kt
@@ -1,13 +1,13 @@
package dulkirmod.features.chat
-import dulkirmod.DulkirMod
import dulkirmod.config.Config
+import dulkirmod.utils.TextUtils
object VanquisherTrigger {
fun handle(message: String) {
if (!Config.vanqBroadcast) return
if (message == "A Vanquisher is spawning nearby!") {
- DulkirMod.mc.thePlayer.sendChatMessage("/patcher sendcoords")
+ TextUtils.sendMessage("/patcher sendcoords")
}
}
} \ No newline at end of file