diff --git a/build-data/mappings-patch.tiny b/build-data/mappings-patch.tiny index 4dddff41f..3e893934c 100644 --- a/build-data/mappings-patch.tiny +++ b/build-data/mappings-patch.tiny @@ -109,29 +109,3 @@ c net/minecraft/world/level/saveddata/maps/WorldMap$WorldMapHumanTracker net/min # CraftBukkit adds a level resource key to LevelStorageSource#createAccess c net/minecraft/world/level/storage/Convertable net/minecraft/world/level/storage/LevelStorageSource m (Ljava/lang/String;Lnet/minecraft/resources/ResourceKey;)Lnet/minecraft/world/level/storage/Convertable$ConversionSession; c createAccess - -# Missed mappings - these should work as they are unmodified by CraftBukkit but don't for some reason -c net/minecraft/network/NetworkManager net/minecraft/network/Connection - m (Lnet/minecraft/network/protocol/Packet;Lio/netty/util/concurrent/GenericFutureListener;Lnet/minecraft/network/EnumProtocol;Lnet/minecraft/network/EnumProtocol;)V a doSendPacket - -c net/minecraft/server/gui/ServerGUI net/minecraft/server/gui/MinecraftServerGui - m (Ljavax/swing/JTextArea;Ljavax/swing/JScrollPane;Ljava/lang/String;)V a print - -c net/minecraft/server/level/PlayerChunk net/minecraft/server/level/ChunkHolder - m (Lnet/minecraft/world/level/World;Lnet/minecraft/core/BlockPosition;Lnet/minecraft/world/level/block/state/IBlockData;)V a broadcastBlockEntityIfNeeded - -c net/minecraft/server/level/PlayerChunkMap net/minecraft/server/level/ChunkMap - m (Lnet/minecraft/world/level/chunk/ChunkStatus;I)Lnet/minecraft/world/level/chunk/ChunkStatus; a getDependencyStatus - -c net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet net/minecraft/world/entity/ai/behavior/StartAttacking - m (Lnet/minecraft/world/entity/EntityInsentient;Lnet/minecraft/world/entity/EntityLiving;)V a setAttackTarget - -c net/minecraft/world/entity/ai/behavior/BehaviorMakeLove net/minecraft/world/entity/ai/behavior/VillagerMakeLove - m (Lnet/minecraft/world/entity/npc/EntityVillager;Lnet/minecraft/core/BlockPosition;)Z a canReach - -c net/minecraft/world/level/block/MultifaceBlock net/minecraft/world/level/block/MultifaceBlock - m (Lnet/minecraft/world/level/block/state/IBlockData;Lnet/minecraft/world/level/IBlockAccess;Lnet/minecraft/core/BlockPosition;Lnet/minecraft/core/EnumDirection;)Lnet/minecraft/world/level/block/state/IBlockData; c getStateForPlacement - -c net/minecraft/server/players/UserCache net/minecraft/server/players/GameProfileCache - m (Ljava/lang/String;)Ljava/util/Optional; getProfile get - p 0 name diff --git a/build-data/reobf-mappings-patch.tiny b/build-data/reobf-mappings-patch.tiny index 41b337439..945731b50 100644 --- a/build-data/reobf-mappings-patch.tiny +++ b/build-data/reobf-mappings-patch.tiny @@ -22,7 +22,3 @@ c net/minecraft/world/level/chunk/LevelChunk net/minecraft/world/level/chunk/Chu # Paper changes type c net/minecraft/core/MappedRegistry net/minecraft/core/RegistryMaterials f Lit/unimi/dsi/fastutil/objects/Reference2IntOpenHashMap; toId bw - -# Remove streams from Mob AI System changes type from EnumSet to com.destroystokyo.paper.util.set.OptimizedSmallEnumSet -c net/minecraft/world/entity/ai/goal/Goal net/minecraft/world/entity/ai/goal/PathfinderGoal - m ()Lcom/destroystokyo/paper/util/set/OptimizedSmallEnumSet; getFlags i diff --git a/build.gradle.kts b/build.gradle.kts index 9a44dad12..9ca58a4b4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,7 +2,7 @@ plugins { java `maven-publish` id("com.github.johnrengelman.shadow") version "7.1.0" apply false - id("io.papermc.paperweight.core") version "1.1.14" + id("io.papermc.paperweight.core") version "1.2.0" } allprojects { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ffed3a254..e750102e0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/patches/server/0011-Adventure.patch b/patches/server/0011-Adventure.patch index 59eb1f8dd..755337e4b 100644 --- a/patches/server/0011-Adventure.patch +++ b/patches/server/0011-Adventure.patch @@ -7,7 +7,7 @@ Co-authored-by: zml Co-authored-by: Jake Potrebic diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java -index c6a38fefbb1c0e0483a1d0468dd4e7c2b3881097..4a2edc70432a45931fcc0e98be3ca900df02814b 100644 +index 756a2ab6ad416f55fa3864cff9818473840b04fc..701a2ffd04df48d437b2cb963dd150af99725b6e 100644 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java @@ -225,4 +225,13 @@ public class PaperConfig { @@ -1312,7 +1312,7 @@ index 5f243953d6d9710280bd099b7560c18d30dddfa0..0e7c09c80509c83a52f32f735a1b1996 // CraftBukkit end this.chatVisibility = packet.getChatVisibility(); diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 0ed1d4b09b4d540a0bf420d8f63eb31fcfc7b8c2..fbf2a0d697b1ece82983154cdf585a101df391f4 100644 +index fd4bfb2b373acec07ca77414c8527b8d416b1b49..cab69dfc5be1ebbabab5a750b6119c65a6cf0320 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -161,6 +161,8 @@ import org.apache.logging.log4j.LogManager; @@ -1396,28 +1396,29 @@ index 0ed1d4b09b4d540a0bf420d8f63eb31fcfc7b8c2..fbf2a0d697b1ece82983154cdf585a10 Player player = this.getCraftPlayer(); AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, s, new LazyPlayerSet(this.server)); this.cserver.getPluginManager().callEvent(event); -@@ -2634,30 +2645,28 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser +@@ -2634,30 +2645,30 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser return; } - // CraftBukkit start + // CraftBukkit start // Paper start - Adventure Player player = this.player.getBukkitEntity(); - int x = packetplayinupdatesign.getPos().getX(); - int y = packetplayinupdatesign.getPos().getY(); - int z = packetplayinupdatesign.getPos().getZ(); + int x = packet.getPos().getX(); + int y = packet.getPos().getY(); + int z = packet.getPos().getZ(); - String[] lines = new String[4]; + List lines = new java.util.ArrayList<>(); - for (int i = 0; i < list.size(); ++i) { -- TextFilter.FilteredText itextfilter_a = (TextFilter.FilteredText) list.get(i); -- + for (int i = 0; i < signText.size(); ++i) { +- TextFilter.FilteredText itextfilter_a = (TextFilter.FilteredText) signText.get(i); ++ TextFilter.FilteredText currentLine = signText.get(i); + if (this.player.isTextFilteringEnabled()) { - lines[i] = ChatFormatting.stripFormatting(new TextComponent(ChatFormatting.stripFormatting(itextfilter_a.getFiltered())).getString()); -+ lines.add(net.kyori.adventure.text.Component.text(list.get(i).getFiltered())); ++ lines.add(net.kyori.adventure.text.Component.text(currentLine.getFiltered())); } else { - lines[i] = ChatFormatting.stripFormatting(new TextComponent(ChatFormatting.stripFormatting(itextfilter_a.getRaw())).getString()); -+ lines.add(net.kyori.adventure.text.Component.text(list.get(i).getRaw())); ++ lines.add(net.kyori.adventure.text.Component.text(currentLine.getRaw())); } } SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.player.getBukkitEntity(), lines); diff --git a/patches/server/0123-Properly-fix-item-duplication-bug.patch b/patches/server/0123-Properly-fix-item-duplication-bug.patch index f76a42965..2bc365640 100644 --- a/patches/server/0123-Properly-fix-item-duplication-bug.patch +++ b/patches/server/0123-Properly-fix-item-duplication-bug.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Properly fix item duplication bug Credit to prplz for figuring out the real issue diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 7e7bbb6817ceddbbb90c1ac45d8e974d3f95c089..d4614faa22485dce226f3dc17ef984212ac8fcb9 100644 +index da722cddaaa8c40715748de81104a5b213c2fea8..a61798909aee1b73b62c88c22fa6cfc1fe2a5942 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -2128,7 +2128,7 @@ public class ServerPlayer extends Player { @@ -19,10 +19,10 @@ index 7e7bbb6817ceddbbb90c1ac45d8e974d3f95c089..d4614faa22485dce226f3dc17ef98421 @Override diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 9026dd91f8d874209bbfd4cdfd3c41e37cdd7560..6eb01dcf59fda2656b6d93b0c39380302665f930 100644 +index 9c7843c2623fce4ec423acbcc0c76a35b1bd5969..36bb3b502a26ab43f442d85b3cad4a1de0a5bda8 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2810,7 +2810,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser +@@ -2812,7 +2812,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser } public final boolean isDisconnected() { diff --git a/patches/server/0160-handle-PacketPlayInKeepAlive-async.patch b/patches/server/0160-handle-PacketPlayInKeepAlive-async.patch index b1a73aa4d..591fa7496 100644 --- a/patches/server/0160-handle-PacketPlayInKeepAlive-async.patch +++ b/patches/server/0160-handle-PacketPlayInKeepAlive-async.patch @@ -15,10 +15,10 @@ also adding some additional logging in order to help work out what is causing random disconnections for clients. diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 7759bf2afb9edeaca24726aace9358a8d5eafc64..652703b1582e63148658a3a9d2604afa55674c23 100644 +index 89588d6478ebd7d4892dceb03026dff89e1844db..7b6e6e646511bc47d2215c512b4d839b3f3a1c55 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2769,14 +2769,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser +@@ -2771,14 +2771,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser @Override public void handleKeepAlive(ServerboundKeepAlivePacket packet) { diff --git a/patches/server/0194-Fix-exploit-that-allowed-colored-signs-to-be-created.patch b/patches/server/0194-Fix-exploit-that-allowed-colored-signs-to-be-created.patch index 98a1b490e..ae082f810 100644 --- a/patches/server/0194-Fix-exploit-that-allowed-colored-signs-to-be-created.patch +++ b/patches/server/0194-Fix-exploit-that-allowed-colored-signs-to-be-created.patch @@ -5,18 +5,18 @@ Subject: [PATCH] Fix exploit that allowed colored signs to be created diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 8c2242d7e443bee26741608c65d314d8902f5765..4cbdf64b0e6271a1cf0f31d486d8fad4f941b913 100644 +index 25ea7a94407dfdb613ee15de4eb2a9c3252c6b27..e83232f18871a04fadbc053b1e1e7f94d2492159 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2775,9 +2775,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser +@@ -2777,9 +2777,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser + TextFilter.FilteredText currentLine = signText.get(i); - for (int i = 0; i < list.size(); ++i) { if (this.player.isTextFilteringEnabled()) { -- lines.add(net.kyori.adventure.text.Component.text(list.get(i).getFiltered())); -+ lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(list.get(i).getFiltered()))); +- lines.add(net.kyori.adventure.text.Component.text(currentLine.getFiltered())); ++ lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(currentLine.getFiltered()))); } else { -- lines.add(net.kyori.adventure.text.Component.text(list.get(i).getRaw())); -+ lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(list.get(i).getRaw()))); +- lines.add(net.kyori.adventure.text.Component.text(currentLine.getRaw())); ++ lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(currentLine.getRaw()))); } } SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.player.getBukkitEntity(), lines); diff --git a/patches/server/0260-Asynchronous-chunk-IO-and-loading.patch b/patches/server/0260-Asynchronous-chunk-IO-and-loading.patch index 3f59bba05..8ac9baec8 100644 --- a/patches/server/0260-Asynchronous-chunk-IO-and-loading.patch +++ b/patches/server/0260-Asynchronous-chunk-IO-and-loading.patch @@ -159,7 +159,7 @@ index 0fda52841b5e1643efeda92106124998abc4e0aa..fe79c0add4f7cb18d487c5bb9415c40c public static Timing getTickList(ServerLevel worldserver, String timingsType) { diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java -index 15e71c00f98721e609dfab341395313db95cdfc7..c29da813f5fcba07860314914180c9d9a3ec560a 100644 +index 73b49d24cd428e2328d56f5f42333a25a1d6ebae..a89ccdf2ea517d2ec38c9433bdc26802884ed988 100644 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java @@ -1,5 +1,6 @@ @@ -2278,7 +2278,7 @@ index a5e438a834826161c52ca9db57d234d9ff80a591..b8bc1b9b8e8a33df90a963f9f9769292 @Override diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java -index aa96017819712f42e16c7eac57222301600b66a5..802e0259f660c05afb2b772f0e617d819b19c7cc 100644 +index 70f2a946f50ca6be2ffaef8db8c1c03a729c757b..4f45ac04a219e619c13b31befd2c4e452057079c 100644 --- a/src/main/java/net/minecraft/server/MCUtil.java +++ b/src/main/java/net/minecraft/server/MCUtil.java @@ -505,4 +505,8 @@ public final class MCUtil { @@ -2291,7 +2291,7 @@ index aa96017819712f42e16c7eac57222301600b66a5..802e0259f660c05afb2b772f0e617d81 + } } diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java -index fb0b3c5770f66cc3590f5ac4e690a33cb6179be3..7ce854edba32ffcafaa5268d4bb2822a5233e40b 100644 +index 6f30e10d59416799edbe362951ce61733e37b256..2b8b47f121b78cc5fe166c4280a327ddcf799b77 100644 --- a/src/main/java/net/minecraft/server/Main.java +++ b/src/main/java/net/minecraft/server/Main.java @@ -217,6 +217,7 @@ public class Main { @@ -2303,7 +2303,7 @@ index fb0b3c5770f66cc3590f5ac4e690a33cb6179be3..7ce854edba32ffcafaa5268d4bb2822a DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, datapackconfiguration1, thread, iregistrycustom_dimension, convertable_conversionsession, resourcepackrepository, datapackresources, null, dedicatedserversettings, DataFixers.getDataFixer(), minecraftsessionservice, gameprofilerepository, usercache, LoggerChunkProgressListener::new); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 13f94e196ffd9f37e8049a4a76bc83389ff58d84..50d4948034036b0ec6cdf447f03743baa33ab2ac 100644 +index cb2ca56df7f2adedff2ebdd26957c23164b56255..7a7c501b1dffb4928aa74edd684d79f7fa312789 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1001,7 +1001,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop> getChunkFutureMainThread(int i, int j, ChunkStatus chunkstatus, boolean flag) { + private CompletableFuture> getChunkFutureMainThread(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) { + // Paper start - add isUrgent - old sig left in place for dirty nms plugins -+ return getChunkFutureMainThread(i, j, chunkstatus, flag, false); ++ return getChunkFutureMainThread(chunkX, chunkZ, leastStatus, create, false); + } -+ private CompletableFuture> getChunkFutureMainThread(int i, int j, ChunkStatus chunkstatus, boolean flag, boolean isUrgent) { ++ private CompletableFuture> getChunkFutureMainThread(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create, boolean isUrgent) { + // Paper end - ChunkPos chunkcoordintpair = new ChunkPos(i, j); + ChunkPos chunkcoordintpair = new ChunkPos(chunkX, chunkZ); long k = chunkcoordintpair.toLong(); - int l = 33 + ChunkStatus.getDistance(chunkstatus); + int l = 33 + ChunkStatus.getDistance(leastStatus); @@ -997,11 +1125,12 @@ public class ServerChunkCache extends ChunkSource { // CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task public boolean pollTask() { @@ -2806,7 +2806,7 @@ index 1f3fe980e71c13b5e7852349cba1cb0e4aa42dcd..30b88f0e8ad40438af8a7d5bec1471a6 } finally { chunkMap.callbackExecutor.run(); diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index aa9999437b4b1b0b41ebf988e26bc3c3c262e985..5be5f95fe01e0132f9d4477149ba022351d8b2be 100644 +index afdb25743ceb404b4681ee2965fe3448f1f1b06a..e4626f6edb845ce751235c4341a608de81857603 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -295,6 +295,78 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -2910,7 +2910,7 @@ index 0d536d72ac918fbd403397ff369d10143ee9c204..be677d437d17b74c6188ce1bd5fc6fdc private final String name; private final Comparator comparator; diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 678487d92095957d1346cf555486a7f2125f566b..c748446e423e3af92a0fccef45fcea45b158a272 100644 +index cc1b855b09d4826f88b0c2b9c08fb901191a2108..1e3d7081467cccf09d4510907388479560f67f67 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -711,6 +711,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser diff --git a/patches/server/0308-Limit-Client-Sign-length-more.patch b/patches/server/0308-Limit-Client-Sign-length-more.patch index cf8986b2c..bbf5fc414 100644 --- a/patches/server/0308-Limit-Client-Sign-length-more.patch +++ b/patches/server/0308-Limit-Client-Sign-length-more.patch @@ -22,7 +22,7 @@ it only impacts data sent from the client. Set -DPaper.maxSignLength=XX to change limit or -1 to disable diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 0103c76c183d0e866a98c26f2d1cf557ba4f67e8..d24d42ef0a00b9420700e58f555f8448f8d01747 100644 +index 2ea1e58cf721a8ae339cbfd6192f3312061249ba..b9f9314befff581e70ae7d8d4eab9040e4e4d26d 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -254,6 +254,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser @@ -33,26 +33,19 @@ index 0103c76c183d0e866a98c26f2d1cf557ba4f67e8..d24d42ef0a00b9420700e58f555f8448 private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit public ServerGamePacketListenerImpl(MinecraftServer server, Connection connection, ServerPlayer player) { -@@ -2847,10 +2848,20 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser - List lines = new java.util.ArrayList<>(); +@@ -2848,6 +2849,15 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser - for (int i = 0; i < list.size(); ++i) { + for (int i = 0; i < signText.size(); ++i) { + TextFilter.FilteredText currentLine = signText.get(i); + // Paper start - cap line length - modified clients can send longer data than normal -+ net.minecraft.server.network.TextFilter.FilteredText currentLine = list.get(i); + if (MAX_SIGN_LINE_LENGTH > 0 && currentLine.getRaw().length() > MAX_SIGN_LINE_LENGTH) { + // This handles multibyte characters as 1 + int offset = currentLine.getRaw().codePoints().limit(MAX_SIGN_LINE_LENGTH).map(Character::charCount).sum(); + if (offset < currentLine.getRaw().length()) { -+ list.set(i, currentLine = net.minecraft.server.network.TextFilter.FilteredText.passThrough(currentLine.getRaw().substring(0, offset))); // this will break any filtering, but filtering is NYI as of 1.17 ++ signText.set(i, currentLine = net.minecraft.server.network.TextFilter.FilteredText.passThrough(currentLine.getRaw().substring(0, offset))); // this will break any filtering, but filtering is NYI as of 1.17 + } + } + // Paper end + if (this.player.isTextFilteringEnabled()) { -- lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(list.get(i).getFiltered()))); -+ lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(currentLine.getFiltered()))); - } else { -- lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(list.get(i).getRaw()))); -+ lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(currentLine.getRaw()))); - } - } - SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.player.getBukkitEntity(), lines); + lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(currentLine.getFiltered()))); diff --git a/patches/server/0310-Optimize-Network-Manager-and-add-advanced-packet-sup.patch b/patches/server/0310-Optimize-Network-Manager-and-add-advanced-packet-sup.patch index d07d6874e..2f21dd231 100644 --- a/patches/server/0310-Optimize-Network-Manager-and-add-advanced-packet-sup.patch +++ b/patches/server/0310-Optimize-Network-Manager-and-add-advanced-packet-sup.patch @@ -28,7 +28,7 @@ and then catch exceptions and close if they fire. Part of this commit was authored by: Spottedleaf diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index e5f8c48c8d57ce0df4e7aacdbc3a6d3e9b3cb6e1..3faf9bc694016f3f46576a549814ff8e6070598a 100644 +index b96ef2374b689ad715ce3b3a7c0b599a56b4c2d1..a3bfc12e34754dc5f8f53b968451a07f3a0ab496 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -87,6 +87,10 @@ public class Connection extends SimpleChannelInboundHandler> { @@ -157,8 +157,8 @@ index e5f8c48c8d57ce0df4e7aacdbc3a6d3e9b3cb6e1..3faf9bc694016f3f46576a549814ff8e + // Paper end ChannelFuture channelfuture = this.channel.writeAndFlush(packet); - if (genericfuturelistener != null) { - channelfuture.addListener(genericfuturelistener); + if (callback != null) { + channelfuture.addListener(callback); } + // Paper start + if (packet.hasFinishListener()) { diff --git a/patches/server/0325-Mob-Spawner-API-Enhancements.patch b/patches/server/0325-Mob-Spawner-API-Enhancements.patch index c4515a26b..7cd5c3a51 100644 --- a/patches/server/0325-Mob-Spawner-API-Enhancements.patch +++ b/patches/server/0325-Mob-Spawner-API-Enhancements.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Mob Spawner API Enhancements diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java -index f2c69ce7a33ef69c71e218cdb2f6a429c5e7b531..409467ca9a8a21d1e22e3a08f462e54d6124f6a1 100644 +index 24b99df8854902958a72dd14fa15e32f847cc02b..47ca1710ae3ef93a4a1a7444dbabfa534de377c6 100644 --- a/src/main/java/net/minecraft/world/level/BaseSpawner.java +++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java @@ -31,7 +31,7 @@ public abstract class BaseSpawner { @@ -50,7 +50,7 @@ index f2c69ce7a33ef69c71e218cdb2f6a429c5e7b531..409467ca9a8a21d1e22e3a08f462e54d if (nbt.contains("SpawnPotentials", 9)) { @@ -259,10 +265,15 @@ public abstract class BaseSpawner { - this.setSpawnData(world, pos, mobspawnerdata); + this.setNextSpawnData(world, pos, mobspawnerdata); }); } - @@ -93,7 +93,7 @@ index f2c69ce7a33ef69c71e218cdb2f6a429c5e7b531..409467ca9a8a21d1e22e3a08f462e54d nbt.putShort("MaxNearbyEntities", (short) this.maxNearbyEntities); nbt.putShort("RequiredPlayerRange", (short) this.requiredPlayerRange); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java -index 38dc811970b8f90b11a2b0013da3b6b3b775cbec..6bc17063c7ed9da9a16e2f8ab6117d49729c9b28 100644 +index 38dc811970b8f90b11a2b0013da3b6b3b775cbec..b6c1460e342685c9c3c418be786d9b19c006184b 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java @@ -116,4 +116,30 @@ public class CraftCreatureSpawner extends CraftBlockEntityState { diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index d70d977290b07fca61fea965a907c9f60a393ba7..324fe352fd108ef1d9f63a224b61c362adafc8d0 100644 +index d77aabe4997b816b23a1f39ac353ae5bc7b8e1e4..f0154a13dbdad970042e248b3adc776573ab5d35 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -122,6 +122,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -991,7 +991,7 @@ index d94241bcca4f2fd5e464a860bd356af504dc68b7..1cc4e0a1f3d8235ef88b48e01ca8b78a } } diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index e5317a994cb9b30293ad54b8fc537f703ef994dc..eb6a802ea12a19a058fb7e23b7418b8b426b4ca0 100644 +index 8cef8dca3971cbbb4eddf08ff47eca6874c1ac99..77a6a5883d7e9fba12d0a2c8f3e7f2565d4785b4 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java @@ -610,6 +610,26 @@ public class ServerChunkCache extends ChunkSource { @@ -1040,7 +1040,7 @@ index e5317a994cb9b30293ad54b8fc537f703ef994dc..eb6a802ea12a19a058fb7e23b7418b8b ichunkaccess = (ChunkAccess) ((Either) completablefuture.join()).map((ichunkaccess1) -> { return ichunkaccess1; @@ -731,10 +755,12 @@ public class ServerChunkCache extends ChunkSource { - if (flag && !currentlyUnloading) { + if (create && !currentlyUnloading) { // CraftBukkit end this.distanceManager.addTicket(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair); + if (isUrgent) this.distanceManager.markUrgent(chunkcoordintpair); // Paper - Chunk priority @@ -1052,14 +1052,13 @@ index e5317a994cb9b30293ad54b8fc537f703ef994dc..eb6a802ea12a19a058fb7e23b7418b8b this.runDistanceManagerUpdates(); playerchunk = this.getVisibleChunkIfPresent(k); gameprofilerfiller.pop(); -@@ -743,8 +769,13 @@ public class ServerChunkCache extends ChunkSource { - } +@@ -744,7 +770,13 @@ public class ServerChunkCache extends ChunkSource { } } -- -- return this.chunkAbsent(playerchunk, l) ? ChunkHolder.UNLOADED_CHUNK_FUTURE : playerchunk.getOrScheduleFuture(chunkstatus, this.chunkMap); + +- return this.chunkAbsent(playerchunk, l) ? ChunkHolder.UNLOADED_CHUNK_FUTURE : playerchunk.getOrScheduleFuture(leastStatus, this.chunkMap); + // Paper start - Chunk priority -+ CompletableFuture> future = this.chunkAbsent(playerchunk, l) ? ChunkHolder.UNLOADED_CHUNK_FUTURE : playerchunk.getOrScheduleFuture(chunkstatus, this.chunkMap); ++ CompletableFuture> future = this.chunkAbsent(playerchunk, l) ? ChunkHolder.UNLOADED_CHUNK_FUTURE : playerchunk.getOrScheduleFuture(leastStatus, this.chunkMap); + if (isUrgent) { + future.thenAccept(either -> this.distanceManager.clearUrgent(chunkcoordintpair)); + } @@ -1068,7 +1067,7 @@ index e5317a994cb9b30293ad54b8fc537f703ef994dc..eb6a802ea12a19a058fb7e23b7418b8b } private boolean chunkAbsent(@Nullable ChunkHolder holder, int maxLevel) { -@@ -796,6 +827,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -796,6 +828,7 @@ public class ServerChunkCache extends ChunkSource { } public boolean runDistanceManagerUpdates() { @@ -1424,7 +1423,7 @@ index 8770fe0db46b01e8b608637df4f1a669a3f4cdde..3c1698ba0d3bc412ab957777d9b5211d private final String name; private final Comparator comparator; diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 8d86b9cacfaf71ec04dd530f3c0d75ee46c517df..14d4ef096624112c732b4c4f15763dc7c287d576 100644 +index 001167097afed95f93f54ff0e61220148849dd85..ffdba71ca4a42fee989438799d485826c9bb647a 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -1545,6 +1545,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser @@ -1467,7 +1466,7 @@ index a5fb401e04bf194224d05020fe397e231e2f715c..0e3726495ef10717627dcf4297c944da entityplayer1.setPos(entityplayer1.getX(), entityplayer1.getY() + 1.0D, entityplayer1.getZ()); } diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index bed497f56b9b1fa16ef7b91744bb27d228fb5a66..3279ddbafef921e30d40874708acb4f7d32c060e 100644 +index 2806d247e92600a592615241a6d07527f6b527e8..9aa75a9e997825c27d57eae992ca58ecbb807dfb 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -223,7 +223,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n diff --git a/patches/server/0504-Brand-support.patch b/patches/server/0504-Brand-support.patch index 1a013e31c..2a407b24c 100644 --- a/patches/server/0504-Brand-support.patch +++ b/patches/server/0504-Brand-support.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Brand support diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 4b2ec9ff11fd1d164eb883a3ad2944804fb63eff..617d5c7ee88b6e652b4fbb73b3858cad8c15c1d9 100644 +index ce4f1ab41ec2e5f656114fbd7b6f825bccf15d17..76794189454f5dd935fcd77e3c89a1ce58a9b570 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -4,6 +4,7 @@ import com.google.common.collect.Lists; @@ -33,7 +33,7 @@ index 4b2ec9ff11fd1d164eb883a3ad2944804fb63eff..617d5c7ee88b6e652b4fbb73b3858cad public ServerGamePacketListenerImpl(MinecraftServer server, Connection connection, ServerPlayer player) { this.server = server; this.connection = connection; -@@ -2991,6 +2995,8 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser +@@ -2992,6 +2996,8 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser private static final ResourceLocation CUSTOM_REGISTER = new ResourceLocation("register"); private static final ResourceLocation CUSTOM_UNREGISTER = new ResourceLocation("unregister"); @@ -42,7 +42,7 @@ index 4b2ec9ff11fd1d164eb883a3ad2944804fb63eff..617d5c7ee88b6e652b4fbb73b3858cad @Override public void handleCustomPayload(ServerboundCustomPayloadPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); -@@ -3018,6 +3024,15 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser +@@ -3019,6 +3025,15 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser try { byte[] data = new byte[packet.data.readableBytes()]; packet.data.readBytes(data); @@ -58,7 +58,7 @@ index 4b2ec9ff11fd1d164eb883a3ad2944804fb63eff..617d5c7ee88b6e652b4fbb73b3858cad this.cserver.getMessenger().dispatchIncomingMessage(this.player.getBukkitEntity(), packet.identifier.toString(), data); } catch (Exception ex) { ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t dispatch custom payload", ex); -@@ -3027,6 +3042,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser +@@ -3028,6 +3043,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser } diff --git a/patches/server/0612-Skip-distance-map-update-when-spawning-disabled.patch b/patches/server/0612-Skip-distance-map-update-when-spawning-disabled.patch index 98765f2ca..114cc0dd0 100644 --- a/patches/server/0612-Skip-distance-map-update-when-spawning-disabled.patch +++ b/patches/server/0612-Skip-distance-map-update-when-spawning-disabled.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Skip distance map update when spawning disabled. diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index eb6a802ea12a19a058fb7e23b7418b8b426b4ca0..16b406067ac7697ab598f9f27f5e688687f206ee 100644 +index 77a6a5883d7e9fba12d0a2c8f3e7f2565d4785b4..6d0c56e4071a990a3b168143e8ac73f8b5ed0379 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -973,7 +973,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -974,7 +974,7 @@ public class ServerChunkCache extends ChunkSource { int l = this.distanceManager.getNaturalSpawnChunkCount(); // Paper start - per player mob spawning NaturalSpawner.SpawnState spawnercreature_d; // moved down diff --git a/patches/server/0692-Add-PlayerKickEvent-causes.patch b/patches/server/0692-Add-PlayerKickEvent-causes.patch index 8cc31b43d..234bd6656 100644 --- a/patches/server/0692-Add-PlayerKickEvent-causes.patch +++ b/patches/server/0692-Add-PlayerKickEvent-causes.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add PlayerKickEvent causes diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 18a9d84c9508318132bb9b1dcb01ea11ea018916..71181012314d20e3505543a6d2abe88cb8e17a27 100644 +index 87a50ca1d2482a384944e13aac32c3a81659970f..98eb8318413014f0650dc5c80125aa84b51cfc93 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -2126,7 +2126,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { @@ -290,7 +290,7 @@ index b4e11d39cf1d9791a8fe4ccd297f6afde7a38c7b..b9f1384d742d612dd4d40929dfe812e5 }); // Paper end } -@@ -3047,7 +3055,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser +@@ -3048,7 +3056,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser } } catch (Exception ex) { ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t register custom payload", ex); @@ -299,7 +299,7 @@ index b4e11d39cf1d9791a8fe4ccd297f6afde7a38c7b..b9f1384d742d612dd4d40929dfe812e5 } } else if (packet.identifier.equals(CUSTOM_UNREGISTER)) { try { -@@ -3057,7 +3065,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser +@@ -3058,7 +3066,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser } } catch (Exception ex) { ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t unregister custom payload", ex); @@ -308,7 +308,7 @@ index b4e11d39cf1d9791a8fe4ccd297f6afde7a38c7b..b9f1384d742d612dd4d40929dfe812e5 } } else { try { -@@ -3075,7 +3083,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser +@@ -3076,7 +3084,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser this.cserver.getMessenger().dispatchIncomingMessage(this.player.getBukkitEntity(), packet.identifier.toString(), data); } catch (Exception ex) { ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t dispatch custom payload", ex); @@ -342,7 +342,7 @@ index 34dd85bbaa2e693d9b6a4db880b42501b3b9225c..8528cb537ea2329e866dee20fe1e5034 // CraftBukkit end diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 7150db24248b72c5ce2006ecff949315c71821d0..c775014177caf0d1138bde1cc5726dc657176325 100644 +index d9445e8f95013e687274aa3228faf11745ca4898..73ca3b00cbc8b61ca07ae342fec27c9942034495 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -499,16 +499,21 @@ public class CraftPlayer extends CraftHumanEntity implements Player { diff --git a/patches/server/0747-Prevent-unload-calls-removing-tickets-for-sync-loads.patch b/patches/server/0747-Prevent-unload-calls-removing-tickets-for-sync-loads.patch index e44eb397c..b95a4cdfe 100644 --- a/patches/server/0747-Prevent-unload-calls-removing-tickets-for-sync-loads.patch +++ b/patches/server/0747-Prevent-unload-calls-removing-tickets-for-sync-loads.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Prevent unload() calls removing tickets for sync loads diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 16b406067ac7697ab598f9f27f5e688687f206ee..f5ccbff7a6b51cf71e28e514d853a500f9acd43f 100644 +index 6d0c56e4071a990a3b168143e8ac73f8b5ed0379..d03ca9b30380209397aed5371686e0022bf631d5 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java @@ -734,6 +734,8 @@ public class ServerChunkCache extends ChunkSource { @@ -14,15 +14,15 @@ index 16b406067ac7697ab598f9f27f5e688687f206ee..f5ccbff7a6b51cf71e28e514d853a500 + private long syncLoadCounter; // Paper - prevent plugin unloads from removing our ticket + - private CompletableFuture> getChunkFutureMainThread(int i, int j, ChunkStatus chunkstatus, boolean flag) { + private CompletableFuture> getChunkFutureMainThread(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) { // Paper start - add isUrgent - old sig left in place for dirty nms plugins - return getChunkFutureMainThread(i, j, chunkstatus, flag, false); + return getChunkFutureMainThread(chunkX, chunkZ, leastStatus, create, false); @@ -752,9 +754,12 @@ public class ServerChunkCache extends ChunkSource { ChunkHolder.FullChunkStatus currentChunkState = ChunkHolder.getFullChunkStatus(playerchunk.getTicketLevel()); currentlyUnloading = (oldChunkState.isOrAfter(ChunkHolder.FullChunkStatus.BORDER) && !currentChunkState.isOrAfter(ChunkHolder.FullChunkStatus.BORDER)); } + final Long identifier; // Paper - prevent plugin unloads from removing our ticket - if (flag && !currentlyUnloading) { + if (create && !currentlyUnloading) { // CraftBukkit end this.distanceManager.addTicket(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair); + identifier = Long.valueOf(this.syncLoadCounter++); // Paper - prevent plugin unloads from removing our ticket @@ -30,7 +30,7 @@ index 16b406067ac7697ab598f9f27f5e688687f206ee..f5ccbff7a6b51cf71e28e514d853a500 if (isUrgent) this.distanceManager.markUrgent(chunkcoordintpair); // Paper - Chunk priority if (this.chunkAbsent(playerchunk, l)) { ProfilerFiller gameprofilerfiller = this.level.getProfiler(); -@@ -765,12 +770,20 @@ public class ServerChunkCache extends ChunkSource { +@@ -765,13 +770,21 @@ public class ServerChunkCache extends ChunkSource { playerchunk = this.getVisibleChunkIfPresent(k); gameprofilerfiller.pop(); if (this.chunkAbsent(playerchunk, l)) { @@ -39,11 +39,12 @@ index 16b406067ac7697ab598f9f27f5e688687f206ee..f5ccbff7a6b51cf71e28e514d853a500 } } - } + + } else { identifier = null; } // Paper - prevent plugin unloads from removing our ticket // Paper start - Chunk priority - CompletableFuture> future = this.chunkAbsent(playerchunk, l) ? ChunkHolder.UNLOADED_CHUNK_FUTURE : playerchunk.getOrScheduleFuture(chunkstatus, this.chunkMap); + CompletableFuture> future = this.chunkAbsent(playerchunk, l) ? ChunkHolder.UNLOADED_CHUNK_FUTURE : playerchunk.getOrScheduleFuture(leastStatus, this.chunkMap); + // Paper start - prevent plugin unloads from removing our ticket -+ if (flag && !currentlyUnloading) { ++ if (create && !currentlyUnloading) { + future.thenAcceptAsync((either) -> { + ServerChunkCache.this.distanceManager.removeTicketAtLevel(TicketType.REQUIRED_LOAD, chunkcoordintpair, l, identifier); + }, ServerChunkCache.this.mainThreadProcessor); diff --git a/patches/server/0748-Do-not-allow-ticket-level-changes-while-unloading-pl.patch b/patches/server/0748-Do-not-allow-ticket-level-changes-while-unloading-pl.patch index 437118869..6adcb35ae 100644 --- a/patches/server/0748-Do-not-allow-ticket-level-changes-while-unloading-pl.patch +++ b/patches/server/0748-Do-not-allow-ticket-level-changes-while-unloading-pl.patch @@ -8,7 +8,7 @@ Sync loading the chunk at this stage would cause it to load older data, as well as screwing our region state. diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 173c9d06b28db3e776c762903a0409234c08b13c..dcb5b1022eb72c50dc1df3654b0c9db7c782517c 100644 +index ba1c55c4f2486cae25ce570132d9222f6ab77d49..fe15f8fdb886674278513c5fdbf17f066c9f0b4f 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -341,6 +341,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -49,10 +49,10 @@ index 173c9d06b28db3e776c762903a0409234c08b13c..dcb5b1022eb72c50dc1df3654b0c9db7 } }; diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index f5ccbff7a6b51cf71e28e514d853a500f9acd43f..11907bdf8c2b26d02aac5d7696d5f41d9c7d334d 100644 +index d03ca9b30380209397aed5371686e0022bf631d5..e88cae362fa167252aaa785895e378caec6ad757 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -841,6 +841,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -842,6 +842,7 @@ public class ServerChunkCache extends ChunkSource { public boolean runDistanceManagerUpdates() { if (distanceManager.delayDistanceManagerTick) return false; // Paper - Chunk priority diff --git a/patches/server/0749-Do-not-allow-the-server-to-unload-chunks-at-request-.patch b/patches/server/0749-Do-not-allow-the-server-to-unload-chunks-at-request-.patch index 4ad0b1db9..834f48a1c 100644 --- a/patches/server/0749-Do-not-allow-the-server-to-unload-chunks-at-request-.patch +++ b/patches/server/0749-Do-not-allow-the-server-to-unload-chunks-at-request-.patch @@ -10,10 +10,10 @@ to be unloaded will simply be unloaded next tick, rather than immediately. diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 11907bdf8c2b26d02aac5d7696d5f41d9c7d334d..9196be25ff874a0c81868906c5b86bfe4e2968f5 100644 +index e88cae362fa167252aaa785895e378caec6ad757..b5c8f3f57d09de4caffeb9f3e20e9bf4daba1cdd 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -908,6 +908,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -909,6 +909,7 @@ public class ServerChunkCache extends ChunkSource { // CraftBukkit start - modelled on below public void purgeUnload() { diff --git a/patches/server/0760-Allow-controlled-flushing-for-network-manager.patch b/patches/server/0760-Allow-controlled-flushing-for-network-manager.patch index 0ea16419c..447bf4138 100644 --- a/patches/server/0760-Allow-controlled-flushing-for-network-manager.patch +++ b/patches/server/0760-Allow-controlled-flushing-for-network-manager.patch @@ -9,7 +9,7 @@ This patch will be used to optimise out flush calls in later patches. diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index c327609fdb7641e4dc5fb58d97903fa666eac24d..0b47144cb8ad72efebf10e163f5b442995ef213e 100644 +index 3eff1c97dcdc6bd8a0c4b7c5bbead2bd68490a4b..032d65a489d65e9b5b5066dff80c65d2e1b28c82 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -94,6 +94,39 @@ public class Connection extends SimpleChannelInboundHandler> { @@ -91,11 +91,11 @@ index c327609fdb7641e4dc5fb58d97903fa666eac24d..0b47144cb8ad72efebf10e163f5b4429 } - private void doSendPacket(Packet packet, @Nullable GenericFutureListener> genericfuturelistener, ConnectionProtocol enumprotocol, ConnectionProtocol enumprotocol1) { + private void doSendPacket(Packet packet, @Nullable GenericFutureListener> callback, ConnectionProtocol enumprotocol, ConnectionProtocol enumprotocol1) { + // Paper start - add flush parameter -+ this.doSendPacket(packet, genericfuturelistener, enumprotocol, enumprotocol1, true); ++ this.doSendPacket(packet, callback, enumprotocol, enumprotocol1, true); + } -+ private void doSendPacket(Packet packet, @Nullable GenericFutureListener> genericfuturelistener, ConnectionProtocol enumprotocol, ConnectionProtocol enumprotocol1, boolean flush) { ++ private void doSendPacket(Packet packet, @Nullable GenericFutureListener> callback, ConnectionProtocol enumprotocol, ConnectionProtocol enumprotocol1, boolean flush) { + // Paper end - add flush parameter if (enumprotocol != enumprotocol1) { this.setProtocol(enumprotocol); @@ -107,8 +107,8 @@ index c327609fdb7641e4dc5fb58d97903fa666eac24d..0b47144cb8ad72efebf10e163f5b4429 - ChannelFuture channelfuture = this.channel.writeAndFlush(packet); + ChannelFuture channelfuture = flush ? this.channel.writeAndFlush(packet) : this.channel.write(packet); // Paper - add flush parameter - if (genericfuturelistener != null) { - channelfuture.addListener(genericfuturelistener); + if (callback != null) { + channelfuture.addListener(callback); @@ -354,6 +400,10 @@ public class Connection extends SimpleChannelInboundHandler> { } private boolean processQueue() { diff --git a/patches/server/0765-Optimise-chunk-tick-iteration.patch b/patches/server/0765-Optimise-chunk-tick-iteration.patch index fd2b4dd0f..7ca249733 100644 --- a/patches/server/0765-Optimise-chunk-tick-iteration.patch +++ b/patches/server/0765-Optimise-chunk-tick-iteration.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Optimise chunk tick iteration Use a dedicated list of entity ticking chunks to reduce the cost diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 9196be25ff874a0c81868906c5b86bfe4e2968f5..7ea86cbeb72f08d751c14006f428fe5921916061 100644 +index b5c8f3f57d09de4caffeb9f3e20e9bf4daba1cdd..d6981bbcf480c5856b51960013d144beba2361b3 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -1006,19 +1006,35 @@ public class ServerChunkCache extends ChunkSource { +@@ -1007,19 +1007,35 @@ public class ServerChunkCache extends ChunkSource { this.lastSpawnState = spawnercreature_d; this.level.getProfiler().pop(); @@ -54,7 +54,7 @@ index 9196be25ff874a0c81868906c5b86bfe4e2968f5..7ea86cbeb72f08d751c14006f428fe59 chunk.setInhabitedTime(chunk.getInhabitedTime() + j); if (flag1 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunk.getPos()) && !this.chunkMap.isOutsideOfRange(playerchunk, chunkcoordintpair, true)) { // Spigot // Paper - optimise isOutsideOfRange NaturalSpawner.spawnForChunk(this.level, chunk, spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag2); -@@ -1029,7 +1045,13 @@ public class ServerChunkCache extends ChunkSource { +@@ -1030,7 +1046,13 @@ public class ServerChunkCache extends ChunkSource { // this.level.timings.doTickTiles.stopTiming(); // Spigot // Paper } } @@ -69,7 +69,7 @@ index 9196be25ff874a0c81868906c5b86bfe4e2968f5..7ea86cbeb72f08d751c14006f428fe59 this.level.timings.chunkTicks.stopTiming(); // Paper this.level.getProfiler().push("customSpawners"); if (flag1) { -@@ -1038,21 +1060,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -1039,21 +1061,7 @@ public class ServerChunkCache extends ChunkSource { } // Paper - timings } diff --git a/patches/server/0766-Execute-chunk-tasks-mid-tick.patch b/patches/server/0766-Execute-chunk-tasks-mid-tick.patch index 258228486..a1266038e 100644 --- a/patches/server/0766-Execute-chunk-tasks-mid-tick.patch +++ b/patches/server/0766-Execute-chunk-tasks-mid-tick.patch @@ -120,10 +120,10 @@ index 98eb8318413014f0650dc5c80125aa84b51cfc93..57cb2722e973cfc8edc845bc7154b8b8 } else { if (this.haveTime()) { diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 7ea86cbeb72f08d751c14006f428fe5921916061..108f2212f8bd00247bf73ff4f3ba42830abad459 100644 +index d6981bbcf480c5856b51960013d144beba2361b3..39840403da99252c5d634e99e1da19f6066dee7c 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -1022,6 +1022,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -1023,6 +1023,7 @@ public class ServerChunkCache extends ChunkSource { Collections.shuffle(shuffled); iterator = shuffled.iterator(); } @@ -131,7 +131,7 @@ index 7ea86cbeb72f08d751c14006f428fe5921916061..108f2212f8bd00247bf73ff4f3ba4283 try { while (iterator.hasNext()) { LevelChunk chunk = iterator.next(); ChunkHolder playerchunk = chunk.playerChunk; -@@ -1044,6 +1045,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -1045,6 +1046,7 @@ public class ServerChunkCache extends ChunkSource { this.level.tickChunk(chunk, k); // this.level.timings.doTickTiles.stopTiming(); // Spigot // Paper } diff --git a/patches/server/0769-Replace-player-chunk-loader-system.patch b/patches/server/0769-Replace-player-chunk-loader-system.patch index 1fb5a0148..ef546632f 100644 --- a/patches/server/0769-Replace-player-chunk-loader-system.patch +++ b/patches/server/0769-Replace-player-chunk-loader-system.patch @@ -1109,7 +1109,7 @@ index 0000000000000000000000000000000000000000..4eadc15f747528b59349f095171dd5a6 + } +} diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index 0b47144cb8ad72efebf10e163f5b442995ef213e..03c6cdec727b03c2f61eaae339a2ff58c64d5ebc 100644 +index 032d65a489d65e9b5b5066dff80c65d2e1b28c82..580bdaa99129c8edb82b835edfa822892f1cd243 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -93,6 +93,28 @@ public class Connection extends SimpleChannelInboundHandler> { @@ -1176,7 +1176,7 @@ index 82a233b413791eff4bc6b9140b5bbf99354ed671..15fb4ee2066df1c8ce341913a64f350f worldData.addProperty("keep-spawn-loaded-range", world.paperConfig.keepLoadedRange); worldData.addProperty("visible-chunk-count", visibleChunks.size()); diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java -index a98d7b5e755da7ad98d133fc50785e1bf70b4ddd..3db72a4416d3125c37f6c1dc2c3803fbb14b9c97 100644 +index a9267e64e54f451c896e35693f469b8563f578f9..326aecc38a7f93fe0d25fb9b772d06f78f99781d 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java @@ -491,7 +491,7 @@ public class ChunkHolder { @@ -1205,7 +1205,7 @@ index a98d7b5e755da7ad98d133fc50785e1bf70b4ddd..3db72a4416d3125c37f6c1dc2c3803fb } } diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 4d18b217f21ce60b691c6bf964f81129718b8f56..a474e83df65bb48779fe135b14d6a9a3f74d1bf4 100644 +index 85c97767cdaf45b24f5764a6a1ef3c56535bb37f..8e0762bc1d705b7df664b6270c4d536f77572b87 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -187,22 +187,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1531,10 +1531,10 @@ index 1cc4e0a1f3d8235ef88b48e01ca8b78a263d2676..0b34536cdffab31a717b613042d70981 + */ // Paper - replace old loader system } diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 108f2212f8bd00247bf73ff4f3ba42830abad459..0d8a47770435c27519af4ebd78835ec787551733 100644 +index 39840403da99252c5d634e99e1da19f6066dee7c..6db8c95693772296d947fbc051b97937fd184685 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -928,6 +928,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -929,6 +929,7 @@ public class ServerChunkCache extends ChunkSource { this.level.timings.doChunkMap.stopTiming(); // Spigot this.level.getProfiler().popPush("chunks"); this.level.timings.chunks.startTiming(); // Paper - timings @@ -1542,7 +1542,7 @@ index 108f2212f8bd00247bf73ff4f3ba42830abad459..0d8a47770435c27519af4ebd78835ec7 this.tickChunks(); this.level.timings.chunks.stopTiming(); // Paper - timings this.level.timings.doChunkUnload.startTiming(); // Spigot -@@ -1218,6 +1219,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -1219,6 +1220,7 @@ public class ServerChunkCache extends ChunkSource { public boolean pollTask() { try { boolean execChunkTask = com.destroystokyo.paper.io.chunk.ChunkTaskManager.pollChunkWaitQueue() || ServerChunkCache.this.level.asyncChunkTaskManager.pollNextChunkTask(); // Paper diff --git a/patches/server/0776-Distance-manager-tick-timings.patch b/patches/server/0776-Distance-manager-tick-timings.patch index c7cc5bf24..8825901f2 100644 --- a/patches/server/0776-Distance-manager-tick-timings.patch +++ b/patches/server/0776-Distance-manager-tick-timings.patch @@ -19,10 +19,10 @@ index eada966d7f108a6081be7a848f5c1dfcb1eed676..a977f7483f37df473096b2234dc1308b public static final Timing midTickChunkTasks = Timings.ofSafe("Mid Tick Chunk Tasks"); diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 0d8a47770435c27519af4ebd78835ec787551733..d7ec783caebd71364c1c3a414bcf1aac271b0574 100644 +index 6db8c95693772296d947fbc051b97937fd184685..6589baa5680a154e47e7e28223e2214ca36790f3 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -842,6 +842,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -843,6 +843,7 @@ public class ServerChunkCache extends ChunkSource { public boolean runDistanceManagerUpdates() { if (distanceManager.delayDistanceManagerTick) return false; // Paper - Chunk priority if (this.chunkMap.unloadingPlayerChunk) { net.minecraft.server.MinecraftServer.LOGGER.fatal("Cannot tick distance manager while unloading playerchunks", new Throwable()); throw new IllegalStateException("Cannot tick distance manager while unloading playerchunks"); } // Paper @@ -30,7 +30,7 @@ index 0d8a47770435c27519af4ebd78835ec787551733..d7ec783caebd71364c1c3a414bcf1aac boolean flag = this.distanceManager.runAllUpdates(this.chunkMap); boolean flag1 = this.chunkMap.promoteChunkMap(); -@@ -851,6 +852,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -852,6 +853,7 @@ public class ServerChunkCache extends ChunkSource { this.clearCache(); return true; } diff --git a/patches/server/0782-Consolidate-flush-calls-for-entity-tracker-packets.patch b/patches/server/0782-Consolidate-flush-calls-for-entity-tracker-packets.patch index e6e5fe03e..0e44c24f7 100644 --- a/patches/server/0782-Consolidate-flush-calls-for-entity-tracker-packets.patch +++ b/patches/server/0782-Consolidate-flush-calls-for-entity-tracker-packets.patch @@ -22,10 +22,10 @@ With this change I could get all 200 on at 0ms ping. So in general this patch should reduce Netty I/O thread load. diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index d7ec783caebd71364c1c3a414bcf1aac271b0574..7470f3ba66c2e894b5a5b0ba392ecabf8b04aff9 100644 +index 6589baa5680a154e47e7e28223e2214ca36790f3..4a3dbcfdacb809d162663c379c4e8151be522432 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -1069,7 +1069,24 @@ public class ServerChunkCache extends ChunkSource { +@@ -1070,7 +1070,24 @@ public class ServerChunkCache extends ChunkSource { this.level.getProfiler().pop(); }