mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-04-22 03:08:16 +02:00
Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@e4a5a894 Update to Minecraft 26.1.1 PaperMC/Paper@92a4d8db Update "Only write chunk data to disk if it serializes without throwing" PaperMC/Paper@02d9cbce Update "Entity load/save limit per chunk" PaperMC/Paper@cb696286 Update "Attempt to recalculate regionfile header if it is corrupt" PaperMC/Paper@4662bab9 Update "Incremental chunk and player saving" PaperMC/Paper@4dddc82f Implement new version schema: `<mcver>.build.<paper_build_no>-<paper_status>` / `<mcver>.local-SNAPSHOT` PaperMC/Paper@fc0a9980 Set channel to ALPHA PaperMC/Paper@a4fa0357 update gradle wrapper PaperMC/Paper@a15ceb7a Update fill-gradle to 1.0.11 PaperMC/Paper@52f7e24e Publish to releases repository PaperMC/Paper@bb7ff8f0 Update "Optimise general POI access" PaperMC/Paper@ac42a07e Update "Flush regionfiles on save configuration option" PaperMC/Paper@14357cc5 Avoid using the regionfile directory name to determine if it is chunk data PaperMC/Paper@a2f4d349 Update "Optimise collision checking in player move packet handling" PaperMC/Paper@50303a0e Update "Add explicit flush support to Log4j AsyncAppender" PaperMC/Paper@7bc4f895 Shift unapplied patches PaperMC/Paper@62ba2c4f Update "Improve keepalive ping system" PaperMC/Paper@f6d27019 Update "Optimise EntityScheduler ticking" PaperMC/Paper@4d8d06c7 Fix WorldBorder#setCenter ignoring new values on 26.1.1 (#13741) PaperMC/Paper@f9da8035 update unpick definitions PaperMC/Paper@fc71a133 [ci/skip] fixup previous commit PaperMC/Paper@4c91cd34 Lazy set Entity.projectileSource in AbstractProjectile#getShooter PaperMC/Paper@3d1da60c Cache the climbing check in activation range (#12764) PaperMC/Paper@575630f3 feat: Optimize ServerWaypointManager when locator bar is disabled PaperMC/Paper@742daf02 [ci/skip] fixup previous commit PaperMC/Paper@d29063da Rebuild patches PaperMC/Paper@ce581c3c Bump deps to match Vanilla versions (#13744) PaperMC/Paper@f3e9a934 Fix attack check PaperMC/Paper@b4743b58 Fix gamerule loading in Management Protocol (#13753) PaperMC/Paper@c53ac8a1 Add PlayerToggleEntityAgeLockEvent (#13742) PaperMC/Paper@59081719 fixup previous event PaperMC/Paper@7b49b586 Update "Optional per player mob spawns" PaperMC/Paper@1fae14c2 Update "Improve cancelling PreCreatureSpawnEvent with per player mob spawns" PaperMC/Paper@c40cb75b Update "Optimize Hoppers" PaperMC/Paper@edad1e4c Update "Anti-Xray" PaperMC/Paper@106a934d [ci/skip] Drop stale TODO PaperMC/Paper@77c0866f handle legacy uid in vanilla migration and always write metadata during migration
This commit is contained in:
@@ -1,14 +1,19 @@
|
||||
--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
@@ -44,6 +_,7 @@
|
||||
private long keepAliveChallenge;
|
||||
@@ -40,10 +_,11 @@
|
||||
public final Connection connection; // Paper
|
||||
private final boolean transferred;
|
||||
//private long keepAliveTime; // Paper - improve keepalives
|
||||
- //private boolean keepAlivePending; // Paper - improve keepalives
|
||||
+ private boolean keepAlivePending; // Paper - improve keepalives // Purpur - Alternative Keepalive Handling
|
||||
//private long keepAliveChallenge; // Paper - improve keepalives
|
||||
private long closedListenerTime;
|
||||
private boolean closed = false;
|
||||
+ private it.unimi.dsi.fastutil.longs.LongList keepAlives = new it.unimi.dsi.fastutil.longs.LongArrayList(); // Purpur - Alternative Keepalive Handling
|
||||
private int latency;
|
||||
private volatile int latency; // Paper - improve keepalives - make volatile
|
||||
private final io.papermc.paper.util.KeepAlive keepAlive; // Paper - improve keepalives
|
||||
private volatile boolean suspendFlushingOnServerThread = false;
|
||||
// CraftBukkit start
|
||||
@@ -53,6 +_,10 @@
|
||||
@@ -54,6 +_,10 @@
|
||||
public final java.util.Map<java.util.UUID, net.kyori.adventure.resource.ResourcePackCallback> packCallbacks = new java.util.concurrent.ConcurrentHashMap<>(); // Paper - adventure resource pack callbacks
|
||||
private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit
|
||||
protected static final net.minecraft.resources.Identifier MINECRAFT_BRAND = net.minecraft.resources.Identifier.withDefaultNamespace("brand"); // Paper - Brand support
|
||||
@@ -19,24 +24,26 @@
|
||||
// Paper start - retain certain values
|
||||
public @Nullable String playerBrand;
|
||||
public final java.util.Set<String> pluginMessagerChannels;
|
||||
@@ -100,6 +_,16 @@
|
||||
|
||||
@Override
|
||||
public void handleKeepAlive(final ServerboundKeepAlivePacket packet) {
|
||||
@@ -105,6 +_,18 @@
|
||||
// Paper start - improve keepalives
|
||||
long now = System.nanoTime();
|
||||
io.papermc.paper.util.KeepAlive.PendingKeepAlive pending = this.keepAlive.pendingKeepAlives.peek();
|
||||
+ // Purpur start - Alternative Keepalive Handling
|
||||
+ if (org.purpurmc.purpur.PurpurConfig.useAlternateKeepAlive) {
|
||||
+ if (this.keepAlivePending && !keepAlives.isEmpty() && keepAlives.contains(packet.getId())) {
|
||||
+ int ping = (int) (Util.getMillis() - packet.getId());
|
||||
+ this.latency = (this.latency * 3 + ping) / 4;
|
||||
+ int updatedLatency = (this.latency * 3 + ping) / 4;
|
||||
+ this.latency = updatedLatency;
|
||||
+ this.keepAlivePending = false;
|
||||
+ keepAlives.clear(); // we got a valid response, lets roll with it and forget the rest
|
||||
+ }
|
||||
+ return;
|
||||
+ } else
|
||||
+ // Purpur end - Alternative Keepalive Handling
|
||||
if (this.keepAlivePending && packet.getId() == this.keepAliveChallenge) {
|
||||
int time = (int)(Util.getMillis() - this.keepAliveTime);
|
||||
this.latency = (this.latency * 3 + time) / 4;
|
||||
@@ -149,6 +_,12 @@
|
||||
if (pending != null && pending.challengeId() == packet.getId()) {
|
||||
this.keepAlive.pendingKeepAlives.remove(pending);
|
||||
|
||||
@@ -179,6 +_,12 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -49,24 +56,27 @@
|
||||
if (identifier.equals(MINECRAFT_BRAND)) {
|
||||
this.playerBrand = new net.minecraft.network.FriendlyByteBuf(io.netty.buffer.Unpooled.wrappedBuffer(data)).readUtf(256);
|
||||
}
|
||||
@@ -236,6 +_,20 @@
|
||||
// Paper start - give clients a longer time to respond to pings as per pre 1.12.2 timings
|
||||
// This should effectively place the keepalive handling back to "as it was" before 1.12.2
|
||||
final long elapsedTime = now - this.keepAliveTime;
|
||||
@@ -264,6 +_,23 @@
|
||||
Profiler.get().push("keepAlive");
|
||||
long now = Util.getMillis();
|
||||
// Paper start - improve keepalives
|
||||
+ // Purpur start - Alternative Keepalive Handling
|
||||
+ if (org.purpurmc.purpur.PurpurConfig.useAlternateKeepAlive) {
|
||||
+ if (elapsedTime >= 1000L) { // 1 second
|
||||
+ if (this.keepAlivePending && !this.processedDisconnect && keepAlives.size() * 1000L >= KEEPALIVE_LIMIT) {
|
||||
+ this.disconnect(TIMEOUT_DISCONNECTION_MESSAGE, io.papermc.paper.connection.DisconnectionReason.TIMEOUT); // Paper - kick event cause
|
||||
+ } else if (this.checkIfClosed(now)) {
|
||||
+ this.keepAlivePending = true;
|
||||
+ this.keepAliveTime = now; // hijack this field for 1 second intervals
|
||||
+ this.keepAlives.add(now); // currentTime is ID
|
||||
+ this.send(new ClientboundKeepAlivePacket(now));
|
||||
+ if (this.checkIfClosed(now) && !this.processedDisconnect) {
|
||||
+ long currTime = System.nanoTime();
|
||||
+ if ((currTime - this.keepAlive.lastKeepAliveTx) >= java.util.concurrent.TimeUnit.SECONDS.toNanos(1L)) { // 1 second
|
||||
+ this.keepAlive.lastKeepAliveTx = currTime;
|
||||
+ if (this.keepAlivePending && !this.processedDisconnect && keepAlives.size() * 1000L >= KEEPALIVE_LIMIT) {
|
||||
+ this.disconnect(TIMEOUT_DISCONNECTION_MESSAGE, io.papermc.paper.connection.DisconnectionReason.TIMEOUT);
|
||||
+ } else if (this.checkIfClosed(now)) {
|
||||
+ this.keepAlivePending = true;
|
||||
+ this.keepAlives.add(now); // currentTime is ID
|
||||
+ this.send(new ClientboundKeepAlivePacket(now));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ } else
|
||||
+ // Purpur end - Alternative Keepalive Handling
|
||||
if (!this.isSingleplayerOwner() && elapsedTime >= 15000L) { // use vanilla's 15000L between keep alive packets
|
||||
if (this.keepAlivePending) {
|
||||
if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected
|
||||
if (this.checkIfClosed(now) && !this.processedDisconnect) {
|
||||
long currTime = System.nanoTime();
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
this.disconnect(Component.translatable("multiplayer.disconnect.idling"), org.bukkit.event.player.PlayerKickEvent.Cause.IDLING); // Paper - kick event cause
|
||||
}
|
||||
}
|
||||
@@ -682,6 +_,8 @@
|
||||
@@ -693,6 +_,8 @@
|
||||
this.lastYaw = to.getYaw();
|
||||
this.lastPitch = to.getPitch();
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
Location oldTo = to.clone();
|
||||
PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
|
||||
this.cserver.getPluginManager().callEvent(event);
|
||||
@@ -738,6 +_,7 @@
|
||||
@@ -772,6 +_,7 @@
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level());
|
||||
if (packet.getId() == this.awaitingTeleport) {
|
||||
if (this.awaitingPositionFromClient == null) {
|
||||
@@ -51,7 +51,7 @@
|
||||
this.disconnect(Component.translatable("multiplayer.disconnect.invalid_player_movement"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PLAYER_MOVEMENT); // Paper - kick event cause
|
||||
return;
|
||||
}
|
||||
@@ -1306,6 +_,10 @@
|
||||
@@ -1340,6 +_,10 @@
|
||||
final int maxBookPageSize = pageMax.intValue();
|
||||
final double multiplier = Math.clamp(io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.bookSize.totalMultiplier, 0.3D, 1D);
|
||||
long byteAllowed = maxBookPageSize;
|
||||
@@ -62,7 +62,7 @@
|
||||
for (final String page : pageList) {
|
||||
final int byteLength = page.getBytes(java.nio.charset.StandardCharsets.UTF_8).length;
|
||||
byteTotal += byteLength;
|
||||
@@ -1330,7 +_,8 @@
|
||||
@@ -1364,7 +_,8 @@
|
||||
}
|
||||
|
||||
if (byteTotal > byteAllowed) {
|
||||
@@ -72,7 +72,7 @@
|
||||
this.disconnectAsync(Component.literal("Book too large!"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause // Paper - add proper async disconnect
|
||||
return;
|
||||
}
|
||||
@@ -1349,31 +_,45 @@
|
||||
@@ -1383,31 +_,45 @@
|
||||
Optional<String> title = packet.title();
|
||||
title.ifPresent(contents::add);
|
||||
contents.addAll(packet.pages());
|
||||
@@ -122,7 +122,7 @@
|
||||
writtenBook.set(
|
||||
DataComponents.WRITTEN_BOOK_CONTENT, new WrittenBookContent(this.filterableFromOutgoing(title), this.player.getPlainTextName(), 0, pages, true)
|
||||
);
|
||||
@@ -1386,6 +_,16 @@
|
||||
@@ -1420,6 +_,16 @@
|
||||
return this.player.isTextFilteringEnabled() ? Filterable.passThrough(text.filteredOrEmpty()) : Filterable.from(text);
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@
|
||||
@Override
|
||||
public void handleEntityTagQuery(final ServerboundEntityTagQueryPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level());
|
||||
@@ -1425,7 +_,15 @@
|
||||
@@ -1459,7 +_,15 @@
|
||||
@Override
|
||||
public void handleMovePlayer(final ServerboundMovePlayerPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level());
|
||||
@@ -156,7 +156,7 @@
|
||||
this.disconnect(Component.translatable("multiplayer.disconnect.invalid_player_movement"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PLAYER_MOVEMENT); // Paper - kick event cause
|
||||
} else {
|
||||
ServerLevel level = this.player.level();
|
||||
@@ -1609,7 +_,7 @@
|
||||
@@ -1644,7 +_,7 @@
|
||||
movedWrongly = true;
|
||||
if (event.getLogWarning())
|
||||
// Paper end
|
||||
@@ -165,7 +165,7 @@
|
||||
} // Paper
|
||||
}
|
||||
|
||||
@@ -1664,6 +_,8 @@
|
||||
@@ -1709,6 +_,8 @@
|
||||
this.lastYaw = to.getYaw();
|
||||
this.lastPitch = to.getPitch();
|
||||
|
||||
@@ -174,7 +174,7 @@
|
||||
Location oldTo = to.clone();
|
||||
PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
|
||||
this.cserver.getPluginManager().callEvent(event);
|
||||
@@ -1719,6 +_,13 @@
|
||||
@@ -1764,6 +_,13 @@
|
||||
this.player.tryResetCurrentImpulseContext();
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@
|
||||
this.player.checkMovementStatistics(this.player.getX() - startX, this.player.getY() - startY, this.player.getZ() - startZ);
|
||||
this.lastGoodX = this.player.getX();
|
||||
this.lastGoodY = this.player.getY();
|
||||
@@ -1739,6 +_,17 @@
|
||||
@@ -1784,6 +_,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@
|
||||
private boolean shouldCheckPlayerMovement(final boolean isFallFlying) {
|
||||
if (this.isSingleplayerOwner()) {
|
||||
return false;
|
||||
@@ -2150,6 +_,7 @@
|
||||
@@ -2228,6 +_,7 @@
|
||||
|
||||
boolean cancelled;
|
||||
if (hitResult == null || hitResult.getType() != HitResult.Type.BLOCK) {
|
||||
@@ -214,7 +214,7 @@
|
||||
org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemStack, hand);
|
||||
cancelled = event.useItemInHand() == Event.Result.DENY;
|
||||
} else {
|
||||
@@ -2791,6 +_,7 @@
|
||||
@@ -2869,6 +_,7 @@
|
||||
ItemStack mainHandItem = this.player.getMainHandItem();
|
||||
if (this.player.isWithinAttackRange(mainHandItem, targetBounds, io.papermc.paper.configuration.GlobalConfiguration.get().misc.clientInteractionLeniencyDistance.or(3.0))) { // Paper - configurable lenience
|
||||
if (!mainHandItem.has(DataComponents.PIERCING_WEAPON)) {
|
||||
@@ -222,7 +222,7 @@
|
||||
if (target instanceof ItemEntity
|
||||
|| target instanceof ExperienceOrb
|
||||
|| target == this.player
|
||||
@@ -3572,7 +_,7 @@
|
||||
@@ -3650,7 +_,7 @@
|
||||
@Override
|
||||
public void handleChangeGameMode(final ServerboundChangeGameModePacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level());
|
||||
|
||||
Reference in New Issue
Block a user