aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlmarsXd <ilmars500@gmail.com>2023-02-08 16:21:36 +0200
committerIlmarsXd <ilmars500@gmail.com>2023-02-08 16:21:36 +0200
commit154f612ed8d866755a227b42d5485d3ac08e1d7c (patch)
tree6ec2f3c925e67998cdcb5cb223fdd063eabaca6b
parent695ca674ce4cd4d7565cbdd08986394d65fac90e (diff)
downloadDulkirMod-154f612ed8d866755a227b42d5485d3ac08e1d7c.tar.gz
DulkirMod-154f612ed8d866755a227b42d5485d3ac08e1d7c.tar.bz2
DulkirMod-154f612ed8d866755a227b42d5485d3ac08e1d7c.zip
use TextUtils for messages
-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/features/chat/ThrottleNotif.kt11
-rw-r--r--src/main/kotlin/dulkirmod/features/chat/VanquisherTrigger.kt4
-rw-r--r--src/main/kotlin/dulkirmod/utils/Utils.kt9
9 files changed, 37 insertions, 106 deletions
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/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/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