aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/dulkirmod
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/dulkirmod')
-rw-r--r--src/main/kotlin/dulkirmod/DulkirMod.kt2
-rw-r--r--src/main/kotlin/dulkirmod/command/LeapNameCommand.kt72
-rw-r--r--src/main/kotlin/dulkirmod/config/Config.kt5
-rw-r--r--src/main/kotlin/dulkirmod/features/DungeonLeap.kt5
-rw-r--r--src/main/kotlin/dulkirmod/features/chat/Bridge.kt6
5 files changed, 74 insertions, 16 deletions
diff --git a/src/main/kotlin/dulkirmod/DulkirMod.kt b/src/main/kotlin/dulkirmod/DulkirMod.kt
index e4270e8..4a29113 100644
--- a/src/main/kotlin/dulkirmod/DulkirMod.kt
+++ b/src/main/kotlin/dulkirmod/DulkirMod.kt
@@ -114,7 +114,7 @@ class DulkirMod {
companion object {
const val MOD_ID = "dulkirmod"
const val MOD_NAME = "Dulkir Mod"
- const val MOD_VERSION = "1.1.1"
+ const val MOD_VERSION = "1.1.2"
const val CHAT_PREFIX = "§f<§3DulkirMod§f>"
val mc: Minecraft = Minecraft.getMinecraft()
diff --git a/src/main/kotlin/dulkirmod/command/LeapNameCommand.kt b/src/main/kotlin/dulkirmod/command/LeapNameCommand.kt
index cacaaea..b7156b7 100644
--- a/src/main/kotlin/dulkirmod/command/LeapNameCommand.kt
+++ b/src/main/kotlin/dulkirmod/command/LeapNameCommand.kt
@@ -2,6 +2,7 @@ package dulkirmod.command
import dulkirmod.DulkirMod
import dulkirmod.config.Config
+import dulkirmod.utils.TabListUtils
import net.minecraft.command.CommandException
import net.minecraft.command.ICommandSender
import net.minecraft.util.ChatComponentText
@@ -11,15 +12,74 @@ class LeapNameCommand : ClientCommandBase("hl") {
override fun processCommand(sender: ICommandSender, args: Array<String>) {
if (args.isEmpty()) {
DulkirMod.mc.thePlayer.addChatMessage(
- ChatComponentText("${DulkirMod.CHAT_PREFIX} §6Please give a username argument (case sensitive) for who you want to be highlighted.")
+ 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.")
)
return
}
- val username = args[0]
- Config.highlightLeapName = username
- DulkirMod.mc.thePlayer.addChatMessage(
- ChatComponentText("${DulkirMod.CHAT_PREFIX} §6Selected Leap Highlight for username: §f$username§6.")
- )
+ val username = args[0].lowercase()
+
+ var isClassName = true
+ var foundPlayer = when (username) {
+ "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)
+ }
+ }
+
+ if (foundPlayer) {
+ DulkirMod.mc.thePlayer.addChatMessage(
+ ChatComponentText("${DulkirMod.CHAT_PREFIX} §6Selected Leap Highlight for username: §f${Config.highlightLeapName}§6.")
+ )
+ }
+ }
+ private fun findUserNameFor(input: String, isClassName: Boolean): Boolean {
+ val scoreboardList: List<String?> = TabListUtils.fetchTabEntires().map {
+ it.displayName?.unformattedText
+ }
+ if (isClassName) {
+ for (l in scoreboardList) {
+ if (l != null && 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.")
+ )
+ 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
+ val username = strArr[1]
+ if (username.lowercase() == input.lowercase()) {
+ Config.highlightLeapName = username
+ return true
+ }
+ }
+ DulkirMod.mc.thePlayer.addChatMessage(
+ ChatComponentText("${DulkirMod.CHAT_PREFIX} §6Couldn't find anyone with this username on tab list.")
+ )
+ return false
+ }
}
+
} \ No newline at end of file
diff --git a/src/main/kotlin/dulkirmod/config/Config.kt b/src/main/kotlin/dulkirmod/config/Config.kt
index 2fce7ed..09de6cb 100644
--- a/src/main/kotlin/dulkirmod/config/Config.kt
+++ b/src/main/kotlin/dulkirmod/config/Config.kt
@@ -268,7 +268,7 @@ object Config : Vigilant(File("./config/dulkirmod/config.toml"), "DulkirMod", so
@Property(
type = PropertyType.SWITCH,
name = "Highlight custom player for leap in menu",
- description = "changes texture to green wool!",
+ description = "Changes texture to green wool! Use the \"/hl\" command for convenient assignment.",
category = "Dungeons"
)
var highlightLeap = false
@@ -493,8 +493,7 @@ object Config : Vigilant(File("./config/dulkirmod/config.toml"), "DulkirMod", so
)
setCategoryDescription(
"Bridge",
- "Does not work for replies, or having spaces in your discord username. I will not fix these " +
- "issues. If you have unrelated problems, dm me on discord."
+ "Dm me on discord with formatting issues."
)
}
diff --git a/src/main/kotlin/dulkirmod/features/DungeonLeap.kt b/src/main/kotlin/dulkirmod/features/DungeonLeap.kt
index 91e85f7..901c839 100644
--- a/src/main/kotlin/dulkirmod/features/DungeonLeap.kt
+++ b/src/main/kotlin/dulkirmod/features/DungeonLeap.kt
@@ -1,6 +1,5 @@
package dulkirmod.features
-import dulkirmod.DulkirMod
import dulkirmod.DulkirMod.Companion.mc
import dulkirmod.config.Config
import dulkirmod.utils.ContainerNameUtil
@@ -33,11 +32,11 @@ class DungeonLeap {
if (inLeapMenuBool && System.currentTimeMillis() - lastGuiOpenEvent < 300) {
for (i in 11..15) {
boolArray[i - 11] = false
- val slotIn = DulkirMod.mc.thePlayer.openContainer.getSlot(i)
+ val slotIn = mc.thePlayer.openContainer.getSlot(i)
if (slotIn.stack == null) continue
val stack = slotIn.stack
- if (Utils.stripColorCodes(stack.displayName) == Config.highlightLeapName) boolArray[i - 11] = true
+ if (Utils.stripColorCodes(stack.displayName).lowercase() == Config.highlightLeapName.lowercase()) boolArray[i - 11] = true
}
}
}
diff --git a/src/main/kotlin/dulkirmod/features/chat/Bridge.kt b/src/main/kotlin/dulkirmod/features/chat/Bridge.kt
index 835d64d..6249ead 100644
--- a/src/main/kotlin/dulkirmod/features/chat/Bridge.kt
+++ b/src/main/kotlin/dulkirmod/features/chat/Bridge.kt
@@ -8,11 +8,11 @@ import net.minecraftforge.client.event.ClientChatReceivedEvent
object Bridge {
private val guildFormat =
- "^(§2Guild|§3Officer) > (?:\\S+ )?([\\w§]{3,18})(?: §[a-z0-9]\\[[A-Z]+])?§f: (\\w+) > .+".toRegex()
+ "^(§2Guild|§3Officer) > (?:\\S+ )?([\\w§]{3,18})(?: §[a-z0-9]\\[[A-Z]+])?§f: ([^>]+) > .+".toRegex()
private val alternateFormat =
- "^(§2Guild|§3Officer) > (?:\\S+ )?([\\w§]{3,18})(?: §[a-z0-9]\\[[A-Z]+])?§f: (\\w+): .+".toRegex()
+ "^(§2Guild|§3Officer) > (?:\\S+ )?([\\w§]{3,18})(?: §[a-z0-9]\\[[A-Z]+])?§f: ([^:]+): .+".toRegex()
private val otherAltFormat =
- "^(§2Guild|§3Officer) > (?:\\S+ )?([\\w§]{3,18})(?: §[a-z0-9]\\[[A-Z]+])?§f: (\\w+) » .+".toRegex()
+ "^(§2Guild|§3Officer) > (?:\\S+ )?([\\w§]{3,18})(?: §[a-z0-9]\\[[A-Z]+])?§f: ([^»]+) » .+".toRegex()
fun handle(event: ClientChatReceivedEvent) {
val message = event.message.unformattedText