aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoringlettronald <71849533+inglettronald@users.noreply.github.com>2023-02-13 20:10:06 -0600
committerGitHub <noreply@github.com>2023-02-13 20:10:06 -0600
commit7df778d6ac01a6d350608a5962b9344493444ebc (patch)
tree69abbc662cbb3a325f05aa4fbcd2f0fa0ff37cd6
parent1c27ca0e7586c27de7ddd51723b5bf7b0ab50230 (diff)
parent3985b5f7417571f4a1e90eefa287af053b740e69 (diff)
downloadDulkirMod-7df778d6ac01a6d350608a5962b9344493444ebc.tar.gz
DulkirMod-7df778d6ac01a6d350608a5962b9344493444ebc.tar.bz2
DulkirMod-7df778d6ac01a6d350608a5962b9344493444ebc.zip
Merge pull request #10 from IlmarsXd/master
Cleaned up some code and fixed AbiphoneDND log spam
-rw-r--r--src/main/kotlin/dulkirmod/DulkirMod.kt18
-rw-r--r--src/main/kotlin/dulkirmod/command/EnchantRuneCommand.kt12
-rw-r--r--src/main/kotlin/dulkirmod/command/FairyCommand.kt12
-rw-r--r--src/main/kotlin/dulkirmod/command/HelpCommand.kt28
-rw-r--r--src/main/kotlin/dulkirmod/command/HurtCamCommand.kt7
-rw-r--r--src/main/kotlin/dulkirmod/command/JoinDungeonCommand.kt13
-rw-r--r--src/main/kotlin/dulkirmod/command/LeapNameCommand.kt47
-rw-r--r--src/main/kotlin/dulkirmod/config/Config.kt2
-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
-rw-r--r--src/main/kotlin/dulkirmod/utils/TextUtils.kt24
-rw-r--r--src/main/kotlin/dulkirmod/utils/Utils.kt9
16 files changed, 111 insertions, 182 deletions
diff --git a/src/main/kotlin/dulkirmod/DulkirMod.kt b/src/main/kotlin/dulkirmod/DulkirMod.kt
index ab11e9e..51df365 100644
--- a/src/main/kotlin/dulkirmod/DulkirMod.kt
+++ b/src/main/kotlin/dulkirmod/DulkirMod.kt
@@ -6,6 +6,7 @@ import dulkirmod.events.ChatEvent
import dulkirmod.features.*
import dulkirmod.features.chat.AbiphoneDND
import dulkirmod.utils.ContainerNameUtil
+import dulkirmod.utils.TextUtils
import dulkirmod.utils.TitleUtils
import dulkirmod.utils.Utils.getArea
import kotlinx.coroutines.CoroutineScope
@@ -14,7 +15,6 @@ import kotlinx.coroutines.launch
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.GuiScreen
import net.minecraft.client.settings.KeyBinding
-import net.minecraft.util.ChatComponentText
import net.minecraftforge.client.ClientCommandHandler
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.fml.client.registry.ClientRegistry
@@ -93,19 +93,13 @@ class DulkirMod {
display = null
}
- var longupdate = false
- val currTime: Long = System.currentTimeMillis()
- if (currTime - lastLongUpdate > 1000) {
- longupdate = true
- lastLongUpdate = currTime
- }
- if (longupdate) {
- // EXECUTE STUFF HERE THAT DOESN'T REALLY NEED TO BE RUN EVERY TICK
+ val currTime = System.currentTimeMillis()
+ if (currTime - lastLongUpdate > 1000) { // long update
alarmClock()
brokenHypeNotif()
matchoAlert.alert()
getArea()
- longupdate = false
+ lastLongUpdate = currTime
}
}
@@ -114,7 +108,7 @@ class DulkirMod {
if (keyBinds[0].isPressed) display = config.gui()
if (keyBinds[1].isPressed) {
Config.noReverse3rdPerson = !Config.noReverse3rdPerson
- mc.thePlayer.addChatMessage(ChatComponentText("§7Toggling No Selfie Camera Setting... now: §6${Config.noReverse3rdPerson}"))
+ TextUtils.toggledMessage("No Selfie Camera", Config.noReverse3rdPerson)
}
}
@@ -122,7 +116,7 @@ class DulkirMod {
const val MOD_ID = "dulkirmod"
const val MOD_NAME = "Dulkir Mod"
const val MOD_VERSION = "1.1.5"
- const val CHAT_PREFIX = "§f<§3DulkirMod§f>"
+ const val CHAT_PREFIX = "§f<§3DulkirMod§f>§r"
val mc: Minecraft = Minecraft.getMinecraft()
var config = Config
diff --git a/src/main/kotlin/dulkirmod/command/EnchantRuneCommand.kt b/src/main/kotlin/dulkirmod/command/EnchantRuneCommand.kt
index 40cdc6c..36e8b69 100644
--- a/src/main/kotlin/dulkirmod/command/EnchantRuneCommand.kt
+++ b/src/main/kotlin/dulkirmod/command/EnchantRuneCommand.kt
@@ -1,23 +1,15 @@
package dulkirmod.command
import dulkirmod.DulkirMod.Companion.config
-import dulkirmod.DulkirMod.Companion.mc
+import dulkirmod.utils.TextUtils
import net.minecraft.command.CommandException
import net.minecraft.command.ICommandSender
-import net.minecraft.util.ChatComponentText
-import net.minecraft.util.EnumChatFormatting
class EnchantRuneCommand : ClientCommandBase("enchantrune") {
@Throws(CommandException::class)
override fun processCommand(sender: ICommandSender, args: Array<String>) {
- mc.thePlayer.addChatMessage(
- ChatComponentText(
- EnumChatFormatting.BLUE.toString() + "" + "Enchant rune hider toggled - now: " +
- EnumChatFormatting.GREEN + !config.hideEnchantRune
- )
- )
config.hideEnchantRune = !config.hideEnchantRune
-
+ TextUtils.toggledMessage("Enchant Rune Hider", config.hideEnchantRune)
config.markDirty()
config.writeData()
}
diff --git a/src/main/kotlin/dulkirmod/command/FairyCommand.kt b/src/main/kotlin/dulkirmod/command/FairyCommand.kt
index ba7a74b..a6c1b00 100644
--- a/src/main/kotlin/dulkirmod/command/FairyCommand.kt
+++ b/src/main/kotlin/dulkirmod/command/FairyCommand.kt
@@ -1,23 +1,15 @@
package dulkirmod.command
import dulkirmod.DulkirMod.Companion.config
-import dulkirmod.DulkirMod.Companion.mc
+import dulkirmod.utils.TextUtils
import net.minecraft.command.CommandException
import net.minecraft.command.ICommandSender
-import net.minecraft.util.ChatComponentText
-import net.minecraft.util.EnumChatFormatting
class FairyCommand : ClientCommandBase("fairy") {
@Throws(CommandException::class)
override fun processCommand(sender: ICommandSender, args: Array<String>) {
- mc.thePlayer.addChatMessage(
- ChatComponentText(
- EnumChatFormatting.BLUE.toString() + "Healer fairy hider toggled - now: " +
- EnumChatFormatting.GREEN + !config.hideHealerFairy
- )
- )
config.hideHealerFairy = !config.hideHealerFairy
-
+ TextUtils.toggledMessage("Healer Fairy Hider", config.hideHealerFairy)
config.markDirty()
config.writeData()
}
diff --git a/src/main/kotlin/dulkirmod/command/HelpCommand.kt b/src/main/kotlin/dulkirmod/command/HelpCommand.kt
index 0180fac..2b7a9b0 100644
--- a/src/main/kotlin/dulkirmod/command/HelpCommand.kt
+++ b/src/main/kotlin/dulkirmod/command/HelpCommand.kt
@@ -1,33 +1,15 @@
package dulkirmod.command
-import net.minecraft.client.Minecraft
+import dulkirmod.utils.TextUtils
import net.minecraft.command.CommandException
import net.minecraft.command.ICommandSender
-import net.minecraft.util.ChatComponentText
-import net.minecraft.util.EnumChatFormatting
class HelpCommand : ClientCommandBase("dulkirhelp") {
@Throws(CommandException::class)
override fun processCommand(sender: ICommandSender, args: Array<String>) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(
- ChatComponentText(
- EnumChatFormatting.GOLD.toString() + "" + EnumChatFormatting.BOLD + " HI THIS IS DULKIRMOD!"
- )
- )
- Minecraft.getMinecraft().thePlayer.addChatMessage(
- ChatComponentText(
- EnumChatFormatting.GRAY.toString() + "/enchantrune - toggles enchant rune visibility."
- )
- )
- Minecraft.getMinecraft().thePlayer.addChatMessage(
- ChatComponentText(
- EnumChatFormatting.GRAY.toString() + "/fairy - toggles healer fairy visibility."
- )
- )
- Minecraft.getMinecraft().thePlayer.addChatMessage(
- ChatComponentText(
- EnumChatFormatting.GRAY.toString() + "/hl - helps change highlighted leap player on the fly"
- )
- )
+ TextUtils.info("§6§l HI THIS IS DULKIRMOD!", false)
+ TextUtils.info(" §7/enchantrune - toggles enchant rune visibility.", false)
+ TextUtils.info(" §7/fairy - toggles healer fairy visibility.", false)
+ TextUtils.info(" §7/hl - helps change highlighted leap player on the fly.", false)
}
} \ No newline at end of file
diff --git a/src/main/kotlin/dulkirmod/command/HurtCamCommand.kt b/src/main/kotlin/dulkirmod/command/HurtCamCommand.kt
index 3dce80e..200fa22 100644
--- a/src/main/kotlin/dulkirmod/command/HurtCamCommand.kt
+++ b/src/main/kotlin/dulkirmod/command/HurtCamCommand.kt
@@ -1,17 +1,14 @@
package dulkirmod.command
-import dulkirmod.DulkirMod
import dulkirmod.config.Config
+import dulkirmod.utils.TextUtils
import net.minecraft.command.CommandException
import net.minecraft.command.ICommandSender
-import net.minecraft.util.ChatComponentText
class HurtCamCommand : ClientCommandBase("ouch") {
@Throws(CommandException::class)
override fun processCommand(sender: ICommandSender, args: Array<String>) {
Config.hurtCamIntensity = 7f
- DulkirMod.mc.thePlayer.addChatMessage(
- ChatComponentText("${DulkirMod.CHAT_PREFIX} §6§lOUCH! THAT HURT!")
- )
+ TextUtils.info("§6§lOUCH! THAT HURT!")
}
} \ No newline at end of file
diff --git a/src/main/kotlin/dulkirmod/command/JoinDungeonCommand.kt b/src/main/kotlin/dulkirmod/command/JoinDungeonCommand.kt
index 25b7c7c..f6f5a5e 100644
--- a/src/main/kotlin/dulkirmod/command/JoinDungeonCommand.kt
+++ b/src/main/kotlin/dulkirmod/command/JoinDungeonCommand.kt
@@ -1,11 +1,9 @@
package dulkirmod.command
-import dulkirmod.DulkirMod
-import dulkirmod.DulkirMod.Companion.mc
import dulkirmod.config.Config
+import dulkirmod.utils.TextUtils
import net.minecraft.command.CommandException
import net.minecraft.command.ICommandSender
-import net.minecraft.util.ChatComponentText
class JoinDungeonCommand : ClientCommandBase("joindungeon") {
@Throws(CommandException::class)
@@ -24,14 +22,11 @@ class JoinDungeonCommand : ClientCommandBase("joindungeon") {
if (args[1].toInt() in 1..7) {
num = args[1]
}
- } catch (e: NumberFormatException) {
- }
+ } catch (_: NumberFormatException) {}
if (Config.dungeonCommandConfirm) {
- mc.thePlayer.addChatMessage(
- ChatComponentText("${DulkirMod.CHAT_PREFIX} §6Running command: $type$num")
- )
+ TextUtils.info("§6Running command: $type$num")
}
- mc.thePlayer.sendChatMessage("/joindungeon $arguments")
+ TextUtils.sendMessage("/joindungeon $arguments")
}
} \ No newline at end of file
diff --git a/src/main/kotlin/dulkirmod/command/LeapNameCommand.kt b/src/main/kotlin/dulkirmod/command/LeapNameCommand.kt
index b7156b7..185a181 100644
--- a/src/main/kotlin/dulkirmod/command/LeapNameCommand.kt
+++ b/src/main/kotlin/dulkirmod/command/LeapNameCommand.kt
@@ -1,71 +1,50 @@
package dulkirmod.command
-import dulkirmod.DulkirMod
import dulkirmod.config.Config
import dulkirmod.utils.TabListUtils
+import dulkirmod.utils.TextUtils
import net.minecraft.command.CommandException
import net.minecraft.command.ICommandSender
-import net.minecraft.util.ChatComponentText
class LeapNameCommand : ClientCommandBase("hl") {
@Throws(CommandException::class)
override fun processCommand(sender: ICommandSender, args: Array<String>) {
if (args.isEmpty()) {
- DulkirMod.mc.thePlayer.addChatMessage(
- ChatComponentText("${DulkirMod.CHAT_PREFIX} §6Please give a username or class argument for who you want to be highlighted.")
- )
- DulkirMod.mc.thePlayer.addChatMessage(
- ChatComponentText("${DulkirMod.CHAT_PREFIX} §7 - Class argument will take the first person tab list with that class.")
- )
- DulkirMod.mc.thePlayer.addChatMessage(
- ChatComponentText("${DulkirMod.CHAT_PREFIX} §7 - example: §f/hl h§7, §f/hl tank§7, or §f/hl Tazboi§7.")
- )
- DulkirMod.mc.thePlayer.addChatMessage(
- ChatComponentText("${DulkirMod.CHAT_PREFIX} §7 - This command will need to be ran again if some person of class §fX §7leaves and a new one joins.")
- )
+ TextUtils.info("§6Please give a username or class argument for who you want to be highlighted.")
+ TextUtils.info("§7 - Class argument will take the first person tab list with that class.", false)
+ TextUtils.info("§7 - Example: §f/hl h§7, §f/hl tank§7, or §f/hl Tazboi§7.", false)
+ TextUtils.info("§7 - This command will need to be ran again if some person of class §fX §7leaves and a new one joins.", false)
return
}
- val username = args[0].lowercase()
-
- var isClassName = true
- var foundPlayer = when (username) {
+ val foundPlayer = when (val username = args[0].lowercase()) {
"h", "healer" -> findUserNameFor("(Healer", true)
"b", "berserk" -> findUserNameFor("(Berserk", true)
"m", "mage" -> findUserNameFor("(Mage", true)
"t", "tank" -> findUserNameFor("(Tank", true)
"a", "archer" -> findUserNameFor("(Archer", true)
- else -> {
- isClassName = false
- findUserNameFor(username, false)
- }
+ else -> findUserNameFor(username, false)
}
-
if (foundPlayer) {
- DulkirMod.mc.thePlayer.addChatMessage(
- ChatComponentText("${DulkirMod.CHAT_PREFIX} §6Selected Leap Highlight for username: §f${Config.highlightLeapName}§6.")
- )
+ TextUtils.info("§6Selected Leap Highlight for username: §f${Config.highlightLeapName}§6.")
}
}
private fun findUserNameFor(input: String, isClassName: Boolean): Boolean {
- val scoreboardList: List<String?> = TabListUtils.fetchTabEntires().map {
+ val scoreboardList = TabListUtils.fetchTabEntires().mapNotNull {
it.displayName?.unformattedText
}
if (isClassName) {
for (l in scoreboardList) {
- if (l != null && l.contains(input)) {
+ if (l.contains(input)) {
val strArr = l.split(" ")
Config.highlightLeapName = strArr[1]
return true
}
}
- DulkirMod.mc.thePlayer.addChatMessage(
- ChatComponentText("${DulkirMod.CHAT_PREFIX} §6Couldn't find anyone playing this class.")
- )
+ TextUtils.info("§6Couldn't find anyone playing this class.")
return false
} else {
for (l in scoreboardList) {
- if (l == null) continue
val strArr = l.split(" ")
// another safety check, probably not necessary but oh well
if (strArr.size < 2) continue
@@ -75,9 +54,7 @@ class LeapNameCommand : ClientCommandBase("hl") {
return true
}
}
- DulkirMod.mc.thePlayer.addChatMessage(
- ChatComponentText("${DulkirMod.CHAT_PREFIX} §6Couldn't find anyone with this username on tab list.")
- )
+ TextUtils.info("§6Couldn't find anyone with this username on tab list.")
return false
}
}
diff --git a/src/main/kotlin/dulkirmod/config/Config.kt b/src/main/kotlin/dulkirmod/config/Config.kt
index 11f4ea5..6dad478 100644
--- a/src/main/kotlin/dulkirmod/config/Config.kt
+++ b/src/main/kotlin/dulkirmod/config/Config.kt
@@ -495,7 +495,7 @@ object Config : Vigilant(File("./config/dulkirmod/config.toml"), "DulkirMod", so
subcategory = "Audio"
)
fun demoVolume() {
- DulkirMod.mc.thePlayer.playSound("mob.ghast.scream", 1f * Config.bestiaryNotifVol, 1f)
+ DulkirMod.mc.thePlayer.playSound("mob.ghast.scream", 1f * bestiaryNotifVol, 1f)
}
@Property(
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
diff --git a/src/main/kotlin/dulkirmod/utils/TextUtils.kt b/src/main/kotlin/dulkirmod/utils/TextUtils.kt
new file mode 100644
index 0000000..6da1dd8
--- /dev/null
+++ b/src/main/kotlin/dulkirmod/utils/TextUtils.kt
@@ -0,0 +1,24 @@
+package dulkirmod.utils
+
+import dulkirmod.DulkirMod
+import net.minecraft.util.ChatComponentText
+
+object TextUtils {
+ fun info(text: String, prefix: Boolean = true) {
+ val textPrefix = if (prefix) "${DulkirMod.CHAT_PREFIX} " else ""
+ DulkirMod.mc.thePlayer.addChatMessage(ChatComponentText("$textPrefix$text§r"))
+ }
+
+ fun toggledMessage(message: String, state: Boolean) {
+ val stateText = if (state) "§aON" else "§cOFF"
+ info("§9Toggled $message §8[$stateText§8]§r")
+ }
+
+ fun sendPartyChatMessage(message: String) {
+ sendMessage("/pc $message")
+ }
+
+ fun sendMessage(message: String) {
+ DulkirMod.mc.thePlayer.sendChatMessage(message)
+ }
+} \ No newline at end of file
diff --git a/src/main/kotlin/dulkirmod/utils/Utils.kt b/src/main/kotlin/dulkirmod/utils/Utils.kt
index 81646cb..47408c3 100644
--- a/src/main/kotlin/dulkirmod/utils/Utils.kt
+++ b/src/main/kotlin/dulkirmod/utils/Utils.kt
@@ -3,7 +3,6 @@ package dulkirmod.utils
import com.google.gson.Gson
import dulkirmod.DulkirMod.Companion.mc
import dulkirmod.config.Config
-import net.minecraft.util.ChatComponentText
import net.minecraft.util.EnumChatFormatting
import java.awt.Toolkit
import java.awt.datatransfer.Clipboard
@@ -48,11 +47,7 @@ object Utils {
Config.drinkingSelector = import.drinkingFix
Config.ignoreHaste = import.ignoreHaste
} catch (e: Exception) {
- mc.thePlayer.addChatMessage(
- ChatComponentText(
- EnumChatFormatting.GOLD.toString() + "" + EnumChatFormatting.BOLD + "Current clipboard is not a recognizable Custom Animation Preset."
- )
- )
+ TextUtils.info("§6§lCurrent clipboard is not a recognizable Custom Animation Preset.")
}
mc.displayGuiScreen(null)
}
@@ -65,7 +60,7 @@ object Utils {
return false
}
if (mc.thePlayer.worldScoreboard.getObjectiveInDisplaySlot(1) == null)
- return false;
+ return false
return stripColorCodes(mc.thePlayer.worldScoreboard.getObjectiveInDisplaySlot(1).displayName).contains("SKYBLOCK")
}
return false