Remove redundant getRemoteAddress that can cause an NPE (#7331)

This commit is contained in:
PureGero 2022-01-14 13:56:45 +10:00
parent 4627ffe255
commit 2c7a063234
2 changed files with 21 additions and 13 deletions

View File

@ -85,20 +85,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -0,0 +0,0 @@ public abstract class PlayerList {
String s1 = "local";
final String s1;
if (connection.getRemoteAddress() != null) {
- s1 = connection.getRemoteAddress().toString();
+ s1 = com.destroystokyo.paper.PaperConfig.logPlayerIpAddresses ? connection.getRemoteAddress().toString() : "<ip address withheld>"; // Paper
} else {
s1 = "local";
}
// Spigot start - spawn location event
@@ -0,0 +0,0 @@ public abstract class PlayerList {
playerconnection.playerJoinReady = () -> {
postChunkLoadJoin(
player, finalWorldserver, connection, playerconnection,
- nbttagcompound, connection.getRemoteAddress().toString(), lastKnownName
+ nbttagcompound, com.destroystokyo.paper.PaperConfig.logPlayerIpAddresses ? connection.getRemoteAddress().toString() : "<ip address withheld>", lastKnownName // Paper
);
};
});

View File

@ -136,6 +136,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit end
if (nbttagcompound != null) {
@@ -0,0 +0,0 @@ public abstract class PlayerList {
if (nbttagcompound == null) player.fudgeSpawnLocation(worldserver1); // Paper - only move to spawn on first login, otherwise, stay where you are....
player.setLevel(worldserver1);
- String s1 = "local";
+ // Paper start - make s1 final
+ final String s1;
if (connection.getRemoteAddress() != null) {
s1 = connection.getRemoteAddress().toString();
+ } else {
+ s1 = "local";
}
+ // Paper end
// Spigot start - spawn location event
Player spawnPlayer = player.getBukkitEntity();
@@ -0,0 +0,0 @@ public abstract class PlayerList {
player.getRecipeBook().sendInitialRecipeBook(player);
this.updateEntireScoreboard(worldserver1.getScoreboard(), player);
@ -160,7 +177,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ playerconnection.playerJoinReady = () -> {
+ postChunkLoadJoin(
+ player, finalWorldserver, connection, playerconnection,
+ nbttagcompound, connection.getRemoteAddress().toString(), lastKnownName
+ nbttagcompound, s1, lastKnownName
+ );
+ };
+ });