From 03c36a06fe886889044aa1d457c56ff2f1933f7a Mon Sep 17 00:00:00 2001 From: xGinko Date: Tue, 5 Mar 2024 14:55:36 +0100 Subject: [PATCH] properly log without prefix in folia --- .../modules/misc/FirstJoinMessages.java | 5 ++++- .../modules/misc/JoinLeaveMessages.java | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/misc/FirstJoinMessages.java b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/misc/FirstJoinMessages.java index 09e70d51c..94a3c6674 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/misc/FirstJoinMessages.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/misc/FirstJoinMessages.java @@ -7,6 +7,7 @@ import me.moomoo.anarchyexploitfixes.modules.AnarchyExploitFixesModule; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextReplacementConfig; +import net.kyori.adventure.text.logger.slf4j.ComponentLogger; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -23,6 +24,7 @@ public class FirstJoinMessages implements AnarchyExploitFixesModule, Listener { private final AnarchyExploitFixes plugin; + private final ComponentLogger unprefixedLogger; private final Config config; private final HashMap formats = new HashMap<>(); private final AtomicInteger uniquePlayerCount = new AtomicInteger(0); @@ -31,6 +33,7 @@ public class FirstJoinMessages implements AnarchyExploitFixesModule, Listener { public FirstJoinMessages() { shouldEnable(); this.config = AnarchyExploitFixes.getConfiguration(); + this.unprefixedLogger = ComponentLogger.logger(""); config.addComment("misc.join-leave-messages.first-join-messages.enable", "Configure messages in lang folder."); this.plugin = AnarchyExploitFixes.getInstance(); @@ -100,7 +103,7 @@ private void onPlayerJoin(PlayerJoinEvent event) { if (logFirstJoin) { for (Component line : AnarchyExploitFixes.getLang(joiningPlayer.locale()).misc_firstJoinMessage) { - plugin.getComponentLogger().info(line + unprefixedLogger.info(line .replaceText(TextReplacementConfig.builder() .matchLiteral("%player%") .replacement(joiningPlayer.name()) diff --git a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/misc/JoinLeaveMessages.java b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/misc/JoinLeaveMessages.java index 174d37789..903f52a75 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/misc/JoinLeaveMessages.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/misc/JoinLeaveMessages.java @@ -6,6 +6,7 @@ import me.moomoo.anarchyexploitfixes.modules.AnarchyExploitFixesModule; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextReplacementConfig; +import net.kyori.adventure.text.logger.slf4j.ComponentLogger; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -19,11 +20,13 @@ public class JoinLeaveMessages implements AnarchyExploitFixesModule, Listener { private final AnarchyExploitFixes plugin; + private final ComponentLogger unprefixedLogger; private final boolean connectionMsgsOnByDefault, showInConsole, firstJoinEnabled; public JoinLeaveMessages() { shouldEnable(); this.plugin = AnarchyExploitFixes.getInstance(); + this.unprefixedLogger = ComponentLogger.logger(""); Config config = AnarchyExploitFixes.getConfiguration(); config.addComment("misc.join-leave-messages.enable", "If you want to hide yourself or someone else when logging into the game,\n" + @@ -79,7 +82,7 @@ private void onPlayerJoinEvent(PlayerJoinEvent event) { } if (showInConsole) { - plugin.getComponentLogger().info(AnarchyExploitFixes.getLang(joiningPlayer.locale()).misc_joinMessage + unprefixedLogger.info(AnarchyExploitFixes.getLang(joiningPlayer.locale()).misc_joinMessage .replaceText(TextReplacementConfig.builder().matchLiteral("%player%").replacement(joiningPlayer.name()).build()) .append(Component.text(" (" + joiningPlayer.locale() + ")"))); } @@ -106,7 +109,7 @@ private void onPlayerLeaveEvent(PlayerQuitEvent event) { } if (showInConsole) { - plugin.getComponentLogger().info(AnarchyExploitFixes.getLang(leavingPlayer.locale()).misc_leaveMessage + unprefixedLogger.info(AnarchyExploitFixes.getLang(leavingPlayer.locale()).misc_leaveMessage .replaceText(TextReplacementConfig.builder().matchLiteral("%player%").replacement(leavingPlayer.name()).build()) .append(Component.text(" (" + leavingPlayer.locale() + ")"))); }