aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/event/PartyChatEvent.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/commands/PartyChatCommands.kt16
2 files changed, 15 insertions, 8 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/event/PartyChatEvent.kt b/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/event/PartyChatEvent.kt
index dc9e921cc..bb3abad24 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/event/PartyChatEvent.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/event/PartyChatEvent.kt
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.data.hypixel.chat.event
+import at.hannibal2.skyhanni.utils.StringUtils.cleanPlayerName
import net.minecraft.util.IChatComponent
class PartyChatEvent(
@@ -7,4 +8,8 @@ class PartyChatEvent(
message: String,
chatComponent: IChatComponent,
blockedReason: String? = null,
-) : AbstractChatEvent(author, message, chatComponent, blockedReason)
+) : AbstractChatEvent(author, message, chatComponent, blockedReason) {
+ val cleanedAuthor by lazy {
+ author.cleanPlayerName()
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/PartyChatCommands.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/PartyChatCommands.kt
index 8ead93fcf..2f53a232d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/commands/PartyChatCommands.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/commands/PartyChatCommands.kt
@@ -19,13 +19,14 @@ object PartyChatCommands {
)
private fun useConfig() = SkyHanniMod.feature.misc.partyCommands
- val allPartyCommands = listOf(
+
+ private val allPartyCommands = listOf(
PartyChatCommand(
listOf("pt", "ptme", "transfer"),
{ useConfig().transferCommand },
requiresPartyLead = true,
executable = {
- ChatUtils.sendCommandToServer("party transfer ${it.author}")
+ ChatUtils.sendCommandToServer("party transfer ${it.cleanedAuthor}")
}
),
PartyChatCommand(
@@ -38,7 +39,7 @@ object PartyChatCommands {
),
)
- val indexedPartyChatCommands = buildMap {
+ private val indexedPartyChatCommands = buildMap {
for (command in allPartyCommands) {
for (name in command.names) {
put(name.lowercase(), command)
@@ -46,7 +47,7 @@ object PartyChatCommands {
}
}
- fun isTrustedUser(name: String): Boolean {
+ private fun isTrustedUser(name: String): Boolean {
val friend = FriendAPI.getAllFriends().find { it.name == name }
return when (useConfig().defaultRequiredTrustLevel) {
PartyCommandsConfig.TrustedUser.FRIENDS -> friend != null
@@ -64,15 +65,16 @@ object PartyChatCommands {
return
val commandLabel = event.message.substring(1).substringBefore(' ')
val command = indexedPartyChatCommands[commandLabel.lowercase()] ?: return
- if (event.author == LorenzUtils.getPlayerName()) {
+ val name = event.cleanedAuthor
+ if (name == LorenzUtils.getPlayerName()) {
return
}
if (!command.isEnabled()) return
if (command.requiresPartyLead && PartyAPI.partyLeader != LorenzUtils.getPlayerName()) {
return
}
- if (!isTrustedUser(event.author)) {
- ChatUtils.chat("§cIgnoring chat command from ${event.author}. Change your party chat command settings or /friend (best) them.")
+ if (!isTrustedUser(name)) {
+ ChatUtils.chat("§cIgnoring chat command from $name. Change your party chat command settings or /friend (best) them.")
return
}
command.executable(event)