From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: AlphaKR93 Date: Sun, 5 Nov 2023 10:40:49 +0900 Subject: [PATCH] Tweak console logging diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java index e4fd372a1d585887287253a02531cd192929377b..6624fb97404c3032d60167e3fb108dcfcd066784 100644 --- a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java +++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java @@ -355,7 +355,7 @@ public final class ChatProcessor { private void sendToServer(final ChatType.Bound chatType, final @Nullable Function msgFunction) { final PlayerChatMessage toConsoleMessage = msgFunction == null ? ChatProcessor.this.message : ChatProcessor.this.message.withUnsignedContent(msgFunction.apply(ChatProcessor.this.server.console)); - ChatProcessor.this.server.logChatMessage(toConsoleMessage.decoratedContent(), chatType, ChatProcessor.this.server.getPlayerList().verifyChatTrusted(toConsoleMessage) ? null : "Not Secure"); + ChatProcessor.this.server.logChatMessage(toConsoleMessage.decoratedContent(), chatType, (!org.plazmamc.plazma.configurations.GlobalConfiguration.get().consoleLogs.notSecurePrefix || ChatProcessor.this.server.getPlayerList().verifyChatTrusted(toConsoleMessage)) ? null : "Not Secure"); // Plazma - Tweak console logging } } diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java index 8fc6b2e4be405d6738fedb91ffee5cbfe4fca67d..5c897d11e6ae17d8feaeedc7edf7ede02571a207 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java @@ -180,16 +180,6 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface DedicatedServer.LOGGER.warn("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); } - // Paper start - detect running as root - if (io.papermc.paper.util.ServerEnvironment.userIsRootOrAdmin()) { - DedicatedServer.LOGGER.warn("****************************"); - DedicatedServer.LOGGER.warn("YOU ARE RUNNING THIS SERVER AS AN ADMINISTRATIVE OR ROOT USER. THIS IS NOT ADVISED."); - DedicatedServer.LOGGER.warn("YOU ARE OPENING YOURSELF UP TO POTENTIAL RISKS WHEN DOING THIS."); - DedicatedServer.LOGGER.warn("FOR MORE INFORMATION, SEE https://madelinemiller.dev/blog/root-minecraft-server/"); - DedicatedServer.LOGGER.warn("****************************"); - } - // Paper end - DedicatedServer.LOGGER.info("Loading properties"); DedicatedServerProperties dedicatedserverproperties = this.settings.getProperties(); @@ -319,6 +309,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface String proxyFlavor = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "Velocity" : "BungeeCord"; String proxyLink = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "https://docs.papermc.io/velocity/security" : "http://www.spigotmc.org/wiki/firewall-guide/"; // Paper end + if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().consoleLogs.offlineWarnings) // Plazma - Tweak console logging if (!this.usesAuthentication()) { DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); @@ -335,6 +326,17 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface DedicatedServer.LOGGER.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file."); } + // Plazma - Moved down - Tweak console logging + // Paper start - detect running as root + if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().consoleLogs.rootUserWarnings && io.papermc.paper.util.ServerEnvironment.userIsRootOrAdmin()) { + DedicatedServer.LOGGER.warn("****************************"); + DedicatedServer.LOGGER.warn("YOU ARE RUNNING THIS SERVER AS AN ADMINISTRATIVE OR ROOT USER. THIS IS NOT ADVISED."); + DedicatedServer.LOGGER.warn("YOU ARE OPENING YOURSELF UP TO POTENTIAL RISKS WHEN DOING THIS."); + DedicatedServer.LOGGER.warn("FOR MORE INFORMATION, SEE https://madelinemiller.dev/blog/root-minecraft-server/"); + DedicatedServer.LOGGER.warn("****************************"); + } + // Paper end + // Plazma end if (!OldUsersConverter.serverReadyAfterUserconversion(this)) { return false; diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java index 92717b7aa7ac94a2b1d11b5ba46522057903f981..80dc93b8c96d78a4080c0636b8cd7c470a1e3922 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -1468,6 +1468,7 @@ public abstract class PlayerList { public void broadcastChatMessage(PlayerChatMessage message, Predicate shouldSendFiltered, @Nullable ServerPlayer sender, ChatType.Bound params, @Nullable Function unsignedFunction) { // Paper end boolean flag = this.verifyChatTrusted(message); + flag = flag || org.plazmamc.plazma.configurations.GlobalConfiguration.get().consoleLogs.notSecurePrefix; // Plazma - Tweak console logging this.server.logChatMessage((unsignedFunction == null ? message.decoratedContent() : unsignedFunction.apply(this.server.console)), params, flag ? null : "Not Secure"); // Paper OutgoingChatMessage outgoingchatmessage = OutgoingChatMessage.create(message); diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java index 5875aae8d7d0146ef9903d8b4bc2b673a615fd98..51413e828500792cc493b836bb1460a394ff4f75 100644 --- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java @@ -42,4 +42,13 @@ public class GlobalConfiguration extends ConfigurationPart { } + public ConsoleLogs consoleLogs; + public class ConsoleLogs extends ConfigurationPart { + + public boolean offlineWarnings = true; + public boolean rootUserWarnings = true; + public boolean notSecurePrefix = true; + + } + }