aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-12-04 16:10:20 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-12-04 16:10:20 +0100
commit357f7493e2cadbe8a543710e71e702874e16df29 (patch)
tree7dd7c5f35eb24b0123a723b1739068b443a5f41c /src/main/java/at/hannibal2
parent5a8d02dcd10015f310bab9d18558d2299c856dd1 (diff)
downloadskyhanni-357f7493e2cadbe8a543710e71e702874e16df29.tar.gz
skyhanni-357f7493e2cadbe8a543710e71e702874e16df29.tar.bz2
skyhanni-357f7493e2cadbe8a543710e71e702874e16df29.zip
cleanPlayerName respects playerRankHider option now.
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt39
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt13
5 files changed, 44 insertions, 23 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt
index 43ea37c16..9d071b956 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt
@@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.groupOrNull
+import at.hannibal2.skyhanni.utils.StringUtils.cleanPlayerName
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -48,7 +49,10 @@ class CompactSplashPotionMessage {
it.matchMatcher(this) {
val effectName = group("effectName")
// If splashed by a player, append their name.
- val byPlayer = groupOrNull("playerName")?.let { player -> " by $player" } ?: ""
+ val byPlayer = groupOrNull("playerName")?.let { player ->
+ val displayName = player.cleanPlayerName(displayName = true)
+ " §aby $displayName"
+ } ?: ""
sendMessage("§a§lPotion Effect! §r$effectName$byPlayer")
} != null
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt
index 9a28dcc06..46e2e0514 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt
@@ -20,13 +20,13 @@ class DungeonRankTabListColor {
val playerName = group("playerName")
val split = playerName.split(" ")
val sbLevel = split[0]
- val cleanName = split[1].cleanPlayerName()
+ val cleanName = split[1].cleanPlayerName(displayName = true)
val className = group("className")
val level = group("classLevel").romanToDecimal()
val color = getColor(level)
- event.text = "$sbLevel §b$cleanName §7(§e$className $color$level§7)"
+ event.text = "$sbLevel $cleanName §7(§e$className $color$level§7)"
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt
index 01aabed38..14422e6b4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt
@@ -152,7 +152,6 @@ object GriffinBurrowHelper {
val playerLocation = LocationUtils.playerLocation()
if (config.inquisitorSharing.enabled) {
for (inquis in InquisitorWaypointShare.waypoints.values) {
- val playerName = inquis.fromPlayer
val location = inquis.location
event.drawColor(location, LorenzColor.LIGHT_PURPLE)
val distance = location.distance(playerLocation)
@@ -163,9 +162,9 @@ object GriffinBurrowHelper {
event.drawDynamicText(location.add(y = 1), "§d§lInquisitor", 1.7)
}
if (distance < 5) {
- InquisitorWaypointShare.maybeRemove(playerName)
+ InquisitorWaypointShare.maybeRemove(inquis)
}
- event.drawDynamicText(location.add(y = 1), "§eFrom §b$playerName", 1.6, yOff = 9f)
+ event.drawDynamicText(location.add(y = 1), "§eFrom §b${inquis.displayName}", 1.6, yOff = 9f)
if (config.inquisitorSharing.showDespawnTime) {
val spawnTime = inquis.spawnTime
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt
index a99be4102..5532d70e9 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt
@@ -1,6 +1,5 @@
package at.hannibal2.skyhanni.features.event.diana
-
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
@@ -47,7 +46,12 @@ object InquisitorWaypointShare {
var waypoints = mapOf<String, SharedInquisitor>()
- class SharedInquisitor(val fromPlayer: String, val location: LorenzVec, val spawnTime: SimpleTimeMark)
+ class SharedInquisitor(
+ val fromPlayer: String,
+ val displayName: String,
+ val location: LorenzVec,
+ val spawnTime: SimpleTimeMark
+ )
private var test = false
@@ -221,22 +225,23 @@ object InquisitorWaypointShare {
if (packet.type.toInt() != 0) return
partyPattern.matchMatcher(message) {
- val playerName = group("playerName")
+ val rawName = group("playerName")
val x = group("x").trim().toInt()
val y = group("y").trim().toInt()
val z = group("z").trim().toInt()
val location = LorenzVec(x, y, z)
- val cleanName = playerName.cleanPlayerName()
- if (!waypoints.containsKey(cleanName)) {
- LorenzUtils.chat("$playerName §l§efound an inquisitor at §l§c$x $y $z!")
- if (cleanName != LorenzUtils.getPlayerName()) {
- LorenzUtils.sendTitle("§dINQUISITOR §efrom §b$cleanName", 5.seconds)
+ val name = rawName.cleanPlayerName()
+ val displayName = rawName.cleanPlayerName(displayName = true)
+ if (!waypoints.containsKey(name)) {
+ LorenzUtils.chat("$displayName §l§efound an inquisitor at §l§c$x $y $z!")
+ if (name != LorenzUtils.getPlayerName()) {
+ LorenzUtils.sendTitle("§dINQUISITOR §efrom §b$displayName", 5.seconds)
SoundUtils.playBeepSound()
}
}
- val inquis = SharedInquisitor(cleanName, location, SimpleTimeMark.now())
- waypoints = waypoints.editCopy { this[cleanName] = inquis }
+ val inquis = SharedInquisitor(name, displayName, location, SimpleTimeMark.now())
+ waypoints = waypoints.editCopy { this[name] = inquis }
if (config.focusInquisitor) {
GriffinBurrowHelper.setTargetLocation(location.add(y = 1))
GriffinBurrowHelper.animationLocation = LocationUtils.playerLocation()
@@ -245,18 +250,20 @@ object InquisitorWaypointShare {
event.isCanceled = true
}
diedPattern.matchMatcher(message) {
- val playerName = group("playerName").cleanPlayerName()
- waypoints = waypoints.editCopy { remove(playerName) }
- logger.log("Inquisitor died from '$playerName'")
+ val rawName = group("playerName")
+ val name = rawName.cleanPlayerName()
+ val displayName = rawName.cleanPlayerName(displayName = true)
+ waypoints = waypoints.editCopy { remove(name) }
+ logger.log("Inquisitor died from '$displayName'")
}
}
fun isEnabled() = DianaAPI.featuresEnabled() && config.enabled
- fun maybeRemove(playerName: String) {
+ fun maybeRemove(inquis: SharedInquisitor) {
if (inquisitorsNearby.isEmpty()) {
- waypoints = waypoints.editCopy { remove(playerName) }
- LorenzUtils.chat("Inquisitor from $playerName not found, deleting.")
+ waypoints = waypoints.editCopy { remove(inquis.fromPlayer) }
+ LorenzUtils.chat("Inquisitor from ${inquis.displayName} not found, deleting.")
}
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
index 8c75475c9..cb7a0fa23 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.utils
+import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.mixins.transformers.AccessorChatComponentText
import at.hannibal2.skyhanni.utils.GuiRenderUtils.darkenColor
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
@@ -80,7 +81,7 @@ object StringUtils {
inline fun <T> Pattern.matchMatcher(text: String, consumer: Matcher.() -> T) =
matcher(text).let { if (it.matches()) consumer(it) else null }
- fun String.cleanPlayerName(): String {
+ private fun String.internalCleanPlayerName(): String {
val split = trim().split(" ")
return if (split.size > 1) {
split[1].removeColor()
@@ -89,6 +90,16 @@ object StringUtils {
}
}
+ fun String.cleanPlayerName(displayName: Boolean = false): String {
+ return if (displayName) {
+ if (SkyHanniMod.feature.chat.playerMessage.playerRankHider) {
+ "§b" + internalCleanPlayerName()
+ } else this
+ } else {
+ internalCleanPlayerName()
+ }
+ }
+
inline fun <T> List<Pattern>.matchMatchers(text: String, consumer: Matcher.() -> T): T? {
for (pattern in iterator()) {
pattern.matchMatcher<T>(text) {