Fix chunkbans patch

This commit is contained in:
Telesphoreo 2024-01-25 23:52:22 -06:00
parent 3c75bc7ebf
commit a17100a2ff
39 changed files with 36 additions and 32 deletions

View File

@ -95,10 +95,10 @@ index c5d5648f4ca603ef2b1df723b58f9caf4dd3c722..21ded7c14c56a40feaa7741131be5166
.completer(new ConsoleCommandCompleter(this.server)) .completer(new ConsoleCommandCompleter(this.server))
.option(LineReader.Option.COMPLETE_IN_WORD, true); .option(LineReader.Option.COMPLETE_IN_WORD, true);
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 4e1011dca1081a5246981fabb93f142442dcc92c..75a19ba0863854026c0697a5ede0761e9ae70b56 100644 index fa2b4cdd4c4e2c1df3e378a7c706f06c3361ad53..ac0000d7dbe732c96b853a6ed9e3636e23e6f2d0 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1850,7 +1850,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1854,7 +1854,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@DontObfuscate @DontObfuscate
public String getServerModName() { public String getServerModName() {
@ -108,7 +108,7 @@ index 4e1011dca1081a5246981fabb93f142442dcc92c..75a19ba0863854026c0697a5ede0761e
public SystemReport fillSystemReport(SystemReport details) { public SystemReport fillSystemReport(SystemReport details) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 9d00c98ddfa1b9c04e6d587dcdf779822f35964a..99d7d1e760aa4b9eecd20093aca1c23c0683e53a 100644 index 25f41119bcc19bab7cd2fdb044147b3f78a8ef1c..f4d2b7c1d12bff88aec747ded3a6626dbba3baae 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -264,7 +264,7 @@ import javax.annotation.Nullable; // Paper @@ -264,7 +264,7 @@ import javax.annotation.Nullable; // Paper

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Add Scissors configuration file & command
diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java
index a2f71a6d1a9e98133dff6cd0f625da9435a8af14..f83b2c4298bd1a5f65487f64bd6a11fb190a622d 100644 index 7620c72a4c243cbeea245203ce03a97cbfa7d922..a05a348c299a68a61fabcbdcc689a89a81d1301f 100644
--- a/src/main/java/co/aikar/timings/TimingsExport.java --- a/src/main/java/co/aikar/timings/TimingsExport.java
+++ b/src/main/java/co/aikar/timings/TimingsExport.java +++ b/src/main/java/co/aikar/timings/TimingsExport.java
@@ -25,6 +25,7 @@ package co.aikar.timings; @@ -25,6 +25,7 @@ package co.aikar.timings;
@ -16,7 +16,7 @@ index a2f71a6d1a9e98133dff6cd0f625da9435a8af14..f83b2c4298bd1a5f65487f64bd6a11fb
import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
@@ -242,7 +243,8 @@ public class TimingsExport extends Thread { @@ -240,7 +241,8 @@ public class TimingsExport extends Thread {
parent.put("config", createObject( parent.put("config", createObject(
pair("spigot", mapAsJSON(Bukkit.spigot().getSpigotConfig(), null)), pair("spigot", mapAsJSON(Bukkit.spigot().getSpigotConfig(), null)),
pair("bukkit", mapAsJSON(Bukkit.spigot().getBukkitConfig(), null)), pair("bukkit", mapAsJSON(Bukkit.spigot().getBukkitConfig(), null)),
@ -447,7 +447,7 @@ index 6de6dad36203479677a29ad61e21bc369d4e5513..2aed9abbcb2526a2535099fe8d345d25
this.setFlightAllowed(dedicatedserverproperties.allowFlight); this.setFlightAllowed(dedicatedserverproperties.allowFlight);
this.setMotd(dedicatedserverproperties.motd); this.setMotd(dedicatedserverproperties.motd);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 99d7d1e760aa4b9eecd20093aca1c23c0683e53a..ac2b2664789114b7068abf31be7a619f55a362d0 100644 index f4d2b7c1d12bff88aec747ded3a6626dbba3baae..0a94c7face891dfbb124f39632ea2d8770201a2d 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1036,6 +1036,7 @@ public final class CraftServer implements Server { @@ -1036,6 +1036,7 @@ public final class CraftServer implements Server {
@ -466,7 +466,7 @@ index 99d7d1e760aa4b9eecd20093aca1c23c0683e53a..ac2b2664789114b7068abf31be7a619f
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*"); this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions"); this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
@@ -3007,6 +3009,14 @@ public final class CraftServer implements Server { @@ -2998,6 +3000,14 @@ public final class CraftServer implements Server {
return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console); return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console);
} }

View File

@ -1,31 +1,32 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: ayunami2000 <spwilliamsiam@gmail.com> From: Telesphoreo <me@telesphoreo.me>
Date: Mon, 28 Mar 2022 17:02:21 -0400 Date: Thu, 25 Jan 2024 23:48:51 -0600
Subject: [PATCH] Block server-side chunkbans Subject: [PATCH] Block server-side chunkbans
diff --git a/src/main/java/net/minecraft/network/PacketEncoder.java b/src/main/java/net/minecraft/network/PacketEncoder.java diff --git a/src/main/java/net/minecraft/network/PacketEncoder.java b/src/main/java/net/minecraft/network/PacketEncoder.java
index b5b228e67284baad3639b283595427a819bb1a44..617d7f41a57fb86620183b219f025bb8f747bcf8 100644 index 85b8be8ffac0fb40e9cae0528271ed41473811c8..d0cfc4fc00d45c91380d2d794ca816db74d40266 100644
--- a/src/main/java/net/minecraft/network/PacketEncoder.java --- a/src/main/java/net/minecraft/network/PacketEncoder.java
+++ b/src/main/java/net/minecraft/network/PacketEncoder.java +++ b/src/main/java/net/minecraft/network/PacketEncoder.java
@@ -7,8 +7,16 @@ import io.netty.handler.codec.MessageToByteEncoder; @@ -7,8 +7,17 @@ import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.util.Attribute; import io.netty.util.Attribute;
import io.netty.util.AttributeKey; import io.netty.util.AttributeKey;
import java.io.IOException; import java.io.IOException;
+import java.util.Collections; // Scissors +import java.util.Collections;
+import net.minecraft.ChatFormatting; // Scissors +
+import net.minecraft.core.NonNullList; // Scissors +import net.minecraft.ChatFormatting;
+import net.minecraft.nbt.CompoundTag; // Scissors +import net.minecraft.core.NonNullList;
+import net.minecraft.network.chat.Component; // Scissors +import net.minecraft.nbt.CompoundTag;
+import net.minecraft.network.chat.SignedMessageBody; // Scissors +import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.SignedMessageBody;
import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.Packet;
+import net.minecraft.network.protocol.game.*; // Scissors +import net.minecraft.network.protocol.game.*;
import net.minecraft.util.profiling.jfr.JvmProfiler; import net.minecraft.util.profiling.jfr.JvmProfiler;
+import net.minecraft.world.item.ItemStack; // Scissors +import net.minecraft.world.item.ItemStack;
import org.slf4j.Logger; import org.slf4j.Logger;
public class PacketEncoder extends MessageToByteEncoder<Packet<?>> { public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
@@ -19,6 +27,23 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> { @@ -19,6 +28,23 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
this.codecKey = protocolKey; this.codecKey = protocolKey;
} }
@ -49,9 +50,12 @@ index b5b228e67284baad3639b283595427a819bb1a44..617d7f41a57fb86620183b219f025bb8
protected void encode(ChannelHandlerContext channelHandlerContext, Packet<?> packet, ByteBuf byteBuf) throws Exception { protected void encode(ChannelHandlerContext channelHandlerContext, Packet<?> packet, ByteBuf byteBuf) throws Exception {
Attribute<ConnectionProtocol.CodecData<?>> attribute = channelHandlerContext.channel().attr(this.codecKey); Attribute<ConnectionProtocol.CodecData<?>> attribute = channelHandlerContext.channel().attr(this.codecKey);
ConnectionProtocol.CodecData<?> codecData = attribute.get(); ConnectionProtocol.CodecData<?> codecData = attribute.get();
@@ -37,43 +62,58 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> { @@ -34,46 +60,58 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
friendlyByteBuf.writeVarInt(i); throw new IOException("Can't serialize unregistered packet");
friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(io.papermc.paper.adventure.PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper - adventure; set player's locale } else {
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(byteBuf);
- friendlyByteBuf.writeVarInt(i);
- friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(io.papermc.paper.adventure.PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper - adventure; set player's locale
+ // Scissors start + // Scissors start
+ int k; + int k;
@ -59,7 +63,7 @@ index b5b228e67284baad3639b283595427a819bb1a44..617d7f41a57fb86620183b219f025bb8
- int j = friendlyByteBuf.writerIndex(); - int j = friendlyByteBuf.writerIndex();
- packet.write(friendlyByteBuf); - packet.write(friendlyByteBuf);
- int k = friendlyByteBuf.writerIndex() - j; - int k = friendlyByteBuf.writerIndex() - j;
- if (false && k > 8388608) { // Paper - disable - if (false && k > 8388608) { // Paper - Handle large packets disconnecting client; disable
- throw new IllegalArgumentException("Packet too big (is " + k + ", should be less than 8388608): " + packet); - throw new IllegalArgumentException("Packet too big (is " + k + ", should be less than 8388608): " + packet);
- } - }
- -
@ -80,7 +84,7 @@ index b5b228e67284baad3639b283595427a819bb1a44..617d7f41a57fb86620183b219f025bb8
- -
- throw var13; - throw var13;
- } finally { - } finally {
- // Paper start - // Paper start - Handle large packets disconnecting client
- int packetLength = friendlyByteBuf.readableBytes(); - int packetLength = friendlyByteBuf.readableBytes();
- if (packetLength > MAX_PACKET_SIZE) { - if (packetLength > MAX_PACKET_SIZE) {
- throw new PacketTooLargeException(packet, this.codecKey, packetLength); - throw new PacketTooLargeException(packet, this.codecKey, packetLength);
@ -88,12 +92,12 @@ index b5b228e67284baad3639b283595427a819bb1a44..617d7f41a57fb86620183b219f025bb8
+ if (packet == null) { + if (packet == null) {
+ throw new SkipPacketException(new IllegalArgumentException("Packet too big: " + packet)); + throw new SkipPacketException(new IllegalArgumentException("Packet too big: " + packet));
} }
- // Paper end - // Paper end - Handle large packets disconnecting client
- ProtocolSwapHandler.swapProtocolIfNeeded(attribute, packet); - ProtocolSwapHandler.swapProtocolIfNeeded(attribute, packet);
+ friendlyByteBuf.clear(); + friendlyByteBuf.clear();
+ k = this.tryWrite(packet, friendlyByteBuf, channelHandlerContext, i); + k = this.tryWrite(packet, friendlyByteBuf, channelHandlerContext, i);
} }
-
+ JvmProfiler.INSTANCE.onPacketSent(codecData.protocol(), i, channelHandlerContext.channel().remoteAddress(), k); + JvmProfiler.INSTANCE.onPacketSent(codecData.protocol(), i, channelHandlerContext.channel().remoteAddress(), k);
+ ProtocolSwapHandler.swapProtocolIfNeeded(attribute, packet); + ProtocolSwapHandler.swapProtocolIfNeeded(attribute, packet);
+ // Scissors end + // Scissors end
@ -150,12 +154,12 @@ index 3944852921335c78a04a9dc301882ab5b152b1ed..96ee53c7cc862e059328c5cdf5e07f30
this.type = blockEntityType; this.type = blockEntityType;
this.tag = nbt.isEmpty() ? null : nbt; this.tag = nbt.isEmpty() ? null : nbt;
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
index 51e24105facfe71ce9f2757c6c881a21b58dacfd..5692fbae221fb01d32d92edc7bea0f6312e24e1c 100644 index 998deae645b4497c3285bfba3260c636439f9ecf..f419d4330ea55c1ed91c539a7884ee6814a16ca3 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
@@ -33,6 +33,13 @@ public class ClientboundLevelChunkPacketData { @@ -33,6 +33,13 @@ public class ClientboundLevelChunkPacketData {
} }
// Paper end // Paper end - Handle oversized block entities in chunks
+ // Scissors start + // Scissors start
+ public void clearNBT() { + public void clearNBT() {
@ -168,10 +172,10 @@ index 51e24105facfe71ce9f2757c6c881a21b58dacfd..5692fbae221fb01d32d92edc7bea0f63
@Deprecated @io.papermc.paper.annotation.DoNotUse public ClientboundLevelChunkPacketData(LevelChunk chunk) { this(chunk, null); } @Deprecated @io.papermc.paper.annotation.DoNotUse public ClientboundLevelChunkPacketData(LevelChunk chunk) { this(chunk, null); }
public ClientboundLevelChunkPacketData(LevelChunk chunk, com.destroystokyo.paper.antixray.ChunkPacketInfo<net.minecraft.world.level.block.state.BlockState> chunkPacketInfo) { public ClientboundLevelChunkPacketData(LevelChunk chunk, com.destroystokyo.paper.antixray.ChunkPacketInfo<net.minecraft.world.level.block.state.BlockState> chunkPacketInfo) {
@@ -58,6 +65,7 @@ public class ClientboundLevelChunkPacketData { @@ -58,6 +65,7 @@ public class ClientboundLevelChunkPacketData {
int totalTileEntities = 0; // Paper int totalTileEntities = 0; // Paper - Handle oversized block entities in chunks
for(Map.Entry<BlockPos, BlockEntity> entry2 : chunk.getBlockEntities().entrySet()) { for(Map.Entry<BlockPos, BlockEntity> entry2 : chunk.getBlockEntities().entrySet()) {
+ if (this.extraPackets.size() > 50) break; // Scissors - Limit extraPackets size + if (this.extraPackets.size() > 50) break; // Scissors - Limit extraPackets size
// Paper start // Paper start - Handle oversized block entities in chunks
if (++totalTileEntities > TE_LIMIT) { if (++totalTileEntities > TE_LIMIT) {
var packet = entry2.getValue().getUpdatePacket(); var packet = entry2.getValue().getUpdatePacket();

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Patch invalid entity rotation log spam
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index ec0e041ee2ce4d763859a53221fb75a8da6dc283..760c3cdccb4361538bc0c4269ec4a7c9d6fa2db0 100644 index fc6cff4121db4c08452817df846286103fe23ad9..3594e87329b99a2741749df04ac577a8fbe1a2fa 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -4732,7 +4732,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @@ -4732,7 +4732,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S