|
1 | 1 | --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java |
2 | 2 | +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java |
3 | | -@@ -326,6 +_,20 @@ |
4 | | - this.chatMessageChain = new FutureChain(server.chatExecutor); // CraftBukkit - async chat |
| 3 | +@@ -328,6 +_,20 @@ |
| 4 | + this.tickEndEvent = new io.papermc.paper.event.packet.ClientTickEndEvent(player.getBukkitEntity()); // Paper - add client tick end event |
5 | 5 | } |
6 | 6 |
|
7 | 7 | + // Purpur start - AFK API |
|
21 | 21 | @Override |
22 | 22 | public void tick() { |
23 | 23 | if (this.ackBlockChangesUpTo > -1) { |
24 | | -@@ -384,6 +_,12 @@ |
| 24 | +@@ -386,6 +_,12 @@ |
25 | 25 | if (this.player.getLastActionTime() > 0L |
26 | 26 | && this.server.getPlayerIdleTimeout() > 0 |
27 | 27 | && Util.getMillis() - this.player.getLastActionTime() > this.server.getPlayerIdleTimeout() * 1000L * 60L && !this.player.wonGame) { // Paper - Prevent AFK kick while watching end credits |
|
34 | 34 | this.player.resetLastActionTime(); // CraftBukkit - SPIGOT-854 |
35 | 35 | this.disconnect(Component.translatable("multiplayer.disconnect.idling"), org.bukkit.event.player.PlayerKickEvent.Cause.IDLING); // Paper - kick event cause |
36 | 36 | } |
37 | | -@@ -629,6 +_,8 @@ |
| 37 | +@@ -631,6 +_,8 @@ |
38 | 38 | this.lastYaw = to.getYaw(); |
39 | 39 | this.lastPitch = to.getPitch(); |
40 | 40 |
|
|
43 | 43 | Location oldTo = to.clone(); |
44 | 44 | PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); |
45 | 45 | this.cserver.getPluginManager().callEvent(event); |
46 | | -@@ -709,6 +_,7 @@ |
| 46 | +@@ -711,6 +_,7 @@ |
47 | 47 | PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); |
48 | 48 | if (packet.getId() == this.awaitingTeleport) { |
49 | 49 | if (this.awaitingPositionFromClient == null) { |
50 | 50 | + ServerGamePacketListenerImpl.LOGGER.warn("Disconnected on accept teleport packet. Was not expecting position data from client at this time"); // Purpur - Add more logger output for invalid movement kicks |
51 | 51 | this.disconnect(Component.translatable("multiplayer.disconnect.invalid_player_movement"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PLAYER_MOVEMENT); // Paper - kick event cause |
52 | 52 | return; |
53 | 53 | } |
54 | | -@@ -1176,6 +_,10 @@ |
| 54 | +@@ -1179,6 +_,10 @@ |
55 | 55 | final int maxBookPageSize = pageMax.intValue(); |
56 | 56 | final double multiplier = Math.clamp(io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.bookSize.totalMultiplier, 0.3D, 1D); |
57 | 57 | long byteAllowed = maxBookPageSize; |
|
62 | 62 | for (final String page : pageList) { |
63 | 63 | final int byteLength = page.getBytes(java.nio.charset.StandardCharsets.UTF_8).length; |
64 | 64 | byteTotal += byteLength; |
65 | | -@@ -1200,7 +_,8 @@ |
| 65 | +@@ -1203,7 +_,8 @@ |
66 | 66 | } |
67 | 67 |
|
68 | 68 | if (byteTotal > byteAllowed) { |
|
72 | 72 | this.disconnectAsync(Component.literal("Book too large!"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause // Paper - add proper async disconnect |
73 | 73 | return; |
74 | 74 | } |
75 | | -@@ -1219,31 +_,45 @@ |
| 75 | +@@ -1222,31 +_,45 @@ |
76 | 76 | Optional<String> optional = packet.title(); |
77 | 77 | optional.ifPresent(list::add); |
78 | 78 | list.addAll(packet.pages()); |
|
122 | 122 | itemStack.set( |
123 | 123 | DataComponents.WRITTEN_BOOK_CONTENT, |
124 | 124 | new WrittenBookContent(this.filterableFromOutgoing(title), this.player.getName().getString(), 0, list, true) |
125 | | -@@ -1257,6 +_,16 @@ |
| 125 | +@@ -1260,6 +_,16 @@ |
126 | 126 | return this.player.isTextFilteringEnabled() ? Filterable.passThrough(filteredText.filteredOrEmpty()) : Filterable.from(filteredText); |
127 | 127 | } |
128 | 128 |
|
|
139 | 139 | @Override |
140 | 140 | public void handleEntityTagQuery(ServerboundEntityTagQueryPacket packet) { |
141 | 141 | PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); |
142 | | -@@ -1292,7 +_,15 @@ |
| 142 | +@@ -1295,7 +_,15 @@ |
143 | 143 | @Override |
144 | 144 | public void handleMovePlayer(ServerboundMovePlayerPacket packet) { |
145 | 145 | PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); |
|
156 | 156 | this.disconnect(Component.translatable("multiplayer.disconnect.invalid_player_movement"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PLAYER_MOVEMENT); // Paper - kick event cause |
157 | 157 | } else { |
158 | 158 | ServerLevel serverLevel = this.player.serverLevel(); |
159 | | -@@ -1467,7 +_,7 @@ |
| 159 | +@@ -1470,7 +_,7 @@ |
160 | 160 | movedWrongly = true; |
161 | 161 | if (event.getLogWarning()) |
162 | 162 | // Paper end |
|
165 | 165 | } // Paper |
166 | 166 | } |
167 | 167 |
|
168 | | -@@ -1533,6 +_,8 @@ |
| 168 | +@@ -1536,6 +_,8 @@ |
169 | 169 | this.lastYaw = to.getYaw(); |
170 | 170 | this.lastPitch = to.getPitch(); |
171 | 171 |
|
|
174 | 174 | Location oldTo = to.clone(); |
175 | 175 | PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); |
176 | 176 | this.cserver.getPluginManager().callEvent(event); |
177 | | -@@ -1589,6 +_,13 @@ |
| 177 | +@@ -1592,6 +_,13 @@ |
178 | 178 | this.player.tryResetCurrentImpulseContext(); |
179 | 179 | } |
180 | 180 |
|
|
188 | 188 | this.player.checkMovementStatistics(this.player.getX() - x, this.player.getY() - y, this.player.getZ() - z); |
189 | 189 | this.lastGoodX = this.player.getX(); |
190 | 190 | this.lastGoodY = this.player.getY(); |
191 | | -@@ -1637,6 +_,17 @@ |
| 191 | +@@ -1640,6 +_,17 @@ |
192 | 192 | } |
193 | 193 | } |
194 | 194 |
|
|
206 | 206 | // Paper start - optimise out extra getCubes |
207 | 207 | private boolean hasNewCollision(final ServerLevel level, final Entity entity, final AABB oldBox, final AABB newBox) { |
208 | 208 | final List<AABB> collisionsBB = new java.util.ArrayList<>(); |
209 | | -@@ -2001,6 +_,7 @@ |
| 209 | +@@ -2010,6 +_,7 @@ |
210 | 210 |
|
211 | 211 | boolean cancelled; |
212 | 212 | if (hitResult == null || hitResult.getType() != HitResult.Type.BLOCK) { |
213 | 213 | + if (this.player.gameMode.shiftClickMended(itemInHand)) return; // Purpur - Shift right click to use exp for mending |
214 | 214 | org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemInHand, hand); |
215 | 215 | cancelled = event.useItemInHand() == Event.Result.DENY; |
216 | 216 | } else { |
217 | | -@@ -2741,6 +_,7 @@ |
| 217 | +@@ -2751,6 +_,7 @@ |
218 | 218 |
|
219 | 219 | AABB boundingBox = target.getBoundingBox(); |
220 | 220 | if (this.player.canInteractWithEntity(boundingBox, io.papermc.paper.configuration.GlobalConfiguration.get().misc.clientInteractionLeniencyDistance.or(3.0))) { // Paper - configurable lenience value for interact range |
|
0 commit comments