diff --git a/patches/server/Paper-Plugins.patch b/patches/server/Paper-Plugins.patch index 1a3efcae08..761cc4df4f 100644 --- a/patches/server/Paper-Plugins.patch +++ b/patches/server/Paper-Plugins.patch @@ -4878,6 +4878,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import io.papermc.paper.plugin.provider.configuration.type.DependencyConfiguration; +import io.papermc.paper.plugin.provider.configuration.type.PermissionConfiguration; +import io.papermc.paper.plugin.provider.configuration.type.PluginDependencyLifeCycle; ++import java.lang.reflect.Type; ++import java.util.function.Predicate; ++import org.bukkit.craftbukkit.util.ApiVersion; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionDefault; +import org.bukkit.plugin.PluginLoadOrder; @@ -4890,6 +4893,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.spongepowered.configurate.objectmapping.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.ObjectMapper; +import org.spongepowered.configurate.objectmapping.meta.Required; ++import org.spongepowered.configurate.serialize.ScalarSerializer; ++import org.spongepowered.configurate.serialize.SerializationException; +import org.spongepowered.configurate.yaml.NodeStyle; +import org.spongepowered.configurate.yaml.YamlConfigurationLoader; + @@ -4925,14 +4930,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @FlattenedResolver + private PermissionConfiguration permissionConfiguration = new PermissionConfiguration(PermissionDefault.OP, List.of()); + @Required -+ @PluginConfigConstraints.PluginVersion -+ private String apiVersion; ++ private ApiVersion apiVersion; + + private Map> dependencies = new EnumMap<>(PluginDependencyLifeCycle.class); + + public PaperPluginMeta() { + } + ++ static final ApiVersion MINIMUM = ApiVersion.getOrCreateVersion("1.19"); + public static PaperPluginMeta create(BufferedReader reader) throws ConfigurateException { + YamlConfigurationLoader loader = YamlConfigurationLoader.builder() + .indent(2) @@ -4943,6 +4948,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + return options.serializers((serializers) -> { + serializers ++ .register(new ScalarSerializer<>(ApiVersion.class) { ++ @Override ++ public ApiVersion deserialize(final Type type, final Object obj) throws SerializationException { ++ try { ++ final ApiVersion version = ApiVersion.getOrCreateVersion(obj.toString()); ++ if (version.isOlderThan(MINIMUM)) { ++ throw new SerializationException(version + " is too old for a paper plugin!"); ++ } ++ return version; ++ } catch (final IllegalArgumentException e) { ++ throw new SerializationException(e); ++ } ++ } ++ ++ @Override ++ protected Object serialize(final ApiVersion item, final Predicate> typeSupported) { ++ return item.getVersionString(); ++ } ++ }) + .register(new EnumValueSerializer()) + .register(PermissionConfiguration.class, PermissionConfigurationSerializer.SERIALIZER) + .register(new ComponentSerializer()) @@ -4950,7 +4974,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + ObjectMapper.factoryBuilder() + .addConstraint(Constraint.class, new Constraint.Factory()) + .addConstraint(PluginConfigConstraints.PluginName.class, String.class, new PluginConfigConstraints.PluginName.Factory()) -+ .addConstraint(PluginConfigConstraints.PluginVersion.class, String.class, new PluginConfigConstraints.PluginVersion.Factory()) + .addConstraint(PluginConfigConstraints.PluginNameSpace.class, String.class, new PluginConfigConstraints.PluginNameSpace.Factory()) + .addNodeResolver(new FlattenedResolver.Factory()) + .build() @@ -5092,7 +5115,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public @NotNull String getAPIVersion() { -+ return this.apiVersion; ++ return this.apiVersion.getVersionString(); + } + + @Override @@ -5345,7 +5368,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +public final class PluginConfigConstraints { + + public static final Set RESERVED_KEYS = Set.of("bukkit", "minecraft", "mojang", "spigot", "paper"); -+ public static final Set VALID_PAPER_VERSIONS = Set.of("1.19", "1.20"); + + @Documented + @Retention(RetentionPolicy.RUNTIME) @@ -5393,24 +5415,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + } + } -+ -+ @Documented -+ @Retention(RetentionPolicy.RUNTIME) -+ @Target(ElementType.FIELD) -+ public @interface PluginVersion { -+ -+ final class Factory implements Constraint.Factory { -+ -+ @Override -+ public Constraint make(PluginVersion data, Type type) { -+ return value -> { -+ if (value != null && !VALID_PAPER_VERSIONS.contains(value)) { -+ throw new SerializationException("Provided plugin's version (%s) is not supported on this version.".formatted(value)); -+ } -+ }; -+ } -+ } -+ } +} diff --git a/src/main/java/io/papermc/paper/plugin/provider/configuration/type/DependencyConfiguration.java b/src/main/java/io/papermc/paper/plugin/provider/configuration/type/DependencyConfiguration.java new file mode 100644 @@ -7332,7 +7336,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + @Override + public boolean isSupportedApiVersion(String apiVersion) { -+ return apiVersion != null && SUPPORTED_API.contains(apiVersion); ++ if (apiVersion == null) return false; ++ final ApiVersion toCheck = ApiVersion.getOrCreateVersion(apiVersion); ++ final ApiVersion minimumVersion = MinecraftServer.getServer().server.minimumAPI; ++ ++ return !toCheck.isNewerThan(ApiVersion.CURRENT) && !toCheck.isOlderThan(minimumVersion); + } + // Paper end diff --git a/removed-patches-1-20-5/0042-fix-ItemMeta-removing-CustomModelData.patch b/removed-patches-1-20-5/0042-fix-ItemMeta-removing-CustomModelData.patch deleted file mode 100644 index 2889221beb..0000000000 --- a/removed-patches-1-20-5/0042-fix-ItemMeta-removing-CustomModelData.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic -Date: Tue, 2 Jan 2024 10:35:46 -0800 -Subject: [PATCH] fix ItemMeta removing CustomModelData - - -diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { - } - } - -- if (tag.contains(CraftMetaItem.CUSTOM_MODEL_DATA.NBT, CraftMagicNumbers.NBT.TAG_INT)) { -+ if (tag.contains(CraftMetaItem.CUSTOM_MODEL_DATA.NBT, CraftMagicNumbers.NBT.TAG_ANY_NUMBER)) { // Paper - correctly allow any number type - this.customModelData = tag.getInt(CraftMetaItem.CUSTOM_MODEL_DATA.NBT); - } - if (tag.contains(CraftMetaItem.BLOCK_DATA.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { diff --git a/removed-patches-1-20-5/0486-Cache-burn-durations.patch b/removed-patches-1-20-5/0486-Cache-burn-durations.patch deleted file mode 100644 index bdf0e3e625..0000000000 --- a/removed-patches-1-20-5/0486-Cache-burn-durations.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: lukas -Date: Sun, 27 Dec 2020 16:47:00 +0100 -Subject: [PATCH] Cache burn durations - - -diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -@@ -0,0 +0,0 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit - this.recipeType = recipeType; // Paper - cook speed multiplier API - } - -+ private static Map cachedBurnDurations = null; // Paper - cache burn durations - public static Map getFuel() { -+ // Paper start - cache burn durations -+ if(cachedBurnDurations != null) { -+ return cachedBurnDurations; -+ } -+ // Paper end - cache burn durations - Map map = Maps.newLinkedHashMap(); - - AbstractFurnaceBlockEntity.add(map, (ItemLike) Items.LAVA_BUCKET, 20000); -@@ -0,0 +0,0 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit - AbstractFurnaceBlockEntity.add(map, (ItemLike) Blocks.AZALEA, 100); - AbstractFurnaceBlockEntity.add(map, (ItemLike) Blocks.FLOWERING_AZALEA, 100); - AbstractFurnaceBlockEntity.add(map, (ItemLike) Blocks.MANGROVE_ROOTS, 300); -- return map; -+ // Paper start - cache burn durations -+ cachedBurnDurations = com.google.common.collect.ImmutableMap.copyOf(map); -+ return cachedBurnDurations; -+ // Paper end - cache burn durations - } - - // CraftBukkit start - add fields and methods