mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Limit Client Sign length more
modified clients can send more data from the client to the server and it would get stored on the sign as sent. Mojang has a limit of 384 which is much higher than reasonable. the client can barely render around 16 characters as-is, but formatting codes can get it to be more than 16 actual length. Set a limit of 80 which should give an average of 16 characters 2 sets of legacy formatting codes which should be plenty for all uses. This does not strip any existing data from the NBT as plugins may use this for storing data out of the rendered area. it only impacts data sent from the client. Set -DPaper.maxSignLength=XX to change limit or -1 to disable
This commit is contained in:
parent
05f977e3d1
commit
04c783377e
1 changed files with 91 additions and 68 deletions
|
@ -48,7 +48,7 @@
|
|||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -192,12 +196,72 @@
|
||||
@@ -192,11 +196,71 @@
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
@ -58,7 +58,7 @@
|
|||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+
|
||||
+// CraftBukkit start
|
||||
+import io.papermc.paper.adventure.ChatProcessor; // Paper
|
||||
+import io.papermc.paper.adventure.PaperAdventure; // Paper
|
||||
|
@ -117,10 +117,9 @@
|
|||
+import org.bukkit.inventory.InventoryView;
|
||||
+import org.bukkit.inventory.SmithingInventory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
|
||||
public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl implements ServerGamePacketListener, ServerPlayerConnection, TickablePacketListener {
|
||||
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -212,6 +276,7 @@
|
||||
private int tickCount;
|
||||
private int ackBlockChangesUpTo = -1;
|
||||
|
@ -129,8 +128,11 @@
|
|||
private final TickThrottler dropSpamThrottler = new TickThrottler(20, 1480);
|
||||
private double firstGoodX;
|
||||
private double firstGoodY;
|
||||
@@ -247,7 +312,7 @@
|
||||
@@ -245,9 +310,10 @@
|
||||
private final MessageSignatureCache messageSignatureCache = MessageSignatureCache.createDefault();
|
||||
private final FutureChain chatMessageChain;
|
||||
private boolean waitingForSwitchToConfig;
|
||||
+ private static final int MAX_SIGN_LINE_LENGTH = Integer.getInteger("Paper.maxSignLength", 80); // Paper - Limit client sign length
|
||||
|
||||
public ServerGamePacketListenerImpl(MinecraftServer server, Connection connection, ServerPlayer player, CommonListenerCookie clientData) {
|
||||
- super(server, connection, clientData);
|
||||
|
@ -138,7 +140,7 @@
|
|||
this.chunkSender = new PlayerChunkSender(connection.isMemoryConnection());
|
||||
this.player = player;
|
||||
player.connection = this;
|
||||
@@ -256,9 +321,25 @@
|
||||
@@ -256,9 +322,25 @@
|
||||
|
||||
Objects.requireNonNull(server);
|
||||
this.signedMessageDecoder = SignedMessageChain.Decoder.unsigned(uuid, server::enforceSecureProfile);
|
||||
|
@ -165,7 +167,7 @@
|
|||
@Override
|
||||
public void tick() {
|
||||
if (this.ackBlockChangesUpTo > -1) {
|
||||
@@ -277,7 +358,7 @@
|
||||
@@ -277,7 +359,7 @@
|
||||
if (this.clientIsFloating && !this.player.isSleeping() && !this.player.isPassenger() && !this.player.isDeadOrDying()) {
|
||||
if (++this.aboveGroundTickCount > this.getMaximumFlyingTicks(this.player)) {
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked for floating too long!", this.player.getName().getString());
|
||||
|
@ -174,7 +176,7 @@
|
|||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -296,7 +377,7 @@
|
||||
@@ -296,7 +378,7 @@
|
||||
if (this.clientVehicleIsFloating && this.lastVehicle.getControllingPassenger() == this.player) {
|
||||
if (++this.aboveGroundVehicleTickCount > this.getMaximumFlyingTicks(this.lastVehicle)) {
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked for floating a vehicle too long!", this.player.getName().getString());
|
||||
|
@ -183,7 +185,7 @@
|
|||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -311,8 +392,10 @@
|
||||
@@ -311,8 +393,10 @@
|
||||
|
||||
this.keepConnectionAlive();
|
||||
this.chatSpamThrottler.tick();
|
||||
|
@ -194,7 +196,7 @@
|
|||
this.disconnect((Component) Component.translatable("multiplayer.disconnect.idling"));
|
||||
}
|
||||
|
||||
@@ -376,6 +459,12 @@
|
||||
@@ -376,6 +460,12 @@
|
||||
@Override
|
||||
public void handlePlayerInput(ServerboundPlayerInputPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
|
@ -207,7 +209,7 @@
|
|||
this.player.setLastClientInput(packet.input());
|
||||
}
|
||||
|
||||
@@ -401,12 +490,19 @@
|
||||
@@ -401,12 +491,19 @@
|
||||
|
||||
if (entity != this.player && entity.getControllingPassenger() == this.player && entity == this.lastVehicle) {
|
||||
ServerLevel worldserver = this.player.serverLevel();
|
||||
|
@ -230,7 +232,7 @@
|
|||
float f = Mth.wrapDegrees(packet.yRot());
|
||||
float f1 = Mth.wrapDegrees(packet.xRot());
|
||||
double d6 = d3 - this.vehicleFirstGoodX;
|
||||
@@ -415,7 +511,43 @@
|
||||
@@ -415,7 +512,43 @@
|
||||
double d9 = entity.getDeltaMovement().lengthSqr();
|
||||
double d10 = d6 * d6 + d7 * d7 + d8 * d8;
|
||||
|
||||
|
@ -275,7 +277,7 @@
|
|||
ServerGamePacketListenerImpl.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8});
|
||||
this.send(ClientboundMoveVehiclePacket.fromEntity(entity));
|
||||
return;
|
||||
@@ -449,19 +581,72 @@
|
||||
@@ -449,19 +582,72 @@
|
||||
d10 = d6 * d6 + d7 * d7 + d8 * d8;
|
||||
boolean flag2 = false;
|
||||
|
||||
|
@ -349,7 +351,7 @@
|
|||
|
||||
this.player.serverLevel().getChunkSource().move(this.player);
|
||||
entity.recordMovementThroughBlocks(new Vec3(d0, d1, d2), entity.position());
|
||||
@@ -499,6 +684,7 @@
|
||||
@@ -499,6 +685,7 @@
|
||||
this.lastGoodZ = this.awaitingPositionFromClient.z;
|
||||
this.player.hasChangedDimension();
|
||||
this.awaitingPositionFromClient = null;
|
||||
|
@ -357,7 +359,7 @@
|
|||
}
|
||||
|
||||
}
|
||||
@@ -528,6 +714,7 @@
|
||||
@@ -528,6 +715,7 @@
|
||||
@Override
|
||||
public void handleRecipeBookChangeSettingsPacket(ServerboundRecipeBookChangeSettingsPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
|
@ -365,7 +367,7 @@
|
|||
this.player.getRecipeBook().setBookSetting(packet.getBookType(), packet.isOpen(), packet.isFiltering());
|
||||
}
|
||||
|
||||
@@ -545,21 +732,80 @@
|
||||
@@ -545,21 +733,80 @@
|
||||
|
||||
}
|
||||
|
||||
|
@ -450,7 +452,7 @@
|
|||
});
|
||||
}
|
||||
|
||||
@@ -668,7 +914,7 @@
|
||||
@@ -668,7 +915,7 @@
|
||||
ItemStack itemstack = iblockdata.getCloneItemStack(worldserver, blockposition, flag);
|
||||
|
||||
if (!itemstack.isEmpty()) {
|
||||
|
@ -459,7 +461,7 @@
|
|||
ServerGamePacketListenerImpl.addBlockDataToItem(iblockdata, worldserver, blockposition, itemstack);
|
||||
}
|
||||
|
||||
@@ -866,6 +1112,13 @@
|
||||
@@ -866,6 +1113,13 @@
|
||||
AbstractContainerMenu container = this.player.containerMenu;
|
||||
|
||||
if (container instanceof MerchantMenu containermerchant) {
|
||||
|
@ -473,7 +475,7 @@
|
|||
if (!containermerchant.stillValid(this.player)) {
|
||||
ServerGamePacketListenerImpl.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant);
|
||||
return;
|
||||
@@ -879,6 +1132,51 @@
|
||||
@@ -879,6 +1133,51 @@
|
||||
|
||||
@Override
|
||||
public void handleEditBook(ServerboundEditBookPacket packet) {
|
||||
|
@ -525,7 +527,7 @@
|
|||
int i = packet.slot();
|
||||
|
||||
if (Inventory.isHotbarSlot(i) || i == 40) {
|
||||
@@ -899,12 +1197,16 @@
|
||||
@@ -899,12 +1198,16 @@
|
||||
}
|
||||
|
||||
private void updateBookContents(List<FilteredText> pages, int slotId) {
|
||||
|
@ -543,7 +545,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -915,12 +1217,13 @@
|
||||
@@ -915,12 +1218,13 @@
|
||||
ItemStack itemstack1 = itemstack.transmuteCopy(Items.WRITTEN_BOOK);
|
||||
|
||||
itemstack1.remove(DataComponents.WRITABLE_BOOK_CONTENT);
|
||||
|
@ -559,7 +561,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -982,22 +1285,30 @@
|
||||
@@ -982,22 +1286,30 @@
|
||||
} else {
|
||||
ServerLevel worldserver = this.player.serverLevel();
|
||||
|
||||
|
@ -594,7 +596,7 @@
|
|||
double d3 = this.player.getX();
|
||||
double d4 = this.player.getY();
|
||||
double d5 = this.player.getZ();
|
||||
@@ -1019,15 +1330,39 @@
|
||||
@@ -1019,15 +1331,39 @@
|
||||
++this.receivedMovePacketCount;
|
||||
int i = this.receivedMovePacketCount - this.knownMovePacketCount;
|
||||
|
||||
|
@ -636,7 +638,7 @@
|
|||
ServerGamePacketListenerImpl.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d6, d7, d8});
|
||||
this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
|
||||
return;
|
||||
@@ -1043,12 +1378,40 @@
|
||||
@@ -1043,12 +1379,40 @@
|
||||
boolean flag1 = d7 > 0.0D;
|
||||
|
||||
if (this.player.onGround() && !packet.isOnGround() && flag1) {
|
||||
|
@ -678,7 +680,7 @@
|
|||
double d11 = d7;
|
||||
|
||||
d6 = d0 - this.player.getX();
|
||||
@@ -1061,15 +1424,81 @@
|
||||
@@ -1061,15 +1425,81 @@
|
||||
d10 = d6 * d6 + d7 * d7 + d8 * d8;
|
||||
boolean flag3 = false;
|
||||
|
||||
|
@ -762,7 +764,7 @@
|
|||
this.player.absMoveTo(d0, d1, d2, f, f1);
|
||||
boolean flag4 = this.player.isAutoSpinAttack();
|
||||
|
||||
@@ -1119,6 +1548,7 @@
|
||||
@@ -1119,6 +1549,7 @@
|
||||
this.awaitingTeleportTime = this.tickCount;
|
||||
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
|
||||
}
|
||||
|
@ -770,7 +772,7 @@
|
|||
|
||||
return true;
|
||||
} else {
|
||||
@@ -1147,23 +1577,83 @@
|
||||
@@ -1147,23 +1578,83 @@
|
||||
}
|
||||
|
||||
public void teleport(double x, double y, double z, float yaw, float pitch) {
|
||||
|
@ -857,7 +859,7 @@
|
|||
if (this.player.hasClientLoaded()) {
|
||||
BlockPos blockposition = packet.getPos();
|
||||
|
||||
@@ -1175,14 +1665,46 @@
|
||||
@@ -1175,14 +1666,46 @@
|
||||
if (!this.player.isSpectator()) {
|
||||
ItemStack itemstack = this.player.getItemInHand(InteractionHand.OFF_HAND);
|
||||
|
||||
|
@ -906,7 +908,7 @@
|
|||
this.player.drop(false);
|
||||
}
|
||||
|
||||
@@ -1199,6 +1721,12 @@
|
||||
@@ -1199,6 +1722,12 @@
|
||||
case START_DESTROY_BLOCK:
|
||||
case ABORT_DESTROY_BLOCK:
|
||||
case STOP_DESTROY_BLOCK:
|
||||
|
@ -919,7 +921,7 @@
|
|||
this.player.gameMode.handleBlockBreakAction(blockposition, packetplayinblockdig_enumplayerdigtype, packet.getDirection(), this.player.level().getMaxY(), packet.getSequence());
|
||||
this.player.connection.ackBlockChangesUpTo(packet.getSequence());
|
||||
return;
|
||||
@@ -1218,9 +1746,31 @@
|
||||
@@ -1218,9 +1747,31 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -951,7 +953,7 @@
|
|||
if (this.player.hasClientLoaded()) {
|
||||
this.player.connection.ackBlockChangesUpTo(packet.getSequence());
|
||||
ServerLevel worldserver = this.player.serverLevel();
|
||||
@@ -1244,6 +1794,7 @@
|
||||
@@ -1244,6 +1795,7 @@
|
||||
|
||||
if (blockposition.getY() <= i) {
|
||||
if (this.awaitingPositionFromClient == null && worldserver.mayInteract(this.player, blockposition)) {
|
||||
|
@ -959,7 +961,7 @@
|
|||
InteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
|
||||
|
||||
if (enuminteractionresult.consumesAction()) {
|
||||
@@ -1281,6 +1832,8 @@
|
||||
@@ -1281,6 +1833,8 @@
|
||||
@Override
|
||||
public void handleUseItem(ServerboundUseItemPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
|
@ -968,7 +970,7 @@
|
|||
if (this.player.hasClientLoaded()) {
|
||||
this.ackBlockChangesUpTo(packet.getSequence());
|
||||
ServerLevel worldserver = this.player.serverLevel();
|
||||
@@ -1294,8 +1847,49 @@
|
||||
@@ -1294,8 +1848,49 @@
|
||||
|
||||
if (f1 != this.player.getXRot() || f != this.player.getYRot()) {
|
||||
this.player.absRotateTo(f, f1);
|
||||
|
@ -1018,7 +1020,7 @@
|
|||
InteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
|
||||
|
||||
if (enuminteractionresult instanceof InteractionResult.Success) {
|
||||
@@ -1321,7 +1915,7 @@
|
||||
@@ -1321,7 +1916,7 @@
|
||||
Entity entity = packet.getEntity(worldserver);
|
||||
|
||||
if (entity != null) {
|
||||
|
@ -1027,7 +1029,7 @@
|
|||
return;
|
||||
}
|
||||
}
|
||||
@@ -1342,6 +1936,13 @@
|
||||
@@ -1342,6 +1937,13 @@
|
||||
|
||||
@Override
|
||||
public void onDisconnect(DisconnectionDetails info) {
|
||||
|
@ -1041,7 +1043,7 @@
|
|||
ServerGamePacketListenerImpl.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), info.reason().getString());
|
||||
this.removePlayerFromWorld();
|
||||
super.onDisconnect(info);
|
||||
@@ -1349,10 +1950,20 @@
|
||||
@@ -1349,10 +1951,20 @@
|
||||
|
||||
private void removePlayerFromWorld() {
|
||||
this.chatMessageChain.close();
|
||||
|
@ -1064,7 +1066,7 @@
|
|||
this.player.getTextFilter().leave();
|
||||
}
|
||||
|
||||
@@ -1367,7 +1978,16 @@
|
||||
@@ -1367,7 +1979,16 @@
|
||||
@Override
|
||||
public void handleSetCarriedItem(ServerboundSetCarriedItemPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
|
@ -1081,7 +1083,7 @@
|
|||
if (this.player.getInventory().selected != packet.getSlot() && this.player.getUsedItemHand() == InteractionHand.MAIN_HAND) {
|
||||
this.player.stopUsingItem();
|
||||
}
|
||||
@@ -1376,11 +1996,18 @@
|
||||
@@ -1376,11 +1997,18 @@
|
||||
this.player.resetLastActionTime();
|
||||
} else {
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
|
||||
|
@ -1100,7 +1102,7 @@
|
|||
Optional<LastSeenMessages> optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages());
|
||||
|
||||
if (!optional.isEmpty()) {
|
||||
@@ -1394,27 +2021,44 @@
|
||||
@@ -1394,27 +2022,44 @@
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1152,7 +1154,7 @@
|
|||
ParseResults<CommandSourceStack> parseresults = this.parseCommand(command);
|
||||
|
||||
if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseresults)) {
|
||||
@@ -1431,19 +2075,37 @@
|
||||
@@ -1431,19 +2076,37 @@
|
||||
|
||||
if (!optional.isEmpty()) {
|
||||
this.tryHandleChat(packet.command(), () -> {
|
||||
|
@ -1194,7 +1196,7 @@
|
|||
} catch (SignedMessageChain.DecodeException signedmessagechain_a) {
|
||||
this.handleMessageDecodeFailure(signedmessagechain_a);
|
||||
return;
|
||||
@@ -1451,10 +2113,10 @@
|
||||
@@ -1451,10 +2114,10 @@
|
||||
|
||||
CommandSigningContext.SignedArguments commandsigningcontext_a = new CommandSigningContext.SignedArguments(map);
|
||||
|
||||
|
@ -1207,7 +1209,7 @@
|
|||
}
|
||||
|
||||
private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) {
|
||||
@@ -1530,14 +2192,20 @@
|
||||
@@ -1530,14 +2193,20 @@
|
||||
return com_mojang_brigadier_commanddispatcher.parse(command, this.player.createCommandSourceStack());
|
||||
}
|
||||
|
||||
|
@ -1232,7 +1234,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -1566,6 +2234,127 @@
|
||||
@@ -1566,6 +2235,127 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1360,7 +1362,7 @@
|
|||
private PlayerChatMessage getSignedMessage(ServerboundChatPacket packet, LastSeenMessages lastSeenMessages) throws SignedMessageChain.DecodeException {
|
||||
SignedMessageBody signedmessagebody = new SignedMessageBody(packet.message(), packet.timeStamp(), packet.salt(), lastSeenMessages);
|
||||
|
||||
@@ -1573,13 +2362,42 @@
|
||||
@@ -1573,13 +2363,42 @@
|
||||
}
|
||||
|
||||
private void broadcastChatMessage(PlayerChatMessage message) {
|
||||
|
@ -1408,7 +1410,7 @@
|
|||
this.disconnect((Component) Component.translatable("disconnect.spam"));
|
||||
}
|
||||
|
||||
@@ -1601,7 +2419,33 @@
|
||||
@@ -1601,7 +2420,33 @@
|
||||
@Override
|
||||
public void handleAnimate(ServerboundSwingPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
|
@ -1442,7 +1444,7 @@
|
|||
this.player.swing(packet.getHand());
|
||||
}
|
||||
|
||||
@@ -1609,6 +2453,29 @@
|
||||
@@ -1609,6 +2454,29 @@
|
||||
public void handlePlayerCommand(ServerboundPlayerCommandPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
if (this.player.hasClientLoaded()) {
|
||||
|
@ -1472,7 +1474,7 @@
|
|||
this.player.resetLastActionTime();
|
||||
Entity entity;
|
||||
PlayerRideableJumping ijumpable;
|
||||
@@ -1616,6 +2483,11 @@
|
||||
@@ -1616,6 +2484,11 @@
|
||||
switch (packet.getAction()) {
|
||||
case PRESS_SHIFT_KEY:
|
||||
this.player.setShiftKeyDown(true);
|
||||
|
@ -1484,7 +1486,7 @@
|
|||
break;
|
||||
case RELEASE_SHIFT_KEY:
|
||||
this.player.setShiftKeyDown(false);
|
||||
@@ -1691,6 +2563,12 @@
|
||||
@@ -1691,6 +2564,12 @@
|
||||
}
|
||||
|
||||
public void sendPlayerChatMessage(PlayerChatMessage message, ChatType.Bound params) {
|
||||
|
@ -1497,7 +1499,7 @@
|
|||
this.send(new ClientboundPlayerChatPacket(message.link().sender(), message.link().index(), message.signature(), message.signedBody().pack(this.messageSignatureCache), message.unsignedContent(), message.filterMask(), params));
|
||||
this.addPendingMessage(message);
|
||||
}
|
||||
@@ -1703,6 +2581,13 @@
|
||||
@@ -1703,6 +2582,13 @@
|
||||
return this.connection.getRemoteAddress();
|
||||
}
|
||||
|
||||
|
@ -1511,7 +1513,7 @@
|
|||
public void switchToConfig() {
|
||||
this.waitingForSwitchToConfig = true;
|
||||
this.removePlayerFromWorld();
|
||||
@@ -1718,9 +2603,17 @@
|
||||
@@ -1718,9 +2604,17 @@
|
||||
@Override
|
||||
public void handleInteract(ServerboundInteractPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
|
@ -1529,7 +1531,7 @@
|
|||
|
||||
this.player.resetLastActionTime();
|
||||
this.player.setShiftKeyDown(packet.isUsingSecondaryAction());
|
||||
@@ -1733,20 +2626,58 @@
|
||||
@@ -1733,20 +2627,58 @@
|
||||
|
||||
if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) {
|
||||
packet.dispatch(new ServerboundInteractPacket.Handler() {
|
||||
|
@ -1592,7 +1594,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -1755,19 +2686,20 @@
|
||||
@@ -1755,19 +2687,20 @@
|
||||
|
||||
@Override
|
||||
public void onInteraction(InteractionHand hand) {
|
||||
|
@ -1616,7 +1618,7 @@
|
|||
label23:
|
||||
{
|
||||
if (entity instanceof AbstractArrow) {
|
||||
@@ -1785,6 +2717,11 @@
|
||||
@@ -1785,6 +2718,11 @@
|
||||
}
|
||||
|
||||
ServerGamePacketListenerImpl.this.player.attack(entity);
|
||||
|
@ -1628,7 +1630,7 @@
|
|||
return;
|
||||
}
|
||||
}
|
||||
@@ -1795,7 +2732,26 @@
|
||||
@@ -1795,7 +2733,26 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1655,7 +1657,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -1809,7 +2765,7 @@
|
||||
@@ -1809,7 +2766,7 @@
|
||||
case PERFORM_RESPAWN:
|
||||
if (this.player.wonGame) {
|
||||
this.player.wonGame = false;
|
||||
|
@ -1664,7 +1666,7 @@
|
|||
this.resetPosition();
|
||||
CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD);
|
||||
} else {
|
||||
@@ -1817,11 +2773,11 @@
|
||||
@@ -1817,11 +2774,11 @@
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1678,7 +1680,7 @@
|
|||
}
|
||||
}
|
||||
break;
|
||||
@@ -1833,16 +2789,27 @@
|
||||
@@ -1833,16 +2790,27 @@
|
||||
|
||||
@Override
|
||||
public void handleContainerClose(ServerboundContainerClosePacket packet) {
|
||||
|
@ -1708,7 +1710,7 @@
|
|||
this.player.containerMenu.sendAllDataToRemote();
|
||||
} else if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
ServerGamePacketListenerImpl.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
|
||||
@@ -1855,7 +2822,284 @@
|
||||
@@ -1855,7 +2823,284 @@
|
||||
boolean flag = packet.getStateId() != this.player.containerMenu.getStateId();
|
||||
|
||||
this.player.containerMenu.suppressRemoteUpdates();
|
||||
|
@ -1994,7 +1996,7 @@
|
|||
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packet.getChangedSlots()).iterator();
|
||||
|
||||
while (objectiterator.hasNext()) {
|
||||
@@ -1901,8 +3145,22 @@
|
||||
@@ -1901,8 +3146,22 @@
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2018,7 +2020,7 @@
|
|||
if (containerrecipebook_a == RecipeBookMenu.PostPlaceAction.PLACE_GHOST_RECIPE) {
|
||||
this.player.connection.send(new ClientboundPlaceGhostRecipePacket(this.player.containerMenu.containerId, craftingmanager_d.display().display()));
|
||||
}
|
||||
@@ -1917,6 +3175,7 @@
|
||||
@@ -1917,6 +3176,7 @@
|
||||
@Override
|
||||
public void handleContainerButtonClick(ServerboundContainerButtonClickPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
|
@ -2026,7 +2028,7 @@
|
|||
this.player.resetLastActionTime();
|
||||
if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) {
|
||||
if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
@@ -1945,7 +3204,44 @@
|
||||
@@ -1945,7 +3205,44 @@
|
||||
|
||||
boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45;
|
||||
boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize();
|
||||
|
@ -2034,7 +2036,7 @@
|
|||
+ // CraftBukkit start - Call click event
|
||||
+ InventoryView inventory = this.player.inventoryMenu.getBukkitView();
|
||||
+ org.bukkit.inventory.ItemStack item = CraftItemStack.asBukkitCopy(packet.itemStack());
|
||||
+
|
||||
|
||||
+ SlotType type = SlotType.QUICKBAR;
|
||||
+ if (flag) {
|
||||
+ type = SlotType.OUTSIDE;
|
||||
|
@ -2047,7 +2049,7 @@
|
|||
+ }
|
||||
+ InventoryCreativeEvent event = new InventoryCreativeEvent(inventory, type, flag ? -999 : packet.slotNum(), item);
|
||||
+ this.cserver.getPluginManager().callEvent(event);
|
||||
|
||||
+
|
||||
+ itemstack = CraftItemStack.asNMSCopy(event.getCursor());
|
||||
+
|
||||
+ switch (event.getResult()) {
|
||||
|
@ -2071,7 +2073,28 @@
|
|||
if (flag1 && flag2) {
|
||||
this.player.inventoryMenu.getSlot(packet.slotNum()).setByPlayer(itemstack);
|
||||
this.player.inventoryMenu.setRemoteSlot(packet.slotNum(), itemstack);
|
||||
@@ -1972,6 +3268,7 @@
|
||||
@@ -1964,7 +3261,19 @@
|
||||
|
||||
@Override
|
||||
public void handleSignUpdate(ServerboundSignUpdatePacket packet) {
|
||||
- List<String> list = (List) Stream.of(packet.getLines()).map(ChatFormatting::stripFormatting).collect(Collectors.toList());
|
||||
+ // Paper start - Limit client sign length
|
||||
+ String[] lines = packet.getLines();
|
||||
+ for (int i = 0; i < lines.length; ++i) {
|
||||
+ if (MAX_SIGN_LINE_LENGTH > 0 && lines[i].length() > MAX_SIGN_LINE_LENGTH) {
|
||||
+ // This handles multibyte characters as 1
|
||||
+ int offset = lines[i].codePoints().limit(MAX_SIGN_LINE_LENGTH).map(Character::charCount).sum();
|
||||
+ if (offset < lines[i].length()) {
|
||||
+ lines[i] = lines[i].substring(0, offset); // this will break any filtering, but filtering is NYI as of 1.17
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ List<String> list = (List) Stream.of(lines).map(ChatFormatting::stripFormatting).collect(Collectors.toList());
|
||||
+ // Paper end - Limit client sign length
|
||||
|
||||
this.filterTextPacket(list).thenAcceptAsync((list1) -> {
|
||||
this.updateSignText(packet, list1);
|
||||
@@ -1972,6 +3281,7 @@
|
||||
}
|
||||
|
||||
private void updateSignText(ServerboundSignUpdatePacket packet, List<FilteredText> signText) {
|
||||
|
@ -2079,7 +2102,7 @@
|
|||
this.player.resetLastActionTime();
|
||||
ServerLevel worldserver = this.player.serverLevel();
|
||||
BlockPos blockposition = packet.getPos();
|
||||
@@ -1993,7 +3290,17 @@
|
||||
@@ -1993,7 +3303,17 @@
|
||||
@Override
|
||||
public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
|
@ -2098,7 +2121,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -2002,6 +3309,7 @@
|
||||
@@ -2002,6 +3322,7 @@
|
||||
boolean flag = this.player.isModelPartShown(PlayerModelPart.HAT);
|
||||
|
||||
this.player.updateOptions(packet.information());
|
||||
|
@ -2106,7 +2129,7 @@
|
|||
if (this.player.isModelPartShown(PlayerModelPart.HAT) != flag) {
|
||||
this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_HAT, this.player));
|
||||
}
|
||||
@@ -2058,7 +3366,7 @@
|
||||
@@ -2058,7 +3379,7 @@
|
||||
if (!this.waitingForSwitchToConfig) {
|
||||
throw new IllegalStateException("Client acknowledged config, but none was requested");
|
||||
} else {
|
||||
|
@ -2115,7 +2138,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -2083,8 +3391,10 @@
|
||||
@@ -2083,8 +3404,10 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue