Skip to content

Commit

Permalink
properly log without prefix in folia
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Mar 5, 2024
1 parent 55f6ace commit 03c36a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Locale, RuleBasedNumberFormat> formats = new HashMap<>();
private final AtomicInteger uniquePlayerCount = new AtomicInteger(0);
Expand All @@ -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();
Expand Down Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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" +
Expand Down Expand Up @@ -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() + ")")));
}
Expand All @@ -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() + ")")));
}
Expand Down

0 comments on commit 03c36a0

Please sign in to comment.