aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/dulkirmod/command
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 /src/main/kotlin/dulkirmod/command
parent695ca674ce4cd4d7565cbdd08986394d65fac90e (diff)
downloadDulkirMod-154f612ed8d866755a227b42d5485d3ac08e1d7c.tar.gz
DulkirMod-154f612ed8d866755a227b42d5485d3ac08e1d7c.tar.bz2
DulkirMod-154f612ed8d866755a227b42d5485d3ac08e1d7c.zip
use TextUtils for messages
Diffstat (limited to 'src/main/kotlin/dulkirmod/command')
-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
6 files changed, 27 insertions, 92 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
}
}