2024-12-11 22:26:55 +01:00
|
|
|
--- a/net/minecraft/network/Connection.java
|
|
|
|
+++ b/net/minecraft/network/Connection.java
|
2014-04-25 23:46:46 +02:00
|
|
|
@@ -96,6 +96,11 @@
|
2014-04-12 13:23:58 +02:00
|
|
|
private final Queue<Consumer<Connection>> pendingActions = Queues.newConcurrentLinkedQueue();
|
|
|
|
public Channel channel;
|
|
|
|
public SocketAddress address;
|
|
|
|
+ // Spigot Start
|
|
|
|
+ public java.util.UUID spoofedUUID;
|
|
|
|
+ public com.mojang.authlib.properties.Property[] spoofedProfile;
|
2014-04-25 23:46:46 +02:00
|
|
|
+ public boolean preparing = true;
|
2014-04-12 13:23:58 +02:00
|
|
|
+ // Spigot End
|
|
|
|
@Nullable
|
|
|
|
private volatile PacketListener disconnectListener;
|
|
|
|
@Nullable
|
2016-03-29 02:55:47 +02:00
|
|
|
@@ -114,6 +119,19 @@
|
2024-12-11 22:26:55 +01:00
|
|
|
private volatile DisconnectionDetails delayedDisconnect;
|
|
|
|
@Nullable
|
|
|
|
BandwidthDebugMonitor bandwidthDebugMonitor;
|
|
|
|
+ public String hostname = ""; // CraftBukkit - add field
|
2016-03-29 02:55:47 +02:00
|
|
|
+
|
|
|
|
+ // Paper start - add utility methods
|
|
|
|
+ public final net.minecraft.server.level.ServerPlayer getPlayer() {
|
|
|
|
+ if (this.packetListener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl impl) {
|
|
|
|
+ return impl.player;
|
|
|
|
+ } else if (this.packetListener instanceof net.minecraft.server.network.ServerCommonPacketListenerImpl impl) {
|
|
|
|
+ org.bukkit.craftbukkit.entity.CraftPlayer player = impl.getCraftPlayer();
|
|
|
|
+ return player == null ? null : player.getHandle();
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ // Paper end - add utility methods
|
2024-12-11 22:26:55 +01:00
|
|
|
|
|
|
|
public Connection(PacketFlow side) {
|
|
|
|
this.receiving = side;
|
2016-03-29 02:55:47 +02:00
|
|
|
@@ -123,6 +141,9 @@
|
2014-04-25 23:46:46 +02:00
|
|
|
super.channelActive(channelhandlercontext);
|
|
|
|
this.channel = channelhandlercontext.channel();
|
|
|
|
this.address = this.channel.remoteAddress();
|
|
|
|
+ // Spigot Start
|
|
|
|
+ this.preparing = false;
|
|
|
|
+ // Spigot End
|
|
|
|
if (this.delayedDisconnect != null) {
|
|
|
|
this.disconnect(this.delayedDisconnect);
|
|
|
|
}
|
2016-03-29 02:55:47 +02:00
|
|
|
@@ -176,6 +197,7 @@
|
2014-04-13 01:00:59 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+ if (net.minecraft.server.MinecraftServer.getServer().isDebugging()) throwable.printStackTrace(); // Spigot
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void channelRead0(ChannelHandlerContext channelhandlercontext, Packet<?> packet) {
|
2016-03-29 02:55:47 +02:00
|
|
|
@@ -205,7 +227,7 @@
|
2024-12-11 22:26:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private static <T extends PacketListener> void genericsFtw(Packet<T> packet, PacketListener listener) {
|
|
|
|
- packet.handle(listener);
|
|
|
|
+ packet.handle((T) listener); // CraftBukkit - decompile error
|
|
|
|
}
|
|
|
|
|
|
|
|
private void validateListener(ProtocolInfo<?> state, PacketListener listener) {
|
2016-03-29 02:55:47 +02:00
|
|
|
@@ -464,12 +486,15 @@
|
2014-04-25 23:46:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void disconnect(DisconnectionDetails disconnectionInfo) {
|
|
|
|
+ // Spigot Start
|
|
|
|
+ this.preparing = false;
|
|
|
|
+ // Spigot End
|
|
|
|
if (this.channel == null) {
|
|
|
|
this.delayedDisconnect = disconnectionInfo;
|
2024-12-11 22:26:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.isConnected()) {
|
|
|
|
- this.channel.close().awaitUninterruptibly();
|
|
|
|
+ this.channel.close(); // We can't wait as this may be called from an event loop.
|
|
|
|
this.disconnectionDetails = disconnectionInfo;
|
|
|
|
}
|
|
|
|
|
2016-03-29 02:55:47 +02:00
|
|
|
@@ -537,7 +562,7 @@
|
2024-12-11 22:26:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void configurePacketHandler(ChannelPipeline pipeline) {
|
|
|
|
- pipeline.addLast("hackfix", new ChannelOutboundHandlerAdapter(this) {
|
|
|
|
+ pipeline.addLast("hackfix", new ChannelOutboundHandlerAdapter() { // CraftBukkit - decompile error
|
|
|
|
public void write(ChannelHandlerContext channelhandlercontext, Object object, ChannelPromise channelpromise) throws Exception {
|
|
|
|
super.write(channelhandlercontext, object, channelpromise);
|
|
|
|
}
|
2016-03-29 02:55:47 +02:00
|
|
|
@@ -661,6 +686,7 @@
|
2015-07-22 11:04:37 +02:00
|
|
|
|
|
|
|
packetlistener1.onDisconnect(disconnectiondetails);
|
|
|
|
}
|
|
|
|
+ this.pendingActions.clear(); // Free up packet queue.
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|