aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLorenz <ESs95s3P5z8Pheb>2022-07-08 13:29:29 +0200
committerLorenz <ESs95s3P5z8Pheb>2022-07-08 13:29:29 +0200
commit07ccd2ac5f80679f353f26593c38e497e9de38c3 (patch)
tree8604ffa6e7546b5ab4728a8a7bbce3c41ba3265e /src
parenta4861334a90c7f87318dba5bcbf5ae738fb4136a (diff)
downloadskyhanni-07ccd2ac5f80679f353f26593c38e497e9de38c3.tar.gz
skyhanni-07ccd2ac5f80679f353f26593c38e497e9de38c3.tar.bz2
skyhanni-07ccd2ac5f80679f353f26593c38e497e9de38c3.zip
moved player chat messages into separate setting
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/lorenz/mod/chat/ChatFilter.kt1
-rw-r--r--src/main/java/at/lorenz/mod/chat/PlayerChatFilter.kt125
-rw-r--r--src/main/java/at/lorenz/mod/config/Features.java5
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/LorenzMod.java6
4 files changed, 77 insertions, 60 deletions
diff --git a/src/main/java/at/lorenz/mod/chat/ChatFilter.kt b/src/main/java/at/lorenz/mod/chat/ChatFilter.kt
index 29700a099..2ad5284c9 100644
--- a/src/main/java/at/lorenz/mod/chat/ChatFilter.kt
+++ b/src/main/java/at/lorenz/mod/chat/ChatFilter.kt
@@ -25,7 +25,6 @@ class ChatFilter {
warping(message) -> "warping"
welcome(message) -> "welcome"
guild(message) -> "guild"
- PlayerChatFilter.shouldBlock(message) -> "player_chat"
killCombo(message) -> "kill_combo"
bazaarAndAHMiniMessages(message) -> "bz_ah_minis"
watchdogAnnouncement(message) -> "watchdog"
diff --git a/src/main/java/at/lorenz/mod/chat/PlayerChatFilter.kt b/src/main/java/at/lorenz/mod/chat/PlayerChatFilter.kt
index b8ec7f87f..db8afe4cd 100644
--- a/src/main/java/at/lorenz/mod/chat/PlayerChatFilter.kt
+++ b/src/main/java/at/lorenz/mod/chat/PlayerChatFilter.kt
@@ -1,78 +1,89 @@
package at.lorenz.mod.chat
+import at.lorenz.mod.events.LorenzChatEvent
import at.lorenz.mod.utils.LorenzLogger
import at.lorenz.mod.utils.LorenzUtils
import at.lorenz.mod.utils.LorenzUtils.removeColorCodes
import at.lorenz.mod.events.PlayerSendChatEvent
+import com.thatgravyboat.skyblockhud.LorenzMod
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class PlayerChatFilter {
- companion object {
- val loggerPlayerChat = LorenzLogger("chat/player")
+ @SubscribeEvent
+ fun onChatMessage(event: LorenzChatEvent) {
+ if (!LorenzMod.feature.chat.playerMessages) return
- fun shouldBlock(originalMessage: String): Boolean {
- val split: List<String> = if (originalMessage.contains("§7§r§7: ")) {
- originalMessage.split("§7§r§7: ")
- } else if (originalMessage.contains("§f: ")) {
- originalMessage.split("§f: ")
- } else {
- return false
- }
+ if (shouldBlock(event.message)) {
+ event.blockedReason = "player_chat"
+ }
+ }
- var rawName = split[0]
- val message = split[1]
-
- val channel: PlayerMessageChannel
- if (rawName.startsWith("§9Party §8> ")) {
- channel = PlayerMessageChannel.PARTY
- rawName = rawName.substring(12)
- } else if (rawName.startsWith("§2Guild > ")) {
- channel = PlayerMessageChannel.GUILD
- rawName = rawName.substring(10)
- } else if (rawName.startsWith("§bCo-op > ")) {
- channel = PlayerMessageChannel.COOP
- rawName = rawName.substring(10)
- } else {
- channel = PlayerMessageChannel.ALL
- }
+ val loggerPlayerChat = LorenzLogger("chat/player")
- val nameSplit = rawName.split(" ")
- val first = nameSplit[0]
+ fun shouldBlock(originalMessage: String): Boolean {
+ val split: List<String> = if (originalMessage.contains("§7§r§7: ")) {
+ originalMessage.split("§7§r§7: ")
+ } else if (originalMessage.contains("§f: ")) {
+ originalMessage.split("§f: ")
+ } else {
+ return false
+ }
- val last = nameSplit.last()
- val name = if (last.endsWith("]")) {
- nameSplit[nameSplit.size - 2]
- } else {
- last
- }
+ var rawName = split[0]
+ val message = split[1]
- if (first != name) {
- if (!first.contains("VIP") && !first.contains("MVP")) {
- //TODO support yt + admin
- return false
- }
- }
+ val channel: PlayerMessageChannel
+ if (rawName.startsWith("§9Party §8> ")) {
+ channel = PlayerMessageChannel.PARTY
+ rawName = rawName.substring(12)
+ } else if (rawName.startsWith("§2Guild > ")) {
+ channel = PlayerMessageChannel.GUILD
+ rawName = rawName.substring(10)
+ } else if (rawName.startsWith("§bCo-op > ")) {
+ channel = PlayerMessageChannel.COOP
+ rawName = rawName.substring(10)
+ } else {
+ channel = PlayerMessageChannel.ALL
+ }
+
+ val nameSplit = rawName.split(" ")
+ val first = nameSplit[0]
- send(channel, name.removeColorCodes(), message.removeColorCodes())
- return true
+ val last = nameSplit.last()
+ val name = if (last.endsWith("]")) {
+ nameSplit[nameSplit.size - 2]
+ } else {
+ last
}
- private fun send(channel: PlayerMessageChannel, name: String, message: String) {
- loggerPlayerChat.log("[$channel] $name: $message")
- val event = PlayerSendChatEvent(channel, name, message)
- event.postAndCatch()
-
- if (event.cancelledReason != "") {
- loggerPlayerChat.log("cancelled: " + event.cancelledReason)
- } else {
- val finalMessage = event.message
- if (finalMessage != message) {
- loggerPlayerChat.log("message changed: $finalMessage")
- }
-
- val prefix = channel.prefix
- LorenzUtils.chat("$prefix §b$name §f$finalMessage")
+ if (first != name) {
+ if (!first.contains("VIP") && !first.contains("MVP")) {
+ //TODO support yt + admin
+ return false
}
}
+
+ send(channel, name.removeColorCodes(), message.removeColorCodes())
+ return true
}
+
+ private fun send(channel: PlayerMessageChannel, name: String, message: String) {
+ loggerPlayerChat.log("[$channel] $name: $message")
+ val event = PlayerSendChatEvent(channel, name, message)
+ event.postAndCatch()
+
+ if (event.cancelledReason != "") {
+ loggerPlayerChat.log("cancelled: " + event.cancelledReason)
+ } else {
+ val finalMessage = event.message
+ if (finalMessage != message) {
+ loggerPlayerChat.log("message changed: $finalMessage")
+ }
+
+ val prefix = channel.prefix
+ LorenzUtils.chat("$prefix §b$name §f$finalMessage")
+ }
+ }
+
} \ No newline at end of file
diff --git a/src/main/java/at/lorenz/mod/config/Features.java b/src/main/java/at/lorenz/mod/config/Features.java
index 6c484290d..988b65f76 100644
--- a/src/main/java/at/lorenz/mod/config/Features.java
+++ b/src/main/java/at/lorenz/mod/config/Features.java
@@ -90,6 +90,11 @@ public class Features extends Config {
@ConfigOption(name = "Main Chat Filter", desc = "Hides all the annoying chat messages.")
@ConfigEditorBoolean
public boolean mainFilter = true;
+
+ @Expose
+ @ConfigOption(name = "Player Messages", desc = "Add a fancy new chat format for player messages.")
+ @ConfigEditorBoolean
+ public boolean playerMessages = false;
}
public static class Dungeon {
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/LorenzMod.java b/src/main/java/com/thatgravyboat/skyblockhud/LorenzMod.java
index 94e745476..18a1b32b4 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/LorenzMod.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/LorenzMod.java
@@ -6,6 +6,7 @@ import at.lorenz.mod.bazaar.BazaarApi;
import at.lorenz.mod.bazaar.BazaarOrderHelper;
import at.lorenz.mod.chat.ChatFilter;
import at.lorenz.mod.chat.ChatManager;
+import at.lorenz.mod.chat.PlayerChatFilter;
import at.lorenz.mod.config.Features;
import at.lorenz.mod.dungeon.DungeonChatFilter;
import at.lorenz.mod.dungeon.DungeonHighlightClickedBlocks;
@@ -47,11 +48,12 @@ public class LorenzMod {
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
new BazaarApi();
-
MinecraftForge.EVENT_BUS.register(this);
- MinecraftForge.EVENT_BUS.register(new BazaarOrderHelper());
MinecraftForge.EVENT_BUS.register(new ChatManager());
+
+ MinecraftForge.EVENT_BUS.register(new BazaarOrderHelper());
MinecraftForge.EVENT_BUS.register(new ChatFilter());
+ MinecraftForge.EVENT_BUS.register(new PlayerChatFilter());
MinecraftForge.EVENT_BUS.register(new DungeonChatFilter());
MinecraftForge.EVENT_BUS.register(new HideNotClickableItems());
MinecraftForge.EVENT_BUS.register(new DungeonHighlightClickedBlocks());