diff --git a/patches/server/0005-Paper-config-files.patch b/patches/server/0005-Paper-config-files.patch index 750014e360..8106551cac 100644 --- a/patches/server/0005-Paper-config-files.patch +++ b/patches/server/0005-Paper-config-files.patch @@ -1390,7 +1390,7 @@ index 0000000000000000000000000000000000000000..351fbbc577556ebbd62222615801a96b +} diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java new file mode 100644 -index 0000000000000000000000000000000000000000..071d3877e386a0c7c4d2f2e8ddd06e0765c49d0d +index 0000000000000000000000000000000000000000..385ca2c1022e0985550a5cc2bbff953f1aa33f5c --- /dev/null +++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java @@ -0,0 +1,548 @@ @@ -4814,17 +4814,17 @@ index 0000000000000000000000000000000000000000..614aba60bb07946a144650fd3aedb316 + protected abstract boolean belowZero(O value); +} diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java -index 6b0a1ff870e013a83f7922021ab296bb1c716079..f3130afbfd70e39a8000b0471854f8ef892bbbf5 100644 +index 6b0a1ff870e013a83f7922021ab296bb1c716079..403c57fc683bb0497602e1a9ec7b81b2722ecc01 100644 --- a/src/main/java/net/minecraft/server/Main.java +++ b/src/main/java/net/minecraft/server/Main.java @@ -137,6 +137,10 @@ public class Main { dedicatedserversettings.forceSave(); Path path2 = Paths.get("eula.txt"); Eula eula = new Eula(path2); -+ // Paper start - load config files for access below if needed ++ // Paper start - load config files early for access below if needed + org.bukkit.configuration.file.YamlConfiguration bukkitConfiguration = io.papermc.paper.configuration.PaperConfigurations.loadLegacyConfigFile((File) optionset.valueOf("bukkit-settings")); + org.bukkit.configuration.file.YamlConfiguration spigotConfiguration = io.papermc.paper.configuration.PaperConfigurations.loadLegacyConfigFile((File) optionset.valueOf("spigot-settings")); -+ // Paper end ++ // Paper end - load config files early for access below if needed if (optionset.has("initSettings")) { // CraftBukkit // CraftBukkit start - SPIGOT-5761: Create bukkit.yml and commands.yml if not present @@ -4833,19 +4833,19 @@ index 6b0a1ff870e013a83f7922021ab296bb1c716079..f3130afbfd70e39a8000b0471854f8ef File file = (File) optionset.valueOf("universe"); // CraftBukkit - Services services = Services.create(new YggdrasilAuthenticationService(Proxy.NO_PROXY), file); -+ Services services = Services.create(new YggdrasilAuthenticationService(Proxy.NO_PROXY), file, optionset); // Paper ++ Services services = Services.create(new YggdrasilAuthenticationService(Proxy.NO_PROXY), file, optionset); // Paper - pass OptionSet to load paper config files // CraftBukkit start String s = (String) Optional.ofNullable((String) optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName); LevelStorageSource convertable = LevelStorageSource.createDefault(file.toPath()); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 8cc3fd73eaa41b87c63cf26e299affca16f20d87..afd39623d2c2e9270510a6a83b5918392442744d 100644 +index 8cc3fd73eaa41b87c63cf26e299affca16f20d87..7193029f1f8b5db7d94306e7dd07c5053795533c 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -295,6 +295,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop S spin(Function serverFactory) { AtomicReference atomicreference = new AtomicReference(); @@ -4853,12 +4853,12 @@ index 8cc3fd73eaa41b87c63cf26e299affca16f20d87..afd39623d2c2e9270510a6a83b591839 } Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this)); // CraftBukkit end -+ this.paperConfigurations = services.paperConfigurations(); // Paper ++ this.paperConfigurations = services.paperConfigurations(); // Paper - add paper configuration files } private void readScoreboard(DimensionDataStorage persistentStateManager) { diff --git a/src/main/java/net/minecraft/server/Services.java b/src/main/java/net/minecraft/server/Services.java -index 1d611538d339345df065cd9c0c582d02e1fb0cc7..92d1ad919c1b3e27af9cc74ada19f1e9c4f3471f 100644 +index 1d611538d339345df065cd9c0c582d02e1fb0cc7..d200619b4aa820e273c26f2f6133589c727f8a0e 100644 --- a/src/main/java/net/minecraft/server/Services.java +++ b/src/main/java/net/minecraft/server/Services.java @@ -10,14 +10,30 @@ import javax.annotation.Nullable; @@ -4866,7 +4866,7 @@ index 1d611538d339345df065cd9c0c582d02e1fb0cc7..92d1ad919c1b3e27af9cc74ada19f1e9 import net.minecraft.util.SignatureValidator; -public record Services(MinecraftSessionService sessionService, ServicesKeySet servicesKeySet, GameProfileRepository profileRepository, GameProfileCache profileCache) { -+// Paper start ++// Paper start - add paper configuration files +public record Services(MinecraftSessionService sessionService, ServicesKeySet servicesKeySet, GameProfileRepository profileRepository, GameProfileCache profileCache, @javax.annotation.Nullable io.papermc.paper.configuration.PaperConfigurations paperConfigurations) { + + public Services(MinecraftSessionService sessionService, ServicesKeySet servicesKeySet, GameProfileRepository profileRepository, GameProfileCache profileCache) { @@ -4877,53 +4877,53 @@ index 1d611538d339345df065cd9c0c582d02e1fb0cc7..92d1ad919c1b3e27af9cc74ada19f1e9 + public io.papermc.paper.configuration.PaperConfigurations paperConfigurations() { + return java.util.Objects.requireNonNull(this.paperConfigurations); + } -+ // Paper end ++ // Paper end - add paper configuration files private static final String USERID_CACHE_FILE = "usercache.json"; - public static Services create(YggdrasilAuthenticationService authenticationService, File rootDirectory) { -+ public static Services create(YggdrasilAuthenticationService authenticationService, File rootDirectory, joptsimple.OptionSet optionSet) throws Exception { // Paper ++ public static Services create(YggdrasilAuthenticationService authenticationService, File rootDirectory, joptsimple.OptionSet optionSet) throws Exception { // Paper - add optionset to load paper config files MinecraftSessionService minecraftSessionService = authenticationService.createMinecraftSessionService(); GameProfileRepository gameProfileRepository = authenticationService.createProfileRepository(); GameProfileCache gameProfileCache = new GameProfileCache(gameProfileRepository, new File(rootDirectory, "usercache.json")); - return new Services(minecraftSessionService, authenticationService.getServicesKeySet(), gameProfileRepository, gameProfileCache); -+ // Paper start ++ // Paper start - load paper config files from cli options + final java.nio.file.Path legacyConfigPath = ((File) optionSet.valueOf("paper-settings")).toPath(); + final java.nio.file.Path configDirPath = ((File) optionSet.valueOf("paper-settings-directory")).toPath(); + io.papermc.paper.configuration.PaperConfigurations paperConfigurations = io.papermc.paper.configuration.PaperConfigurations.setup(legacyConfigPath, configDirPath, rootDirectory.toPath(), (File) optionSet.valueOf("spigot-settings")); + return new Services(minecraftSessionService, authenticationService.getServicesKeySet(), gameProfileRepository, gameProfileCache, paperConfigurations); -+ // Paper end ++ // Paper end - load paper config files from cli options } @Nullable diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index dd16b56a478e1cd6f1b3c5563c9c02025d894802..458c04786f7b56f3c006e1e717c0ac709fddb1a0 100644 +index dd16b56a478e1cd6f1b3c5563c9c02025d894802..c56c7293261ec2601ab02d051b37e820f023f0ff 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java @@ -183,6 +183,10 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface org.spigotmc.SpigotConfig.init((java.io.File) this.options.valueOf("spigot-settings")); org.spigotmc.SpigotConfig.registerCommands(); // Spigot end -+ // Paper start -+ paperConfigurations.initializeGlobalConfiguration(this.registryAccess()); -+ paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); -+ // Paper end ++ // Paper start - initialize global and world-defaults configuration ++ this.paperConfigurations.initializeGlobalConfiguration(this.registryAccess()); ++ this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); ++ // Paper end - initialize global and world-defaults configuration this.setPvpAllowed(dedicatedserverproperties.pvp); this.setFlightAllowed(dedicatedserverproperties.allowFlight); diff --git a/src/main/java/net/minecraft/server/dedicated/Settings.java b/src/main/java/net/minecraft/server/dedicated/Settings.java -index 37ab411817008d4e6194e177d88d50931e53b42e..ca23639f15107ccd43b874ae38fa37279b827a8f 100644 +index 397c978c71f36c8abe1c52e545699fc7928a6917..fc45c2c4ecdf3906df6bceaf3e019c462fe62186 100644 --- a/src/main/java/net/minecraft/server/dedicated/Settings.java +++ b/src/main/java/net/minecraft/server/dedicated/Settings.java @@ -119,6 +119,7 @@ public abstract class Settings> { try { // CraftBukkit start - Don't attempt writing to file if it's read only if (path.toFile().exists() && !path.toFile().canWrite()) { -+ Settings.LOGGER.warn("Can not write to file {}, skipping.", path); // Paper ++ Settings.LOGGER.warn("Can not write to file {}, skipping.", path); // Paper - log message file is read-only return; } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index ecc61c7b1b4eb887795ffd39578b70b4e77f5213..92cb1c23f2ef95f9be6c688146ee81aae5ac101c 100644 +index ecc61c7b1b4eb887795ffd39578b70b4e77f5213..674c996af91de91ee6302cc67334b836ea4fa4de 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -236,7 +236,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -4931,24 +4931,24 @@ index ecc61c7b1b4eb887795ffd39578b70b4e77f5213..92cb1c23f2ef95f9be6c688146ee81aa // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error - super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env); -+ super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess()))); // Paper ++ super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess()))); // Paper - create paper world configs this.pvpMode = minecraftserver.isPvpAllowed(); this.convertable = convertable_conversionsession; this.uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile()); diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index cff78fc8d073be7541628bb40670f82d1e9917cd..50ea733f42d0f06a62b55e61b0c73995896b0d6a 100644 +index 8487fa452e4009c0f2a23a0d4eac4bf56f91447b..00ddf94c5bade8c0c486337ce920f59d63cb64e2 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -158,6 +158,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public final it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap ticksPerSpawnCategory = new it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<>(); public boolean populating; public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot -+ // Paper start ++ // Paper start - add paper world config + private final io.papermc.paper.configuration.WorldConfiguration paperConfig; + public io.papermc.paper.configuration.WorldConfiguration paperConfig() { + return this.paperConfig; + } -+ // Paper end ++ // Paper end - add paper world config public final SpigotTimings.WorldTimingsHandler timings; // Spigot public static BlockPos lastPhysicsProblem; // Spigot @@ -4957,9 +4957,9 @@ index cff78fc8d073be7541628bb40670f82d1e9917cd..50ea733f42d0f06a62b55e61b0c73995 public abstract ResourceKey getTypeKey(); - protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env) { -+ protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator) { // Paper ++ protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator) { // Paper - create paper world config this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot -+ this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper ++ this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config this.generator = gen; this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env); diff --git a/patches/server/0009-MC-Utils.patch b/patches/server/0009-MC-Utils.patch index 3701ba05fa..555936c837 100644 --- a/patches/server/0009-MC-Utils.patch +++ b/patches/server/0009-MC-Utils.patch @@ -6051,14 +6051,14 @@ index 44cac39893eb968aa8ea21ee571c0dcb866ce06c..5151d68ba6ec72a7124f298253c5f0af + } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 21e84dfd9ee3f8ce6234581ec31c64c35021d3c8..729849caf3e3cb542d5c4097a568c5fadeff0f6d 100644 +index fb9f70b08e96ba4de52dca717ee245c405bf06e5..d4fb6d031acbb009fcb600718a16ac0b5437d88e 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -296,6 +296,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop S spin(Function serverFactory) { AtomicReference atomicreference = new AtomicReference(); @@ -6076,7 +6076,7 @@ index 21e84dfd9ee3f8ce6234581ec31c64c35021d3c8..729849caf3e3cb542d5c4097a568c5fa } } // Spigot start -+ ++MinecraftServer.currentTickLong; // Paper ++ ++MinecraftServer.currentTickLong; // Paper - track current tick as a long if ( tickCount++ % MinecraftServer.SAMPLE_INTERVAL == 0 ) { long curTime = Util.getMillis(); @@ -6962,7 +6962,7 @@ index 1d12a7934308aa48d7ea7fa10c7b6b5ccb27e707..7cacfceed5ef9276a19123a8a9079579 ChunkHolder playerchunk = this.getVisibleChunkIfPresent(pos); diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 9cf839be15126444d4d2ffdb7faa637859941d6b..cb6fbb3a1512d69a3f1192c969c3d5c78c046cef 100644 +index 93867b8883c6f5d5086e8fdc153e6d7c1e5d9fec..aa2c9b13b86130a613ed171a3c16f3639e7c82c6 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -230,6 +230,98 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -7355,7 +7355,7 @@ index 3c707d6674b2594b09503b959a31c1f4ad3981e6..db61b6b0158a9bcc0e1d735e34fe3671 public BlockState getBlockState(BlockPos pos) { return Blocks.AIR.defaultBlockState(); diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 81fbc18b0cd9bc443555001947796342be4123b8..9f8f9dea26e55f8785d3702c1e3d83f6f87358bb 100644 +index 00ddf94c5bade8c0c486337ce920f59d63cb64e2..32afa096f148ebb546963bae7c9c9b194cb1a99c 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -93,6 +93,7 @@ import org.bukkit.craftbukkit.CraftServer; diff --git a/patches/server/0010-Adventure.patch b/patches/server/0010-Adventure.patch index 5bdea15032..59f6755727 100644 --- a/patches/server/0010-Adventure.patch +++ b/patches/server/0010-Adventure.patch @@ -2077,14 +2077,14 @@ index 0000000000000000000000000000000000000000..c0701d4f93a4d77a8177d2dd8d5076f9 + } +} diff --git a/src/main/java/net/minecraft/ChatFormatting.java b/src/main/java/net/minecraft/ChatFormatting.java -index e7980c88d036c617420e80bda8e1972723f97b52..44a1c467c429feee2f6292b6fcb1dbfa0354d46b 100644 +index e7980c88d036c617420e80bda8e1972723f97b52..efbc104acc62c5af8acf35b15f1be0d9f11113c9 100644 --- a/src/main/java/net/minecraft/ChatFormatting.java +++ b/src/main/java/net/minecraft/ChatFormatting.java @@ -113,6 +113,18 @@ public enum ChatFormatting implements StringRepresentable { return name == null ? null : FORMATTING_BY_NAME.get(cleanName(name)); } -+ // Paper start ++ // Paper start - add method to get by hex value + @Nullable public static ChatFormatting getByHexValue(int i) { + for (ChatFormatting value : values()) { + if (value.getColor() != null && value.getColor() == i) { @@ -2094,25 +2094,25 @@ index e7980c88d036c617420e80bda8e1972723f97b52..44a1c467c429feee2f6292b6fcb1dbfa + + return null; + } -+ // Paper end ++ // Paper end - add method to get by hex value + @Nullable public static ChatFormatting getById(int colorIndex) { if (colorIndex < 0) { diff --git a/src/main/java/net/minecraft/commands/CommandSourceStack.java b/src/main/java/net/minecraft/commands/CommandSourceStack.java -index db93483cfee13ca4303d7452ecbb47507dc5f89e..b836a85ce3a4374e94061fe9368e86a61522615d 100644 +index db93483cfee13ca4303d7452ecbb47507dc5f89e..f6938c35ac6f6116084d3e7ec9cdc918f20b6f61 100644 --- a/src/main/java/net/minecraft/commands/CommandSourceStack.java +++ b/src/main/java/net/minecraft/commands/CommandSourceStack.java @@ -65,6 +65,7 @@ public class CommandSourceStack implements ExecutionCommandSource @@ -2122,11 +2122,11 @@ index 979ea69678319338c543185ba026ad0699a388d6..34ed1f92328ee8826b58dfaf239a96b6 - Component component = minecraftServer.getChatDecorator().decorate(source.getPlayer(), message.decoratedContent()); - source.getChatMessageChainer().append(completableFuture, (filtered) -> { - PlayerChatMessage playerChatMessage2 = message.withUnsignedContent(component).filter(filtered.mask()); -+ // Paper start ++ // Paper start - support asynchronous chat decoration + CompletableFuture componentFuture = minecraftServer.getChatDecorator().decorate(source.getPlayer(), source, message.decoratedContent()); + source.getChatMessageChainer().append(CompletableFuture.allOf(completableFuture, componentFuture), (filtered) -> { -+ PlayerChatMessage playerChatMessage2 = message.withUnsignedContent(componentFuture.join().component()).filter(completableFuture.join().mask()); // Paper -+ // Paper end ++ PlayerChatMessage playerChatMessage2 = message.withUnsignedContent(componentFuture.join().component()).filter(completableFuture.join().mask()); ++ // Paper end - support asynchronous chat decoration callback.accept(playerChatMessage2); }); } @@ -2135,15 +2135,15 @@ index 979ea69678319338c543185ba026ad0699a388d6..34ed1f92328ee8826b58dfaf239a96b6 ChatDecorator chatDecorator = source.getServer().getChatDecorator(); - Component component = chatDecorator.decorate(source.getPlayer(), message.decoratedContent()); - callback.accept(message.withUnsignedContent(component)); -+ // Paper start ++ // Paper start - support asynchronous chat decoration + CompletableFuture componentFuture = chatDecorator.decorate(source.getPlayer(), source, message.decoratedContent()); + source.getChatMessageChainer().append(componentFuture, (result) -> callback.accept(message.withUnsignedContent(result.component()))); -+ // Paper end ++ // Paper end - support asynchronous chat decoration } private static CompletableFuture filterPlainText(CommandSourceStack source, PlayerChatMessage message) { diff --git a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java -index d120fff432d9c4fc7a35ddffdc4186459e45e950..73c15a0c56a103ba4e62f0a51af8d42566b07245 100644 +index d120fff432d9c4fc7a35ddffdc4186459e45e950..676a1499747b071515479130875157263d3a8352 100644 --- a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java @@ -92,7 +92,7 @@ public class EntitySelector { @@ -2151,19 +2151,19 @@ index d120fff432d9c4fc7a35ddffdc4186459e45e950..73c15a0c56a103ba4e62f0a51af8d425 private void checkPermissions(CommandSourceStack source) throws CommandSyntaxException { - if (this.usesSelector && !source.hasPermission(2, "minecraft.command.selector")) { // CraftBukkit -+ if (source.bypassSelectorPermissions || (this.usesSelector && !source.hasPermission(2, "minecraft.command.selector"))) { // CraftBukkit // Paper ++ if (source.bypassSelectorPermissions || (this.usesSelector && !source.hasPermission(2, "minecraft.command.selector"))) { // CraftBukkit // Paper - add bypass for selector perms throw EntityArgument.ERROR_SELECTORS_NOT_ALLOWED.create(); } } diff --git a/src/main/java/net/minecraft/network/FriendlyByteBuf.java b/src/main/java/net/minecraft/network/FriendlyByteBuf.java -index 9373502ede6c8a881af67db005cf12fd9313f37f..39940edf4aef21842c8abd77bec0d0f1e7e9c762 100644 +index 9373502ede6c8a881af67db005cf12fd9313f37f..53f033d2d887909f5f905c00122d1b09809e5e3c 100644 --- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java +++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java @@ -87,6 +87,7 @@ public class FriendlyByteBuf extends ByteBuf { public static final int DEFAULT_NBT_QUOTA = 2097152; private final ByteBuf source; -+ public java.util.Locale adventure$locale; // Paper ++ public java.util.Locale adventure$locale; // Paper - track player's locale for server-side translations public static final short MAX_STRING_LENGTH = 32767; public static final int MAX_COMPONENT_STRING_LENGTH = 262144; private static final int PUBLIC_KEY_SIZE = 256; @@ -2171,17 +2171,17 @@ index 9373502ede6c8a881af67db005cf12fd9313f37f..39940edf4aef21842c8abd77bec0d0f1 } public void writeJsonWithCodec(Codec codec, T value) { -+ // Paper start - Adventure ++ // Paper start - Adventure; add max length parameter + this.writeJsonWithCodec(codec, value, MAX_STRING_LENGTH); + } + public void writeJsonWithCodec(Codec codec, T value, int maxLength) { -+ // Paper end - Adventure ++ // Paper end - Adventure; add max length parameter DataResult dataresult = codec.encodeStart(JsonOps.INSTANCE, value); this.writeUtf(FriendlyByteBuf.GSON.toJson((JsonElement) Util.getOrThrow(dataresult, (s) -> { return new EncoderException("Failed to encode: " + s + " " + value); - }))); -+ })), maxLength); // Paper - Adventure ++ })), maxLength); // Paper - Adventure; add max length parameter } public void writeId(IdMap registry, T value) { @@ -2189,7 +2189,7 @@ index 9373502ede6c8a881af67db005cf12fd9313f37f..39940edf4aef21842c8abd77bec0d0f1 return (Component) this.readWithCodecTrusted(NbtOps.INSTANCE, ComponentSerialization.CODEC); } -+ // Paper start - adventure ++ // Paper start - adventure; support writing adventure components directly and server-side translations + public FriendlyByteBuf writeComponent(final net.kyori.adventure.text.Component component) { + return this.writeWithCodec(NbtOps.INSTANCE, io.papermc.paper.adventure.PaperAdventure.localizedCodec(this.adventure$locale), component); + } @@ -2201,24 +2201,24 @@ index 9373502ede6c8a881af67db005cf12fd9313f37f..39940edf4aef21842c8abd77bec0d0f1 + } + + return this.writeWithCodec(NbtOps.INSTANCE, ComponentSerialization.localizedCodec(this.adventure$locale), text); -+ // Paper end - adventure ++ // Paper end - adventure; support writing adventure components directly and server-side translations } public > T readEnum(Class enumClass) { diff --git a/src/main/java/net/minecraft/network/PacketEncoder.java b/src/main/java/net/minecraft/network/PacketEncoder.java -index 344c5af75c4a66bb27f3f422937c6c427c15ed25..3d359f80f52bff6f19fcb484f491a874f9dcff27 100644 +index 344c5af75c4a66bb27f3f422937c6c427c15ed25..7070d093c80033b61a9c8495bc56153d986b6b03 100644 --- a/src/main/java/net/minecraft/network/PacketEncoder.java +++ b/src/main/java/net/minecraft/network/PacketEncoder.java @@ -35,6 +35,7 @@ public class PacketEncoder extends MessageToByteEncoder> { } else { FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(byteBuf); friendlyByteBuf.writeVarInt(i); -+ friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(io.papermc.paper.adventure.PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper ++ friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(io.papermc.paper.adventure.PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper - adventure; set player's locale try { int j = friendlyByteBuf.writerIndex(); diff --git a/src/main/java/net/minecraft/network/chat/ChatDecorator.java b/src/main/java/net/minecraft/network/chat/ChatDecorator.java -index 887b9fd625aa23c4ec828a175d63695f915232d3..8152420b9c3eb1bf13c012dd43505d9913fb9c4d 100644 +index 887b9fd625aa23c4ec828a175d63695f915232d3..8e4a4b15152c2f83444fa8017bec06bbd1389e2c 100644 --- a/src/main/java/net/minecraft/network/chat/ChatDecorator.java +++ b/src/main/java/net/minecraft/network/chat/ChatDecorator.java @@ -2,12 +2,72 @@ package net.minecraft.network.chat; @@ -2231,14 +2231,14 @@ index 887b9fd625aa23c4ec828a175d63695f915232d3..8152420b9c3eb1bf13c012dd43505d99 public interface ChatDecorator { ChatDecorator PLAIN = (sender, message) -> { - return message; -+ return CompletableFuture.completedFuture(message); // Paper ++ return CompletableFuture.completedFuture(message); // Paper - adventure; support async chat decoration events }; - Component decorate(@Nullable ServerPlayer sender, Component message); -+ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper -+ CompletableFuture decorate(@Nullable ServerPlayer sender, Component message); // Paper - make a completable future again ++ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper - adventure; support chat decoration events ++ CompletableFuture decorate(@Nullable ServerPlayer sender, Component message); // Paper - adventure; support async chat decoration events + -+ // Paper start ++ // Paper start - adventure; support async chat decoration events + default CompletableFuture decorate(@Nullable ServerPlayer sender, @Nullable net.minecraft.commands.CommandSourceStack commandSourceStack, Component message) { + throw new UnsupportedOperationException("Must override this implementation"); + } @@ -2294,17 +2294,17 @@ index 887b9fd625aa23c4ec828a175d63695f915232d3..8152420b9c3eb1bf13c012dd43505d99 + return new MessagePair(adventureComponent, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(adventureComponent)); + } + } -+ // Paper end ++ // Paper end - adventure; support async chat decoration events } diff --git a/src/main/java/net/minecraft/network/chat/ComponentSerialization.java b/src/main/java/net/minecraft/network/chat/ComponentSerialization.java -index 49138ccda0f378b13c7f425be765876eb4026b06..dc572d5be6ee3af74be2ffb4c02351c8be235159 100644 +index 49138ccda0f378b13c7f425be765876eb4026b06..30568c1be4d412bfae5bd07d45b823861ec39ab3 100644 --- a/src/main/java/net/minecraft/network/chat/ComponentSerialization.java +++ b/src/main/java/net/minecraft/network/chat/ComponentSerialization.java @@ -55,12 +55,58 @@ public class ComponentSerialization { return ExtraCodecs.orCompressed(mapCodec3, mapCodec2); } -+ // Paper start - adventure ++ // Paper start - adventure; create separate codec for each locale + private static final java.util.Map> LOCALIZED_CODECS = new java.util.concurrent.ConcurrentHashMap<>(); + + public static Codec localizedCodec(final java.util.@org.checkerframework.checker.nullness.qual.Nullable Locale locale) { @@ -2314,21 +2314,21 @@ index 49138ccda0f378b13c7f425be765876eb4026b06..dc572d5be6ee3af74be2ffb4c02351c8 + return LOCALIZED_CODECS.computeIfAbsent(locale, + loc -> ExtraCodecs.recursive("Component", selfCodec -> createCodec(selfCodec, loc))); + } -+ // Paper end ++ // Paper end - adventure; create separate codec for each locale + private static Codec createCodec(Codec selfCodec) { -+ // Paper start - adventure ++ // Paper start - adventure; create separate codec for each locale + return createCodec(selfCodec, null); + } + + private static Codec createCodec(Codec selfCodec, @javax.annotation.Nullable java.util.Locale locale) { -+ // Paper end ++ // Paper end - adventure; create separate codec for each locale ComponentContents.Type[] types = new ComponentContents.Type[]{PlainTextContents.TYPE, TranslatableContents.TYPE, KeybindContents.TYPE, ScoreContents.TYPE, SelectorContents.TYPE, NbtContents.TYPE}; MapCodec mapCodec = createLegacyComponentMatcher(types, ComponentContents.Type::codec, ComponentContents::type, "type"); Codec codec = RecordCodecBuilder.create((instance) -> { return instance.group(mapCodec.forGetter(Component::getContents), ExtraCodecs.strictOptionalField(ExtraCodecs.nonEmptyList(selfCodec.listOf()), "extra", List.of()).forGetter(Component::getSiblings), Style.Serializer.MAP_CODEC.forGetter(Component::getStyle)).apply(instance, MutableComponent::new); }); -+ // Paper start - adventure ++ // Paper start - adventure; create separate codec for each locale + final Codec origCodec = codec; + codec = new Codec<>() { + @Override @@ -2355,35 +2355,35 @@ index 49138ccda0f378b13c7f425be765876eb4026b06..dc572d5be6ee3af74be2ffb4c02351c8 + return origCodec.toString() + "[AdventureComponentAware]"; + } + }; -+ // Paper end ++ // Paper end - adventure; create separate codec for each locale return Codec.either(Codec.either(Codec.STRING, ExtraCodecs.nonEmptyList(selfCodec.listOf())), codec).xmap((either) -> { return either.map((either2) -> { return either2.map(Component::literal, ComponentSerialization::createFromList); diff --git a/src/main/java/net/minecraft/network/chat/ComponentUtils.java b/src/main/java/net/minecraft/network/chat/ComponentUtils.java -index b6506e881ef337bfd2a7a0644296b48b7300a0f6..7daca712816a79cc4a30b084afbd3d07b5d3755f 100644 +index b6506e881ef337bfd2a7a0644296b48b7300a0f6..57206594f305961a33542e1f8079c75bfa7c535f 100644 --- a/src/main/java/net/minecraft/network/chat/ComponentUtils.java +++ b/src/main/java/net/minecraft/network/chat/ComponentUtils.java @@ -41,6 +41,11 @@ public class ComponentUtils { if (depth > 100) { return text.copy(); } else { -+ // Paper start ++ // Paper start - adventure; pass actual vanilla component + if (text instanceof io.papermc.paper.adventure.AdventureComponent adventureComponent) { + text = adventureComponent.deepConverted(); + } -+ // Paper end ++ // Paper end - adventure; pass actual vanilla component MutableComponent mutableComponent = text.getContents().resolve(source, sender, depth + 1); for(Component component : text.getSiblings()) { diff --git a/src/main/java/net/minecraft/network/chat/MessageSignature.java b/src/main/java/net/minecraft/network/chat/MessageSignature.java -index df9997873c4bbec184379ec14dca1bf4566eb89d..e2812cdce3b1170b7b7d0f52209e8b4fd2b64c61 100644 +index df9997873c4bbec184379ec14dca1bf4566eb89d..a3e2d03ffe9392cc69e850c5db7d71889a0a27ea 100644 --- a/src/main/java/net/minecraft/network/chat/MessageSignature.java +++ b/src/main/java/net/minecraft/network/chat/MessageSignature.java @@ -13,11 +13,12 @@ import net.minecraft.util.SignatureUpdater; import net.minecraft.util.SignatureValidator; public record MessageSignature(byte[] bytes) { -+ public net.kyori.adventure.chat.SignedMessage.Signature adventure() { return () -> this.bytes; } // Paper ++ public net.kyori.adventure.chat.SignedMessage.Signature adventure() { return () -> this.bytes; } // Paper - adventure; support signed messages public static final Codec CODEC = ExtraCodecs.BASE64_STRING.xmap(MessageSignature::new, MessageSignature::bytes); public static final int BYTES = 256; @@ -2439,7 +2439,7 @@ index f8773f2982e6cd40661d138a7c32f219cda9225c..74cf1c043beef03cfd5adf481414a5ee sender.connection.sendPlayerChatMessage(playerChatMessage, params); } diff --git a/src/main/java/net/minecraft/network/chat/PlayerChatMessage.java b/src/main/java/net/minecraft/network/chat/PlayerChatMessage.java -index 901c1aba1653ed70f4af931835ceb12a357aff55..4ac5276dae775210d73ae943d183e5aa8c10bf57 100644 +index 901c1aba1653ed70f4af931835ceb12a357aff55..00560ea19c29fd0e16cbe11ab0b07f12a2ff0cb6 100644 --- a/src/main/java/net/minecraft/network/chat/PlayerChatMessage.java +++ b/src/main/java/net/minecraft/network/chat/PlayerChatMessage.java @@ -14,7 +14,53 @@ import net.minecraft.Util; @@ -2447,7 +2447,7 @@ index 901c1aba1653ed70f4af931835ceb12a357aff55..4ac5276dae775210d73ae943d183e5aa import net.minecraft.util.SignatureValidator; -public record PlayerChatMessage(SignedMessageLink link, @Nullable MessageSignature signature, SignedMessageBody signedBody, @Nullable Component unsignedContent, FilterMask filterMask) { -+// Paper start ++// Paper start - adventure; support signed messages +public record PlayerChatMessage(SignedMessageLink link, @Nullable MessageSignature signature, SignedMessageBody signedBody, @Nullable Component unsignedContent, FilterMask filterMask, @Nullable net.minecraft.network.chat.ChatDecorator.Result result) { + public PlayerChatMessage(SignedMessageLink link, @Nullable MessageSignature signature, SignedMessageBody signedBody, @Nullable Component unsignedContent, FilterMask filterMask) { + this(link, signature, signedBody, unsignedContent, filterMask, null); @@ -2493,7 +2493,7 @@ index 901c1aba1653ed70f4af931835ceb12a357aff55..4ac5276dae775210d73ae943d183e5aa + public AdventureView adventureView() { + return new AdventureView(); + } -+ // Paper end ++ // Paper end - adventure; support signed messages public static final MapCodec MAP_CODEC = RecordCodecBuilder.mapCodec((instance) -> { return instance.group(SignedMessageLink.CODEC.fieldOf("link").forGetter(PlayerChatMessage::link), MessageSignature.CODEC.optionalFieldOf("signature").forGetter((message) -> { return Optional.ofNullable(message.signature); @@ -2502,7 +2502,7 @@ index 901c1aba1653ed70f4af931835ceb12a357aff55..4ac5276dae775210d73ae943d183e5aa public PlayerChatMessage withUnsignedContent(Component unsignedContent) { - Component component = !unsignedContent.equals(Component.literal(this.signedContent())) ? unsignedContent : null; -+ Component component = !(unsignedContent instanceof io.papermc.paper.adventure.AdventureComponent advComponent ? advComponent.deepConverted() : unsignedContent).equals(Component.literal(this.signedContent())) ? unsignedContent : null; // Paper ++ Component component = !(unsignedContent instanceof io.papermc.paper.adventure.AdventureComponent advComponent ? advComponent.deepConverted() : unsignedContent).equals(Component.literal(this.signedContent())) ? unsignedContent : null; // Paper - adventure; convert adventure component wraps return new PlayerChatMessage(this.link, this.signature, this.signedBody, component, this.filterMask); } @@ -2648,7 +2648,7 @@ index a5578cbce2d1d39ba3315e53425d5323e6823a65..7a036c08fa67504d06c8f72a32c22814 @Override diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 729849caf3e3cb542d5c4097a568c5fadeff0f6d..1eb0809addfd77303b94bb594701ee7f38483909 100644 +index d4fb6d031acbb009fcb600718a16ac0b5437d88e..47f01de166a4048824f3075deb596084b7d42978 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -191,6 +191,7 @@ import org.bukkit.craftbukkit.SpigotTimings; // Spigot diff --git a/patches/server/0011-Paper-command.patch b/patches/server/0011-Paper-command.patch index 32ca916d95..85195efecb 100644 --- a/patches/server/0011-Paper-command.patch +++ b/patches/server/0011-Paper-command.patch @@ -605,19 +605,19 @@ index 0000000000000000000000000000000000000000..ae60bd96b5284d54676d8e7e4dd5d170 + } +} diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 458c04786f7b56f3c006e1e717c0ac709fddb1a0..6c83df6290e4ec59c596f1b9e2f10f0a80004acd 100644 +index c56c7293261ec2601ab02d051b37e820f023f0ff..faab5e8c952a2af6a286043617cded4e6ca5c3c6 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -186,6 +186,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - // Paper start - paperConfigurations.initializeGlobalConfiguration(this.registryAccess()); - paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); -+ io.papermc.paper.command.PaperCommands.registerCommands(this); - // Paper end +@@ -187,6 +187,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + this.paperConfigurations.initializeGlobalConfiguration(this.registryAccess()); + this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); + // Paper end - initialize global and world-defaults configuration ++ io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command this.setPvpAllowed(dedicatedserverproperties.pvp); + this.setFlightAllowed(dedicatedserverproperties.allowFlight); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 085844c5257c667838f637e98f32688b5e2ceaca..b7a7258321b5c312b9697ce40c1ea7bee469b3fc 100644 +index 4e155510337d73cd65f722c1360d87d14312b874..cded844ac9fb2167fd0c751d47439d6597e34d05 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -939,6 +939,7 @@ public final class CraftServer implements Server { diff --git a/patches/server/0012-Paper-Metrics.patch b/patches/server/0012-Paper-Metrics.patch index 49ea4af626..56286148ba 100644 --- a/patches/server/0012-Paper-Metrics.patch +++ b/patches/server/0012-Paper-Metrics.patch @@ -698,17 +698,17 @@ index 0000000000000000000000000000000000000000..6aaed8e8bf8c721fc834da5c76ac72a4 + } +} diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 6c83df6290e4ec59c596f1b9e2f10f0a80004acd..4b303d8acc663cfd3b86e37f4a3110d5335d07ad 100644 +index faab5e8c952a2af6a286043617cded4e6ca5c3c6..813fd87df0dfed8fe46389db8333d1d9f409fbe4 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -187,6 +187,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - paperConfigurations.initializeGlobalConfiguration(this.registryAccess()); - paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); - io.papermc.paper.command.PaperCommands.registerCommands(this); -+ com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); - // Paper end +@@ -188,6 +188,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); + // Paper end - initialize global and world-defaults configuration + io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command ++ com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics this.setPvpAllowed(dedicatedserverproperties.pvp); + this.setFlightAllowed(dedicatedserverproperties.allowFlight); diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java index 1d066ce7dcf5f548c2a34d308d4422ab4fd02e5a..0fca20580d81c461e903c8cbd1cf090f5d5083c6 100644 --- a/src/main/java/org/spigotmc/SpigotConfig.java diff --git a/patches/server/0014-Timings-v2.patch b/patches/server/0014-Timings-v2.patch index 9f4a054eee..839ff00321 100644 --- a/patches/server/0014-Timings-v2.patch +++ b/patches/server/0014-Timings-v2.patch @@ -712,7 +712,7 @@ index daedf825e68655492f5ab776bc206a5eb87c0170..7de24c39b460e43d27839b3821e67213 } catch (Exception exception) { label25: diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 1eb0809addfd77303b94bb594701ee7f38483909..206751253a02a5f144bbf7bfc5401577767e9030 100644 +index 47f01de166a4048824f3075deb596084b7d42978..57e15d66bf59c23d9dc87aa811ff6c3c2084a4c4 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -186,7 +186,7 @@ import org.bukkit.craftbukkit.Main; @@ -891,7 +891,7 @@ index 1eb0809addfd77303b94bb594701ee7f38483909..206751253a02a5f144bbf7bfc5401577 this.profiler.popPush("send chunks"); iterator = this.playerList.getPlayers().iterator(); diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 4b303d8acc663cfd3b86e37f4a3110d5335d07ad..cb95818bfb5f0a9274b4e0f2530000bfca7ffc87 100644 +index 813fd87df0dfed8fe46389db8333d1d9f409fbe4..dfb37ddb89c2f43d9f9a34a6b2d38616575eb39b 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java @@ -58,8 +58,9 @@ import org.apache.logging.log4j.Level; @@ -1123,7 +1123,7 @@ index 7cacfceed5ef9276a19123a8a9079579423d03ac..5cd680d2ed47aadb5e65a775d70bc662 gameprofilerfiller.pop(); gameprofilerfiller.pop(); diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index cb6fbb3a1512d69a3f1192c969c3d5c78c046cef..96b1e1669b4a425bc18e5c00da18a79f20fc3e9b 100644 +index aa2c9b13b86130a613ed171a3c16f3639e7c82c6..d00b789d8deb0163726acbcb10edb0965ac9f326 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -1,6 +1,8 @@ @@ -1472,7 +1472,7 @@ index b71b702471599fc8f1de42919ade8ee6a4e6247c..2e47008a8ff1bb56b752d4eb880173b9 if (!this.level().isClientSide && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) { this.hurt(this.damageSources().drown(), 1.0F); diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 9f8f9dea26e55f8785d3702c1e3d83f6f87358bb..6e3bdcea55490b23066ab90966698e59847cdffa 100644 +index 32afa096f148ebb546963bae7c9c9b194cb1a99c..6dbc4c74b4d6b8e6c4763366e70ca9292b4a25d5 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -91,7 +91,6 @@ import org.bukkit.Bukkit; @@ -1485,7 +1485,7 @@ index 9f8f9dea26e55f8785d3702c1e3d83f6f87358bb..6e3bdcea55490b23066ab90966698e59 import org.bukkit.craftbukkit.block.data.CraftBlockData; @@ -166,7 +165,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } - // Paper end + // Paper end - add paper world config - public final SpigotTimings.WorldTimingsHandler timings; // Spigot + public final co.aikar.timings.WorldTimingsHandler timings; // Paper diff --git a/patches/server/0029-Add-version-history-to-version-command.patch b/patches/server/0029-Add-version-history-to-version-command.patch index d84d36ed17..b6afc3dbac 100644 --- a/patches/server/0029-Add-version-history-to-version-command.patch +++ b/patches/server/0029-Add-version-history-to-version-command.patch @@ -209,14 +209,14 @@ index 0000000000000000000000000000000000000000..660b2ec6b63a4ceffee44ab11f54dfa7 + } +} diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index b6d5e0962abb62a30c1561d3b1e970884b5b13dc..a267ab0b217573373d7b6a1f48cadab0f431da40 100644 +index 0f516d126ce834adadd6a57a762e34c996403ab2..69e8a7551762ab6de03f43d823e2149f5f9eca70 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -189,6 +189,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); - io.papermc.paper.command.PaperCommands.registerCommands(this); - com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); -+ com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // load version history now - // Paper end +@@ -190,6 +190,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + // Paper end - initialize global and world-defaults configuration + io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command + com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics ++ com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now this.setPvpAllowed(dedicatedserverproperties.pvp); + this.setFlightAllowed(dedicatedserverproperties.allowFlight); diff --git a/patches/server/0031-Further-improve-server-tick-loop.patch b/patches/server/0031-Further-improve-server-tick-loop.patch index c63df8e085..467d67138a 100644 --- a/patches/server/0031-Further-improve-server-tick-loop.patch +++ b/patches/server/0031-Further-improve-server-tick-loop.patch @@ -12,7 +12,7 @@ Previous implementation did not calculate TPS correctly. Switch to a realistic rolling average and factor in std deviation as an extra reporting variable diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 457b0f1f469436f6caa7473d91f906f1a61d6c74..2f04f10f5819be04b98ac0b52a2d7f4dfa525cea 100644 +index 9d2ec082302a422e3135dc0ff6fedf86456b74b5..2defe6f950b8a5e1f039f61fa30343ccc7d4617a 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -283,7 +283,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess()))); // Paper -+ super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess())), executor); // Paper - Async-Anti-Xray - Pass executor +- super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess()))); // Paper - create paper world configs ++ super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess())), executor); // Paper - create paper world configs; Async-Anti-Xray: Pass executor this.pvpMode = minecraftserver.isPvpAllowed(); this.convertable = convertable_conversionsession; this.uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile()); @@ -1155,12 +1155,12 @@ index 5de5209e04d631bd6a50e28e8d3abebf148252c1..19b3f4fa7678a038bf25efc2a8b46dda DebugPackets.sendPoiPacketsForChunk(world, chunkPos); } diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 8c4fcb49c1cd90751bcc776a119f4d503b2bbf06..864b1985ba645b709e2cb5e7fd036e7664063ce5 100644 +index 9e4ab11521b853d0db55b382413c1f49cbff9e9e..8782c443d6288cb1cadc181e7f2923cbcd3061d2 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -178,6 +178,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } - // Paper end + // Paper end - add paper world config + public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray public final co.aikar.timings.WorldTimingsHandler timings; // Paper @@ -1170,10 +1170,10 @@ index 8c4fcb49c1cd90751bcc776a119f4d503b2bbf06..864b1985ba645b709e2cb5e7fd036e76 public abstract ResourceKey getTypeKey(); -- protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator) { // Paper -+ protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor +- protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator) { // Paper - create paper world config ++ protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config; Async-Anti-Xray: Pass executor this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot - this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper + this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config this.generator = gen; @@ -282,6 +283,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.keepSpawnInMemory = this.paperConfig().spawn.keepSpawnLoaded; // Paper diff --git a/patches/server/0365-Improved-Watchdog-Support.patch b/patches/server/0365-Improved-Watchdog-Support.patch index 4e6962d78d..89c7318629 100644 --- a/patches/server/0365-Improved-Watchdog-Support.patch +++ b/patches/server/0365-Improved-Watchdog-Support.patch @@ -71,7 +71,7 @@ index a9a0248b1bd1ac454064e977b61f9b7d80962ff8..059b1a0bf048af6a28c322f35da3d3cb cause = cause.getCause(); } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 2deb639d404943ef5b028c4ede59cab99b31a40f..08f7f287af32597d8a39f429013adec9266020bf 100644 +index 961a4953be8561e31d8df3ce812d9ab6e3a573a5..011d9854731425cb5116db8cd726326c4a38fc06 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -297,7 +297,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop packet) { diff --git a/src/main/java/net/minecraft/network/PacketEncoder.java b/src/main/java/net/minecraft/network/PacketEncoder.java -index 45b4f1c295eda2fcc5067a4b21de247218ef117f..d364bd57b1675c8b21d781c2bc16c3e65800455c 100644 +index 2907536f8f9b4b9dccb96f8b4f19d75fa3c5b864..b5b228e67284baad3639b283595427a819bb1a44 100644 --- a/src/main/java/net/minecraft/network/PacketEncoder.java +++ b/src/main/java/net/minecraft/network/PacketEncoder.java @@ -47,7 +47,14 @@ public class PacketEncoder extends MessageToByteEncoder> { @@ -545,19 +545,19 @@ index 45b4f1c295eda2fcc5067a4b21de247218ef117f..d364bd57b1675c8b21d781c2bc16c3e6 throw new SkipPacketException(var13); } diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index fe47a38137f7b7fa94c507e790eec4fb7303595f..7f5ecea0ee78a534d7c56fa9e3ad2117b5192c0a 100644 +index 9ddcca2c17c15c5c7d88046aeae8b5588ad4612d..c7696765ff6b1e27c108d2668c32abbbab35896c 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -195,6 +195,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -194,6 +194,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + org.spigotmc.SpigotConfig.init((java.io.File) this.options.valueOf("spigot-settings")); org.spigotmc.SpigotConfig.registerCommands(); // Spigot end - // Paper start + io.papermc.paper.util.ObfHelper.INSTANCE.getClass(); // Paper - load mappings for stacktrace deobf and etc. - paperConfigurations.initializeGlobalConfiguration(this.registryAccess()); - paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); - org.spigotmc.WatchdogThread.doStart(org.spigotmc.SpigotConfig.timeoutTime, org.spigotmc.SpigotConfig.restartOnCrash); + // Paper start - initialize global and world-defaults configuration + this.paperConfigurations.initializeGlobalConfiguration(this.registryAccess()); + this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index bd40d4056fbf237f2a3f6c7178bed699f9bdf389..2e04cf910a520b92ac43a5ff2d06d9d61402c3cb 100644 +index 1c0d2aad70b3817913e93354ccc055b82ae321bc..51379dc93af2eaa3294179debe067d62627b60e1 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -222,7 +222,9 @@ public class ServerLevel extends Level implements WorldGenLevel { diff --git a/patches/server/0430-Thread-Safe-Vanilla-Command-permission-checking.patch b/patches/server/0430-Thread-Safe-Vanilla-Command-permission-checking.patch index 048e161f33..a6303d1a68 100644 --- a/patches/server/0430-Thread-Safe-Vanilla-Command-permission-checking.patch +++ b/patches/server/0430-Thread-Safe-Vanilla-Command-permission-checking.patch @@ -26,7 +26,7 @@ index 3384501f83d445f45aa8233e98c7597daa67b8ef..6875e15aac37d3566bf04f1a6ee79a21 } // CraftBukkit end diff --git a/src/main/java/net/minecraft/commands/CommandSourceStack.java b/src/main/java/net/minecraft/commands/CommandSourceStack.java -index 75b7b3cf90d1d67203ae19dc3302f06a57470f92..e58c2844356c71973d81b460a21aab795b506d77 100644 +index c772fa3b7a1276b0b41c45c6e0f5584b9c3a90cd..79732086bc4cdbca8364d78eb60d68c758055966 100644 --- a/src/main/java/net/minecraft/commands/CommandSourceStack.java +++ b/src/main/java/net/minecraft/commands/CommandSourceStack.java @@ -64,7 +64,7 @@ public class CommandSourceStack implements ExecutionCommandSource currentCommand = new java.util.concurrent.ConcurrentHashMap<>(); // CraftBukkit // Paper - public boolean bypassSelectorPermissions = false; // Paper ++ public java.util.Map currentCommand = new java.util.concurrent.ConcurrentHashMap<>(); // CraftBukkit // Paper - make thread-safe + public boolean bypassSelectorPermissions = false; // Paper - add bypass for selector permissions public CommandSourceStack(CommandSource output, Vec3 pos, Vec2 rot, ServerLevel world, int level, String name, Component displayName, MinecraftServer server, @Nullable Entity entity) { @@ -193,9 +193,11 @@ public class CommandSourceStack implements ExecutionCommandSource public -- public static Services create(YggdrasilAuthenticationService authenticationService, File rootDirectory, joptsimple.OptionSet optionSet) throws Exception { // Paper -+ public static Services create(YggdrasilAuthenticationService authenticationService, File rootDirectory, File userCacheFile, joptsimple.OptionSet optionSet) throws Exception { // Paper +- public static Services create(YggdrasilAuthenticationService authenticationService, File rootDirectory, joptsimple.OptionSet optionSet) throws Exception { // Paper - add optionset to load paper config files ++ public static Services create(YggdrasilAuthenticationService authenticationService, File rootDirectory, File userCacheFile, joptsimple.OptionSet optionSet) throws Exception { // Paper - add optionset to load paper config files; add userCacheFile parameter MinecraftSessionService minecraftSessionService = authenticationService.createMinecraftSessionService(); GameProfileRepository gameProfileRepository = authenticationService.createProfileRepository(); - GameProfileCache gameProfileCache = new GameProfileCache(gameProfileRepository, new File(rootDirectory, "usercache.json")); -+ GameProfileCache gameProfileCache = new GameProfileCache(gameProfileRepository, userCacheFile); // Paper - // Paper start ++ GameProfileCache gameProfileCache = new GameProfileCache(gameProfileRepository, userCacheFile); // Paper - use specified user cache file + // Paper start - load paper config files from cli options final java.nio.file.Path legacyConfigPath = ((File) optionSet.valueOf("paper-settings")).toPath(); final java.nio.file.Path configDirPath = ((File) optionSet.valueOf("paper-settings-directory")).toPath(); diff --git a/patches/server/0549-fix-converting-txt-to-json-file.patch b/patches/server/0549-fix-converting-txt-to-json-file.patch index 5ba9235c6a..4761cc2aeb 100644 --- a/patches/server/0549-fix-converting-txt-to-json-file.patch +++ b/patches/server/0549-fix-converting-txt-to-json-file.patch @@ -21,22 +21,22 @@ index a20d47f54f12dfc0a5f76dd969238e34c958b618..935dac757280731bfeb0a8f033cbe315 this.saveUserBanList(); this.loadIpBanList(); diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index ac918da8234553e4d88664b240feddc1fea8bd6b..e92708f60fec876c62e720420f133a9b28c6f66f 100644 +index 4d76d64fad92510de5098613aa0a04e1bbf7bca5..d7a147cc29f9d6882326ddac29449e1b14ae9c96 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -198,6 +198,12 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - io.papermc.paper.util.ObfHelper.INSTANCE.getClass(); // Paper - load mappings for stacktrace deobf and etc. - paperConfigurations.initializeGlobalConfiguration(this.registryAccess()); - paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); -+ // Paper start - moved up to right after PlayerList creation but before file load/save +@@ -199,6 +199,12 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + this.paperConfigurations.initializeGlobalConfiguration(this.registryAccess()); + this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); + // Paper end - initialize global and world-defaults configuration ++ // Paper start - convert old users earlier after PlayerList creation but before file load/save + if (this.convertOldUsers()) { + this.getProfileCache().save(false); // Paper + } + this.getPlayerList().loadAndSaveFiles(); // Must be after convertNames -+ // Paper end - moved up - org.spigotmc.WatchdogThread.doStart(org.spigotmc.SpigotConfig.timeoutTime, org.spigotmc.SpigotConfig.restartOnCrash); - io.papermc.paper.command.PaperCommands.registerCommands(this); - com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); ++ // Paper end - convert old users earlier after PlayerList creation but before file load/save + org.spigotmc.WatchdogThread.doStart(org.spigotmc.SpigotConfig.timeoutTime, org.spigotmc.SpigotConfig.restartOnCrash); // Paper - start watchdog thread + io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command + com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics @@ -253,9 +259,6 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface DedicatedServer.LOGGER.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file."); } @@ -48,7 +48,7 @@ index ac918da8234553e4d88664b240feddc1fea8bd6b..e92708f60fec876c62e720420f133a9b if (!OldUsersConverter.serverReadyAfterUserconversion(this)) { return false; diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index bf361396bc2ec5d5c7b45d425af990c037ba0694..c8f40d71619a53f85b71ef5af397bbfa65fd797f 100644 +index 32f93ed20f5f2cec71850d7e0ce8a633fd5efc82..8a13160ff62a671a11740c456a2cbc3ccbac708f 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -176,6 +176,7 @@ public abstract class PlayerList { diff --git a/patches/server/0563-Enhance-console-tab-completions-for-brigadier-comman.patch b/patches/server/0563-Enhance-console-tab-completions-for-brigadier-comman.patch index 5513bfc5df..12c556faf5 100644 --- a/patches/server/0563-Enhance-console-tab-completions-for-brigadier-comman.patch +++ b/patches/server/0563-Enhance-console-tab-completions-for-brigadier-comman.patch @@ -208,7 +208,7 @@ index 0000000000000000000000000000000000000000..dd9d77d7c7f1a5a130a1f4c15e5b1e68 + public void setErrorIndex(final int errorIndex) {} +} diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index e92708f60fec876c62e720420f133a9b28c6f66f..3cacbbc03a3207656b71a1a05d95dbb750815bab 100644 +index d7a147cc29f9d6882326ddac29449e1b14ae9c96..5c455e4fba3e7b6064d869340667f48ed9cb3e9e 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java @@ -173,7 +173,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -220,14 +220,14 @@ index e92708f60fec876c62e720420f133a9b28c6f66f..3cacbbc03a3207656b71a1a05d95dbb7 DedicatedServer.LOGGER.info("Starting minecraft server version {}", SharedConstants.getCurrentVersion().getName()); if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) { DedicatedServer.LOGGER.warn("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); -@@ -205,6 +205,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -206,6 +206,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface this.getPlayerList().loadAndSaveFiles(); // Must be after convertNames - // Paper end - moved up - org.spigotmc.WatchdogThread.doStart(org.spigotmc.SpigotConfig.timeoutTime, org.spigotmc.SpigotConfig.restartOnCrash); + // Paper end - convert old users earlier after PlayerList creation but before file load/save + org.spigotmc.WatchdogThread.doStart(org.spigotmc.SpigotConfig.timeoutTime, org.spigotmc.SpigotConfig.restartOnCrash); // Paper - start watchdog thread + thread.start(); // Paper - start console thread after MinecraftServer.console & PaperConfig are initialized - io.papermc.paper.command.PaperCommands.registerCommands(this); - com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); - com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // load version history now + io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command + com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics + com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now diff --git a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java index 8f82041f0482df22a6a9ea38d50d56228131775d..12eeabafbad9da8796dc6fc383b732cf75bb7ddb 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java diff --git a/patches/server/0575-Implement-methods-to-convert-between-Component-and-B.patch b/patches/server/0575-Implement-methods-to-convert-between-Component-and-B.patch index dd25fe454b..573adc1950 100644 --- a/patches/server/0575-Implement-methods-to-convert-between-Component-and-B.patch +++ b/patches/server/0575-Implement-methods-to-convert-between-Component-and-B.patch @@ -42,14 +42,14 @@ index 0000000000000000000000000000000000000000..dd6012b6a097575b2d1471be5069ecce + } +} diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 3cacbbc03a3207656b71a1a05d95dbb750815bab..8f9ea1907ed4574cca8d362a0f207fb546cb6484 100644 +index 5c455e4fba3e7b6064d869340667f48ed9cb3e9e..f9e39f557f04269769b869ff24127a6f312ddec3 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -209,6 +209,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - io.papermc.paper.command.PaperCommands.registerCommands(this); - com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); - com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // load version history now -+ io.papermc.paper.brigadier.PaperBrigadierProviderImpl.INSTANCE.getClass(); // init PaperBrigadierProvider - // Paper end +@@ -210,6 +210,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command + com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics + com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now ++ io.papermc.paper.brigadier.PaperBrigadierProviderImpl.INSTANCE.getClass(); // Paper - init PaperBrigadierProvider this.setPvpAllowed(dedicatedserverproperties.pvp); + this.setFlightAllowed(dedicatedserverproperties.allowFlight); diff --git a/patches/server/0621-Use-getChunkIfLoadedImmediately-in-places.patch b/patches/server/0621-Use-getChunkIfLoadedImmediately-in-places.patch index 0cf92aab06..b4bfba528c 100644 --- a/patches/server/0621-Use-getChunkIfLoadedImmediately-in-places.patch +++ b/patches/server/0621-Use-getChunkIfLoadedImmediately-in-places.patch @@ -8,7 +8,7 @@ ticket level 33 (yes getChunkIfLoaded will actually perform a chunk load in that case). diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index e00fe39fbcd4aa54eb498b91783b7e4dd021acc0..89396f956fc413f6ce53c2f66a85c395557aa883 100644 +index 8b2f72be4304ebab84fc46e6c4c0984abd8e8905..dbfd4a642e862f46a8b4fd1f3fc52c13ecf74284 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -229,7 +229,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -21,7 +21,7 @@ index e00fe39fbcd4aa54eb498b91783b7e4dd021acc0..89396f956fc413f6ce53c2f66a85c395 @Override diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index da6995bcecfb16567b8a7c13b19d08ef3e5dc5d2..06446b61b79c24bb1df194706a587597a31e5a49 100644 +index 761d01c993b60a11c749e172c3ee3067c055b582..35ca44c88497e0b07f43ba7bf092360365b1c53a 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -204,6 +204,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -37,7 +37,7 @@ index da6995bcecfb16567b8a7c13b19d08ef3e5dc5d2..06446b61b79c24bb1df194706a587597 + public abstract ResourceKey getTypeKey(); - protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor + protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config; Async-Anti-Xray: Pass executor diff --git a/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java b/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java index 0d5ae91a9b43df7b412968ab5faf5498c09169f9..744160405680babbb83c99abcbe2dc89bf312398 100644 --- a/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java diff --git a/patches/server/0964-Only-capture-actual-tree-growth.patch b/patches/server/0964-Only-capture-actual-tree-growth.patch index e938f15f1e..5a3038df4b 100644 --- a/patches/server/0964-Only-capture-actual-tree-growth.patch +++ b/patches/server/0964-Only-capture-actual-tree-growth.patch @@ -29,16 +29,19 @@ index b44c596194f3e9fdd29f3eef1065612f46e7cd66..666533627e772e5e85ba04e65dd2b376 } entityhuman.awardStat(Stats.ITEM_USED.get(item)); // SPIGOT-7236 - award stat diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 3a6615df0e9e0043cebe35268509b882893725fb..d5890f295350ae5fb6e4844c90f6ab8e3a5f5516 100644 +index 7a4c21beaa4004f72cbfe75e567cafb3279a1c94..b8bf9eaae60040a3ba3d395712aa91940a71bea2 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -1898,4 +1898,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1898,4 +1898,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { return null; } // Paper end - optimize redstone (Alternate Current) + // Paper start - notify observers even if grow failed + public void checkCapturedTreeStateForObserverNotify(final BlockPos pos, final CraftBlockState craftBlockState) { -+ if (craftBlockState.getPosition().getY() == pos.getY() && this.getBlockState(craftBlockState.getPosition()) == craftBlockState.getHandle()) { // notify observers if the block state is the same and the Y level equals the original y level (for mega trees) ++ // notify observers if the block state is the same and the Y level equals the original y level (for mega trees) ++ // blocks at the same Y level with the same state can be assumed to be saplings which trigger observers regardless of if the ++ // tree grew or not ++ if (craftBlockState.getPosition().getY() == pos.getY() && this.getBlockState(craftBlockState.getPosition()) == craftBlockState.getHandle()) { // Paper - Fix silent equipment change + this.notifyAndUpdatePhysics(craftBlockState.getPosition(), null, craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getFlag(), 512); + } + } diff --git a/patches/server/1001-Fix-silent-equipment-change-for-mobs.patch b/patches/server/1001-Fix-silent-equipment-change-for-mobs.patch index 9d7a049c8f..07f0f4cc49 100644 --- a/patches/server/1001-Fix-silent-equipment-change-for-mobs.patch +++ b/patches/server/1001-Fix-silent-equipment-change-for-mobs.patch @@ -46,22 +46,6 @@ index 8e9469fec42f7b6a132cf173f6f5a95777a29b3b..a383c0c8b5c89ef1eef7d18edc3a09f7 if (!this.level().isClientSide) { this.reassessWeaponGoal(); } -diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index d5890f295350ae5fb6e4844c90f6ab8e3a5f5516..990bb65f784a2ac52e131d1ed146c2cd6dc19dce 100644 ---- a/src/main/java/net/minecraft/world/level/Level.java -+++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -1900,7 +1900,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - // Paper end - optimize redstone (Alternate Current) - // Paper start - notify observers even if grow failed - public void checkCapturedTreeStateForObserverNotify(final BlockPos pos, final CraftBlockState craftBlockState) { -- if (craftBlockState.getPosition().getY() == pos.getY() && this.getBlockState(craftBlockState.getPosition()) == craftBlockState.getHandle()) { // notify observers if the block state is the same and the Y level equals the original y level (for mega trees) -+ // notify observers if the block state is the same and the Y level equals the original y level (for mega trees) -+ // blocks at the same Y level with the same state can be assumed to be saplings which trigger observers regardless of if the -+ // tree grew or not -+ if (craftBlockState.getPosition().getY() == pos.getY() && this.getBlockState(craftBlockState.getPosition()) == craftBlockState.getHandle()) { // Paper - Fix silent equipment change - this.notifyAndUpdatePhysics(craftBlockState.getPosition(), null, craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getFlag(), 512); - } - } diff --git a/src/test/java/io/papermc/paper/entity/EntitySetItemSlotSilentOverrideTest.java b/src/test/java/io/papermc/paper/entity/EntitySetItemSlotSilentOverrideTest.java new file mode 100644 index 0000000000000000000000000000000000000000..81947843d1f2f7dc6f59d7b52f327d60b17d0dcc