mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-15 14:13:56 +01:00
Implement PlayerFailMoveEvent
This commit is contained in:
parent
02819929b6
commit
31871f6b40
1 changed files with 142 additions and 82 deletions
|
@ -194,7 +194,7 @@
|
|||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -311,10 +396,20 @@
|
||||
@@ -311,11 +396,21 @@
|
||||
|
||||
this.keepConnectionAlive();
|
||||
this.chatSpamThrottler.tick();
|
||||
|
@ -206,17 +206,18 @@
|
|||
+ if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L && !this.player.wonGame) { // Paper - Prevent AFK kick while watching end credits
|
||||
+ this.player.resetLastActionTime(); // CraftBukkit - SPIGOT-854
|
||||
+ this.disconnect((Component) Component.translatable("multiplayer.disconnect.idling"), org.bukkit.event.player.PlayerKickEvent.Cause.IDLING); // Paper - kick event cause
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ // Paper start - Prevent causing expired keys from impacting new joins
|
||||
+ if (!hasLoggedExpiry && this.chatSession != null && this.chatSession.profilePublicKey().data().hasExpired()) {
|
||||
+ LOGGER.info("Player profile key for {} has expired!", this.player.getName().getString());
|
||||
+ hasLoggedExpiry = true;
|
||||
}
|
||||
+ }
|
||||
+ // Paper end - Prevent causing expired keys from impacting new joins
|
||||
|
||||
+
|
||||
}
|
||||
|
||||
private int getMaximumFlyingTicks(Entity vehicle) {
|
||||
@@ -376,6 +471,12 @@
|
||||
@Override
|
||||
public void handlePlayerInput(ServerboundPlayerInputPacket packet) {
|
||||
|
@ -676,11 +677,13 @@
|
|||
- double d0 = ServerGamePacketListenerImpl.clampHorizontal(packet.getX(this.player.getX()));
|
||||
- double d1 = ServerGamePacketListenerImpl.clampVertical(packet.getY(this.player.getY()));
|
||||
- double d2 = ServerGamePacketListenerImpl.clampHorizontal(packet.getZ(this.player.getZ()));
|
||||
- float f = Mth.wrapDegrees(packet.getYRot(this.player.getYRot()));
|
||||
- float f1 = Mth.wrapDegrees(packet.getXRot(this.player.getXRot()));
|
||||
+ double d0 = ServerGamePacketListenerImpl.clampHorizontal(packet.getX(this.player.getX())); final double toX = d0; // Paper - OBFHELPER
|
||||
+ double d1 = ServerGamePacketListenerImpl.clampVertical(packet.getY(this.player.getY())); final double toY = d1; // Paper - OBFHELPER
|
||||
+ double d2 = ServerGamePacketListenerImpl.clampHorizontal(packet.getZ(this.player.getZ())); final double toZ = d2; // Paper - OBFHELPER
|
||||
float f = Mth.wrapDegrees(packet.getYRot(this.player.getYRot()));
|
||||
float f1 = Mth.wrapDegrees(packet.getXRot(this.player.getXRot()));
|
||||
+ float f = Mth.wrapDegrees(packet.getYRot(this.player.getYRot())); final float toYaw = f; // Paper - OBFHELPER
|
||||
+ float f1 = Mth.wrapDegrees(packet.getXRot(this.player.getXRot())); final float toPitch = f1; // Paper - OBFHELPER
|
||||
|
||||
if (this.player.isPassenger()) {
|
||||
this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1);
|
||||
|
@ -715,7 +718,7 @@
|
|||
|
||||
if (this.player.isSleeping()) {
|
||||
if (d10 > 1.0D) {
|
||||
@@ -1019,15 +1370,39 @@
|
||||
@@ -1019,36 +1370,106 @@
|
||||
++this.receivedMovePacketCount;
|
||||
int i = this.receivedMovePacketCount - this.knownMovePacketCount;
|
||||
|
||||
|
@ -728,8 +731,8 @@
|
|||
+ if (i > Math.max(this.allowedPlayerTicks, 5)) {
|
||||
ServerGamePacketListenerImpl.LOGGER.debug("{} is sending move packets too frequently ({} packets since last tick)", this.player.getName().getString(), i);
|
||||
i = 1;
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ if (packet.hasRot || d10 > 0) {
|
||||
+ this.allowedPlayerTicks -= 1;
|
||||
+ } else {
|
||||
|
@ -740,24 +743,42 @@
|
|||
+ speed = this.player.getAbilities().flyingSpeed * 20f;
|
||||
+ } else {
|
||||
+ speed = this.player.getAbilities().walkingSpeed * 10f;
|
||||
+ }
|
||||
}
|
||||
+ // Paper start - Prevent moving into unloaded chunks
|
||||
+ if (this.player.level().paperConfig().chunks.preventMovingIntoUnloadedChunks && (this.player.getX() != toX || this.player.getZ() != toZ) && !worldserver.areChunksLoadedForMove(this.player.getBoundingBox().expandTowards(new Vec3(toX, toY, toZ).subtract(this.player.position())))) {
|
||||
+ this.internalTeleport(PositionMoveRotation.of(this.player), Collections.emptySet());
|
||||
+ return;
|
||||
+ // Paper start - Add fail move event
|
||||
+ io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_INTO_UNLOADED_CHUNK,
|
||||
+ toX, toY, toZ, toYaw, toPitch, false);
|
||||
+ if (!event.isAllowed()) {
|
||||
+ this.internalTeleport(PositionMoveRotation.of(this.player), Collections.emptySet());
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - Add fail move event
|
||||
+ }
|
||||
+ // Paper end - Prevent moving into unloaded chunks
|
||||
+
|
||||
|
||||
if (this.shouldCheckPlayerMovement(flag)) {
|
||||
float f2 = flag ? 300.0F : 100.0F;
|
||||
|
||||
- if (d10 - d9 > (double) (f2 * (float) i)) {
|
||||
- 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;
|
||||
+ if (d10 - d9 > Math.max(f2, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2))) {
|
||||
+ // CraftBukkit end
|
||||
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;
|
||||
@@ -1037,18 +1412,51 @@
|
||||
+ // Paper start - Add fail move event
|
||||
+ io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_TOO_QUICKLY,
|
||||
+ toX, toY, toZ, toYaw, toPitch, true);
|
||||
+ if (!event.isAllowed()) {
|
||||
+ if (event.getLogWarning())
|
||||
+ 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;
|
||||
+ }
|
||||
+ // Paper end - Add fail move event
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AABB axisalignedbb = this.player.getBoundingBox();
|
||||
|
||||
|
@ -813,18 +834,40 @@
|
|||
double d11 = d7;
|
||||
|
||||
d6 = d0 - this.player.getX();
|
||||
@@ -1061,15 +1469,81 @@
|
||||
@@ -1059,17 +1480,100 @@
|
||||
|
||||
d8 = d2 - this.player.getZ();
|
||||
d10 = d6 * d6 + d7 * d7 + d8 * d8;
|
||||
boolean flag3 = false;
|
||||
- boolean flag3 = false;
|
||||
+ boolean movedWrongly = false; // Paper - Add fail move event; rename
|
||||
|
||||
- if (!this.player.isChangingDimension() && d10 > 0.0625D && !this.player.isSleeping() && !this.player.gameMode.isCreative() && this.player.gameMode.getGameModeForPlayer() != GameType.SPECTATOR) {
|
||||
- flag3 = true;
|
||||
+ if (!this.player.isChangingDimension() && d10 > org.spigotmc.SpigotConfig.movedWronglyThreshold && !this.player.isSleeping() && !this.player.gameMode.isCreative() && this.player.gameMode.getGameModeForPlayer() != GameType.SPECTATOR) { // Spigot
|
||||
flag3 = true;
|
||||
+ // Paper start - Add fail move event
|
||||
+ io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_WRONGLY,
|
||||
+ toX, toY, toZ, toYaw, toPitch, true);
|
||||
+ if (!event.isAllowed()) {
|
||||
+ movedWrongly = true;
|
||||
+ if (event.getLogWarning())
|
||||
+ // Paper end
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("{} moved wrongly!", this.player.getName().getString());
|
||||
+ } // Paper
|
||||
}
|
||||
|
||||
if (!this.player.noPhysics && !this.player.isSleeping() && (flag3 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2))) {
|
||||
- if (!this.player.noPhysics && !this.player.isSleeping() && (flag3 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2))) {
|
||||
- this.teleport(d3, d4, d5, f, f1);
|
||||
+ // Paper start - Add fail move event
|
||||
+ boolean teleportBack = !this.player.noPhysics && !this.player.isSleeping() && (movedWrongly && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2));
|
||||
+ if (teleportBack) {
|
||||
+ io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.CLIPPED_INTO_BLOCK,
|
||||
+ toX, toY, toZ, toYaw, toPitch, false);
|
||||
+ if (event.isAllowed()) {
|
||||
+ teleportBack = false;
|
||||
+ }
|
||||
+ }
|
||||
+ if (teleportBack) {
|
||||
+ // Paper end - Add fail move event
|
||||
+ this.internalTeleport(d3, d4, d5, f, f1); // CraftBukkit - SPIGOT-1807: Don't call teleport event, when the client thinks the player is falling, because the chunks are not loaded on the client yet.
|
||||
this.player.doCheckFallDamage(this.player.getX() - d3, this.player.getY() - d4, this.player.getZ() - d5, packet.isOnGround());
|
||||
} else {
|
||||
|
@ -897,7 +940,7 @@
|
|||
this.player.absMoveTo(d0, d1, d2, f, f1);
|
||||
boolean flag4 = this.player.isAutoSpinAttack();
|
||||
|
||||
@@ -1119,6 +1593,7 @@
|
||||
@@ -1119,6 +1623,7 @@
|
||||
this.awaitingTeleportTime = this.tickCount;
|
||||
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
|
||||
}
|
||||
|
@ -905,7 +948,7 @@
|
|||
|
||||
return true;
|
||||
} else {
|
||||
@@ -1147,23 +1622,98 @@
|
||||
@@ -1147,23 +1652,98 @@
|
||||
}
|
||||
|
||||
public void teleport(double x, double y, double z, float yaw, float pitch) {
|
||||
|
@ -1007,7 +1050,7 @@
|
|||
if (this.player.hasClientLoaded()) {
|
||||
BlockPos blockposition = packet.getPos();
|
||||
|
||||
@@ -1175,14 +1725,46 @@
|
||||
@@ -1175,14 +1755,46 @@
|
||||
if (!this.player.isSpectator()) {
|
||||
ItemStack itemstack = this.player.getItemInHand(InteractionHand.OFF_HAND);
|
||||
|
||||
|
@ -1056,7 +1099,7 @@
|
|||
this.player.drop(false);
|
||||
}
|
||||
|
||||
@@ -1199,8 +1781,34 @@
|
||||
@@ -1199,8 +1811,34 @@
|
||||
case START_DESTROY_BLOCK:
|
||||
case ABORT_DESTROY_BLOCK:
|
||||
case STOP_DESTROY_BLOCK:
|
||||
|
@ -1091,10 +1134,12 @@
|
|||
return;
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid player action");
|
||||
@@ -1218,9 +1826,31 @@
|
||||
}
|
||||
}
|
||||
@@ -1216,11 +1854,33 @@
|
||||
|
||||
return (item instanceof BlockItem || item instanceof BucketItem) && !player.getCooldowns().isOnCooldown(stack);
|
||||
}
|
||||
+ }
|
||||
+
|
||||
+ // Spigot start - limit place/interactions
|
||||
+ private int limitedPackets;
|
||||
+ private long lastLimitedPacket = -1;
|
||||
|
@ -1112,9 +1157,9 @@
|
|||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
}
|
||||
+ // Spigot end
|
||||
+
|
||||
|
||||
@Override
|
||||
public void handleUseItemOn(ServerboundUseItemOnPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
|
@ -1123,7 +1168,7 @@
|
|||
if (this.player.hasClientLoaded()) {
|
||||
this.player.connection.ackBlockChangesUpTo(packet.getSequence());
|
||||
ServerLevel worldserver = this.player.serverLevel();
|
||||
@@ -1230,6 +1860,11 @@
|
||||
@@ -1230,6 +1890,11 @@
|
||||
if (itemstack.isItemEnabled(worldserver.enabledFeatures())) {
|
||||
BlockHitResult movingobjectpositionblock = packet.getHitResult();
|
||||
Vec3 vec3d = movingobjectpositionblock.getLocation();
|
||||
|
@ -1135,7 +1180,7 @@
|
|||
BlockPos blockposition = movingobjectpositionblock.getBlockPos();
|
||||
|
||||
if (this.player.canInteractWithBlock(blockposition, 1.0D)) {
|
||||
@@ -1243,7 +1878,8 @@
|
||||
@@ -1243,7 +1908,8 @@
|
||||
int i = this.player.level().getMaxY();
|
||||
|
||||
if (blockposition.getY() <= i) {
|
||||
|
@ -1145,7 +1190,7 @@
|
|||
InteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
|
||||
|
||||
if (enuminteractionresult.consumesAction()) {
|
||||
@@ -1257,11 +1893,11 @@
|
||||
@@ -1257,11 +1923,11 @@
|
||||
} else if (enuminteractionresult instanceof InteractionResult.Success) {
|
||||
InteractionResult.Success enuminteractionresult_d = (InteractionResult.Success) enuminteractionresult;
|
||||
|
||||
|
@ -1159,7 +1204,7 @@
|
|||
} else {
|
||||
MutableComponent ichatmutablecomponent1 = Component.translatable("build.tooHigh", i).withStyle(ChatFormatting.RED);
|
||||
|
||||
@@ -1281,6 +1917,8 @@
|
||||
@@ -1281,6 +1947,8 @@
|
||||
@Override
|
||||
public void handleUseItem(ServerboundUseItemPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
|
@ -1168,7 +1213,7 @@
|
|||
if (this.player.hasClientLoaded()) {
|
||||
this.ackBlockChangesUpTo(packet.getSequence());
|
||||
ServerLevel worldserver = this.player.serverLevel();
|
||||
@@ -1296,6 +1934,47 @@
|
||||
@@ -1296,6 +1964,47 @@
|
||||
this.player.absRotateTo(f, f1);
|
||||
}
|
||||
|
||||
|
@ -1216,7 +1261,7 @@
|
|||
InteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
|
||||
|
||||
if (enuminteractionresult instanceof InteractionResult.Success) {
|
||||
@@ -1321,7 +2000,7 @@
|
||||
@@ -1321,7 +2030,7 @@
|
||||
Entity entity = packet.getEntity(worldserver);
|
||||
|
||||
if (entity != null) {
|
||||
|
@ -1225,7 +1270,7 @@
|
|||
return;
|
||||
}
|
||||
}
|
||||
@@ -1342,22 +2021,52 @@
|
||||
@@ -1342,22 +2051,52 @@
|
||||
|
||||
@Override
|
||||
public void onDisconnect(DisconnectionDetails info) {
|
||||
|
@ -1282,7 +1327,7 @@
|
|||
throw new IllegalArgumentException("Expected packet sequence nr >= 0");
|
||||
} else {
|
||||
this.ackBlockChangesUpTo = Math.max(sequence, this.ackBlockChangesUpTo);
|
||||
@@ -1367,7 +2076,17 @@
|
||||
@@ -1367,7 +2106,17 @@
|
||||
@Override
|
||||
public void handleSetCarriedItem(ServerboundSetCarriedItemPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
|
@ -1300,7 +1345,7 @@
|
|||
if (this.player.getInventory().selected != packet.getSlot() && this.player.getUsedItemHand() == InteractionHand.MAIN_HAND) {
|
||||
this.player.stopUsingItem();
|
||||
}
|
||||
@@ -1376,11 +2095,18 @@
|
||||
@@ -1376,11 +2125,18 @@
|
||||
this.player.resetLastActionTime();
|
||||
} else {
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
|
||||
|
@ -1319,7 +1364,7 @@
|
|||
Optional<LastSeenMessages> optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages());
|
||||
|
||||
if (!optional.isEmpty()) {
|
||||
@@ -1394,27 +2120,46 @@
|
||||
@@ -1394,27 +2150,46 @@
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1373,7 +1418,7 @@
|
|||
ParseResults<CommandSourceStack> parseresults = this.parseCommand(command);
|
||||
|
||||
if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseresults)) {
|
||||
@@ -1431,19 +2176,39 @@
|
||||
@@ -1431,19 +2206,39 @@
|
||||
|
||||
if (!optional.isEmpty()) {
|
||||
this.tryHandleChat(packet.command(), () -> {
|
||||
|
@ -1417,7 +1462,7 @@
|
|||
} catch (SignedMessageChain.DecodeException signedmessagechain_a) {
|
||||
this.handleMessageDecodeFailure(signedmessagechain_a);
|
||||
return;
|
||||
@@ -1451,10 +2216,10 @@
|
||||
@@ -1451,10 +2246,10 @@
|
||||
|
||||
CommandSigningContext.SignedArguments commandsigningcontext_a = new CommandSigningContext.SignedArguments(map);
|
||||
|
||||
|
@ -1430,7 +1475,7 @@
|
|||
}
|
||||
|
||||
private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) {
|
||||
@@ -1530,14 +2295,20 @@
|
||||
@@ -1530,14 +2325,20 @@
|
||||
return com_mojang_brigadier_commanddispatcher.parse(command, this.player.createCommandSourceStack());
|
||||
}
|
||||
|
||||
|
@ -1456,7 +1501,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -1549,7 +2320,7 @@
|
||||
@@ -1549,7 +2350,7 @@
|
||||
|
||||
if (optional.isEmpty()) {
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
|
||||
|
@ -1465,12 +1510,10 @@
|
|||
}
|
||||
|
||||
return optional;
|
||||
@@ -1564,8 +2335,129 @@
|
||||
}
|
||||
|
||||
@@ -1566,6 +2367,127 @@
|
||||
return false;
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - add method
|
||||
+ public void chat(String s, PlayerChatMessage original, boolean async) {
|
||||
+ if (s.isEmpty() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) {
|
||||
|
@ -1563,8 +1606,8 @@
|
|||
+ this.server.console.sendMessage(s);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ private void handleCommand(String s) {
|
||||
+ org.spigotmc.AsyncCatcher.catchOp("Command Dispatched Async: " + s); // Paper - Add async catcher
|
||||
+ if ( org.spigotmc.SpigotConfig.logCommands ) // Spigot
|
||||
|
@ -1595,7 +1638,7 @@
|
|||
private PlayerChatMessage getSignedMessage(ServerboundChatPacket packet, LastSeenMessages lastSeenMessages) throws SignedMessageChain.DecodeException {
|
||||
SignedMessageBody signedmessagebody = new SignedMessageBody(packet.message(), packet.timeStamp(), packet.salt(), lastSeenMessages);
|
||||
|
||||
@@ -1573,15 +2465,44 @@
|
||||
@@ -1573,15 +2495,44 @@
|
||||
}
|
||||
|
||||
private void broadcastChatMessage(PlayerChatMessage message) {
|
||||
|
@ -1646,7 +1689,7 @@
|
|||
|
||||
}
|
||||
|
||||
@@ -1592,7 +2513,7 @@
|
||||
@@ -1592,7 +2543,7 @@
|
||||
synchronized (this.lastSeenMessages) {
|
||||
if (!this.lastSeenMessages.applyOffset(packet.offset())) {
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
|
||||
|
@ -1655,7 +1698,7 @@
|
|||
}
|
||||
|
||||
}
|
||||
@@ -1601,7 +2522,40 @@
|
||||
@@ -1601,7 +2552,40 @@
|
||||
@Override
|
||||
public void handleAnimate(ServerboundSwingPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
|
@ -1696,7 +1739,7 @@
|
|||
this.player.swing(packet.getHand());
|
||||
}
|
||||
|
||||
@@ -1609,6 +2563,29 @@
|
||||
@@ -1609,6 +2593,29 @@
|
||||
public void handlePlayerCommand(ServerboundPlayerCommandPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
if (this.player.hasClientLoaded()) {
|
||||
|
@ -1726,7 +1769,7 @@
|
|||
this.player.resetLastActionTime();
|
||||
Entity entity;
|
||||
PlayerRideableJumping ijumpable;
|
||||
@@ -1616,6 +2593,11 @@
|
||||
@@ -1616,6 +2623,11 @@
|
||||
switch (packet.getAction()) {
|
||||
case PRESS_SHIFT_KEY:
|
||||
this.player.setShiftKeyDown(true);
|
||||
|
@ -1738,7 +1781,7 @@
|
|||
break;
|
||||
case RELEASE_SHIFT_KEY:
|
||||
this.player.setShiftKeyDown(false);
|
||||
@@ -1684,13 +2666,19 @@
|
||||
@@ -1684,13 +2696,19 @@
|
||||
}
|
||||
|
||||
if (i > 4096) {
|
||||
|
@ -1759,7 +1802,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 +2691,18 @@
|
||||
@@ -1703,6 +2721,18 @@
|
||||
return this.connection.getRemoteAddress();
|
||||
}
|
||||
|
||||
|
@ -1778,7 +1821,7 @@
|
|||
public void switchToConfig() {
|
||||
this.waitingForSwitchToConfig = true;
|
||||
this.removePlayerFromWorld();
|
||||
@@ -1718,9 +2718,17 @@
|
||||
@@ -1718,9 +2748,17 @@
|
||||
@Override
|
||||
public void handleInteract(ServerboundInteractPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
|
@ -1796,7 +1839,7 @@
|
|||
|
||||
this.player.resetLastActionTime();
|
||||
this.player.setShiftKeyDown(packet.isUsingSecondaryAction());
|
||||
@@ -1733,20 +2741,58 @@
|
||||
@@ -1733,20 +2771,58 @@
|
||||
|
||||
if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) {
|
||||
packet.dispatch(new ServerboundInteractPacket.Handler() {
|
||||
|
@ -1859,7 +1902,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -1755,19 +2801,20 @@
|
||||
@@ -1755,19 +2831,20 @@
|
||||
|
||||
@Override
|
||||
public void onInteraction(InteractionHand hand) {
|
||||
|
@ -1883,7 +1926,7 @@
|
|||
label23:
|
||||
{
|
||||
if (entity instanceof AbstractArrow) {
|
||||
@@ -1785,17 +2832,41 @@
|
||||
@@ -1785,17 +2862,41 @@
|
||||
}
|
||||
|
||||
ServerGamePacketListenerImpl.this.player.attack(entity);
|
||||
|
@ -1926,7 +1969,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -1809,7 +2880,7 @@
|
||||
@@ -1809,7 +2910,7 @@
|
||||
case PERFORM_RESPAWN:
|
||||
if (this.player.wonGame) {
|
||||
this.player.wonGame = false;
|
||||
|
@ -1935,7 +1978,7 @@
|
|||
this.resetPosition();
|
||||
CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD);
|
||||
} else {
|
||||
@@ -1817,11 +2888,11 @@
|
||||
@@ -1817,11 +2918,11 @@
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1950,7 +1993,7 @@
|
|||
}
|
||||
}
|
||||
break;
|
||||
@@ -1833,16 +2904,27 @@
|
||||
@@ -1833,16 +2934,27 @@
|
||||
|
||||
@Override
|
||||
public void handleContainerClose(ServerboundContainerClosePacket packet) {
|
||||
|
@ -1980,7 +2023,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 +2937,284 @@
|
||||
@@ -1855,7 +2967,284 @@
|
||||
boolean flag = packet.getStateId() != this.player.containerMenu.getStateId();
|
||||
|
||||
this.player.containerMenu.suppressRemoteUpdates();
|
||||
|
@ -2266,7 +2309,7 @@
|
|||
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packet.getChangedSlots()).iterator();
|
||||
|
||||
while (objectiterator.hasNext()) {
|
||||
@@ -1879,6 +3238,14 @@
|
||||
@@ -1879,6 +3268,14 @@
|
||||
|
||||
@Override
|
||||
public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) {
|
||||
|
@ -2281,7 +2324,7 @@
|
|||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
this.player.resetLastActionTime();
|
||||
if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.containerId()) {
|
||||
@@ -1900,9 +3267,43 @@
|
||||
@@ -1900,8 +3297,42 @@
|
||||
ServerGamePacketListenerImpl.LOGGER.debug("Player {} tried to place impossible recipe {}", this.player, recipeholder.id().location());
|
||||
return;
|
||||
}
|
||||
|
@ -2314,7 +2357,7 @@
|
|||
+ return;
|
||||
+ }
|
||||
+ // Paper end - Add PlayerRecipeBookClickEvent - forward to legacy event
|
||||
|
||||
+
|
||||
+ // Cast to keyed should be safe as the recipe will never be a MerchantRecipe.
|
||||
+ recipeholder = this.server.getRecipeManager().byKey(net.minecraft.resources.ResourceKey.create(net.minecraft.core.registries.Registries.RECIPE, org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(recipeName))).orElse(null); // Paper - Add PlayerRecipeBookClickEvent - forward to legacy event
|
||||
+ if (recipeholder == null) {
|
||||
|
@ -2322,11 +2365,10 @@
|
|||
+ }
|
||||
+ RecipeBookMenu.PostPlaceAction containerrecipebook_a = containerrecipebook.handlePlacement(makeAll, this.player.isCreative(), recipeholder, this.player.serverLevel(), this.player.getInventory());
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
if (containerrecipebook_a == RecipeBookMenu.PostPlaceAction.PLACE_GHOST_RECIPE) {
|
||||
this.player.connection.send(new ClientboundPlaceGhostRecipePacket(this.player.containerMenu.containerId, craftingmanager_d.display().display()));
|
||||
}
|
||||
@@ -1917,6 +3318,7 @@
|
||||
@@ -1917,6 +3348,7 @@
|
||||
@Override
|
||||
public void handleContainerButtonClick(ServerboundContainerButtonClickPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
|
@ -2334,7 +2376,7 @@
|
|||
this.player.resetLastActionTime();
|
||||
if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) {
|
||||
if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
@@ -1945,7 +3347,44 @@
|
||||
@@ -1945,7 +3377,44 @@
|
||||
|
||||
boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45;
|
||||
boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize();
|
||||
|
@ -2379,7 +2421,7 @@
|
|||
if (flag1 && flag2) {
|
||||
this.player.inventoryMenu.getSlot(packet.slotNum()).setByPlayer(itemstack);
|
||||
this.player.inventoryMenu.setRemoteSlot(packet.slotNum(), itemstack);
|
||||
@@ -1964,7 +3403,19 @@
|
||||
@@ -1964,7 +3433,19 @@
|
||||
|
||||
@Override
|
||||
public void handleSignUpdate(ServerboundSignUpdatePacket packet) {
|
||||
|
@ -2400,7 +2442,7 @@
|
|||
|
||||
this.filterTextPacket(list).thenAcceptAsync((list1) -> {
|
||||
this.updateSignText(packet, list1);
|
||||
@@ -1972,6 +3423,7 @@
|
||||
@@ -1972,6 +3453,7 @@
|
||||
}
|
||||
|
||||
private void updateSignText(ServerboundSignUpdatePacket packet, List<FilteredText> signText) {
|
||||
|
@ -2408,7 +2450,7 @@
|
|||
this.player.resetLastActionTime();
|
||||
ServerLevel worldserver = this.player.serverLevel();
|
||||
BlockPos blockposition = packet.getPos();
|
||||
@@ -1993,15 +3445,33 @@
|
||||
@@ -1993,15 +3475,33 @@
|
||||
@Override
|
||||
public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
|
@ -2443,7 +2485,7 @@
|
|||
if (this.player.isModelPartShown(PlayerModelPart.HAT) != flag) {
|
||||
this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_HAT, this.player));
|
||||
}
|
||||
@@ -2012,7 +3482,7 @@
|
||||
@@ -2012,7 +3512,7 @@
|
||||
public void handleChangeDifficulty(ServerboundChangeDifficultyPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
if (this.player.hasPermissions(2) || this.isSingleplayerOwner()) {
|
||||
|
@ -2452,7 +2494,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -2033,7 +3503,7 @@
|
||||
@@ -2033,7 +3533,7 @@
|
||||
|
||||
if (!Objects.equals(profilepublickey_a, profilepublickey_a1)) {
|
||||
if (profilepublickey_a != null && profilepublickey_a1.expiresAt().isBefore(profilepublickey_a.expiresAt())) {
|
||||
|
@ -2461,7 +2503,7 @@
|
|||
} else {
|
||||
try {
|
||||
SignatureValidator signaturevalidator = this.server.getProfileKeySignatureValidator();
|
||||
@@ -2045,8 +3515,8 @@
|
||||
@@ -2045,8 +3545,8 @@
|
||||
|
||||
this.resetPlayerChatState(remotechatsession_a.validate(this.player.getGameProfile(), signaturevalidator));
|
||||
} catch (ProfilePublicKey.ValidationException profilepublickey_b) {
|
||||
|
@ -2472,7 +2514,7 @@
|
|||
}
|
||||
|
||||
}
|
||||
@@ -2058,7 +3528,7 @@
|
||||
@@ -2058,7 +3558,7 @@
|
||||
if (!this.waitingForSwitchToConfig) {
|
||||
throw new IllegalStateException("Client acknowledged config, but none was requested");
|
||||
} else {
|
||||
|
@ -2481,7 +2523,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -2076,15 +3546,18 @@
|
||||
@@ -2076,15 +3576,18 @@
|
||||
|
||||
private void resetPlayerChatState(RemoteChatSession session) {
|
||||
this.chatSession = session;
|
||||
|
@ -2503,3 +2545,21 @@
|
|||
|
||||
@Override
|
||||
public void handleClientTickEnd(ServerboundClientTickEndPacket packet) {
|
||||
@@ -2115,4 +3618,17 @@
|
||||
|
||||
InteractionResult run(ServerPlayer player, Entity entity, InteractionHand hand);
|
||||
}
|
||||
+
|
||||
+ // Paper start - Add fail move event
|
||||
+ private io.papermc.paper.event.player.PlayerFailMoveEvent fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason failReason,
|
||||
+ double toX, double toY, double toZ, float toYaw, float toPitch, boolean logWarning) {
|
||||
+ Player player = this.getCraftPlayer();
|
||||
+ Location from = new Location(player.getWorld(), this.lastPosX, this.lastPosY, this.lastPosZ, this.lastYaw, this.lastPitch);
|
||||
+ Location to = new Location(player.getWorld(), toX, toY, toZ, toYaw, toPitch);
|
||||
+ io.papermc.paper.event.player.PlayerFailMoveEvent event = new io.papermc.paper.event.player.PlayerFailMoveEvent(player, failReason,
|
||||
+ false, logWarning, from, to);
|
||||
+ event.callEvent();
|
||||
+ return event;
|
||||
+ }
|
||||
+ // Paper end - Add fail move event
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue