aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/dulkirmod/command/LeapNameCommand.kt
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 /src/main/kotlin/dulkirmod/command/LeapNameCommand.kt
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
Diffstat (limited to 'src/main/kotlin/dulkirmod/command/LeapNameCommand.kt')
-rw-r--r--src/main/kotlin/dulkirmod/command/LeapNameCommand.kt47
1 files changed, 12 insertions, 35 deletions
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
}
}