aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/chat
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2022-09-17 17:40:44 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2022-09-17 17:40:44 +0200
commitce43d92584b785650b35d5a6ebdbfddd7d31661c (patch)
tree08d0cb94c13fc2dd5b2c6e550ff0faea0271346e /src/main/java/at/hannibal2/skyhanni/features/chat
parentdae53e9abc14dde4fb193feace1424776b2535da (diff)
downloadskyhanni-ce43d92584b785650b35d5a6ebdbfddd7d31661c.tar.gz
skyhanni-ce43d92584b785650b35d5a6ebdbfddd7d31661c.tar.bz2
skyhanni-ce43d92584b785650b35d5a6ebdbfddd7d31661c.zip
mark players in chat
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/chat')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/chat/HideFarDeathMessages.kt)30
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFormatter.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/chat/PlayerChatFormatter.kt)16
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerMessageChannel.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/chat/PlayerMessageChannel.kt)2
3 files changed, 38 insertions, 10 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/HideFarDeathMessages.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt
index 0a3ead47d..4e1e26fdb 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/chat/HideFarDeathMessages.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt
@@ -3,8 +3,10 @@ package at.hannibal2.skyhanni.features.chat
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.HypixelData
import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.features.MarkedPlayerManager
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.getLorenzVec
import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityOtherPlayerMP
@@ -13,7 +15,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
import java.util.regex.Pattern
-class HideFarDeathMessages {
+class PlayerDeathMessages {
private var tick = 0
private val lastTimePlayerSeen = mutableMapOf<String, Long>()
@@ -23,7 +25,7 @@ class HideFarDeathMessages {
@SubscribeEvent
fun onTick(event: TickEvent.ClientTickEvent) {
- if (!isEnabled()) return
+ if (!isHideFarDeathsEnabled()) return
if (tick++ % 20 == 0) {
checkOtherPlayers()
@@ -32,14 +34,30 @@ class HideFarDeathMessages {
@SubscribeEvent
fun onChatMessage(event: LorenzChatEvent) {
- if (!isEnabled()) return
+ if (!LorenzUtils.inSkyblock) return
val message = event.message
val matcher = pattern.matcher(message)
if (matcher.matches()) {
val name = matcher.group(1)
- if (System.currentTimeMillis() > lastTimePlayerSeen.getOrDefault(name, 0) + 30_000) {
- event.blockedReason = "far_away_player_death"
+ if (SkyHanniMod.feature.markedPlayers.highlightInChat && !LorenzUtils.inDungeons && !LorenzUtils.inKuudraFight) {
+ if (MarkedPlayerManager.isMarkedPlayer(name)) {
+ val reason = matcher.group(2).removeColor()
+ LorenzUtils.chat(" §c☠ §e$name §7$reason")
+ event.blockedReason = "marked_player_death"
+ return
+ }
+ }
+
+
+ if (isHideFarDeathsEnabled()) {
+ if (System.currentTimeMillis() > lastTimePlayerSeen.getOrDefault(name, 0) + 30_000) {
+ event.blockedReason = "far_away_player_death"
+ }
+ }
+ } else {
+ if (message.contains("☠")) {
+ println("wrong death message: '$message'")
}
}
}
@@ -58,7 +76,7 @@ class HideFarDeathMessages {
}
}
- private fun isEnabled(): Boolean {
+ private fun isHideFarDeathsEnabled(): Boolean {
return LorenzUtils.inSkyblock && SkyHanniMod.feature.chat.hideFarDeathMessages && !LorenzUtils.inDungeons && !LorenzUtils.inKuudraFight
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerChatFormatter.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFormatter.kt
index 36a9e057c..39b8458f2 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerChatFormatter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFormatter.kt
@@ -1,8 +1,9 @@
-package at.hannibal2.skyhanni.features.chat
+package at.hannibal2.skyhanni.features.chat.playerchat
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.PlayerSendChatEvent
+import at.hannibal2.skyhanni.features.MarkedPlayerManager
import at.hannibal2.skyhanni.utils.LorenzLogger
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
@@ -180,10 +181,19 @@ class PlayerChatFormatter {
return cleanName
}
+ val markedPlayer = MarkedPlayerManager.isMarkedPlayer(cleanName) && SkyHanniMod.feature.markedPlayers.highlightInChat
return if (SkyHanniMod.feature.chat.playerRankHider) {
- "§b$cleanName"
+ if (markedPlayer) "§e$cleanName" else "§b$cleanName"
} else {
- rawName
+ if (markedPlayer) {
+ if (rawName.contains(" ")) {
+ rawName[0] + " §e" + cleanName
+ } else {
+ "§e$cleanName"
+ }
+ } else {
+ rawName
+ }
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerMessageChannel.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerMessageChannel.kt
index e457bea8f..b75f2c970 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerMessageChannel.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerMessageChannel.kt
@@ -1,4 +1,4 @@
-package at.hannibal2.skyhanni.features.chat
+package at.hannibal2.skyhanni.features.chat.playerchat
enum class PlayerMessageChannel(
val prefixColor: String,