Rebase and prepare for merge

This commit is contained in:
Bjarne Koll 2024-05-05 11:46:31 +02:00
parent 5c09e68fc2
commit c8f694273f
No known key found for this signature in database
GPG Key ID: 27F6CCCF55D2EE62
3 changed files with 105 additions and 68 deletions

View File

@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: nostalfinals <yuu8583@proton.me>
Date: Mon, 8 Apr 2024 23:24:38 +0800
Subject: [PATCH] Added API to get player's proxy address
Subject: [PATCH] Added API to get player ha proxy address
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java

View File

@ -0,0 +1,104 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: nostalfinals <yuu8583@proton.me>
Date: Mon, 8 Apr 2024 23:24:38 +0800
Subject: [PATCH] Added API to get player ha proxy address
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 58d28b6c1cc7da7d786f78308db971f7502ad844..80e50e4e59109f63f0ffe0ac711d46347986076c 100644
--- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java
@@ -27,7 +27,6 @@ import io.netty.channel.epoll.EpollSocketChannel;
import io.netty.channel.local.LocalChannel;
import io.netty.channel.local.LocalServerChannel;
import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.flow.FlowControlHandler;
import io.netty.handler.timeout.ReadTimeoutHandler;
@@ -41,7 +40,6 @@ import java.util.concurrent.RejectedExecutionException;
import java.util.function.Consumer;
import java.util.function.Supplier;
import javax.annotation.Nullable;
-import javax.crypto.Cipher;
import net.minecraft.SharedConstants;
import net.minecraft.Util;
import net.minecraft.network.chat.Component;
@@ -157,6 +155,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
this.stopReadingPackets = true;
}
// Paper end - packet limiter
+ @Nullable public SocketAddress haProxyAddress; // Paper - Add API to get player's proxy address
public Connection(PacketFlow side) {
this.receiving = side;
diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
index 52f537b7bfbdeaad9d17c0e88a1ed1c8925a833f..713f86b1b7273368c3f2162ea7feed0d819931ce 100644
--- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
+++ b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
@@ -20,7 +20,6 @@ import io.netty.channel.epoll.EpollServerSocketChannel;
import io.netty.channel.local.LocalAddress;
import io.netty.channel.local.LocalServerChannel;
import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.channel.socket.ServerSocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.timeout.ReadTimeoutHandler;
import io.netty.util.HashedWheelTimer;
@@ -146,6 +145,13 @@ public class ServerConnectionListener {
Connection connection = (Connection) channel.pipeline().get("packet_handler");
connection.address = socketaddr;
+
+ // Paper start - Add API to get player's proxy address
+ final String proxyAddress = message.destinationAddress();
+ final int proxyPort = message.destinationPort();
+
+ connection.haProxyAddress = new java.net.InetSocketAddress(proxyAddress, proxyPort);
+ // Paper end - Add API to get player's proxy address
}
} else {
super.channelRead(ctx, msg);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 0ff9bb5f5d312503ec4b3cf3bf8c532b09a8f08b..5d660f54f88a4108e52fa165c5510d9da84193b1 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -159,7 +159,6 @@ import org.bukkit.craftbukkit.map.CraftMapView;
import org.bukkit.craftbukkit.map.RenderData;
import org.bukkit.craftbukkit.potion.CraftPotionEffectType;
import org.bukkit.craftbukkit.potion.CraftPotionUtil;
-import org.bukkit.craftbukkit.profile.CraftPlayerProfile;
import org.bukkit.craftbukkit.scoreboard.CraftScoreboard;
import org.bukkit.craftbukkit.util.CraftChatMessage;
import org.bukkit.craftbukkit.util.CraftLocation;
@@ -172,7 +171,6 @@ import org.bukkit.event.player.PlayerExpCooldownChangeEvent;
import org.bukkit.event.player.PlayerHideEntityEvent;
import org.bukkit.event.player.PlayerRegisterChannelEvent;
import org.bukkit.event.player.PlayerShowEntityEvent;
-import org.bukkit.event.player.PlayerSpawnChangeEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerUnregisterChannelEvent;
import org.bukkit.inventory.EquipmentSlot;
@@ -185,7 +183,6 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.messaging.StandardMessenger;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
-import org.bukkit.profile.PlayerProfile;
import org.bukkit.scoreboard.Scoreboard;
import org.jetbrains.annotations.NotNull;
@@ -273,6 +270,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
}
+ // Paper start - Add API to get player's proxy address
+ @Override
+ public @Nullable InetSocketAddress getHAProxyAddress() {
+ if (this.getHandle().connection == null) return null;
+
+ return this.getHandle().connection.connection.haProxyAddress instanceof final InetSocketAddress inetSocketAddress ? inetSocketAddress : null;
+ }
+ // Paper end - Add API to get player's proxy address
+
public interface TransferCookieConnection {
boolean isTransferred();

View File

@ -1,67 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: nostalfinals <yuu8583@proton.me>
Date: Mon, 8 Apr 2024 23:24:38 +0800
Subject: [PATCH] Added API to get player's proxy address
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 58d28b6c1cc7da7d786f78308db971f7502ad844..fc4b22cf7c554a7553da8558ec265958509019a6 100644
--- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java
@@ -157,6 +157,8 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
this.stopReadingPackets = true;
}
// Paper end - packet limiter
+ @Nullable
+ public SocketAddress proxyAddress; // Paper - Add API to get player's proxy address
public Connection(PacketFlow side) {
this.receiving = side;
diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
index 52f537b7bfbdeaad9d17c0e88a1ed1c8925a833f..9841ae13e3b547cc90293fa3aa5ba24e46d6c65d 100644
--- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
+++ b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
@@ -146,6 +146,15 @@ public class ServerConnectionListener {
Connection connection = (Connection) channel.pipeline().get("packet_handler");
connection.address = socketaddr;
+
+ // Paper start - Add API to get player's proxy address
+ String proxyAddress = message.destinationAddress();
+ int proxyPort = message.destinationPort();
+
+ SocketAddress proxyAddr = new java.net.InetSocketAddress(proxyAddress, proxyPort);
+
+ connection.proxyAddress = proxyAddr;
+ // Paper end - Add API to get player's proxy address
}
} else {
super.channelRead(ctx, msg);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index eddbbd0e9be3cb81d1030c0c9da829b9193ebc16..6a5c6cf00fd1c69fa5ef2ad4b10fe817d0b51e11 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -273,6 +273,23 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
}
+ // Paper start - Add API to get player's proxy address
+ @Override
+ public @Nullable InetSocketAddress getHAProxyAddress() {
+ if (this.getHandle().connection == null) {
+ return null;
+ }
+
+ SocketAddress addr = this.getHandle().connection.connection.proxyAddress;
+
+ if (addr instanceof InetSocketAddress) {
+ return (InetSocketAddress) addr;
+ }
+
+ return null;
+ }
+ // Paper end - Add API to get player's proxy address
+
public interface TransferCookieConnection {
boolean isTransferred();