mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-14 11:45:52 -07:00
@@ -1,14 +1,14 @@
|
||||
--- a/net/minecraft/network/NetworkManager.java
|
||||
+++ b/net/minecraft/network/NetworkManager.java
|
||||
@@ -88,6 +88,7 @@
|
||||
private boolean handlingFault;
|
||||
@Nullable
|
||||
@@ -105,6 +105,7 @@
|
||||
private volatile IChatBaseComponent delayedDisconnect;
|
||||
@Nullable
|
||||
BandwidthDebugMonitor bandwidthDebugMonitor;
|
||||
+ public String hostname = ""; // CraftBukkit - add field
|
||||
|
||||
public NetworkManager(EnumProtocolDirection enumprotocoldirection) {
|
||||
this.receiving = enumprotocoldirection;
|
||||
@@ -173,7 +174,7 @@
|
||||
@@ -194,7 +195,7 @@
|
||||
}
|
||||
|
||||
private static <T extends PacketListener> void genericsFtw(Packet<T> packet, PacketListener packetlistener) {
|
||||
@@ -16,8 +16,8 @@
|
||||
+ packet.handle((T) packetlistener); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public void setListener(PacketListener packetlistener) {
|
||||
@@ -306,7 +307,7 @@
|
||||
public void suspendInboundAfterProtocolChange() {
|
||||
@@ -421,7 +422,7 @@
|
||||
}
|
||||
|
||||
if (this.isConnected()) {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/network/PacketDataSerializer.java
|
||||
+++ b/net/minecraft/network/PacketDataSerializer.java
|
||||
@@ -81,6 +81,8 @@
|
||||
@@ -80,6 +80,8 @@
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
+
|
||||
public class PacketDataSerializer extends ByteBuf {
|
||||
|
||||
private static final int MAX_VARINT_SIZE = 5;
|
||||
@@ -220,7 +222,7 @@
|
||||
public static final int DEFAULT_NBT_QUOTA = 2097152;
|
||||
@@ -204,7 +206,7 @@
|
||||
|
||||
public <T, C extends Collection<T>> C readCollection(IntFunction<C> intfunction, PacketDataSerializer.a<T> packetdataserializer_a) {
|
||||
int i = this.readVarInt();
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
c0.add(packetdataserializer_a.apply(this));
|
||||
@@ -231,7 +233,7 @@
|
||||
@@ -215,7 +217,7 @@
|
||||
|
||||
public <T> void writeCollection(Collection<T> collection, PacketDataSerializer.b<T> packetdataserializer_b) {
|
||||
this.writeVarInt(collection.size());
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
T t0 = iterator.next();
|
||||
@@ -258,12 +260,12 @@
|
||||
@@ -242,12 +244,12 @@
|
||||
|
||||
public void writeIntIdList(IntList intlist) {
|
||||
this.writeVarInt(intlist.size());
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
K k0 = packetdataserializer_a.apply(this);
|
||||
@@ -297,7 +299,7 @@
|
||||
@@ -281,7 +283,7 @@
|
||||
}
|
||||
|
||||
public <E extends Enum<E>> void writeEnumSet(EnumSet<E> enumset, Class<E> oclass) {
|
||||
@@ -51,7 +51,7 @@
|
||||
BitSet bitset = new BitSet(ae.length);
|
||||
|
||||
for (int i = 0; i < ae.length; ++i) {
|
||||
@@ -308,7 +310,7 @@
|
||||
@@ -292,7 +294,7 @@
|
||||
}
|
||||
|
||||
public <E extends Enum<E>> EnumSet<E> readEnumSet(Class<E> oclass) {
|
||||
@@ -60,7 +60,7 @@
|
||||
BitSet bitset = this.readFixedBitSet(ae.length);
|
||||
EnumSet<E> enumset = EnumSet.noneOf(oclass);
|
||||
|
||||
@@ -545,7 +547,7 @@
|
||||
@@ -530,7 +532,7 @@
|
||||
}
|
||||
|
||||
public <T extends Enum<T>> T readEnum(Class<T> oclass) {
|
||||
@@ -69,16 +69,16 @@
|
||||
}
|
||||
|
||||
public PacketDataSerializer writeEnum(Enum<?> oenum) {
|
||||
@@ -622,7 +624,7 @@
|
||||
} else {
|
||||
try {
|
||||
NBTCompressedStreamTools.write(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this)));
|
||||
- } catch (IOException ioexception) {
|
||||
+ } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception
|
||||
throw new EncoderException(ioexception);
|
||||
}
|
||||
@@ -585,7 +587,7 @@
|
||||
try {
|
||||
NBTCompressedStreamTools.writeAnyTag((NBTBase) nbtbase, new ByteBufOutputStream(this));
|
||||
return this;
|
||||
- } catch (IOException ioexception) {
|
||||
+ } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception
|
||||
throw new EncoderException(ioexception);
|
||||
}
|
||||
@@ -659,7 +661,7 @@
|
||||
}
|
||||
@@ -613,7 +615,7 @@
|
||||
}
|
||||
|
||||
public PacketDataSerializer writeItem(ItemStack itemstack) {
|
||||
@@ -87,7 +87,7 @@
|
||||
this.writeBoolean(false);
|
||||
} else {
|
||||
this.writeBoolean(true);
|
||||
@@ -688,6 +690,11 @@
|
||||
@@ -642,6 +644,11 @@
|
||||
ItemStack itemstack = new ItemStack(item, b0);
|
||||
|
||||
itemstack.setTag(this.readNbt());
|
||||
|
@@ -1,31 +1,31 @@
|
||||
--- a/net/minecraft/network/protocol/PlayerConnectionUtils.java
|
||||
+++ b/net/minecraft/network/protocol/PlayerConnectionUtils.java
|
||||
@@ -7,6 +7,11 @@
|
||||
@@ -8,6 +8,11 @@
|
||||
import net.minecraft.util.thread.IAsyncTaskHandler;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.server.network.PlayerConnection;
|
||||
+import net.minecraft.server.network.ServerCommonPacketListenerImpl;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class PlayerConnectionUtils {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -20,6 +25,7 @@
|
||||
@@ -21,6 +26,7 @@
|
||||
public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T t0, IAsyncTaskHandler<?> iasynctaskhandler) throws CancelledPacketHandleException {
|
||||
if (!iasynctaskhandler.isSameThread()) {
|
||||
iasynctaskhandler.executeIfPossible(() -> {
|
||||
+ if (MinecraftServer.getServer().hasStopped() || (t0 instanceof PlayerConnection && ((PlayerConnection) t0).processedDisconnect)) return; // CraftBukkit, MC-142590
|
||||
if (t0.isAcceptingMessages()) {
|
||||
+ if (MinecraftServer.getServer().hasStopped() || (t0 instanceof ServerCommonPacketListenerImpl && ((ServerCommonPacketListenerImpl) t0).processedDisconnect)) return; // CraftBukkit, MC-142590
|
||||
if (t0.shouldHandleMessage(packet)) {
|
||||
try {
|
||||
packet.handle(t0);
|
||||
@@ -36,6 +42,10 @@
|
||||
@@ -46,6 +52,10 @@
|
||||
|
||||
});
|
||||
throw CancelledPacketHandleException.RUNNING_ON_DIFFERENT_THREAD;
|
||||
+ // CraftBukkit start - SPIGOT-5477, MC-142590
|
||||
+ } else if (MinecraftServer.getServer().hasStopped() || (t0 instanceof PlayerConnection && ((PlayerConnection) t0).processedDisconnect)) {
|
||||
+ } else if (MinecraftServer.getServer().hasStopped() || (t0 instanceof ServerCommonPacketListenerImpl && ((ServerCommonPacketListenerImpl) t0).processedDisconnect)) {
|
||||
+ throw CancelledPacketHandleException.RUNNING_ON_DIFFERENT_THREAD;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
@@ -0,0 +1,43 @@
|
||||
--- a/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java
|
||||
+++ b/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java
|
||||
@@ -12,7 +12,7 @@
|
||||
public record ServerboundCustomPayloadPacket(CustomPacketPayload payload) implements Packet<ServerCommonPacketListener> {
|
||||
|
||||
private static final int MAX_PAYLOAD_SIZE = 32767;
|
||||
- private static final Map<MinecraftKey, PacketDataSerializer.a<? extends CustomPacketPayload>> KNOWN_TYPES = ImmutableMap.builder().put(BrandPayload.ID, BrandPayload::new).build();
|
||||
+ private static final Map<MinecraftKey, PacketDataSerializer.a<? extends CustomPacketPayload>> KNOWN_TYPES = ImmutableMap.<MinecraftKey, PacketDataSerializer.a<? extends CustomPacketPayload>>builder().put(BrandPayload.ID, BrandPayload::new).build(); // CraftBukkit - decompile error
|
||||
|
||||
public ServerboundCustomPayloadPacket(PacketDataSerializer packetdataserializer) {
|
||||
this(readPayload(packetdataserializer.readResourceLocation(), packetdataserializer));
|
||||
@@ -24,12 +24,13 @@
|
||||
return (CustomPacketPayload) (packetdataserializer_a != null ? (CustomPacketPayload) packetdataserializer_a.apply(packetdataserializer) : readUnknownPayload(minecraftkey, packetdataserializer));
|
||||
}
|
||||
|
||||
- private static DiscardedPayload readUnknownPayload(MinecraftKey minecraftkey, PacketDataSerializer packetdataserializer) {
|
||||
+ private static UnknownPayload readUnknownPayload(MinecraftKey minecraftkey, PacketDataSerializer packetdataserializer) { // CraftBukkit
|
||||
int i = packetdataserializer.readableBytes();
|
||||
|
||||
if (i >= 0 && i <= 32767) {
|
||||
- packetdataserializer.skipBytes(i);
|
||||
- return new DiscardedPayload(minecraftkey);
|
||||
+ // CraftBukkit start
|
||||
+ return new UnknownPayload(minecraftkey, packetdataserializer.readBytes(i));
|
||||
+ // CraftBukkit end
|
||||
} else {
|
||||
throw new IllegalArgumentException("Payload may not be larger than 32767 bytes");
|
||||
}
|
||||
@@ -44,4 +45,14 @@
|
||||
public void handle(ServerCommonPacketListener servercommonpacketlistener) {
|
||||
servercommonpacketlistener.handleCustomPayload(this);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public record UnknownPayload(MinecraftKey id, io.netty.buffer.ByteBuf data) implements CustomPacketPayload {
|
||||
+
|
||||
+ @Override
|
||||
+ public void write(PacketDataSerializer packetdataserializer) {
|
||||
+ packetdataserializer.writeBytes(data);
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
@@ -4,4 +4,4 @@
|
||||
+// mc-dev import
|
||||
package net.minecraft.network.protocol.handshake;
|
||||
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.network.EnumProtocol;
|
||||
|
Reference in New Issue
Block a user