Paper/patches/removed/1.19.4/0739-Add-config-option-for-logging-player-ip-addresses-PARTIAL.patch
2023-03-14 16:29:38 -07:00

19 lines
1.9 KiB
Diff

diff --git a/src/main/java/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
index aba1069d29389c07012ba9365fa6ae1d88fdf73c..23c81b3a96056f0b755735ad75fc81af9b046475 100644
--- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java
+++ b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
@@ -51,10 +51,11 @@ public class PacketUtils {
packet.handle(listener);
} catch (Exception exception) {
net.minecraft.network.Connection networkmanager = listener.getConnection();
+ String playerIP = io.papermc.paper.configuration.GlobalConfiguration.get().logging.logPlayerIpAddresses ? String.valueOf(networkmanager.getRemoteAddress()) : "<ip address withheld>"; // Paper
if (networkmanager.getPlayer() != null) {
- LOGGER.error("Error whilst processing packet {} for {}[{}]", packet, networkmanager.getPlayer().getScoreboardName(), networkmanager.getRemoteAddress(), exception);
+ LOGGER.error("Error whilst processing packet {} for {}[{}]", packet, networkmanager.getPlayer().getScoreboardName(), playerIP, exception); // Paper
} else {
- LOGGER.error("Error whilst processing packet {} for connection from {}", packet, networkmanager.getRemoteAddress(), exception);
+ LOGGER.error("Error whilst processing packet {} for connection from {}", packet, playerIP, exception); // Paper
}
net.minecraft.network.chat.Component error = net.minecraft.network.chat.Component.literal("Packet processing error");
networkmanager.send(new net.minecraft.network.protocol.game.ClientboundDisconnectPacket(error), net.minecraft.network.PacketSendListener.thenRun(() -> networkmanager.disconnect(error)));