diff --git a/patches/server/0005-Paper-config-files.patch b/patches/server/0005-Paper-config-files.patch index f5537d6127..b72ae1ee74 100644 --- a/patches/server/0005-Paper-config-files.patch +++ b/patches/server/0005-Paper-config-files.patch @@ -121,16 +121,17 @@ index 0000000000000000000000000000000000000000..042478cf7ce150f1f1bc5cddd7fa40f8 +} diff --git a/src/main/java/io/papermc/paper/configuration/Configurations.java b/src/main/java/io/papermc/paper/configuration/Configurations.java new file mode 100644 -index 0000000000000000000000000000000000000000..9ef6712c70fcd8912a79f3f61e351aac09572cf3 +index 0000000000000000000000000000000000000000..c01b4393439838976965823298f12e4762e72eff --- /dev/null +++ b/src/main/java/io/papermc/paper/configuration/Configurations.java -@@ -0,0 +1,311 @@ +@@ -0,0 +1,355 @@ +package io.papermc.paper.configuration; + +import com.mojang.logging.LogUtils; +import io.leangen.geantyref.TypeToken; +import io.papermc.paper.configuration.constraint.Constraint; +import io.papermc.paper.configuration.constraint.Constraints; ++import net.minecraft.core.RegistryAccess; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerLevel; +import org.checkerframework.checker.nullness.qual.Nullable; @@ -196,6 +197,10 @@ index 0000000000000000000000000000000000000000..9ef6712c70fcd8912a79f3f61e351aac + + protected abstract boolean isConfigType(final Type type); + ++ protected abstract int globalConfigVersion(); ++ ++ protected abstract int worldConfigVersion(); ++ + protected ObjectMapper.Factory.Builder createGlobalObjectMapperFactoryBuilder() { + return this.createObjectMapper(); + } @@ -224,7 +229,7 @@ index 0000000000000000000000000000000000000000..9ef6712c70fcd8912a79f3f61e351aac + }; + } + -+ public G initializeGlobalConfiguration() throws ConfigurateException { ++ public G initializeGlobalConfiguration(final RegistryAccess registryAccess) throws ConfigurateException { + return this.initializeGlobalConfiguration(creator(this.globalConfigClass, true)); + } + @@ -245,10 +250,12 @@ index 0000000000000000000000000000000000000000..9ef6712c70fcd8912a79f3f61e351aac + .path(configFile) + .build(); + final ConfigurationNode node; -+ if (Files.exists(configFile)) { -+ node = loader.load(); -+ } else { ++ if (Files.notExists(configFile)) { + node = CommentedConfigurationNode.root(loader.defaultOptions()); ++ node.node(Configuration.VERSION_FIELD).raw(this.globalConfigVersion()); ++ } else { ++ node = loader.load(); ++ this.verifyGlobalConfigVersion(node); + } + this.applyGlobalConfigTransformations(node); + final G instance = creator.apply(node); @@ -256,18 +263,29 @@ index 0000000000000000000000000000000000000000..9ef6712c70fcd8912a79f3f61e351aac + return instance; + } + ++ protected void verifyGlobalConfigVersion(final ConfigurationNode globalNode) { ++ final ConfigurationNode version = globalNode.node(Configuration.VERSION_FIELD); ++ if (version.virtual()) { ++ LOGGER.warn("The global config file didn't have a version set, assuming latest"); ++ version.raw(this.globalConfigVersion()); ++ } else if (version.getInt() > this.globalConfigVersion()) { ++ LOGGER.error("Loading a newer configuration than is supported ({} > {})! You may have to backup & delete your global config file to start the server.", version.getInt(), this.globalConfigVersion()); ++ } ++ } ++ + protected void applyGlobalConfigTransformations(final ConfigurationNode node) throws ConfigurateException { + } + + @MustBeInvokedByOverriders -+ protected ContextMap.Builder createDefaultContextMap() { ++ protected ContextMap.Builder createDefaultContextMap(final RegistryAccess registryAccess) { + return ContextMap.builder() + .put(WORLD_NAME, WORLD_DEFAULTS) -+ .put(WORLD_KEY, WORLD_DEFAULTS_KEY); ++ .put(WORLD_KEY, WORLD_DEFAULTS_KEY) ++ .put(REGISTRY_ACCESS, registryAccess); + } + -+ public void initializeWorldDefaultsConfiguration() throws ConfigurateException { -+ final ContextMap contextMap = this.createDefaultContextMap() ++ public void initializeWorldDefaultsConfiguration(final RegistryAccess registryAccess) throws ConfigurateException { ++ final ContextMap contextMap = this.createDefaultContextMap(registryAccess) + .put(FIRST_DEFAULT) + .build(); + final Path configFile = this.globalFolder.resolve(this.defaultWorldConfigFileName); @@ -275,7 +293,9 @@ index 0000000000000000000000000000000000000000..9ef6712c70fcd8912a79f3f61e351aac + final YamlConfigurationLoader loader = result.loader(); + final ConfigurationNode node = loader.load(); + if (result.isNewFile()) { // add version to new files -+ node.node(Configuration.VERSION_FIELD).raw(WorldConfiguration.CURRENT_VERSION); ++ node.node(Configuration.VERSION_FIELD).raw(this.worldConfigVersion()); ++ } else { ++ this.verifyWorldConfigVersion(contextMap, node); + } + this.applyWorldConfigTransformations(contextMap, node); + final W instance = node.require(this.worldConfigClass); @@ -316,7 +336,7 @@ index 0000000000000000000000000000000000000000..9ef6712c70fcd8912a79f3f61e351aac + + protected W createWorldConfig(final ContextMap contextMap, final CheckedFunction creator) throws IOException { + final Path defaultsConfigFile = this.globalFolder.resolve(this.defaultWorldConfigFileName); -+ final YamlConfigurationLoader defaultsLoader = this.createDefaultWorldLoader(true, this.createDefaultContextMap().build(), defaultsConfigFile).loader(); ++ final YamlConfigurationLoader defaultsLoader = this.createDefaultWorldLoader(true, this.createDefaultContextMap(contextMap.require(REGISTRY_ACCESS)).build(), defaultsConfigFile).loader(); + final ConfigurationNode defaultsNode = defaultsLoader.load(); + + boolean newFile = false; @@ -334,7 +354,9 @@ index 0000000000000000000000000000000000000000..9ef6712c70fcd8912a79f3f61e351aac + .build(); + final ConfigurationNode worldNode = worldLoader.load(); + if (newFile) { // set the version field if new file -+ worldNode.node(Configuration.VERSION_FIELD).set(WorldConfiguration.CURRENT_VERSION); ++ worldNode.node(Configuration.VERSION_FIELD).set(this.worldConfigVersion()); ++ } else { ++ this.verifyWorldConfigVersion(contextMap, worldNode); + } + this.applyWorldConfigTransformations(contextMap, worldNode); + this.applyDefaultsAwareWorldConfigTransformations(contextMap, worldNode, defaultsNode); @@ -343,6 +365,27 @@ index 0000000000000000000000000000000000000000..9ef6712c70fcd8912a79f3f61e351aac + return creator.apply(worldNode); + } + ++ protected void verifyWorldConfigVersion(final ContextMap contextMap, final ConfigurationNode worldNode) { ++ final ConfigurationNode version = worldNode.node(Configuration.VERSION_FIELD); ++ final String worldName = contextMap.require(WORLD_NAME); ++ if (version.virtual()) { ++ if (worldName.equals(WORLD_DEFAULTS)) { ++ LOGGER.warn("The world defaults config file didn't have a version set, assuming latest"); ++ } else { ++ LOGGER.warn("The world config file for " + worldName + " didn't have a version set, assuming latest"); ++ } ++ version.raw(this.worldConfigVersion()); ++ } else if (version.getInt() > this.worldConfigVersion()) { ++ String msg = "Loading a newer configuration than is supported ({} > {})! "; ++ if (worldName.equals(WORLD_DEFAULTS)) { ++ msg += "You may have to backup & delete the world defaults config file to start the server."; ++ } else { ++ msg += "You may have to backup & delete the " + worldName + " config file to start the server."; ++ } ++ LOGGER.error(msg, version.getInt(), this.worldConfigVersion()); ++ } ++ } ++ + protected void applyWorldConfigTransformations(final ContextMap contextMap, final ConfigurationNode node) throws ConfigurateException { + } + @@ -423,6 +466,7 @@ index 0000000000000000000000000000000000000000..9ef6712c70fcd8912a79f3f61e351aac + public static final ContextKey WORLD_NAME = new ContextKey<>(String.class, "world name"); // TODO remove when we deprecate level names + public static final ContextKey WORLD_KEY = new ContextKey<>(ResourceLocation.class, "world key"); + public static final ContextKey FIRST_DEFAULT = new ContextKey<>(Void.class, "first default"); ++ public static final ContextKey REGISTRY_ACCESS = new ContextKey<>(RegistryAccess.class, "registry access"); + + public record ContextKey(TypeToken type, String name) { + @@ -791,10 +835,10 @@ index 0000000000000000000000000000000000000000..69add4a7f1147015806bc9b63a8340d1 +} diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java new file mode 100644 -index 0000000000000000000000000000000000000000..9e8b8de907654050c51400286af971caca87d6bd +index 0000000000000000000000000000000000000000..fa1c0aee8c3a4d0868482cf5c703bbfd08e09874 --- /dev/null +++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -@@ -0,0 +1,457 @@ +@@ -0,0 +1,465 @@ +package io.papermc.paper.configuration; + +import com.google.common.base.Suppliers; @@ -824,9 +868,9 @@ index 0000000000000000000000000000000000000000..9e8b8de907654050c51400286af971ca +import io.papermc.paper.configuration.type.Duration; +import io.papermc.paper.configuration.type.DurationOrDisabled; +import io.papermc.paper.configuration.type.EngineMode; ++import io.papermc.paper.configuration.type.fallback.FallbackValueSerializer; +import io.papermc.paper.configuration.type.number.DoubleOr; +import io.papermc.paper.configuration.type.number.IntOr; -+import io.papermc.paper.configuration.type.fallback.FallbackValueSerializer; +import it.unimi.dsi.fastutil.objects.Reference2IntMap; +import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap; +import it.unimi.dsi.fastutil.objects.Reference2LongMap; @@ -840,12 +884,14 @@ index 0000000000000000000000000000000000000000..9e8b8de907654050c51400286af971ca +import java.util.List; +import java.util.function.Function; +import java.util.function.Supplier; ++import net.minecraft.core.RegistryAccess; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.item.Item; ++import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import org.apache.commons.lang3.RandomStringUtils; +import org.bukkit.configuration.ConfigurationSection; @@ -941,6 +987,16 @@ index 0000000000000000000000000000000000000000..9e8b8de907654050c51400286af971ca + } + + @Override ++ protected int globalConfigVersion() { ++ return GlobalConfiguration.CURRENT_VERSION; ++ } ++ ++ @Override ++ protected int worldConfigVersion() { ++ return WorldConfiguration.CURRENT_VERSION; ++ } ++ ++ @Override + protected YamlConfigurationLoader.Builder createLoaderBuilder() { + return super.createLoaderBuilder() + .defaultOptions(PaperConfigurations::defaultOptions); @@ -979,15 +1035,15 @@ index 0000000000000000000000000000000000000000..9e8b8de907654050c51400286af971ca + } + + @Override -+ public GlobalConfiguration initializeGlobalConfiguration() throws ConfigurateException { -+ GlobalConfiguration configuration = super.initializeGlobalConfiguration(); ++ public GlobalConfiguration initializeGlobalConfiguration(final RegistryAccess registryAccess) throws ConfigurateException { ++ GlobalConfiguration configuration = super.initializeGlobalConfiguration(registryAccess); + GlobalConfiguration.set(configuration); + return configuration; + } + + @Override -+ protected ContextMap.Builder createDefaultContextMap() { -+ return super.createDefaultContextMap() ++ protected ContextMap.Builder createDefaultContextMap(final RegistryAccess registryAccess) { ++ return super.createDefaultContextMap(registryAccess) + .put(SPIGOT_WORLD_CONFIG_CONTEXT_KEY, SPIGOT_WORLD_DEFAULTS); + } + @@ -1008,6 +1064,7 @@ index 0000000000000000000000000000000000000000..9e8b8de907654050c51400286af971ca + + @Override + protected YamlConfigurationLoader.Builder createWorldConfigLoaderBuilder(final ContextMap contextMap) { ++ final RegistryAccess access = contextMap.require(REGISTRY_ACCESS); + return super.createWorldConfigLoaderBuilder(contextMap) + .defaultOptions(options -> options + .header(contextMap.require(WORLD_NAME).equals(WORLD_DEFAULTS) ? WORLD_DEFAULTS_HEADER : WORLD_HEADER.apply(contextMap)) @@ -1025,22 +1082,16 @@ index 0000000000000000000000000000000000000000..9e8b8de907654050c51400286af971ca + .register(EngineMode.SERIALIZER) + .register(NbtPathSerializer.SERIALIZER) + .register(FallbackValueSerializer.create(contextMap.require(SPIGOT_WORLD_CONFIG_CONTEXT_KEY).get(), MinecraftServer::getServer)) -+ .register(new RegistryValueSerializer<>(new TypeToken>() {}, Registries.ENTITY_TYPE, true)) -+ .register(new RegistryValueSerializer<>(Item.class, Registries.ITEM, true)) -+ .register(new RegistryHolderSerializer<>(new TypeToken>() {}, Registries.CONFIGURED_FEATURE, false)) -+ .register(new RegistryHolderSerializer<>(Item.class, Registries.ITEM, true)) ++ .register(new RegistryValueSerializer<>(new TypeToken>() {}, access, Registries.ENTITY_TYPE, true)) ++ .register(new RegistryValueSerializer<>(Item.class, access, Registries.ITEM, true)) ++ .register(new RegistryValueSerializer<>(Block.class, access, Registries.BLOCK, true)) ++ .register(new RegistryHolderSerializer<>(new TypeToken>() {}, access, Registries.CONFIGURED_FEATURE, false)) + ) + ); + } + + @Override + protected void applyWorldConfigTransformations(final ContextMap contextMap, final ConfigurationNode node) throws ConfigurateException { -+ final ConfigurationNode version = node.node(Configuration.VERSION_FIELD); -+ final String world = contextMap.require(WORLD_NAME); -+ if (version.virtual()) { -+ LOGGER.warn("The world config file for " + world + " didn't have a version set, assuming latest"); -+ version.raw(WorldConfiguration.CURRENT_VERSION); -+ } + ConfigurationTransformation.Builder builder = ConfigurationTransformation.builder(); + for (NodePath path : RemovedConfigurations.REMOVED_WORLD_PATHS) { + builder.addAction(path, TransformAction.remove()); @@ -1103,7 +1154,7 @@ index 0000000000000000000000000000000000000000..9e8b8de907654050c51400286af971ca + public void reloadConfigs(MinecraftServer server) { + try { + this.initializeGlobalConfiguration(reloader(this.globalConfigClass, GlobalConfiguration.get())); -+ this.initializeWorldDefaultsConfiguration(); ++ this.initializeWorldDefaultsConfiguration(server.registryAccess()); + for (ServerLevel level : server.getAllLevels()) { + this.createWorldConfig(createWorldContextMap(level), reloader(this.worldConfigClass, level.paperConfig())); + } @@ -1113,15 +1164,16 @@ index 0000000000000000000000000000000000000000..9e8b8de907654050c51400286af971ca + } + + private static ContextMap createWorldContextMap(ServerLevel level) { -+ return createWorldContextMap(level.convertable.levelDirectory.path(), level.serverLevelData.getLevelName(), level.dimension().location(), level.spigotConfig); ++ return createWorldContextMap(level.convertable.levelDirectory.path(), level.serverLevelData.getLevelName(), level.dimension().location(), level.spigotConfig, level.registryAccess()); + } + -+ public static ContextMap createWorldContextMap(Path dir, String levelName, ResourceLocation worldKey, SpigotWorldConfig spigotConfig) { ++ public static ContextMap createWorldContextMap(Path dir, String levelName, ResourceLocation worldKey, SpigotWorldConfig spigotConfig, RegistryAccess registryAccess) { + return ContextMap.builder() + .put(WORLD_DIRECTORY, dir) + .put(WORLD_NAME, levelName) + .put(WORLD_KEY, worldKey) + .put(SPIGOT_WORLD_CONFIG_CONTEXT_KEY, Suppliers.ofInstance(spigotConfig)) ++ .put(REGISTRY_ACCESS, registryAccess) + .build(); + } + @@ -1338,10 +1390,10 @@ 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..ed79d30f33b2674863b2d73b1abdb48433c33412 +index 0000000000000000000000000000000000000000..84e6fc5bac43ee0499b391827726bc02f6d3e46f --- /dev/null +++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java -@@ -0,0 +1,538 @@ +@@ -0,0 +1,539 @@ +package io.papermc.paper.configuration; + +import com.google.common.collect.HashBasedTable; @@ -1367,6 +1419,7 @@ index 0000000000000000000000000000000000000000..ed79d30f33b2674863b2d73b1abdb484 +import it.unimi.dsi.fastutil.objects.Reference2LongMap; +import it.unimi.dsi.fastutil.objects.Reference2LongOpenHashMap; +import java.util.Arrays; ++import java.util.IdentityHashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Function; @@ -1384,8 +1437,6 @@ index 0000000000000000000000000000000000000000..ed79d30f33b2674863b2d73b1abdb484 +import net.minecraft.world.entity.MobCategory; +import net.minecraft.world.entity.boss.enderdragon.EnderDragon; +import net.minecraft.world.entity.decoration.HangingEntity; -+import net.minecraft.world.entity.decoration.ItemFrame; -+import net.minecraft.world.entity.decoration.Painting; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.monster.Vindicator; +import net.minecraft.world.entity.monster.Zombie; @@ -1393,10 +1444,11 @@ index 0000000000000000000000000000000000000000..ed79d30f33b2674863b2d73b1abdb484 +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.NaturalSpawner; ++import net.minecraft.world.level.block.Block; ++import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import org.slf4j.Logger; +import org.spigotmc.SpigotWorldConfig; -+import org.spigotmc.TrackingRange; +import org.spongepowered.configurate.objectmapping.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.meta.PostProcess; +import org.spongepowered.configurate.objectmapping.meta.Required; @@ -1445,10 +1497,34 @@ index 0000000000000000000000000000000000000000..ed79d30f33b2674863b2d73b1abdb484 + public int updateRadius = 2; + public boolean lavaObscures = false; + public boolean usePermission = false; -+ public List hiddenBlocks = List.of("copper_ore", "deepslate_copper_ore", "raw_copper_block", "gold_ore", "deepslate_gold_ore", "iron_ore", "deepslate_iron_ore", "raw_iron_block", -+ "coal_ore", "deepslate_coal_ore", "lapis_ore", "deepslate_lapis_ore", "mossy_cobblestone", "obsidian", "chest", "diamond_ore", "deepslate_diamond_ore", -+ "redstone_ore", "deepslate_redstone_ore", "clay", "emerald_ore", "deepslate_emerald_ore", "ender_chest"); // TODO update type to List -+ public List replacementBlocks = List.of("stone", "oak_planks", "deepslate"); // TODO update type to List ++ public List hiddenBlocks = List.of( ++ // ++ Blocks.COPPER_ORE, ++ Blocks.DEEPSLATE_COPPER_ORE, ++ Blocks.RAW_COPPER_BLOCK, ++ Blocks.GOLD_ORE, ++ Blocks.DEEPSLATE_GOLD_ORE, ++ Blocks.IRON_ORE, ++ Blocks.DEEPSLATE_IRON_ORE, ++ Blocks.RAW_IRON_BLOCK, ++ Blocks.COAL_ORE, ++ Blocks.DEEPSLATE_COAL_ORE, ++ Blocks.LAPIS_ORE, ++ Blocks.DEEPSLATE_LAPIS_ORE, ++ Blocks.MOSSY_COBBLESTONE, ++ Blocks.OBSIDIAN, ++ Blocks.CHEST, ++ Blocks.DIAMOND_ORE, ++ Blocks.DEEPSLATE_DIAMOND_ORE, ++ Blocks.REDSTONE_ORE, ++ Blocks.DEEPSLATE_REDSTONE_ORE, ++ Blocks.CLAY, ++ Blocks.EMERALD_ORE, ++ Blocks.DEEPSLATE_EMERALD_ORE, ++ Blocks.ENDER_CHEST ++ // ++ ); ++ public List replacementBlocks = List.of(Blocks.STONE, Blocks.OAK_PLANKS, Blocks.DEEPSLATE); + } + } + @@ -1579,38 +1655,15 @@ index 0000000000000000000000000000000000000000..ed79d30f33b2674863b2d73b1abdb484 + public boolean piglinsGuardChests = true; + public double babyZombieMovementModifier = 0.5; + public boolean allowSpiderWorldBorderClimbing = true; -+ public DoorBreakingDifficulty doorBreakingDifficulty; + -+ public class DoorBreakingDifficulty extends ConfigurationPart { // TODO convert to map at some point -+ public List zombie = Arrays.stream(Difficulty.values()).filter(Zombie.DOOR_BREAKING_PREDICATE).toList(); -+ public List husk = Arrays.stream(Difficulty.values()).filter(Zombie.DOOR_BREAKING_PREDICATE).toList(); -+ @Setting("zombie_villager") -+ public List zombieVillager = Arrays.stream(Difficulty.values()).filter(Zombie.DOOR_BREAKING_PREDICATE).toList(); -+ @Setting("zombified_piglin") -+ public List zombified_piglin = Arrays.stream(Difficulty.values()).filter(Zombie.DOOR_BREAKING_PREDICATE).toList(); -+ public List vindicator = Arrays.stream(Difficulty.values()).filter(Vindicator.DOOR_BREAKING_PREDICATE).toList(); -+ -+ // TODO remove when this becomes a proper map -+ public List get(EntityType type) { -+ return this.getOrDefault(type, null); ++ private static final List> ZOMBIE_LIKE = List.of(EntityType.ZOMBIE, EntityType.HUSK, EntityType.ZOMBIE_VILLAGER, EntityType.ZOMBIFIED_PIGLIN); ++ @MergeMap ++ public Map, List> doorBreakingDifficulty = Util.make(new IdentityHashMap<>(), map -> { ++ for (final EntityType type : ZOMBIE_LIKE) { ++ map.put(type, Arrays.stream(Difficulty.values()).filter(Zombie.DOOR_BREAKING_PREDICATE).toList()); + } -+ -+ public List getOrDefault(EntityType type, List fallback) { -+ if (type == EntityType.ZOMBIE) { -+ return this.zombie; -+ } else if (type == EntityType.HUSK) { -+ return this.husk; -+ } else if (type == EntityType.ZOMBIE_VILLAGER) { -+ return this.zombieVillager; -+ } else if (type == EntityType.ZOMBIFIED_PIGLIN) { -+ return this.zombified_piglin; -+ } else if (type == EntityType.VINDICATOR) { -+ return this.vindicator; -+ } else { -+ return fallback; -+ } -+ } -+ } ++ map.put(EntityType.VINDICATOR, Arrays.stream(Difficulty.values()).filter(Vindicator.DOOR_BREAKING_PREDICATE).toList()); ++ }); + + public boolean disableCreeperLingeringEffect = false; + public boolean enderDragonsDeathAlwaysPlacesDragonEgg = false; @@ -3012,43 +3065,45 @@ index 0000000000000000000000000000000000000000..36ca88b677e1b55b41c52750948d5b6d +} diff --git a/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryEntrySerializer.java b/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryEntrySerializer.java new file mode 100644 -index 0000000000000000000000000000000000000000..18da824fd003c110083a6c08d5db75578171433c +index 0000000000000000000000000000000000000000..9073c619f14feb7a14bf32a504eb935f6d4cfe2e --- /dev/null +++ b/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryEntrySerializer.java -@@ -0,0 +1,62 @@ +@@ -0,0 +1,64 @@ +package io.papermc.paper.configuration.serializer.registry; + +import io.leangen.geantyref.TypeToken; ++import java.lang.reflect.Type; ++import java.util.function.Predicate; +import net.minecraft.core.Registry; ++import net.minecraft.core.RegistryAccess; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; -+import net.minecraft.server.MinecraftServer; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.spongepowered.configurate.serialize.ScalarSerializer; +import org.spongepowered.configurate.serialize.SerializationException; + -+import java.lang.reflect.Type; -+import java.util.function.Predicate; -+ +abstract class RegistryEntrySerializer extends ScalarSerializer { + ++ private final RegistryAccess registryAccess; + private final ResourceKey> registryKey; + private final boolean omitMinecraftNamespace; + -+ protected RegistryEntrySerializer(TypeToken type, ResourceKey> registryKey, boolean omitMinecraftNamespace) { ++ protected RegistryEntrySerializer(TypeToken type, final RegistryAccess registryAccess, ResourceKey> registryKey, boolean omitMinecraftNamespace) { + super(type); ++ this.registryAccess = registryAccess; + this.registryKey = registryKey; + this.omitMinecraftNamespace = omitMinecraftNamespace; + } + -+ protected RegistryEntrySerializer(Class type, ResourceKey> registryKey, boolean omitMinecraftNamespace) { ++ protected RegistryEntrySerializer(Class type, final RegistryAccess registryAccess, ResourceKey> registryKey, boolean omitMinecraftNamespace) { + super(type); ++ this.registryAccess = registryAccess; + this.registryKey = registryKey; + this.omitMinecraftNamespace = omitMinecraftNamespace; + } + + protected final Registry registry() { -+ return MinecraftServer.getServer().registryAccess().registryOrThrow(this.registryKey); // TODO don't depend on MinecraftServer#getServer ++ return this.registryAccess.registryOrThrow(this.registryKey); + } + + protected abstract T convertFromResourceKey(ResourceKey key) throws SerializationException; @@ -3080,7 +3135,7 @@ index 0000000000000000000000000000000000000000..18da824fd003c110083a6c08d5db7557 +} diff --git a/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryHolderSerializer.java b/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryHolderSerializer.java new file mode 100644 -index 0000000000000000000000000000000000000000..c03c1f277ff8167e8b3e4bfa0f4dfc86834f82f3 +index 0000000000000000000000000000000000000000..eeae35ede747e473ddba4ca1688f2f6cbc35ce7d --- /dev/null +++ b/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryHolderSerializer.java @@ -0,0 +1,34 @@ @@ -3089,22 +3144,22 @@ index 0000000000000000000000000000000000000000..c03c1f277ff8167e8b3e4bfa0f4dfc86 +import com.google.common.base.Preconditions; +import io.leangen.geantyref.TypeFactory; +import io.leangen.geantyref.TypeToken; ++import java.util.function.Function; +import net.minecraft.core.Holder; +import net.minecraft.core.Registry; ++import net.minecraft.core.RegistryAccess; +import net.minecraft.resources.ResourceKey; +import org.spongepowered.configurate.serialize.SerializationException; + -+import java.util.function.Function; -+ +public final class RegistryHolderSerializer extends RegistryEntrySerializer, T> { + + @SuppressWarnings("unchecked") -+ public RegistryHolderSerializer(TypeToken typeToken, ResourceKey> registryKey, boolean omitMinecraftNamespace) { -+ super((TypeToken>) TypeToken.get(TypeFactory.parameterizedClass(Holder.class, typeToken.getType())), registryKey, omitMinecraftNamespace); ++ public RegistryHolderSerializer(TypeToken typeToken, final RegistryAccess registryAccess, ResourceKey> registryKey, boolean omitMinecraftNamespace) { ++ super((TypeToken>) TypeToken.get(TypeFactory.parameterizedClass(Holder.class, typeToken.getType())), registryAccess, registryKey, omitMinecraftNamespace); + } + -+ public RegistryHolderSerializer(Class type, ResourceKey> registryKey, boolean omitMinecraftNamespace) { -+ this(TypeToken.get(type), registryKey, omitMinecraftNamespace); ++ public RegistryHolderSerializer(Class type, final RegistryAccess registryAccess, ResourceKey> registryKey, boolean omitMinecraftNamespace) { ++ this(TypeToken.get(type), registryAccess, registryKey, omitMinecraftNamespace); + Preconditions.checkArgument(type.getTypeParameters().length == 0, "%s must have 0 type parameters", type); + } + @@ -3120,14 +3175,15 @@ index 0000000000000000000000000000000000000000..c03c1f277ff8167e8b3e4bfa0f4dfc86 +} diff --git a/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryValueSerializer.java b/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryValueSerializer.java new file mode 100644 -index 0000000000000000000000000000000000000000..10d3dd361cd26dc849ebd53c1235aa8e4f7af04d +index 0000000000000000000000000000000000000000..718377ce91a010a48b2b4a5e59e02ee8a42107a7 --- /dev/null +++ b/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryValueSerializer.java -@@ -0,0 +1,34 @@ +@@ -0,0 +1,35 @@ +package io.papermc.paper.configuration.serializer.registry; + +import io.leangen.geantyref.TypeToken; +import net.minecraft.core.Registry; ++import net.minecraft.core.RegistryAccess; +import net.minecraft.resources.ResourceKey; +import org.spongepowered.configurate.serialize.SerializationException; + @@ -3136,12 +3192,12 @@ index 0000000000000000000000000000000000000000..10d3dd361cd26dc849ebd53c1235aa8e + */ +public final class RegistryValueSerializer extends RegistryEntrySerializer { + -+ public RegistryValueSerializer(TypeToken type, ResourceKey> registryKey, boolean omitMinecraftNamespace) { -+ super(type, registryKey, omitMinecraftNamespace); ++ public RegistryValueSerializer(TypeToken type, final RegistryAccess registryAccess, ResourceKey> registryKey, boolean omitMinecraftNamespace) { ++ super(type, registryAccess, registryKey, omitMinecraftNamespace); + } + -+ public RegistryValueSerializer(Class type, ResourceKey> registryKey, boolean omitMinecraftNamespace) { -+ super(type, registryKey, omitMinecraftNamespace); ++ public RegistryValueSerializer(Class type, final RegistryAccess registryAccess, ResourceKey> registryKey, boolean omitMinecraftNamespace) { ++ super(type, registryAccess, registryKey, omitMinecraftNamespace); + } + + @Override @@ -3436,10 +3492,10 @@ index 0000000000000000000000000000000000000000..ef0e834c164b0ccc1a61b349348e6799 +} diff --git a/src/main/java/io/papermc/paper/configuration/transformation/global/versioned/V29_LogIPs.java b/src/main/java/io/papermc/paper/configuration/transformation/global/versioned/V29_LogIPs.java new file mode 100644 -index 0000000000000000000000000000000000000000..f250ea5acd2edce924ee52b8ec16a23261f5e90d +index 0000000000000000000000000000000000000000..90071acf589fb2fa1c3480883165b429db54df69 --- /dev/null +++ b/src/main/java/io/papermc/paper/configuration/transformation/global/versioned/V29_LogIPs.java -@@ -0,0 +1,46 @@ +@@ -0,0 +1,45 @@ +package io.papermc.paper.configuration.transformation.global.versioned; + +import net.minecraft.server.MinecraftServer; @@ -3468,9 +3524,8 @@ index 0000000000000000000000000000000000000000..f250ea5acd2edce924ee52b8ec16a232 + builder.addVersion(VERSION, ConfigurationTransformation.builder().addAction(PATH, INSTANCE).build()); + } + -+ @Nullable + @Override -+ public Object[] visitPath(final NodePath path, final ConfigurationNode value) throws ConfigurateException { ++ public Object @Nullable [] visitPath(final NodePath path, final ConfigurationNode value) throws ConfigurateException { + DedicatedServer server = ((DedicatedServer) MinecraftServer.getServer()); + + boolean val = value.getBoolean(server.settings.getProperties().logIPs); @@ -4832,7 +4887,7 @@ index 71e7beac6cf1e0f813d5ff3e9c51c13491be7139..f1cc27809c1e8612f7c4fa912f5e39c0 @Nullable diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index e62eb92b63c027dfa431f8cc241ab968a3abf3f4..65ea4d909059387e6718ea68a3d9408556d26cbe 100644 +index e62eb92b63c027dfa431f8cc241ab968a3abf3f4..45657deb1ab3ebdfacf2a9bbb591a9a14236840c 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 @@ -4840,8 +4895,8 @@ index e62eb92b63c027dfa431f8cc241ab968a3abf3f4..65ea4d909059387e6718ea68a3d94085 org.spigotmc.SpigotConfig.registerCommands(); // Spigot end + // Paper start -+ paperConfigurations.initializeGlobalConfiguration(); -+ paperConfigurations.initializeWorldDefaultsConfiguration(); ++ paperConfigurations.initializeGlobalConfiguration(this.registryAccess()); ++ paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); + // Paper end this.setPvpAllowed(dedicatedserverproperties.pvp); @@ -4859,7 +4914,7 @@ index 37ab411817008d4e6194e177d88d50931e53b42e..ca23639f15107ccd43b874ae38fa3727 } // 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 c8e5e99d46c711efa90e446689e55267c70c7254..10968eb004ee01c4fb72aeb93f058747b02998b9 100644 +index c8e5e99d46c711efa90e446689e55267c70c7254..64522a15ecb73087222b33ffb13e29ac048b62a7 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -234,7 +234,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -4867,7 +4922,7 @@ index c8e5e99d46c711efa90e446689e55267c70c7254..10968eb004ee01c4fb72aeb93f058747 // 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))); // 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 this.pvpMode = minecraftserver.isPvpAllowed(); this.convertable = convertable_conversionsession; this.uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile()); diff --git a/patches/server/0011-Paper-command.patch b/patches/server/0011-Paper-command.patch index 952a527203..62d96ccc95 100644 --- a/patches/server/0011-Paper-command.patch +++ b/patches/server/0011-Paper-command.patch @@ -605,13 +605,13 @@ 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 65ea4d909059387e6718ea68a3d9408556d26cbe..d013d1ee9c5f75fc25ee4ae285c738728c16f43b 100644 +index 45657deb1ab3ebdfacf2a9bbb591a9a14236840c..7de6d496b40bbef5b628f1f08163ad24bd48c5c5 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(); - paperConfigurations.initializeWorldDefaultsConfiguration(); + paperConfigurations.initializeGlobalConfiguration(this.registryAccess()); + paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); + io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper end diff --git a/patches/server/0012-Paper-Metrics.patch b/patches/server/0012-Paper-Metrics.patch index a128577e17..529e059814 100644 --- a/patches/server/0012-Paper-Metrics.patch +++ b/patches/server/0012-Paper-Metrics.patch @@ -698,19 +698,19 @@ 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 95a4bcd09f3a9d462ff4c92431c07e3d3f55befc..ff3f00cf1d5180f83b16acac5676aa22cd967c8a 100644 +index 7de6d496b40bbef5b628f1f08163ad24bd48c5c5..672c9d304f448922c5a50c725ac1f0dd988b1853 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(); - paperConfigurations.initializeWorldDefaultsConfiguration(); + paperConfigurations.initializeGlobalConfiguration(this.registryAccess()); + paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); io.papermc.paper.command.PaperCommands.registerCommands(this); + com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper end this.setPvpAllowed(dedicatedserverproperties.pvp); diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java -index 83eabc34d952bbb13ec4b4bdcf34f647189c0b46..0a0aa6de31a94a701074cc5f43c94be7515a185c 100644 +index 1d066ce7dcf5f548c2a34d308d4422ab4fd02e5a..0fca20580d81c461e903c8cbd1cf090f5d5083c6 100644 --- a/src/main/java/org/spigotmc/SpigotConfig.java +++ b/src/main/java/org/spigotmc/SpigotConfig.java @@ -83,6 +83,7 @@ public class SpigotConfig 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 a83c0451ea..5eb62e175b 100644 --- a/patches/server/0029-Add-version-history-to-version-command.patch +++ b/patches/server/0029-Add-version-history-to-version-command.patch @@ -209,11 +209,11 @@ 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 71da1294cf3b09e53e3e846d59b3bf27a8dca618..b77cbdd926cd54a4bae89e0d5a21e7d139bc0c63 100644 +index 64958f6cb9162de791ac90e08b19368a7fc59064..dbe57c172ed57694912ef940024f8f33577e92bd 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(); + 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 diff --git a/patches/server/0237-Add-Early-Warning-Feature-to-WatchDog.patch b/patches/server/0237-Add-Early-Warning-Feature-to-WatchDog.patch index 40194b178d..3328925b2d 100644 --- a/patches/server/0237-Add-Early-Warning-Feature-to-WatchDog.patch +++ b/patches/server/0237-Add-Early-Warning-Feature-to-WatchDog.patch @@ -21,19 +21,19 @@ index beebc3ed13b200a0d6585387bb7e06a6aaa07940..88c1c7d0dd8efddcde6d8d81cb89b09c long start = System.nanoTime(), curTime, tickSection = start; // Paper - Further improve server tick loop lastTick = start - TICK_TIME; // Paper diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index b916f11cb3799aecf1edd9c2002f4c631754e89f..e3754d916ce38d0e0e8b8dbb623016ee6ebf4800 100644 +index 567c8fdbb0e21ec9cfc511f8c7487340785d3c62..3e0217cb096ba7a8f589c052db170b84e4d41ddf 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java @@ -197,6 +197,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface // Paper start - paperConfigurations.initializeGlobalConfiguration(); - paperConfigurations.initializeWorldDefaultsConfiguration(); + paperConfigurations.initializeGlobalConfiguration(this.registryAccess()); + paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); + 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(); com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // load version history now diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 0dc45f47960eff60f5d779ee88d49f7477c41944..c32315e6cd06ff02fe2a2c6c3f6f1c3c925147f9 100644 +index 1b903cb9fb0ccbc0e282cad1f6638683ea9e3337..c073f455de6c0b484f5b2e3dcf5e2a11d0d0dc5f 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -919,6 +919,7 @@ public final class CraftServer implements Server { diff --git a/patches/server/0342-Anti-Xray.patch b/patches/server/0342-Anti-Xray.patch index 4e34895245..7c55b57f94 100644 --- a/patches/server/0342-Anti-Xray.patch +++ b/patches/server/0342-Anti-Xray.patch @@ -199,21 +199,27 @@ index 0000000000000000000000000000000000000000..52d2e2b744f91914802506e52a071617 +} diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java new file mode 100644 -index 0000000000000000000000000000000000000000..42fdce97d99618a53f2e9c51804ff2205b574f69 +index 0000000000000000000000000000000000000000..e7fe98ea30ae6d0baea3ec1f9f98a89502a49a12 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java -@@ -0,0 +1,672 @@ +@@ -0,0 +1,676 @@ +package com.destroystokyo.paper.antixray; + +import io.papermc.paper.configuration.WorldConfiguration; +import io.papermc.paper.configuration.type.EngineMode; ++import java.util.ArrayList; ++import java.util.LinkedHashSet; ++import java.util.LinkedList; ++import java.util.List; ++import java.util.Set; ++import java.util.concurrent.Executor; ++import java.util.concurrent.ThreadLocalRandom; ++import java.util.function.IntSupplier; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; -+import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; +import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket; -+import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; @@ -225,14 +231,14 @@ index 0000000000000000000000000000000000000000..42fdce97d99618a53f2e9c51804ff220 +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.EntityBlock; +import net.minecraft.world.level.block.state.BlockState; -+import net.minecraft.world.level.chunk.*; ++import net.minecraft.world.level.chunk.EmptyLevelChunk; ++import net.minecraft.world.level.chunk.GlobalPalette; ++import net.minecraft.world.level.chunk.LevelChunk; ++import net.minecraft.world.level.chunk.LevelChunkSection; ++import net.minecraft.world.level.chunk.MissingPaletteEntryException; ++import net.minecraft.world.level.chunk.Palette; +import org.bukkit.Bukkit; + -+import java.util.*; -+import java.util.concurrent.Executor; -+import java.util.concurrent.ThreadLocalRandom; -+import java.util.function.IntSupplier; -+ +public final class ChunkPacketBlockControllerAntiXray extends ChunkPacketBlockController { + + private static final Palette GLOBAL_BLOCKSTATE_PALETTE = new GlobalPalette<>(Block.BLOCK_STATE_REGISTRY); @@ -265,7 +271,7 @@ index 0000000000000000000000000000000000000000..42fdce97d99618a53f2e9c51804ff220 + maxBlockHeight = paperWorldConfig.maxBlockHeight >> 4 << 4; + updateRadius = paperWorldConfig.updateRadius; + usePermission = paperWorldConfig.usePermission; -+ List toObfuscate; ++ List toObfuscate; + + if (engineMode == EngineMode.HIDE) { + toObfuscate = paperWorldConfig.hiddenBlocks; @@ -284,11 +290,10 @@ index 0000000000000000000000000000000000000000..42fdce97d99618a53f2e9c51804ff220 + toObfuscate = new ArrayList<>(paperWorldConfig.replacementBlocks); + List presetBlockStateList = new LinkedList<>(); + -+ for (String id : paperWorldConfig.hiddenBlocks) { -+ Block block = BuiltInRegistries.BLOCK.getOptional(new ResourceLocation(id)).orElse(null); ++ for (Block block : paperWorldConfig.hiddenBlocks) { + -+ if (block != null && !(block instanceof EntityBlock)) { -+ toObfuscate.add(id); ++ if (!(block instanceof EntityBlock)) { ++ toObfuscate.add(block); + presetBlockStateList.add(block.defaultBlockState()); + } + } @@ -315,8 +320,7 @@ index 0000000000000000000000000000000000000000..42fdce97d99618a53f2e9c51804ff220 + presetBlockStateBitsEndStoneGlobal = null; + } + -+ for (String id : toObfuscate) { -+ Block block = BuiltInRegistries.BLOCK.getOptional(new ResourceLocation(id)).orElse(null); ++ for (Block block : toObfuscate) { + + // Don't obfuscate air because air causes unnecessary block updates and causes block updates to fail in the void + if (block != null && !block.defaultBlockState().isAir()) { @@ -1100,15 +1104,15 @@ index be89e5b8c1ea7f85aef267a15986affa5fa1fd4b..43472855136f26b282d94fd241853d86 public ClientboundLevelChunkWithLightPacket(FriendlyByteBuf buf) { diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 82510154e6a0cef509316b1f8c71021cca39a323..85a2a237c4f84120d0a148c17b4b602c2c8c55e1 100644 +index 88cde9de26d3da3d863a9d44f5c127eed0a1f4b6..90c80bc7fc7d6f9b91d9f9953d19eef021435780 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -566,7 +566,7 @@ public class ServerLevel extends Level implements WorldGenLevel { // Holder holder = worlddimension.type(); // CraftBukkit - decompile error // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error -- 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))); // 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)), 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 ++ 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 this.pvpMode = minecraftserver.isPvpAllowed(); this.convertable = convertable_conversionsession; this.uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile()); @@ -1554,7 +1558,7 @@ index 593cfd68dc0f3679c684b6a1d2036419d4f3bc0c..b4b2f961d1e4f8b5b199052efefd96bc private static final byte[] EMPTY_LIGHT = new byte[2048]; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 4a5b18b4e9e664687c1136c5f1a97b8f50f87bf2..212d8473458ce830804f7a7a2848d2df6f4bb3ba 100644 +index c77e36393a8aaea5954a0ab0fb21f0b6f8d14aee..0e050180f4d35177c7e13dc439813f9fa8ce1d18 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -2341,7 +2341,7 @@ public final class CraftServer implements Server { diff --git a/patches/server/0391-Deobfuscate-stacktraces-in-log-messages-crash-report.patch b/patches/server/0391-Deobfuscate-stacktraces-in-log-messages-crash-report.patch index 9908bd56db..33b9fd128a 100644 --- a/patches/server/0391-Deobfuscate-stacktraces-in-log-messages-crash-report.patch +++ b/patches/server/0391-Deobfuscate-stacktraces-in-log-messages-crash-report.patch @@ -544,7 +544,7 @@ 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 378a6665159b3e62062df4ded024bcc1604f5300..474492c3f02f99e801885a983b9c110a8656c7b5 100644 +index fce3edc97c7df45389bb3754f873a314d42929e4..557fc4e380c00bc2ca34381b36eb3d6a38177209 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 @@ -552,11 +552,11 @@ index 378a6665159b3e62062df4ded024bcc1604f5300..474492c3f02f99e801885a983b9c110a // Spigot end // Paper start + io.papermc.paper.util.ObfHelper.INSTANCE.getClass(); // Paper - load mappings for stacktrace deobf and etc. - paperConfigurations.initializeGlobalConfiguration(); - paperConfigurations.initializeWorldDefaultsConfiguration(); + paperConfigurations.initializeGlobalConfiguration(this.registryAccess()); + paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); org.spigotmc.WatchdogThread.doStart(org.spigotmc.SpigotConfig.timeoutTime, org.spigotmc.SpigotConfig.restartOnCrash); diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index f58ec7dd3ce18f916d0a2fe08a137cdaf111cbc1..754e8de31e27264deebc94b1d3a9a51b5ca7e965 100644 +index 0353b3e3a9d9a0bd44f48a61a02811ec0bad186a..58a44898144af605e6e7d9253d99149ddc12bcbd 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -221,7 +221,9 @@ public class ServerLevel extends Level implements WorldGenLevel { diff --git a/patches/server/0555-fix-converting-txt-to-json-file.patch b/patches/server/0555-fix-converting-txt-to-json-file.patch index 25987960fd..b90cade101 100644 --- a/patches/server/0555-fix-converting-txt-to-json-file.patch +++ b/patches/server/0555-fix-converting-txt-to-json-file.patch @@ -21,13 +21,13 @@ 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 6d7095a62f30b18bc8fb8dbc5a0f3331980b7140..2546136ecfc94a8220932a04993ffa46380aba7e 100644 +index 9e631002278e21f1e0a3989573e7d5b2e1a82dd8..4a088f998befc0f3e21f28da74bba14475b0e1c8 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(); - paperConfigurations.initializeWorldDefaultsConfiguration(); + paperConfigurations.initializeGlobalConfiguration(this.registryAccess()); + paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); + // Paper start - moved up to right after PlayerList creation but before file load/save + if (this.convertOldUsers()) { + this.getProfileCache().save(false); // Paper