diff --git a/patches/api/Add-RegistryAccess-for-managing-registries.patch b/patches/api/Add-RegistryAccess-for-managing-registries.patch index 1913738ee3..0b128edeb0 100644 --- a/patches/api/Add-RegistryAccess-for-managing-registries.patch +++ b/patches/api/Add-RegistryAccess-for-managing-registries.patch @@ -289,7 +289,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 * @see Structure + * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#STRUCTURE} */ -- Registry STRUCTURE = Bukkit.getRegistry(Structure.class); +- Registry STRUCTURE = Objects.requireNonNull(Bukkit.getRegistry(Structure.class), "No registry present for Structure. This is a bug."); + @Deprecated(since = "1.20.6") // Paper + Registry STRUCTURE = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(Structure.class), "No registry present for Structure. This is a bug."); // Paper /** @@ -297,8 +297,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 * * @see StructureType */ -- Registry STRUCTURE_TYPE = Bukkit.getRegistry(StructureType.class); -+ Registry STRUCTURE_TYPE = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.STRUCTURE_TYPE); // Paper +- Registry STRUCTURE_TYPE = Objects.requireNonNull(Bukkit.getRegistry(StructureType.class), "No registry present for StructureType. This is a bug."); ++ Registry STRUCTURE_TYPE = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.STRUCTURE_TYPE), "No registry present for StructureType. This is a bug."); // Paper /** * Sound keys. * @@ -308,7 +308,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 * @see TrimMaterial + * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#TRIM_MATERIAL} */ -- Registry TRIM_MATERIAL = Bukkit.getRegistry(TrimMaterial.class); +- Registry TRIM_MATERIAL = Objects.requireNonNull(Bukkit.getRegistry(TrimMaterial.class), "No registry present for TrimMaterial. This is a bug."); + @Deprecated(since = "1.20.6") // Paper + Registry TRIM_MATERIAL = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(TrimMaterial.class), "No registry present for TrimMaterial. This is a bug."); // Paper /** @@ -317,7 +317,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 * @see TrimPattern + * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#TRIM_PATTERN} */ -- Registry TRIM_PATTERN = Bukkit.getRegistry(TrimPattern.class); +- Registry TRIM_PATTERN = Objects.requireNonNull(Bukkit.getRegistry(TrimPattern.class), "No registry present for TrimPattern. This is a bug."); + @Deprecated(since = "1.20.6") + Registry TRIM_PATTERN = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(TrimPattern.class), "No registry present for TrimPattern. This is a bug."); // Paper /** @@ -460,6 +460,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - @NotNull - @Override +- public Keyed getOrThrow(@NotNull NamespacedKey key) { +- Keyed keyed = get(key); +- +- Preconditions.checkArgument(keyed != null, "No %s registry entry found for key %s.", aClass, key); +- +- return keyed; +- } +- +- @NotNull +- @Override - public Stream stream() { - throw new UnsupportedOperationException("Not supported"); - } diff --git a/patches/api/Add-methods-to-get-translation-keys.patch b/patches/api/Add-methods-to-get-translation-keys.patch index d0b555ac00..1ffd838fb4 100644 --- a/patches/api/Add-methods-to-get-translation-keys.patch +++ b/patches/api/Add-methods-to-get-translation-keys.patch @@ -200,8 +200,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public static final MusicInstrument PONDER_GOAT_HORN = getInstrument("ponder_goat_horn"); public static final MusicInstrument SING_GOAT_HORN = getInstrument("sing_goat_horn"); @@ -0,0 +0,0 @@ public abstract class MusicInstrument implements Keyed { - - return instrument; + private static MusicInstrument getInstrument(@NotNull String key) { + return Registry.INSTRUMENT.getOrThrow(NamespacedKey.minecraft(key)); } + + // Paper start - translation key diff --git a/patches/api/Add-missing-wind-charge-damage-type.patch b/patches/api/Add-missing-wind-charge-damage-type.patch deleted file mode 100644 index 2a1fb0a45b..0000000000 --- a/patches/api/Add-missing-wind-charge-damage-type.patch +++ /dev/null @@ -1,18 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> -Date: Fri, 3 May 2024 22:56:12 +0200 -Subject: [PATCH] Add missing wind charge damage type - - -diff --git a/src/main/java/org/bukkit/damage/DamageType.java b/src/main/java/org/bukkit/damage/DamageType.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/damage/DamageType.java -+++ b/src/main/java/org/bukkit/damage/DamageType.java -@@ -0,0 +0,0 @@ public interface DamageType extends Keyed, Translatable { - public static final DamageType BAD_RESPAWN_POINT = getDamageType("bad_respawn_point"); - public static final DamageType OUTSIDE_BORDER = getDamageType("outside_border"); - public static final DamageType GENERIC_KILL = getDamageType("generic_kill"); -+ DamageType WIND_CHARGE = getDamageType("wind_charge"); // Paper - - @NotNull - private static DamageType getDamageType(@NotNull String key) { diff --git a/patches/api/Adventure.patch b/patches/api/Adventure.patch index 4530381b06..40fdb24632 100644 --- a/patches/api/Adventure.patch +++ b/patches/api/Adventure.patch @@ -1012,8 +1012,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/JukeboxSong.java +++ b/src/main/java/org/bukkit/JukeboxSong.java @@ -0,0 +0,0 @@ public interface JukeboxSong extends Keyed, Translatable { - private static JukeboxSong get(@NotNull String s) { - return Objects.requireNonNull(Registry.JUKEBOX_SONG.get(NamespacedKey.minecraft(s)), "Missing song " + s); + private static JukeboxSong get(@NotNull String key) { + return Registry.JUKEBOX_SONG.getOrThrow(NamespacedKey.minecraft(key)); } + + // Paper start - adventure @@ -4882,9 +4882,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/inventory/meta/trim/TrimMaterial.java +++ b/src/main/java/org/bukkit/inventory/meta/trim/TrimMaterial.java @@ -0,0 +0,0 @@ public interface TrimMaterial extends Keyed, Translatable { - * {@link Material#AMETHYST_SHARD}. - */ - public static final TrimMaterial AMETHYST = Registry.TRIM_MATERIAL.get(NamespacedKey.minecraft("amethyst")); + private static TrimMaterial getTrimMaterial(@NotNull String key) { + return Registry.TRIM_MATERIAL.getOrThrow(NamespacedKey.minecraft(key)); + } + + // Paper start - adventure + /** @@ -4908,9 +4908,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/inventory/meta/trim/TrimPattern.java +++ b/src/main/java/org/bukkit/inventory/meta/trim/TrimPattern.java @@ -0,0 +0,0 @@ public interface TrimPattern extends Keyed, Translatable { - * {@link Material#BOLT_ARMOR_TRIM_SMITHING_TEMPLATE}. - */ - public static final TrimPattern BOLT = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("bolt")); + private static TrimPattern getTrimPattern(@NotNull String key) { + return Registry.TRIM_PATTERN.getOrThrow(NamespacedKey.minecraft(key)); + } + + // Paper start - adventure + /** diff --git a/patches/api/Allow-plugins-to-use-SLF4J-for-logging.patch b/patches/api/Allow-plugins-to-use-SLF4J-for-logging.patch index a544343d4b..18eb3f32c1 100644 --- a/patches/api/Allow-plugins-to-use-SLF4J-for-logging.patch +++ b/patches/api/Allow-plugins-to-use-SLF4J-for-logging.patch @@ -33,8 +33,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + api("org.apache.logging.log4j:log4j-api:$log4jVersion") + api("org.slf4j:slf4j-api:$slf4jVersion") - implementation("org.ow2.asm:asm:9.7") - implementation("org.ow2.asm:asm-commons:9.7") + implementation("org.ow2.asm:asm:9.7.1") + implementation("org.ow2.asm:asm-commons:9.7.1") @@ -0,0 +0,0 @@ tasks.withType { "https://jd.advntr.dev/text-serializer-legacy/$adventureVersion/", "https://jd.advntr.dev/text-serializer-plain/$adventureVersion/", diff --git a/patches/api/Code-Generation.patch b/patches/api/Code-Generation.patch index 8578d9f0fd..3f50edfbf0 100644 --- a/patches/api/Code-Generation.patch +++ b/patches/api/Code-Generation.patch @@ -19,7 +19,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 java { @@ -0,0 +0,0 @@ dependencies { - testImplementation("org.ow2.asm:asm-tree:9.7") + testImplementation("org.ow2.asm:asm-tree:9.7.1") } +// Paper start diff --git a/patches/api/Convert-project-to-Gradle.patch b/patches/api/Convert-project-to-Gradle.patch index c09f55698c..37ea32927d 100644 --- a/patches/api/Convert-project-to-Gradle.patch +++ b/patches/api/Convert-project-to-Gradle.patch @@ -63,8 +63,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + testImplementation("org.apache.commons:commons-lang3:3.12.0") + testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") + testImplementation("org.hamcrest:hamcrest:2.2") -+ testImplementation("org.mockito:mockito-core:5.11.0") -+ testImplementation("org.ow2.asm:asm-tree:9.7") ++ testImplementation("org.mockito:mockito-core:5.14.1") ++ testImplementation("org.ow2.asm:asm-tree:9.7.1") +} + +configure { @@ -236,13 +236,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - org.mockito - mockito-core -- 5.11.0 +- 5.14.1 - test - - - org.ow2.asm - asm-tree -- 9.7 +- 9.7.1 - test - - diff --git a/patches/api/Fix-Spigot-annotation-mistakes.patch b/patches/api/Fix-Spigot-annotation-mistakes.patch index 68a3d170b4..67cd33c729 100644 --- a/patches/api/Fix-Spigot-annotation-mistakes.patch +++ b/patches/api/Fix-Spigot-annotation-mistakes.patch @@ -461,14 +461,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 * @see TrimMaterial */ - @ApiStatus.Experimental - Registry TRIM_MATERIAL = Bukkit.getRegistry(TrimMaterial.class); + Registry TRIM_MATERIAL = Objects.requireNonNull(Bukkit.getRegistry(TrimMaterial.class), "No registry present for TrimMaterial. This is a bug."); /** * Trim patterns. * * @see TrimPattern */ - @ApiStatus.Experimental - Registry TRIM_PATTERN = Bukkit.getRegistry(TrimPattern.class); + Registry TRIM_PATTERN = Objects.requireNonNull(Bukkit.getRegistry(TrimPattern.class), "No registry present for TrimPattern. This is a bug."); /** * Damage types. @@ -0,0 +0,0 @@ public interface Registry extends Iterable { diff --git a/patches/api/Fix-issues-with-recipe-API.patch b/patches/api/Fix-issues-with-recipe-API.patch index 90af74c515..f41bd02ba7 100644 --- a/patches/api/Fix-issues-with-recipe-API.patch +++ b/patches/api/Fix-issues-with-recipe-API.patch @@ -281,7 +281,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class SmithingRecipe implements Recipe, Keyed { */ @Deprecated - public SmithingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyDataComponents) { + public SmithingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @Nullable RecipeChoice base, @Nullable RecipeChoice addition, boolean copyDataComponents) { + com.google.common.base.Preconditions.checkArgument(!result.isEmpty() || this instanceof ComplexRecipe, "Recipe cannot have an empty result."); // Paper this.copyDataComponents = copyDataComponents; // Paper end @@ -289,11 +289,29 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.result = result; - this.base = base; - this.addition = addition; -+ this.base = base.validate(true).clone(); // Paper -+ this.addition = addition.validate(true).clone(); // Paper ++ this.base = base == null ? RecipeChoice.empty() : base.validate(true).clone(); // Paper ++ this.addition = addition == null ? RecipeChoice.empty() : addition.validate(true).clone(); // Paper } /** +@@ -0,0 +0,0 @@ public class SmithingRecipe implements Recipe, Keyed { + * + * @return base choice + */ +- @Nullable ++ @NotNull // Paper - fix issues with recipe api + public RecipeChoice getBase() { + return (base != null) ? base.clone() : null; + } +@@ -0,0 +0,0 @@ public class SmithingRecipe implements Recipe, Keyed { + * + * @return addition choice + */ +- @Nullable ++ @NotNull // Paper - fix issues with recipe api + public RecipeChoice getAddition() { + return (addition != null) ? addition.clone() : null; + } diff --git a/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java b/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java @@ -309,10 +327,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param base The base ingredient ({@link RecipeChoice#empty()} can be used) + * @param addition The addition ingredient ({@link RecipeChoice#empty()} can be used) */ - public SmithingTransformRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition) { +- public SmithingTransformRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @Nullable RecipeChoice template, @Nullable RecipeChoice base, @Nullable RecipeChoice addition) { ++ public SmithingTransformRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition) { // Paper - fix issues with recipe api - prevent null choices super(key, result, base, addition); - this.template = template; -+ this.template = template.validate(true).clone(); // Paper ++ this.template = template == null ? RecipeChoice.empty() : template.validate(true).clone(); // Paper - fix issues with recipe api - prevent null choices } // Paper start /** @@ -328,13 +347,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param addition The addition ingredient ({@link RecipeChoice#empty()} can be used) * @param copyDataComponents whether to copy the data components from the input base item to the output */ - public SmithingTransformRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyDataComponents) { +- public SmithingTransformRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @Nullable RecipeChoice template, @Nullable RecipeChoice base, @Nullable RecipeChoice addition, boolean copyDataComponents) { ++ public SmithingTransformRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyDataComponents) { super(key, result, base, addition, copyDataComponents); - this.template = template; -+ this.template = template.validate(true).clone(); ++ this.template = template == null ? RecipeChoice.empty() : template.validate(true).clone(); // Paper - fix issues with recipe api - prevent null choices } // Paper end +@@ -0,0 +0,0 @@ public class SmithingTransformRecipe extends SmithingRecipe { + * + * @return template choice + */ +- @Nullable ++ @NotNull // Paper - fix issues with recipe api - prevent null choices + public RecipeChoice getTemplate() { + return (template != null) ? template.clone() : null; + } diff --git a/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java b/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java @@ -350,10 +379,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param base The base ingredient ({@link RecipeChoice#empty()} can be used) + * @param addition The addition ingredient ({@link RecipeChoice#empty()} can be used) */ - public SmithingTrimRecipe(@NotNull NamespacedKey key, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition) { +- public SmithingTrimRecipe(@NotNull NamespacedKey key, @Nullable RecipeChoice template, @Nullable RecipeChoice base, @Nullable RecipeChoice addition) { ++ public SmithingTrimRecipe(@NotNull NamespacedKey key, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition) { // Paper - fix issues with recipe api - prevent null choices super(key, new ItemStack(Material.AIR), base, addition); - this.template = template; -+ this.template = template.validate(true).clone(); // Paper ++ this.template = template == null ? RecipeChoice.empty() : template.validate(true).clone(); // Paper } // Paper start /** @@ -368,13 +398,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param addition The addition ingredient ({@link RecipeChoice#empty()} can be used) * @param copyDataComponents whether to copy the data components from the input base item to the output */ - public SmithingTrimRecipe(@NotNull NamespacedKey key, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyDataComponents) { +- public SmithingTrimRecipe(@NotNull NamespacedKey key, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyDataComponents) { ++ public SmithingTrimRecipe(@NotNull NamespacedKey key, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyDataComponents) { // Paper - fix issues with recipe api - prevent null choices super(key, new ItemStack(Material.AIR), base, addition, copyDataComponents); - this.template = template; -+ this.template = template.validate(true).clone(); // Paper ++ this.template = template == null ? RecipeChoice.empty() : template.validate(true).clone(); // Paper } // Paper end +@@ -0,0 +0,0 @@ public class SmithingTrimRecipe extends SmithingRecipe implements ComplexRecipe + * + * @return template choice + */ +- @Nullable ++ @NotNull // Paper - fix issues with recipe api - prevent null choices + public RecipeChoice getTemplate() { + return (template != null) ? template.clone() : null; + } diff --git a/src/main/java/org/bukkit/inventory/StonecuttingRecipe.java b/src/main/java/org/bukkit/inventory/StonecuttingRecipe.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/StonecuttingRecipe.java diff --git a/patches/api/General-ItemMeta-fixes.patch b/patches/api/General-ItemMeta-fixes.patch index 2c8d895461..a7cef958ea 100644 --- a/patches/api/General-ItemMeta-fixes.patch +++ b/patches/api/General-ItemMeta-fixes.patch @@ -19,27 +19,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.flicker = flicker; this.trail = trail; this.colors = colors; -diff --git a/src/main/java/org/bukkit/inventory/ItemType.java b/src/main/java/org/bukkit/inventory/ItemType.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/inventory/ItemType.java -+++ b/src/main/java/org/bukkit/inventory/ItemType.java -@@ -0,0 +0,0 @@ import org.bukkit.inventory.meta.MapMeta; - import org.bukkit.inventory.meta.MusicInstrumentMeta; - import org.bukkit.inventory.meta.OminousBottleMeta; - import org.bukkit.inventory.meta.PotionMeta; -+import org.bukkit.inventory.meta.ShieldMeta; - import org.bukkit.inventory.meta.SkullMeta; - import org.bukkit.inventory.meta.SpawnEggMeta; - import org.bukkit.inventory.meta.SuspiciousStewMeta; -@@ -0,0 +0,0 @@ public interface ItemType extends Keyed, Translatable, net.kyori.adventure.trans - /** - * ItemMeta: {@link BlockStateMeta} - */ -- ItemType.Typed SHIELD = getItemType("shield"); -+ ItemType.Typed SHIELD = getItemType("shield"); // Paper - update shield to its new meta - ItemType.Typed TOTEM_OF_UNDYING = getItemType("totem_of_undying"); - ItemType.Typed SHULKER_SHELL = getItemType("shulker_shell"); - ItemType.Typed IRON_NUGGET = getItemType("iron_nugget"); diff --git a/src/main/java/org/bukkit/inventory/meta/CompassMeta.java b/src/main/java/org/bukkit/inventory/meta/CompassMeta.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/meta/CompassMeta.java diff --git a/patches/api/Improve-Registry.patch b/patches/api/Improve-Registry.patch index 818afdfe45..b1d7971fc2 100644 --- a/patches/api/Improve-Registry.patch +++ b/patches/api/Improve-Registry.patch @@ -32,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/MusicInstrument.java +++ b/src/main/java/org/bukkit/MusicInstrument.java @@ -0,0 +0,0 @@ public abstract class MusicInstrument implements Keyed, net.kyori.adventure.tran - return instrument; + return Registry.INSTRUMENT.getOrThrow(NamespacedKey.minecraft(key)); } + // Paper start - deprecate getKey @@ -130,7 +130,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end - improve Registry + /** - * Returns a new stream, which contains all registry items, which are registered to the registry. + * Get the object by its key. * @@ -0,0 +0,0 @@ public interface Registry extends Iterable { public Class getType() { diff --git a/patches/api/Introduce-registry-entry-and-builders.patch b/patches/api/Introduce-registry-entry-and-builders.patch index 6256102e0f..6f91370b9f 100644 --- a/patches/api/Introduce-registry-entry-and-builders.patch +++ b/patches/api/Introduce-registry-entry-and-builders.patch @@ -464,8 +464,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/GameEvent.java +++ b/src/main/java/org/bukkit/GameEvent.java @@ -0,0 +0,0 @@ public abstract class GameEvent implements Keyed { - - return gameEvent; + private static GameEvent getEvent(@NotNull String key) { + return Registry.GAME_EVENT.getOrThrow(NamespacedKey.minecraft(key)); } + // Paper start + /** diff --git a/patches/api/Material-API-additions.patch b/patches/api/Material-API-additions.patch index 6e56683c2f..f163129e8c 100644 --- a/patches/api/Material-API-additions.patch +++ b/patches/api/Material-API-additions.patch @@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // AIR(9648, 0), @@ -0,0 +0,0 @@ public enum Material implements Keyed, Translatable { - } + }); } + // Paper start diff --git a/patches/api/More-PotionEffectType-API.patch b/patches/api/More-PotionEffectType-API.patch index 53ecfaaf2e..1ab3f08233 100644 --- a/patches/api/More-PotionEffectType-API.patch +++ b/patches/api/More-PotionEffectType-API.patch @@ -19,25 +19,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @see org.bukkit.potion.PotionEffectType + */ -+ Registry POTION_EFFECT_TYPE = new Registry() { -+ -+ @Nullable -+ @Override -+ public org.bukkit.potion.PotionEffectType get(@NotNull NamespacedKey key) { -+ return org.bukkit.potion.PotionEffectType.getByKey(key); -+ } -+ -+ @NotNull -+ @Override -+ public Iterator iterator() { -+ return java.util.Arrays.stream(org.bukkit.potion.PotionEffectType.values()).iterator(); -+ } -+ -+ @Override -+ public @NotNull Stream stream() { -+ return StreamSupport.stream(this.spliterator(), false); -+ } -+ }; ++ Registry POTION_EFFECT_TYPE = EFFECT; + // Paper end - potion effect type registry /** * Get the object by its key. diff --git a/patches/api/Option-to-prevent-data-components-copy-in-smithing-r.patch b/patches/api/Option-to-prevent-data-components-copy-in-smithing-r.patch index 40ad864f46..909559a227 100644 --- a/patches/api/Option-to-prevent-data-components-copy-in-smithing-r.patch +++ b/patches/api/Option-to-prevent-data-components-copy-in-smithing-r.patch @@ -19,7 +19,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class SmithingRecipe implements Recipe, Keyed { */ @Deprecated - public SmithingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice base, @NotNull RecipeChoice addition) { + public SmithingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @Nullable RecipeChoice base, @Nullable RecipeChoice addition) { + // Paper start + this(key, result, base, addition, true); + } @@ -34,7 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @deprecated use {@link SmithingTrimRecipe} or {@link SmithingTransformRecipe} + */ + @Deprecated -+ public SmithingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyDataComponents) { ++ public SmithingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @Nullable RecipeChoice base, @Nullable RecipeChoice addition, boolean copyDataComponents) { + this.copyDataComponents = copyDataComponents; + // Paper end this.key = key; @@ -86,7 +86,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param addition The addition ingredient + * @param copyDataComponents whether to copy the data components from the input base item to the output + */ -+ public SmithingTransformRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyDataComponents) { ++ public SmithingTransformRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @Nullable RecipeChoice template, @Nullable RecipeChoice base, @Nullable RecipeChoice addition, boolean copyDataComponents) { + super(key, result, base, addition, copyDataComponents); + this.template = template; + } diff --git a/patches/api/Paper-Plugins.patch b/patches/api/Paper-Plugins.patch index 0ce54bce47..cf26d84991 100644 --- a/patches/api/Paper-Plugins.patch +++ b/patches/api/Paper-Plugins.patch @@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -0,0 +0,0 @@ dependencies { - implementation("org.ow2.asm:asm-commons:9.7") + implementation("org.ow2.asm:asm-commons:9.7.1") // Paper end - compileOnly("org.apache.maven:maven-resolver-provider:3.9.6") diff --git a/patches/api/Registry-Modification-API.patch b/patches/api/Registry-Modification-API.patch index 049c400f82..e87cdc5a81 100644 --- a/patches/api/Registry-Modification-API.patch +++ b/patches/api/Registry-Modification-API.patch @@ -873,7 +873,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end - RegistrySet API + /** - * Returns a new stream, which contains all registry items, which are registered to the registry. + * Get the object by its key. * @@ -0,0 +0,0 @@ public interface Registry extends Iterable { return value.getKey(); diff --git a/patches/api/Use-ASM-for-event-executors.patch b/patches/api/Use-ASM-for-event-executors.patch index 1b68c017df..bf05f69402 100644 --- a/patches/api/Use-ASM-for-event-executors.patch +++ b/patches/api/Use-ASM-for-event-executors.patch @@ -14,8 +14,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 apiAndDocs("net.kyori:adventure-text-serializer-plain") apiAndDocs("net.kyori:adventure-text-logger-slf4j") + -+ implementation("org.ow2.asm:asm:9.7") -+ implementation("org.ow2.asm:asm-commons:9.7") ++ implementation("org.ow2.asm:asm:9.7.1") ++ implementation("org.ow2.asm:asm-commons:9.7.1") // Paper end compileOnly("org.apache.maven:maven-resolver-provider:3.9.6") diff --git a/patches/server/Add-AnvilView-bypassEnchantmentLevelRestriction.patch b/patches/server/Add-AnvilView-bypassEnchantmentLevelRestriction.patch index ec86441507..9dedf84c9a 100644 --- a/patches/server/Add-AnvilView-bypassEnchantmentLevelRestriction.patch +++ b/patches/server/Add-AnvilView-bypassEnchantmentLevelRestriction.patch @@ -32,7 +32,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/view/CraftAnvilView. index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/view/CraftAnvilView.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/view/CraftAnvilView.java -@@ -0,0 +0,0 @@ public class CraftAnvilView extends CraftInventoryView implements Anv +@@ -0,0 +0,0 @@ public class CraftAnvilView extends CraftInventoryView= this.getMaxDamage()) { Item item = this.getItem(); // CraftBukkit start - Check for item breaking -- if (this.count == 1) { +- if (this.count == 1 && player != null) { - org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent(player, this); -+ if (this.count == 1 && player instanceof final ServerPlayer serverPlayer) { // Paper - Add EntityDamageItemEvent ++ if (this.count == 1 && player != null && player instanceof final ServerPlayer serverPlayer) { // Paper - Add EntityDamageItemEvent + org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent(serverPlayer, this); // Paper - Add EntityDamageItemEvent } // CraftBukkit end diff --git a/patches/server/Add-FeatureFlag-API.patch b/patches/server/Add-FeatureFlag-API.patch index 7e1b2de64f..514de38bab 100644 --- a/patches/server/Add-FeatureFlag-API.patch +++ b/patches/server/Add-FeatureFlag-API.patch @@ -338,7 +338,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.Set; +import java.util.stream.Stream; +import net.kyori.adventure.key.Key; -+import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.flag.FeatureElement; @@ -346,7 +345,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.minecraft.world.flag.FeatureFlags; +import org.bukkit.FeatureFlag; +import org.bukkit.Keyed; -+import org.bukkit.support.AbstractTestingBase; ++import org.bukkit.support.RegistryHelper; ++import org.bukkit.support.environment.AllFeatures; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; @@ -358,7 +358,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; + -+class FeatureFlagTest extends AbstractTestingBase { ++@AllFeatures ++class FeatureFlagTest { + + @Test + void testFeatureFlagParity() { @@ -409,7 +410,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + static Stream> nonFeatureFilteredRegistries() { -+ return AbstractTestingBase.REGISTRY_CUSTOM.registries().filter(r -> { ++ return RegistryHelper.getRegistry().registries().filter(r -> { + final RegistryEntry entry = PaperRegistries.getEntry(r.key()); + // has an API registry and isn't a filtered registry + return entry != null && !FeatureElement.FILTERED_REGISTRIES.contains(r.key()); diff --git a/patches/server/Add-PlayerArmorChangeEvent.patch b/patches/server/Add-PlayerArmorChangeEvent.patch index ef8ffc9dd5..6269595f95 100644 --- a/patches/server/Add-PlayerArmorChangeEvent.patch +++ b/patches/server/Add-PlayerArmorChangeEvent.patch @@ -40,7 +40,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.minecraft.world.item.ItemStack; +import org.bukkit.Material; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; -+import org.bukkit.support.AbstractTestingBase; ++import org.bukkit.support.environment.AllFeatures; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + @@ -48,7 +48,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + -+public class ArmorSlotTypeMaterialTest extends AbstractTestingBase { ++@AllFeatures ++public class ArmorSlotTypeMaterialTest { + + public static Stream slotTypeParams() { + final List parameters = new ArrayList<>(); diff --git a/patches/server/Add-RegistryAccess-for-managing-Registries.patch b/patches/server/Add-RegistryAccess-for-managing-Registries.patch index 671decaca1..1cded328ac 100644 --- a/patches/server/Add-RegistryAccess-for-managing-Registries.patch +++ b/patches/server/Add-RegistryAccess-for-managing-Registries.patch @@ -568,6 +568,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.Iterator; +import java.util.function.Supplier; +import java.util.stream.Stream; ++import net.kyori.adventure.key.Key; +import org.bukkit.Keyed; +import org.bukkit.NamespacedKey; +import org.bukkit.Registry; @@ -604,6 +605,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override ++ public @NotNull T getOrThrow(@NotNull final NamespacedKey key) { ++ return this.delegate().getOrThrow(key); ++ } ++ ++ @Override + public Iterator iterator() { + return this.delegate().iterator(); + } @@ -914,11 +920,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java @@ -0,0 +0,0 @@ public class Commodore { - public static byte[] convert(byte[] b, final String pluginName, final ApiVersion pluginVersion, final Set activeCompatibilities) { + public byte[] convert(byte[] b, final String pluginName, final ApiVersion pluginVersion, final Set activeCompatibilities) { final boolean modern = pluginVersion.isNewerThanOrSameAs(ApiVersion.FLATTENING); - final boolean enumCompatibility = pluginVersion.isOlderThanOrSameAs(ApiVersion.getOrCreateVersion("1.20.6")) && activeCompatibilities.contains("enum-compatibility-mode"); ClassReader cr = new ClassReader(b); - ClassWriter cw = new ClassWriter(0); // TODO 2024-06-22: Open PR to ASM to included interface in handle hash + ClassWriter cw = new ClassWriter(cr, 0); - List methodEnumSignatures = Commodore.getMethodSignatures(b); - Multimap enumLessToEnum = HashMultimap.create(); @@ -981,13 +987,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.GameEvent; +import org.bukkit.MusicInstrument; +import org.bukkit.inventory.meta.trim.TrimPattern; -+import org.bukkit.support.AbstractTestingBase; ++import org.bukkit.support.environment.VanillaFeature; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertSame; + +@Deprecated -+class LegacyRegistryIdentifierTest extends AbstractTestingBase { ++@VanillaFeature ++class LegacyRegistryIdentifierTest { + + @Test + void testSeveralConversions() { @@ -1009,8 +1016,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; -+import org.bukkit.Keyed; - import org.bukkit.support.AbstractTestingBase; +-import org.bukkit.support.AbstractTestingBase; ++import org.bukkit.support.RegistryHelper; ++import org.bukkit.support.environment.AllFeatures; +import org.checkerframework.checker.nullness.qual.Nullable; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.params.ParameterizedTest; @@ -1019,10 +1027,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; - class RegistryKeyTest extends AbstractTestingBase { -@@ -0,0 +0,0 @@ class RegistryKeyTest extends AbstractTestingBase { + @AllFeatures +@@ -0,0 +0,0 @@ class RegistryKeyTest { void testApiRegistryKeysExist(final RegistryKey key) { - final Optional> registry = AbstractTestingBase.REGISTRY_CUSTOM.registry(ResourceKey.createRegistryKey(ResourceLocation.parse(key.key().asString()))); + final Optional> registry = RegistryHelper.getRegistry().registry(ResourceKey.createRegistryKey(ResourceLocation.parse(key.key().asString()))); assertTrue(registry.isPresent(), "Missing vanilla registry for " + key.key().asString()); + } @@ -1037,11 +1045,11 @@ diff --git a/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java b/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java +++ b/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java -@@ -0,0 +0,0 @@ public class RegistryArgumentAddedTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class RegistryArgumentAddedTest { // Make sure every registry is created Class.forName(Registry.class.getName()); -- Set> loadedRegistries = new HashSet<>(DummyServer.registers.keySet()); +- Set> loadedRegistries = new HashSet<>(AllFeaturesExtension.getRealRegistries().keySet()); - Set> notFound = new HashSet<>(); + // Paper start + Set> loadedRegistries = java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<>()); @@ -1062,7 +1070,7 @@ diff --git a/src/test/java/org/bukkit/registry/RegistryConversionTest.java b/src index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/test/java/org/bukkit/registry/RegistryConversionTest.java +++ b/src/test/java/org/bukkit/registry/RegistryConversionTest.java -@@ -0,0 +0,0 @@ public class RegistryConversionTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class RegistryConversionTest { @Order(1) @RegistriesTest @@ -1074,7 +1082,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 for (Keyed item : registry) { if (!(item instanceof Handleable)) { -@@ -0,0 +0,0 @@ public class RegistryConversionTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class RegistryConversionTest { @Order(2) @RegistriesTest @@ -1083,7 +1091,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Class craftClazz, Class minecraftClazz, boolean newMethod) { String methodName = (newMethod) ? RegistryConversionTest.MINECRAFT_TO_BUKKIT_NEW : RegistryConversionTest.MINECRAFT_TO_BUKKIT; Method method = null; -@@ -0,0 +0,0 @@ public class RegistryConversionTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class RegistryConversionTest { @Order(2) @RegistriesTest @@ -1092,7 +1100,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Class craftClazz, Class minecraftClazz, boolean newMethod) { String methodName = (newMethod) ? RegistryConversionTest.BUKKIT_TO_MINECRAFT_NEW : RegistryConversionTest.BUKKIT_TO_MINECRAFT; Method method = null; -@@ -0,0 +0,0 @@ public class RegistryConversionTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class RegistryConversionTest { """, minecraftClazz.getName(), methodName, clazz.getSimpleName()); } @@ -1104,7 +1112,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.checkValidMinecraftToBukkit(clazz); try { -@@ -0,0 +0,0 @@ public class RegistryConversionTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class RegistryConversionTest { @Order(3) @RegistriesTest @@ -1113,7 +1121,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.checkValidBukkitToMinecraft(clazz); try { -@@ -0,0 +0,0 @@ public class RegistryConversionTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class RegistryConversionTest { @Order(3) @RegistriesTest @@ -1130,7 +1138,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Keyed bukkit = (Keyed) arguments[0]; Object minecraft = arguments[1]; -@@ -0,0 +0,0 @@ public class RegistryConversionTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class RegistryConversionTest { @Order(3) @RegistriesTest @@ -1147,7 +1155,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Keyed bukkit = (Keyed) arguments[0]; Object minecraft = arguments[1]; -@@ -0,0 +0,0 @@ public class RegistryConversionTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class RegistryConversionTest { */ @Order(3) @RegistriesTest @@ -1156,22 +1164,85 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Class craftClazz, Class minecraftClazz) throws IllegalAccessException { this.checkValidMinecraftToBukkit(clazz); -diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java +diff --git a/src/test/java/org/bukkit/support/extension/AllFeaturesExtension.java b/src/test/java/org/bukkit/support/extension/AllFeaturesExtension.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/test/java/org/bukkit/support/DummyServer.java -+++ b/src/test/java/org/bukkit/support/DummyServer.java -@@ -0,0 +0,0 @@ public final class DummyServer { - when(instance.getLootTable(any())).then(mock -> new CraftLootTable(mock.getArgument(0), - AbstractTestingBase.DATA_PACK.fullRegistries().getLootTable(ResourceKey.create(Registries.LOOT_TABLE, CraftNamespacedKey.toMinecraft(mock.getArgument(0)))))); +--- a/src/test/java/org/bukkit/support/extension/AllFeaturesExtension.java ++++ b/src/test/java/org/bukkit/support/extension/AllFeaturesExtension.java +@@ -0,0 +0,0 @@ public class AllFeaturesExtension extends BaseExtension { -- when(instance.getRegistry(any())).then((Answer>) mock -> { -- Class aClass = mock.getArgument(0); -- return registers.computeIfAbsent(aClass, key -> CraftRegistry.createRegistry(aClass, AbstractTestingBase.REGISTRY_CUSTOM)); -- }); -+ // Paper - RegistryAccess + Bukkit.setServer(server); - when(instance.getTag(any(), any(), any())).then(mock -> { - String registry = mock.getArgument(0); +- when(server.getRegistry(any())) +- .then(invocation -> { +- Class keyed = invocation.getArgument(0); +- if (spyRegistries.containsKey(keyed)) { +- return spyRegistries.get(keyed); +- } +- +- Registry registry = CraftRegistry.createRegistry(keyed, RegistryHelper.getRegistry()); +- realRegistries.put(keyed, registry); +- +- Registry spy = mock(registry.getClass(), withSettings().stubOnly().spiedInstance(registry).defaultAnswer(CALLS_REAL_METHODS)); +- +- spyRegistries.put(keyed, spy); +- +- return spy; +- }); ++ // Paper - Add RegistryAccess for managing registries - replaced with registry access + + CraftRegistry.setMinecraftRegistry(RegistryHelper.getRegistry()); + } +diff --git a/src/test/java/org/bukkit/support/extension/LegacyExtension.java b/src/test/java/org/bukkit/support/extension/LegacyExtension.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/test/java/org/bukkit/support/extension/LegacyExtension.java ++++ b/src/test/java/org/bukkit/support/extension/LegacyExtension.java +@@ -0,0 +0,0 @@ public class LegacyExtension extends BaseExtension { + + Bukkit.setServer(server); + +- when(server.getRegistry(any())) +- .then(invocation -> { +- Class keyed = invocation.getArgument(0); +- return registries.computeIfAbsent(keyed, k -> CraftRegistry.createRegistry(keyed, RegistryHelper.getRegistry())); +- }); ++ // Paper - Add RegistryAccess for managing registries - replaced with registry access + + CraftRegistry.setMinecraftRegistry(RegistryHelper.getRegistry()); + } +diff --git a/src/test/java/org/bukkit/support/extension/SlowExtension.java b/src/test/java/org/bukkit/support/extension/SlowExtension.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/test/java/org/bukkit/support/extension/SlowExtension.java ++++ b/src/test/java/org/bukkit/support/extension/SlowExtension.java +@@ -0,0 +0,0 @@ public class SlowExtension extends BaseExtension { + + Bukkit.setServer(server); + +- when(server.getRegistry(any())) +- .then(invocation -> { +- Class keyed = invocation.getArgument(0); +- return registries.computeIfAbsent(keyed, k -> CraftRegistry.createRegistry(keyed, RegistryHelper.getRegistry())); +- }); ++ // Paper - Add RegistryAccess for managing registries - replaced with registry access + + CraftRegistry.setMinecraftRegistry(RegistryHelper.getRegistry()); + } +diff --git a/src/test/java/org/bukkit/support/extension/VanillaFeatureExtension.java b/src/test/java/org/bukkit/support/extension/VanillaFeatureExtension.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/test/java/org/bukkit/support/extension/VanillaFeatureExtension.java ++++ b/src/test/java/org/bukkit/support/extension/VanillaFeatureExtension.java +@@ -0,0 +0,0 @@ public class VanillaFeatureExtension extends BaseExtension { + + Bukkit.setServer(server); + +- when(server.getRegistry(any())) +- .then(invocation -> { +- Class keyed = invocation.getArgument(0); +- return registries.computeIfAbsent(keyed, k -> CraftRegistry.createRegistry(keyed, RegistryHelper.getRegistry())); +- }); ++ // Paper - Add RegistryAccess for managing registries - replaced with registry access + + CraftRegistry.setMinecraftRegistry(RegistryHelper.getRegistry()); + } diff --git a/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java b/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java diff --git a/patches/server/Add-Shearable-API.patch b/patches/server/Add-Shearable-API.patch index b5173bd13b..cf13d83e87 100644 --- a/patches/server/Add-Shearable-API.patch +++ b/patches/server/Add-Shearable-API.patch @@ -97,10 +97,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.List; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.Shearable; ++import org.bukkit.support.environment.Normal; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + ++@Normal +class ShearableTest { + + static List> nmsShearables() { diff --git a/patches/server/Add-drops-to-shear-events.patch b/patches/server/Add-drops-to-shear-events.patch index 0750f0254a..74c6004a1c 100644 --- a/patches/server/Add-drops-to-shear-events.patch +++ b/patches/server/Add-drops-to-shear-events.patch @@ -382,13 +382,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import io.github.classgraph.ScanResult; +import java.util.ArrayList; +import net.minecraft.world.entity.Shearable; -+import org.bukkit.support.AbstractTestingBase; ++import org.bukkit.support.environment.Normal; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; + -+class ShearableDropsTest extends AbstractTestingBase { ++@Normal ++class ShearableDropsTest { + + static Iterable parameters() { + try (ScanResult scanResult = new ClassGraph() diff --git a/patches/server/Add-enchantment-seed-update-API.patch b/patches/server/Add-enchantment-seed-update-API.patch index 243adcdb54..52d94f4f0b 100644 --- a/patches/server/Add-enchantment-seed-update-API.patch +++ b/patches/server/Add-enchantment-seed-update-API.patch @@ -23,7 +23,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/view/CraftEnchantmen index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/view/CraftEnchantmentView.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/view/CraftEnchantmentView.java -@@ -0,0 +0,0 @@ public class CraftEnchantmentView extends CraftInventoryView im +@@ -0,0 +0,0 @@ public class CraftEnchantmentView extends CraftInventoryView, Biome> nms : AbstractTestingBase.BIOMES.entrySet()) { ++ for (Map.Entry, Biome> nms : RegistryHelper.getBiomes().entrySet()) { + org.bukkit.block.Biome bukkit = org.bukkit.block.Biome.valueOf(nms.getKey().location().getPath().toUpperCase(Locale.ROOT)); + Assertions.assertEquals(nms.getKey().location().toLanguageKey("biome"), bukkit.translationKey(), "translation key mismatch for " + bukkit); + } diff --git a/patches/server/Add-missing-default-perms-for-commands.patch b/patches/server/Add-missing-default-perms-for-commands.patch index 398302d05a..39ddc2787d 100644 --- a/patches/server/Add-missing-default-perms-for-commands.patch +++ b/patches/server/Add-missing-default-perms-for-commands.patch @@ -96,6 +96,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import com.mojang.brigadier.tree.CommandNode; +import com.mojang.brigadier.tree.RootCommandNode; ++import java.io.PrintStream; ++import java.util.HashSet; ++import java.util.LinkedHashSet; ++import java.util.List; ++import java.util.Set; ++import java.util.TreeSet; +import net.minecraft.commands.CommandBuildContext; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; @@ -105,21 +111,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.craftbukkit.command.VanillaCommandWrapper; +import org.bukkit.craftbukkit.util.permissions.CraftDefaultPermissions; +import org.bukkit.permissions.Permission; -+import org.bukkit.support.AbstractTestingBase; ++import org.bukkit.support.RegistryHelper; ++import org.bukkit.support.environment.VanillaFeature; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + -+import java.io.PrintStream; -+import java.util.HashSet; -+import java.util.LinkedHashSet; -+import java.util.List; -+import java.util.Set; -+import java.util.TreeSet; -+ +import static org.junit.jupiter.api.Assertions.assertTrue; + -+public class MinecraftCommandPermissionsTest extends AbstractTestingBase { ++@VanillaFeature ++public class MinecraftCommandPermissionsTest { + + private static PrintStream old; + @BeforeAll @@ -133,7 +134,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + CraftDefaultPermissions.registerCorePermissions(); + Set perms = collectMinecraftCommandPerms(); + -+ Commands commands = new Commands(Commands.CommandSelection.DEDICATED, CommandBuildContext.simple(AbstractTestingBase.REGISTRY_CUSTOM, FeatureFlags.VANILLA_SET)); ++ Commands commands = new Commands(Commands.CommandSelection.DEDICATED, CommandBuildContext.simple(RegistryHelper.getRegistry(), FeatureFlags.VANILLA_SET)); + RootCommandNode root = commands.getDispatcher().getRoot(); + Set missing = new LinkedHashSet<>(); + Set foundPerms = new HashSet<>(); diff --git a/patches/server/Add-missing-structure-set-seed-configs.patch b/patches/server/Add-missing-structure-set-seed-configs.patch index a9ee34dea3..164562231d 100644 --- a/patches/server/Add-missing-structure-set-seed-configs.patch +++ b/patches/server/Add-missing-structure-set-seed-configs.patch @@ -333,7 +333,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.minecraft.world.level.levelgen.structure.StructureSet; +import net.minecraft.world.level.levelgen.structure.placement.StructurePlacement; +import org.bukkit.configuration.file.YamlConfiguration; -+import org.bukkit.support.AbstractTestingBase; ++import org.bukkit.support.RegistryHelper; ++import org.bukkit.support.environment.AllFeatures; +import org.jetbrains.annotations.NotNull; +import org.junit.jupiter.api.Test; +import org.spigotmc.SpigotConfig; @@ -341,7 +342,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import static org.junit.jupiter.api.Assertions.assertEquals; + -+public class StructureSeedConfigTest extends AbstractTestingBase { ++@AllFeatures ++public class StructureSeedConfigTest { + + @Test + public void checkStructureSeedDefaults() throws ReflectiveOperationException { @@ -354,7 +356,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + final SpigotWorldConfig config = PaperConfigurations.SPIGOT_WORLD_DEFAULTS.get(); + + -+ final Registry structureSets = AbstractTestingBase.REGISTRY_CUSTOM.registryOrThrow(Registries.STRUCTURE_SET); ++ final Registry structureSets = RegistryHelper.getRegistry().registryOrThrow(Registries.STRUCTURE_SET); + for (final ResourceKey setKey : structureSets.registryKeySet()) { + assertEquals(ResourceLocation.DEFAULT_NAMESPACE, setKey.location().getNamespace()); + final StructureSet set = structureSets.getOrThrow(setKey); diff --git a/patches/server/Add-missing-team-sidebar-display-slots.patch b/patches/server/Add-missing-team-sidebar-display-slots.patch index f9768b2928..e1520fdc82 100644 --- a/patches/server/Add-missing-team-sidebar-display-slots.patch +++ b/patches/server/Add-missing-team-sidebar-display-slots.patch @@ -90,10 +90,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import org.bukkit.craftbukkit.scoreboard.CraftScoreboardTranslations; +import org.bukkit.scoreboard.DisplaySlot; ++import org.bukkit.support.environment.Normal; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + ++@Normal +public class DisplaySlotTest { + + @Test diff --git a/patches/server/Add-more-advancement-API.patch b/patches/server/Add-more-advancement-API.patch index bfe2506c04..899a0a9733 100644 --- a/patches/server/Add-more-advancement-API.patch +++ b/patches/server/Add-more-advancement-API.patch @@ -191,10 +191,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.kyori.adventure.text.format.TextColor; +import net.minecraft.advancements.AdvancementType; +import net.minecraft.network.chat.contents.TranslatableContents; ++import org.bukkit.support.environment.Normal; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + ++@Normal +public class AdvancementFrameTest { + + @Test diff --git a/patches/server/Add-paper-mobcaps-and-paper-playermobcaps.patch b/patches/server/Add-paper-mobcaps-and-paper-playermobcaps.patch index 0f94565192..1c48bf66f2 100644 --- a/patches/server/Add-paper-mobcaps-and-paper-playermobcaps.patch +++ b/patches/server/Add-paper-mobcaps-and-paper-playermobcaps.patch @@ -324,9 +324,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.HashSet; +import java.util.Set; +import net.minecraft.world.entity.MobCategory; ++import org.bukkit.support.environment.Normal; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + ++@Normal +public class MobcapsCommandTest { + @Test + public void testMobCategoryColors() { diff --git a/patches/server/Add-recipeBrewTime.patch b/patches/server/Add-recipeBrewTime.patch index ef5b87e03f..b12708cc1f 100644 --- a/patches/server/Add-recipeBrewTime.patch +++ b/patches/server/Add-recipeBrewTime.patch @@ -161,7 +161,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/view/CraftBrewingSta index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/view/CraftBrewingStandView.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/view/CraftBrewingStandView.java -@@ -0,0 +0,0 @@ public class CraftBrewingStandView extends CraftInventoryView +@@ -0,0 +0,0 @@ public class CraftBrewingStandView extends CraftInventoryView 0, "The given brewing ticks must be greater than 0"); this.container.setData(BrewingStandBlockEntity.DATA_BREW_TIME, brewingTicks); } diff --git a/patches/server/Add-registry-entry-and-builders.patch b/patches/server/Add-registry-entry-and-builders.patch index 927d4828a9..4b0dd38c84 100644 --- a/patches/server/Add-registry-entry-and-builders.patch +++ b/patches/server/Add-registry-entry-and-builders.patch @@ -459,16 +459,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import net.minecraft.resources.ResourceKey; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.level.gameevent.GameEvent; - import org.bukkit.support.AbstractTestingBase; --import org.junit.jupiter.api.Disabled; - import org.junit.jupiter.params.ParameterizedTest; - import org.junit.jupiter.params.provider.Arguments; + import org.bukkit.support.RegistryHelper; + import org.bukkit.support.environment.AllFeatures; + import org.junit.jupiter.api.Disabled; +@@ -0,0 +0,0 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.params.provider.Arguments.arguments; - class RegistryBuilderTest extends AbstractTestingBase { + @AllFeatures + class RegistryBuilderTest { static List registries() { return List.of( diff --git a/patches/server/Add-support-for-Proxy-Protocol.patch b/patches/server/Add-support-for-Proxy-Protocol.patch index 5c56d42c70..324ede18bb 100644 --- a/patches/server/Add-support-for-Proxy-Protocol.patch +++ b/patches/server/Add-support-for-Proxy-Protocol.patch @@ -15,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + implementation("io.netty:netty-codec-haproxy:4.1.97.Final") // Paper - Add support for proxy protocol // Paper end implementation("org.apache.logging.log4j:log4j-iostreams:2.22.1") // Paper - remove exclusion - implementation("org.ow2.asm:asm-commons:9.7") + implementation("org.ow2.asm:asm-commons:9.7.1") diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java diff --git a/patches/server/Adopt-MaterialRerouting.patch b/patches/server/Adopt-MaterialRerouting.patch index a5da1f304d..a7d659782e 100644 --- a/patches/server/Adopt-MaterialRerouting.patch +++ b/patches/server/Adopt-MaterialRerouting.patch @@ -97,7 +97,7 @@ diff --git a/src/test/java/org/bukkit/craftbukkit/legacy/MaterialReroutingTest.j index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/test/java/org/bukkit/craftbukkit/legacy/MaterialReroutingTest.java +++ b/src/test/java/org/bukkit/craftbukkit/legacy/MaterialReroutingTest.java -@@ -0,0 +0,0 @@ public class MaterialReroutingTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class MaterialReroutingTest { .filter(entry -> !entry.getName().endsWith("ItemType.class")) .filter(entry -> !entry.getName().endsWith("Registry.class")) .filter(entry -> !entry.getName().startsWith("org/bukkit/material")) @@ -107,7 +107,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 .map(entry -> { try { return MaterialReroutingTest.jarFile.getInputStream(entry); -@@ -0,0 +0,0 @@ public class MaterialReroutingTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class MaterialReroutingTest { continue; } } @@ -116,9 +116,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (isInternal(methodNode.invisibleAnnotations)) continue; + // Paper end - filter out more methods from rerouting test - if (!Commodore.rerouteMethods(Collections.emptySet(), ApiVersion.CURRENT, MaterialReroutingTest.MATERIAL_METHOD_REROUTE, (methodNode.access & Opcodes.ACC_STATIC) != 0, classNode.name, methodNode.name, methodNode.desc, a -> { })) { + if (!Commodore.rerouteMethods(ApiVersion.CURRENT, MaterialReroutingTest.MATERIAL_METHOD_REROUTE, (methodNode.access & Opcodes.ACC_STATIC) != 0, classNode.name, methodNode.name, methodNode.desc, a -> { })) { missingReroute.add(methodNode.name + " " + methodNode.desc + " " + methodNode.signature); -@@ -0,0 +0,0 @@ public class MaterialReroutingTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class MaterialReroutingTest { } } diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index e80232d60e..5f025f5046 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -4806,7 +4806,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.j index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java -@@ -0,0 +0,0 @@ public class CraftInventoryView extends CraftAb +@@ -0,0 +0,0 @@ public class CraftInventoryView AbstractTestingBase.REGISTRY_CUSTOM.createSerializationContext(ops)) ++ .map(ops -> RegistryHelper.getRegistry().createSerializationContext(ops)) + .toList(); + } + @@ -6202,10 +6204,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; ++import org.bukkit.support.environment.AllFeatures; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + ++@AllFeatures +public class ComponentServicesTest { + + @Test diff --git a/patches/server/Brigadier-based-command-API.patch b/patches/server/Brigadier-based-command-API.patch index fcd47ef2a9..bbbd09e8dc 100644 --- a/patches/server/Brigadier-based-command-API.patch +++ b/patches/server/Brigadier-based-command-API.patch @@ -2721,38 +2721,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +package io.papermc.paper.command.brigadier; + +import com.mojang.brigadier.CommandDispatcher; -+import com.mojang.brigadier.ResultConsumer; -+import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.suggestion.Suggestions; -+import com.mojang.brigadier.tree.CommandNode; +import io.papermc.paper.command.brigadier.bukkit.BukkitBrigForwardingMap; -+import net.minecraft.server.MinecraftServer; -+import net.minecraft.world.flag.FeatureFlags; -+import org.apache.logging.log4j.core.util.Assert; ++import java.util.List; ++import java.util.Map; +import org.bukkit.Bukkit; +import org.bukkit.Location; -+import org.bukkit.World; +import org.bukkit.command.Command; +import org.bukkit.command.CommandMap; +import org.bukkit.command.CommandSender; +import org.bukkit.command.SimpleCommandMap; -+import org.bukkit.craftbukkit.command.CraftCommandMap; -+import org.bukkit.craftbukkit.command.VanillaCommandWrapper; -+import org.bukkit.entity.Entity; -+import org.bukkit.plugin.PluginManager; -+import org.bukkit.support.AbstractTestingBase; ++import org.bukkit.support.RegistryHelper; ++import org.bukkit.support.environment.AllFeatures; ++import org.bukkit.support.environment.Normal; +import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; + -+import java.util.List; -+import java.util.Map; -+import java.util.logging.Logger; -+ -+public class BukkitCommandConversionTest extends AbstractTestingBase { ++@Normal ++public class BukkitCommandConversionTest { + + private CommandSender getSender() { + return Mockito.mock(CommandSender.class); @@ -2764,7 +2753,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + CommandSourceStack object = Mockito.mock(CommandSourceStack.class); + Mockito.when(object.getLocation()).thenReturn(new Location(null, 0, 0, 0));; + -+ CommandDispatcher dispatcher = DATA_PACK.commands.getDispatcher(); ++ CommandDispatcher dispatcher = RegistryHelper.getDataPack().commands.getDispatcher(); + dispatcher.setConsumer((context, success, result) -> {}); + CommandMap commandMap = new SimpleCommandMap(Bukkit.getServer(), new BukkitBrigForwardingMap()); + Map stringCommandMap = commandMap.getKnownCommands(); @@ -2831,16 +2820,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + } +} -diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java +diff --git a/src/test/java/org/bukkit/support/DummyServerHelper.java b/src/test/java/org/bukkit/support/DummyServerHelper.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/test/java/org/bukkit/support/DummyServer.java -+++ b/src/test/java/org/bukkit/support/DummyServer.java -@@ -0,0 +0,0 @@ public final class DummyServer { - final Thread currentThread = Thread.currentThread(); - when(instance.isPrimaryThread()).thenAnswer(ignored -> Thread.currentThread().equals(currentThread)); - -- final org.bukkit.plugin.PluginManager pluginManager = new io.papermc.paper.plugin.manager.PaperPluginManagerImpl(instance, new org.bukkit.command.SimpleCommandMap(instance), null); -+ final org.bukkit.plugin.PluginManager pluginManager = new io.papermc.paper.plugin.manager.PaperPluginManagerImpl(instance, new org.bukkit.command.SimpleCommandMap(instance, new java.util.HashMap<>()), null); // Paper - when(instance.getPluginManager()).thenReturn(pluginManager); - // paper end - testing additions +--- a/src/test/java/org/bukkit/support/DummyServerHelper.java ++++ b/src/test/java/org/bukkit/support/DummyServerHelper.java +@@ -0,0 +0,0 @@ public final class DummyServerHelper { + // Paper start - testing additions + final Thread currentThread = Thread.currentThread(); + when(instance.isPrimaryThread()).thenAnswer(ignored -> Thread.currentThread().equals(currentThread)); +- final org.bukkit.plugin.PluginManager pluginManager = new io.papermc.paper.plugin.manager.PaperPluginManagerImpl(instance, new org.bukkit.command.SimpleCommandMap(instance), null); ++ final org.bukkit.plugin.PluginManager pluginManager = new io.papermc.paper.plugin.manager.PaperPluginManagerImpl(instance, new org.bukkit.command.SimpleCommandMap(instance, new java.util.HashMap<>()), null); + when(instance.getPluginManager()).thenReturn(pluginManager); + // Paper end - testing additions diff --git a/patches/server/Build-system-changes.patch b/patches/server/Build-system-changes.patch index 7d6aed787d..a70cb50817 100644 --- a/patches/server/Build-system-changes.patch +++ b/patches/server/Build-system-changes.patch @@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - exclude(group = "org.apache.logging.log4j", module = "log4j-api") - } + implementation("org.apache.logging.log4j:log4j-iostreams:2.22.1") // Paper - remove exclusion - implementation("org.ow2.asm:asm-commons:9.7") + implementation("org.ow2.asm:asm-commons:9.7.1") implementation("commons-lang:commons-lang:2.6") runtimeOnly("org.xerial:sqlite-jdbc:3.46.0.0") @@ -0,0 +0,0 @@ tasks.jar { @@ -57,8 +57,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +// Paper end + tasks.test { - exclude("org/bukkit/craftbukkit/inventory/ItemStack*Test.class") - useJUnitPlatform() + include("**/**TestSuite.class") + workingDir = temporaryDir @@ -0,0 +0,0 @@ tasks.registerRunTask("runReobf") { tasks.registerRunTask("runDev") { description = "Spin up a non-relocated Mojang-mapped test server" @@ -142,7 +142,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + Date buildDate = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").parse(Main.class.getPackage().getImplementationVendor()); // Paper Calendar deadline = Calendar.getInstance(); - deadline.add(Calendar.DAY_OF_YEAR, -14); + deadline.add(Calendar.DAY_OF_YEAR, -28); diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java @@ -171,15 +171,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + "pack_format": 41 + } +} -diff --git a/src/test/java/org/bukkit/support/AbstractTestingBase.java b/src/test/java/org/bukkit/support/AbstractTestingBase.java +diff --git a/src/test/java/org/bukkit/support/RegistryHelper.java b/src/test/java/org/bukkit/support/RegistryHelper.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/test/java/org/bukkit/support/AbstractTestingBase.java -+++ b/src/test/java/org/bukkit/support/AbstractTestingBase.java -@@ -0,0 +0,0 @@ public abstract class AbstractTestingBase { - public static final Registry BIOMES; +--- a/src/test/java/org/bukkit/support/RegistryHelper.java ++++ b/src/test/java/org/bukkit/support/RegistryHelper.java +@@ -0,0 +0,0 @@ public final class RegistryHelper { + } - static { -+ System.setProperty("Paper.pushPaperAssetsRoot", "true"); // Paper + public static void setup(FeatureFlagSet featureFlagSet) { ++ System.setProperty("Paper.pushPaperAssetsRoot", "true"); // Paper - build system changes - push asset root SharedConstants.tryDetectVersion(); Bootstrap.bootStrap(); - // Populate available packs + diff --git a/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch b/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch index 8dbd0f7fec..d9dd354823 100644 --- a/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch +++ b/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch @@ -10,8 +10,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -0,0 +0,0 @@ dependencies { - testImplementation("org.mockito:mockito-core:5.11.0") - testImplementation("org.ow2.asm:asm-tree:9.7") + testImplementation("org.mockito:mockito-core:5.14.1") + testImplementation("org.ow2.asm:asm-tree:9.7.1") testImplementation("org.junit-pioneer:junit-pioneer:2.2.0") // Paper - CartesianTest + implementation("net.neoforged:srgutils:1.0.9") // Paper - mappings handling } diff --git a/patches/server/Expose-server-build-information.patch b/patches/server/Expose-server-build-information.patch index 6f7bbc0108..25a11daa2f 100644 --- a/patches/server/Expose-server-build-information.patch +++ b/patches/server/Expose-server-build-information.patch @@ -671,7 +671,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public static boolean useConsole = true; @@ -0,0 +0,0 @@ public class Main { - deadline.add(Calendar.DAY_OF_YEAR, -14); + deadline.add(Calendar.DAY_OF_YEAR, -28); if (buildDate.before(deadline.getTime())) { System.err.println("*** Error, this build is outdated ***"); - System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/go/outdated-spigot ***"); diff --git a/patches/server/Fix-ItemFlags.patch b/patches/server/Fix-ItemFlags.patch index 42762d86ba..5630d7c6b0 100644 --- a/patches/server/Fix-ItemFlags.patch +++ b/patches/server/Fix-ItemFlags.patch @@ -118,8 +118,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Overridden boolean isEmpty() { -- return !(this.hasDisplayName() || this.hasItemName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.build().isEmpty() || !this.removedTags.isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isHideTooltip() || this.isUnbreakable() || this.hasEnchantmentGlintOverride() || this.isFireResistant() || this.hasMaxStackSize() || this.hasRarity() || this.hasFood() || this.hasTool() || this.hasDamage() || this.hasMaxDamage() || this.hasAttributeModifiers() || this.customTag != null); -+ return !(this.hasDisplayName() || this.hasItemName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.build().isEmpty() || !this.removedTags.isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isHideTooltip() || this.isUnbreakable() || this.hasEnchantmentGlintOverride() || this.isFireResistant() || this.hasMaxStackSize() || this.hasRarity() || this.hasFood() || this.hasTool() || this.hasDamage() || this.hasMaxDamage() || this.hasAttributeModifiers() || this.customTag != null || this.canPlaceOnPredicates != null || this.canBreakPredicates != null); // Paper +- return !(this.hasDisplayName() || this.hasItemName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.build().isEmpty() || !this.removedTags.isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isHideTooltip() || this.isUnbreakable() || this.hasEnchantmentGlintOverride() || this.isFireResistant() || this.hasMaxStackSize() || this.hasRarity() || this.hasFood() || this.hasTool() || this.hasJukeboxPlayable() || this.hasDamage() || this.hasMaxDamage() || this.hasAttributeModifiers() || this.customTag != null); ++ return !(this.hasDisplayName() || this.hasItemName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.build().isEmpty() || !this.removedTags.isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isHideTooltip() || this.isUnbreakable() || this.hasEnchantmentGlintOverride() || this.isFireResistant() || this.hasMaxStackSize() || this.hasRarity() || this.hasFood() || this.hasTool() || this.hasJukeboxPlayable() || this.hasDamage() || this.hasMaxDamage() || this.hasAttributeModifiers() || this.customTag != null || this.canPlaceOnPredicates != null || this.canBreakPredicates != null); // Paper } // Paper start diff --git a/patches/server/Fix-equipment-slot-and-group-API.patch b/patches/server/Fix-equipment-slot-and-group-API.patch index 43b39e66c8..a230d22f50 100644 --- a/patches/server/Fix-equipment-slot-and-group-API.patch +++ b/patches/server/Fix-equipment-slot-and-group-API.patch @@ -90,6 +90,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.minecraft.world.entity.EquipmentSlot; +import org.bukkit.craftbukkit.CraftEquipmentSlot; +import org.bukkit.inventory.EquipmentSlotGroup; ++import org.bukkit.support.environment.Normal; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.junit.jupiter.params.provider.MethodSource; @@ -97,6 +98,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + ++@Normal +class EquipmentSlotGroupTest { + + static List apiValues() throws ReflectiveOperationException { diff --git a/patches/server/Fix-issues-with-Recipe-API.patch b/patches/server/Fix-issues-with-Recipe-API.patch index 529ebb9150..820bd20ea2 100644 --- a/patches/server/Fix-issues-with-Recipe-API.patch +++ b/patches/server/Fix-issues-with-Recipe-API.patch @@ -49,7 +49,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void addToCraftingManager() { ItemStack result = this.getResult(); -- MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTransformRecipe(this.toNMS(this.getTemplate(), true), this.toNMS(this.getBase(), true), this.toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result), this.willCopyDataComponents()))); // Paper - Option to prevent data components copy +- MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTransformRecipe(this.toNMS(this.getTemplate(), false), this.toNMS(this.getBase(), false), this.toNMS(this.getAddition(), false), CraftItemStack.asNMSCopy(result), this.willCopyDataComponents()))); // Paper - Option to prevent data components copy + MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTransformRecipe(this.toNMS(this.getTemplate(), false), this.toNMS(this.getBase(), false), this.toNMS(this.getAddition(), false), CraftItemStack.asNMSCopy(result), this.willCopyDataComponents()))); // Paper - Option to prevent data components copy & support empty RecipeChoice } } @@ -61,7 +61,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void addToCraftingManager() { -- MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTrimRecipe(this.toNMS(this.getTemplate(), true), this.toNMS(this.getBase(), true), this.toNMS(this.getAddition(), true), this.willCopyDataComponents()))); // Paper - Option to prevent data components copy +- MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTrimRecipe(this.toNMS(this.getTemplate(), false), this.toNMS(this.getBase(), false), this.toNMS(this.getAddition(), false), this.willCopyDataComponents()))); // Paper - Option to prevent data components copy + MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTrimRecipe(this.toNMS(this.getTemplate(), false), this.toNMS(this.getBase(), false), this.toNMS(this.getAddition(), false), this.willCopyDataComponents()))); // Paper - Option to prevent data components copy & support empty RecipeChoice } } @@ -76,13 +76,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.Iterator; +import org.bukkit.Bukkit; +import org.bukkit.inventory.Recipe; -+import org.bukkit.support.AbstractTestingBase; ++import org.bukkit.support.environment.AllFeatures; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertTrue; + -+class TestRecipeChoice extends AbstractTestingBase { ++@AllFeatures ++class TestRecipeChoice { + + @Test + void testRecipeChoices() { @@ -95,22 +96,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + assertTrue(foundRecipes, "No recipes found!"); + } +} -diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java +diff --git a/src/test/java/org/bukkit/support/DummyServerHelper.java b/src/test/java/org/bukkit/support/DummyServerHelper.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/test/java/org/bukkit/support/DummyServer.java -+++ b/src/test/java/org/bukkit/support/DummyServer.java -@@ -0,0 +0,0 @@ public final class DummyServer { - when(instance.getPluginManager()).thenReturn(pluginManager); - // paper end - testing additions +--- a/src/test/java/org/bukkit/support/DummyServerHelper.java ++++ b/src/test/java/org/bukkit/support/DummyServerHelper.java +@@ -0,0 +0,0 @@ public final class DummyServerHelper { + // Paper end - testing additions -+ // Paper start - add test for recipe conversion -+ when(instance.recipeIterator()).thenAnswer(ignored -> { -+ return com.google.common.collect.Iterators.transform( -+ AbstractTestingBase.DATA_PACK.getRecipeManager().byType.entries().iterator(), -+ input -> input.getValue().toBukkitRecipe()); -+ }); -+ // Paper end - add test for recipe conversion + io.papermc.paper.configuration.GlobalConfigTestingBase.setupGlobalConfigForTest(); // Paper - configuration files - setup global configuration test base + - Bukkit.setServer(instance); - } catch (Throwable t) { - throw new Error(t); ++ // Paper start - add test for recipe conversion ++ when(instance.recipeIterator()).thenAnswer(ignored -> ++ com.google.common.collect.Iterators.transform( ++ RegistryHelper.getDataPack().getRecipeManager().byType.entries().iterator(), ++ input -> input.getValue().toBukkitRecipe() ++ ) ++ ); ++ // Paper end - add test for recipe conversion + return instance; + } + } diff --git a/patches/server/Fix-setPatternColor-on-tropical-fish-bucket-meta.patch b/patches/server/Fix-setPatternColor-on-tropical-fish-bucket-meta.patch index 667abdfb02..6138171566 100644 --- a/patches/server/Fix-setPatternColor-on-tropical-fish-bucket-meta.patch +++ b/patches/server/Fix-setPatternColor-on-tropical-fish-bucket-meta.patch @@ -36,11 +36,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.entity.TropicalFish; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.TropicalFishBucketMeta; -+import org.bukkit.support.AbstractTestingBase; ++import org.bukkit.support.environment.AllFeatures; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + -+public class CraftMetaTropicalFishBucketTest extends AbstractTestingBase { ++@AllFeatures ++public class CraftMetaTropicalFishBucketTest { + + @Test + public void testAllCombinations() { diff --git a/patches/server/Fix-silent-equipment-change-for-mobs.patch b/patches/server/Fix-silent-equipment-change-for-mobs.patch index e234139ec4..6a2cb608ab 100644 --- a/patches/server/Fix-silent-equipment-change-for-mobs.patch +++ b/patches/server/Fix-silent-equipment-change-for-mobs.patch @@ -70,13 +70,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; -+import org.bukkit.support.AbstractTestingBase; ++import org.bukkit.support.environment.Normal; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.fail; + -+public class EntitySetItemSlotSilentOverrideTest extends AbstractTestingBase { ++@Normal ++public class EntitySetItemSlotSilentOverrideTest { + + public static Stream parameters() { + final List classInfo = new ArrayList<>(); diff --git a/patches/server/Fix-this-stupid-bullshit.patch b/patches/server/Fix-this-stupid-bullshit.patch index 338ff9d49a..6286528519 100644 --- a/patches/server/Fix-this-stupid-bullshit.patch +++ b/patches/server/Fix-this-stupid-bullshit.patch @@ -36,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -0,0 +0,0 @@ public class Main { Calendar deadline = Calendar.getInstance(); - deadline.add(Calendar.DAY_OF_YEAR, -14); + deadline.add(Calendar.DAY_OF_YEAR, -28); if (buildDate.before(deadline.getTime())) { - System.err.println("*** Error, this build is outdated ***"); + // Paper start - This is some stupid bullshit diff --git a/patches/server/Fix-upstreams-block-state-factories.patch b/patches/server/Fix-upstreams-block-state-factories.patch index ff47a6e8e8..686efd6eb9 100644 --- a/patches/server/Fix-upstreams-block-state-factories.patch +++ b/patches/server/Fix-upstreams-block-state-factories.patch @@ -467,9 +467,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; import org.bukkit.Material; - import org.bukkit.support.AbstractTestingBase; + import org.bukkit.support.environment.AllFeatures; import org.junit.jupiter.api.Test; -@@ -0,0 +0,0 @@ public class BlockStateTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class BlockStateTest { } } } diff --git a/patches/server/General-ItemMeta-fixes.patch b/patches/server/General-ItemMeta-fixes.patch index 6033d1e1cb..066086e780 100644 --- a/patches/server/General-ItemMeta-fixes.patch +++ b/patches/server/General-ItemMeta-fixes.patch @@ -171,6 +171,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 final Material material; - private CraftBlockEntityState blockEntityTag; +- private BlockVector position; + // Paper start - store data separately + DataComponentMap components; + CustomData blockEntityTag; @@ -204,6 +205,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + this.components = te.components; this.blockEntityTag = te.blockEntityTag; +- this.position = te.position; + // Paper end } @@ -211,14 +213,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 super(tag, extraHandledDcts); // Paper this.material = material; +- getOrEmpty(tag, CraftMetaBlockState.BLOCK_ENTITY_TAG).ifPresent((blockTag) -> { +- CompoundTag nbt = blockTag.copyTag(); + // Paper start - move to separate method to be re-called + this.updateBlockState(tag); + } -+ + +- this.blockEntityTag = CraftMetaBlockState.getBlockState(material, nbt); +- if (nbt.contains("x", CraftMagicNumbers.NBT.TAG_ANY_NUMBER) && nbt.contains("y", CraftMagicNumbers.NBT.TAG_ANY_NUMBER) && nbt.contains("z", CraftMagicNumbers.NBT.TAG_ANY_NUMBER)) { +- this.position = new BlockVector(nbt.getInt("x"), nbt.getInt("y"), nbt.getInt("z")); +- } + private void updateBlockState(final DataComponentPatch tag) { + // Paper end - getOrEmpty(tag, CraftMetaBlockState.BLOCK_ENTITY_TAG).ifPresent((nbt) -> { -- this.blockEntityTag = CraftMetaBlockState.getBlockState(material, nbt.copyTag()); ++ getOrEmpty(tag, CraftMetaBlockState.BLOCK_ENTITY_TAG).ifPresent((nbt) -> { + this.blockEntityTag = nbt; // Paper }); @@ -271,13 +278,33 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.setBlockState(CraftMetaBlockState.getBlockState(this.material, this.internalTag)); // Paper - general item meta fixes - pass through setter this.internalTag = null; } +- this.position = SerializableMeta.getObject(BlockVector.class, map, "blockPosition", true); ++ // Paper start - general item meta fixes - parse spigot legacy position and merge into block entity tag ++ final BlockVector legacyPosition = SerializableMeta.getObject(BlockVector.class, map, "blockPosition", true); ++ if (legacyPosition != null) { ++ this.blockEntityTag = this.blockEntityTag.update(t -> { ++ if (t.isEmpty()) { ++ BlockEntity.addEntityType(t, java.util.Objects.requireNonNull(CraftBlockStates.getBlockEntityType(this.materialForBlockEntityType()))); ++ } ++ t.putInt("x", legacyPosition.getBlockX()); ++ t.putInt("y", legacyPosition.getBlockY()); ++ t.putInt("z", legacyPosition.getBlockZ()); ++ }); ++ } ++ // Paper end - general item meta fixes - parse spigot legacy position and merge into block entity tag } -@@ -0,0 +0,0 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta + + @Override void applyToItem(CraftMetaItem.Applicator tag) { super.applyToItem(tag); +- CompoundTag nbt = null; - if (this.blockEntityTag != null) { -- tag.put(CraftMetaBlockState.BLOCK_ENTITY_TAG, CustomData.of(this.blockEntityTag.getSnapshotNBTWithoutComponents())); +- nbt = this.blockEntityTag.getItemNBT(); +- +- for (TypedDataComponent component : this.blockEntityTag.collectComponents()) { +- tag.putIfAbsent(component); +- } + // Paper start - accurately replicate logic for creating ItemStack from BlockEntity + // taken from BlockEntity#saveToItem and BlockItem#setBlockEntityData + final CompoundTag nbt = this.blockEntityTag.copyTag(); @@ -286,11 +313,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } else if (!nbt.isEmpty()) { + BlockEntity.addEntityType(nbt, java.util.Objects.requireNonNull(CraftBlockStates.getBlockEntityType(this.materialForBlockEntityType()))); + tag.put(CraftMetaBlockState.BLOCK_ENTITY_TAG, CustomData.of(nbt)); -+ } + } -- for (TypedDataComponent component : this.blockEntityTag.collectComponents()) { -- tag.putIfAbsent(component); +- if (this.position != null) { +- if (nbt == null) { +- nbt = new CompoundTag(); - } +- +- nbt.putInt("x", this.position.getBlockX()); +- nbt.putInt("y", this.position.getBlockY()); +- nbt.putInt("z", this.position.getBlockZ()); +- } +- +- if (nbt != null && !nbt.isEmpty()) { +- CraftBlockEntityState tile = (this.blockEntityTag != null) ? this.blockEntityTag : CraftMetaBlockState.getBlockState(this.material, null); +- // See ItemBlock#setBlockEntityData +- tile.addEntityType(nbt); +- +- tag.put(CraftMetaBlockState.BLOCK_ENTITY_TAG, CustomData.of(nbt)); + for (final TypedDataComponent component : this.components) { + if (CraftMetaItem.DEFAULT_HANDLED_DCTS.contains(component.type())) continue; // if the component type was already handled by CraftMetaItem, don't add it again + tag.builder.set(component); @@ -308,10 +348,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - new serialization format + if (tag.contains(CraftMetaBlockState.BLOCK_ENTITY_TAG_CUSTOM_DATA.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { + this.blockEntityTag = CustomData.of(tag.getCompound(CraftMetaBlockState.BLOCK_ENTITY_TAG_CUSTOM_DATA.NBT)); - } ++ } + if (tag.contains(CraftMetaBlockState.BLOCK_ENTITY_COMPONENTS.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { + this.components = DataComponentMap.CODEC.parse(org.bukkit.craftbukkit.CraftRegistry.getMinecraftRegistry().createSerializationContext(net.minecraft.nbt.NbtOps.INSTANCE), tag.getCompound(CraftMetaBlockState.BLOCK_ENTITY_COMPONENTS.NBT)).getOrThrow(); -+ } + } + // Paper end - new serialization format } @@ -322,15 +362,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - new serialization format + if (!this.blockEntityTag.isEmpty()) { + internalTags.put(CraftMetaBlockState.BLOCK_ENTITY_TAG_CUSTOM_DATA.NBT, this.blockEntityTag.getUnsafe()); // unsafe because it's serialized right away -+ } + } + if (!this.components.isEmpty()) { + final Tag componentsTag = DataComponentMap.CODEC.encodeStart(org.bukkit.craftbukkit.CraftRegistry.getMinecraftRegistry().createSerializationContext(net.minecraft.nbt.NbtOps.INSTANCE), this.components).getOrThrow(); + internalTags.put(CraftMetaBlockState.BLOCK_ENTITY_COMPONENTS.NBT, componentsTag); - } ++ } + // Paper end - new serialization format } @Override + ImmutableMap.Builder serialize(ImmutableMap.Builder builder) { + super.serialize(builder); + builder.put("blockMaterial", this.material.name()); +- if (this.position != null) { +- builder.put("blockPosition", this.position); +- } + return builder; + } + @@ -0,0 +0,0 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta int applyHash() { final int original; @@ -338,6 +387,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - if (this.blockEntityTag != null) { - hash = 61 * hash + this.blockEntityTag.hashCode(); - } +- if (this.position != null) { +- hash = 61 * hash + this.position.hashCode(); +- } + // Paper start + hash = 61 * hash + this.blockEntityTag.hashCode(); + hash = 61 * hash + this.components.hashCode(); @@ -349,21 +401,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (meta instanceof CraftMetaBlockState) { CraftMetaBlockState that = (CraftMetaBlockState) meta; -- return Objects.equal(this.blockEntityTag, that.blockEntityTag); +- return Objects.equal(this.blockEntityTag, that.blockEntityTag) && Objects.equal(this.position, that.position); + return Objects.equal(this.blockEntityTag, that.blockEntityTag) && Objects.equal(this.components, that.components); // Paper } return true; } + boolean isBlockStateEmpty() { +- return !(this.blockEntityTag != null || this.position != null); ++ return !(this.blockEntityTag != null); + } + @Override boolean notUncommon(CraftMetaItem meta) { -- return super.notUncommon(meta) && (meta instanceof CraftMetaBlockState || this.blockEntityTag == null); +- return super.notUncommon(meta) && (meta instanceof CraftMetaBlockState || this.isBlockStateEmpty()); + return super.notUncommon(meta) && (meta instanceof CraftMetaBlockState || (this.blockEntityTag.isEmpty() && this.components.isEmpty())); // Paper } @Override boolean isEmpty() { -- return super.isEmpty() && this.blockEntityTag == null; +- return super.isEmpty() && this.isBlockStateEmpty(); + return super.isEmpty() && this.blockEntityTag.isEmpty() && this.components.isEmpty(); // Paper } @@ -373,6 +430,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - if (this.blockEntityTag != null) { - meta.blockEntityTag = this.blockEntityTag.copy(); - } +- if (this.position != null) { +- meta.position = this.position.clone(); +- } + // Paper start - no need for "clone" because they are essentially immutables + meta.blockEntityTag = this.blockEntityTag; + meta.components = this.components; @@ -1053,6 +1113,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 itemTag.put(CraftMetaItem.DAMAGE, this.damage); } +@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { + } + + void applyEnchantments(Map enchantments, CraftMetaItem.Applicator tag, ItemMetaKeyType key, ItemFlag itemFlag) { +- if (enchantments == null && !this.hasItemFlag(itemFlag)) { ++ if (enchantments == null /*&& !this.hasItemFlag(itemFlag)*/) { // Paper - general item meta fixes - only emit enchantment component if enchantments are defined + return; + } + @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { } @@ -1070,7 +1139,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Overridden boolean isEmpty() { -- return !(this.hasDisplayName() || this.hasItemName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.build().isEmpty() || !this.removedTags.isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isHideTooltip() || this.isUnbreakable() || this.hasEnchantmentGlintOverride() || this.isFireResistant() || this.hasMaxStackSize() || this.hasRarity() || this.hasFood() || this.hasTool() || this.hasDamage() || this.hasMaxDamage() || this.hasAttributeModifiers() || this.customTag != null || this.canPlaceOnPredicates != null || this.canBreakPredicates != null); // Paper +- return !(this.hasDisplayName() || this.hasItemName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.build().isEmpty() || !this.removedTags.isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isHideTooltip() || this.isUnbreakable() || this.hasEnchantmentGlintOverride() || this.isFireResistant() || this.hasMaxStackSize() || this.hasRarity() || this.hasFood() || this.hasTool() || this.hasJukeboxPlayable() || this.hasDamage() || this.hasMaxDamage() || this.hasAttributeModifiers() || this.customTag != null || this.canPlaceOnPredicates != null || this.canBreakPredicates != null); // Paper + return !(this.hasDisplayName() || this.hasItemName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.build().isEmpty() || !this.removedTags.isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isHideTooltip() || this.isUnbreakable() || this.hasEnchantmentGlintOverride() || this.isFireResistant() || this.hasMaxStackSize() || this.hasRarity() || this.hasFood() || this.hasTool() || this.hasJukeboxPlayable() || this.hasDamageValue() || this.hasMaxDamage() || this.hasAttributeModifiers() || this.customTag != null || this.canPlaceOnPredicates != null || this.canBreakPredicates != null); // Paper } @@ -1551,7 +1620,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Invalid colour } @@ -0,0 +0,0 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { - super.applyToItem(tag); + } Optional> defaultPotion = (this.hasBasePotionType()) ? Optional.of(CraftPotionType.bukkitToMinecraftHolder(this.type)) : Optional.empty(); - Optional potionColor = (this.hasColor()) ? Optional.of(this.color.asRGB()) : Optional.empty(); @@ -2035,7 +2104,7 @@ diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/DeprecatedItemMetaCu index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/DeprecatedItemMetaCustomValueTest.java +++ b/src/test/java/org/bukkit/craftbukkit/inventory/DeprecatedItemMetaCustomValueTest.java -@@ -0,0 +0,0 @@ public class DeprecatedItemMetaCustomValueTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class DeprecatedItemMetaCustomValueTest { public void testNBTTagStoring() { CraftMetaItem itemMeta = this.createComplexItemMeta(); @@ -2048,7 +2117,7 @@ diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/PersistentDataContai index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/PersistentDataContainerTest.java +++ b/src/test/java/org/bukkit/craftbukkit/inventory/PersistentDataContainerTest.java -@@ -0,0 +0,0 @@ public class PersistentDataContainerTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class PersistentDataContainerTest { public void testNBTTagStoring() { CraftMetaItem itemMeta = this.createComplexItemMeta(); @@ -2057,7 +2126,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 itemMeta.applyToItem(compound); assertEquals(itemMeta, new CraftMetaItem(compound.build(), null)); // Paper -@@ -0,0 +0,0 @@ public class PersistentDataContainerTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class PersistentDataContainerTest { assertEquals(List.of(), container.get(PersistentDataContainerTest.requestKey("list"), PersistentDataType.LIST.strings())); // Write and read the entire container to NBT diff --git a/patches/server/Get-entity-default-attributes.patch b/patches/server/Get-entity-default-attributes.patch index 706a9e9f53..8f5539c8ac 100644 --- a/patches/server/Get-entity-default-attributes.patch +++ b/patches/server/Get-entity-default-attributes.patch @@ -116,7 +116,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.attribute.AttributeInstance; +import org.bukkit.attribute.AttributeModifier; +import org.bukkit.entity.EntityType; -+import org.bukkit.support.AbstractTestingBase; ++import org.bukkit.support.environment.AllFeatures; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; @@ -124,12 +124,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + -+public class EntityTypeAttributesTest extends AbstractTestingBase { ++@AllFeatures ++public class EntityTypeAttributesTest { + + @Test + public void testIllegalEntity() { + assertFalse(EntityType.EGG.hasDefaultAttributes()); -+ assertThrows(IllegalArgumentException.class, () -> EntityType.EGG.getDefaultAttributes()); ++ assertThrows(IllegalArgumentException.class, EntityType.EGG::getDefaultAttributes); + } + + @Test diff --git a/patches/server/Hook-into-CB-plugin-rewrites.patch b/patches/server/Hook-into-CB-plugin-rewrites.patch index 5bb8bfb7bc..54238633ca 100644 --- a/patches/server/Hook-into-CB-plugin-rewrites.patch +++ b/patches/server/Hook-into-CB-plugin-rewrites.patch @@ -28,8 +28,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import joptsimple.OptionSet; import joptsimple.OptionSpec; @@ -0,0 +0,0 @@ public class Commodore { - private static final Map METHOD_REROUTE = Commodore.createReroutes(MethodRerouting.class); - private static final Map ENUM_METHOD_REROUTE = Commodore.createReroutes(EnumEvil.class); + return this.reroutes; + } + // Paper start - Plugin rewrites + private static final Map SEARCH_AND_REMOVE = initReplacementsMap(); diff --git a/patches/server/Implement-Mob-Goal-API.patch b/patches/server/Implement-Mob-Goal-API.patch index 444378f3b8..3ffc41a511 100644 --- a/patches/server/Implement-Mob-Goal-API.patch +++ b/patches/server/Implement-Mob-Goal-API.patch @@ -14,8 +14,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + testImplementation("io.github.classgraph:classgraph:4.8.47") // Paper - mob goal test testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") + testImplementation("org.junit.platform:junit-platform-suite-engine:1.10.0") testImplementation("org.hamcrest:hamcrest:2.2") - testImplementation("org.mockito:mockito-core:5.11.0") diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java b/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 diff --git a/patches/server/Improve-Registry.patch b/patches/server/Improve-Registry.patch index b52e79bcfb..cb1832e0bf 100644 --- a/patches/server/Improve-Registry.patch +++ b/patches/server/Improve-Registry.patch @@ -64,7 +64,7 @@ diff --git a/src/test/java/org/bukkit/registry/PerRegistryTest.java b/src/test/j index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/test/java/org/bukkit/registry/PerRegistryTest.java +++ b/src/test/java/org/bukkit/registry/PerRegistryTest.java -@@ -0,0 +0,0 @@ public class PerRegistryTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class PerRegistryTest { @ParameterizedTest @MethodSource("data") @@ -91,7 +91,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.assertSameMatchWithKeyMessage(registry, element, key.toString()); // namespace:key this.assertSameMatchWithKeyMessage(registry, element, key.getKey()); // key -@@ -0,0 +0,0 @@ public class PerRegistryTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class PerRegistryTest { }); } diff --git a/patches/server/Improve-entity-effect-API.patch b/patches/server/Improve-entity-effect-API.patch index 155e7e1a4c..f6adedddaf 100644 --- a/patches/server/Improve-entity-effect-API.patch +++ b/patches/server/Improve-entity-effect-API.patch @@ -82,10 +82,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.Map; +import java.util.Set; +import net.minecraft.world.entity.EntityEvent; ++import org.bukkit.support.environment.Normal; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.fail; + ++@Normal +public class EntityEffectTest { + + private static List collectNmsLevelEvents() throws ReflectiveOperationException { diff --git a/patches/server/Improve-java-version-check.patch b/patches/server/Improve-java-version-check.patch index 27baed2e6a..a8edc737b5 100644 --- a/patches/server/Improve-java-version-check.patch +++ b/patches/server/Improve-java-version-check.patch @@ -14,8 +14,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - float javaVersion = Float.parseFloat(System.getProperty("java.class.version")); -- if (javaVersion > 66.0) { -- System.err.println("Unsupported Java detected (" + javaVersion + "). Only up to Java 22 is supported."); +- if (javaVersion > 67.0) { +- System.err.println("Unsupported Java detected (" + javaVersion + "). Only up to Java 23 is supported."); - return; + // Paper start - Improve java version check + boolean skip = Boolean.getBoolean("Paper.IgnoreJavaVersion"); diff --git a/patches/server/ItemStack-repair-check-API.patch b/patches/server/ItemStack-repair-check-API.patch index a70b46274c..06a766fcd7 100644 --- a/patches/server/ItemStack-repair-check-API.patch +++ b/patches/server/ItemStack-repair-check-API.patch @@ -33,14 +33,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; -+import org.bukkit.support.AbstractTestingBase; ++import org.bukkit.support.environment.VanillaFeature; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; -+import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + -+public class ItemStackRepairCheckTest extends AbstractTestingBase { ++@VanillaFeature ++public class ItemStackRepairCheckTest { + + @Test + public void testIsRepariableBy() { diff --git a/patches/server/Moonrise-optimisation-patches.patch b/patches/server/Moonrise-optimisation-patches.patch index 8ba5cedff0..e8389b11df 100644 --- a/patches/server/Moonrise-optimisation-patches.patch +++ b/patches/server/Moonrise-optimisation-patches.patch @@ -23006,18 +23006,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } - protected void updateFutures(ChunkMap chunkLoadingManager, Executor executor) { -- FullChunkStatus fullchunkstatus = ChunkLevel.fullStatus(this.oldTicketLevel); -- FullChunkStatus fullchunkstatus1 = ChunkLevel.fullStatus(this.ticketLevel); -- boolean flag = fullchunkstatus.isOrAfter(FullChunkStatus.FULL); -- boolean flag1 = fullchunkstatus1.isOrAfter(FullChunkStatus.FULL); -- // CraftBukkit start -- // ChunkUnloadEvent: Called before the chunk is unloaded: isChunkLoaded is still true and chunk can still be modified by plugins. -- if (flag && !flag1) { +- // CraftBukkit start +- // ChunkUnloadEvent: Called before the chunk is unloaded: isChunkLoaded is still true and chunk can still be modified by plugins. +- // SPIGOT-7780: Moved out of updateFutures to call all chunk unload events before calling updateHighestAllowedStatus for all chunks +- protected void callEventIfUnloading(ChunkMap playerchunkmap) { +- FullChunkStatus oldFullChunkStatus = ChunkLevel.fullStatus(this.oldTicketLevel); +- FullChunkStatus newFullChunkStatus = ChunkLevel.fullStatus(this.ticketLevel); +- boolean oldIsFull = oldFullChunkStatus.isOrAfter(FullChunkStatus.FULL); +- boolean newIsFull = newFullChunkStatus.isOrAfter(FullChunkStatus.FULL); +- if (oldIsFull && !newIsFull) { - this.getFullChunkFuture().thenAccept((either) -> { - LevelChunk chunk = (LevelChunk) either.orElse(null); - if (chunk != null) { -- chunkLoadingManager.callbackExecutor.execute(() -> { +- playerchunkmap.callbackExecutor.execute(() -> { - // Minecraft will apply the chunks tick lists to the world once the chunk got loaded, and then store the tick - // lists again inside the chunk once the chunk becomes inaccessible and set the chunk's needsSaving flag. - // These actions may however happen deferred, so we manually set the needsSaving flag already here. @@ -23032,9 +23033,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - }); - - // Run callback right away if the future was already done -- chunkLoadingManager.callbackExecutor.run(); +- playerchunkmap.callbackExecutor.run(); - } -- // CraftBukkit end +- } +- // CraftBukkit end +- + protected void updateFutures(ChunkMap chunkLoadingManager, Executor executor) { +- FullChunkStatus fullchunkstatus = ChunkLevel.fullStatus(this.oldTicketLevel); +- FullChunkStatus fullchunkstatus1 = ChunkLevel.fullStatus(this.ticketLevel); +- boolean flag = fullchunkstatus.isOrAfter(FullChunkStatus.FULL); +- boolean flag1 = fullchunkstatus1.isOrAfter(FullChunkStatus.FULL); - - this.wasAccessibleSinceLastSave |= flag1; - if (!flag && flag1) { @@ -24412,6 +24420,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - } - - if (!this.chunksToUpdateFutures.isEmpty()) { +- // CraftBukkit start - SPIGOT-7780: Call chunk unload events before updateHighestAllowedStatus +- this.chunksToUpdateFutures.forEach((playerchunk) -> { +- playerchunk.callEventIfUnloading(chunkLoadingManager); +- }); +- // CraftBukkit end - this.chunksToUpdateFutures.forEach((playerchunk) -> { - playerchunk.updateHighestAllowedStatus(chunkLoadingManager); - }); diff --git a/patches/server/More-PotionEffectType-API.patch b/patches/server/More-PotionEffectType-API.patch index 29671035df..bea67415b0 100644 --- a/patches/server/More-PotionEffectType-API.patch +++ b/patches/server/More-PotionEffectType-API.patch @@ -72,11 +72,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.minecraft.world.effect.MobEffectCategory; +import org.bukkit.craftbukkit.potion.CraftPotionEffectType; +import org.bukkit.potion.PotionEffectType; ++import org.bukkit.support.environment.AllFeatures; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + ++@AllFeatures +public class EffectCategoryTest { + + @Test diff --git a/patches/server/More-Projectile-API.patch b/patches/server/More-Projectile-API.patch index bbe97a147d..0af30d30b3 100644 --- a/patches/server/More-Projectile-API.patch +++ b/patches/server/More-Projectile-API.patch @@ -547,27 +547,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } else if (ThrownPotion.class.isAssignableFrom(projectile)) { if (LingeringPotion.class.isAssignableFrom(projectile)) { launch = new net.minecraft.world.entity.projectile.ThrownPotion(world, this.getHandle()); -@@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { - launch = new net.minecraft.world.entity.projectile.WitherSkull(world, this.getHandle(), vec); - } else if (DragonFireball.class.isAssignableFrom(projectile)) { - launch = new net.minecraft.world.entity.projectile.DragonFireball(world, this.getHandle(), vec); -- } else if (WindCharge.class.isAssignableFrom(projectile)) { -- launch = EntityType.WIND_CHARGE.create(world); -- ((net.minecraft.world.entity.projectile.windcharge.WindCharge) launch).setOwner(this.getHandle()); -- ((net.minecraft.world.entity.projectile.windcharge.WindCharge) launch).assignDirectionalMovement(vec, 0.1D); -+ // Paper start - more projectile API - correctly launch wind charges -+ } else if (org.bukkit.entity.AbstractWindCharge.class.isAssignableFrom(projectile)) { -+ if (org.bukkit.entity.BreezeWindCharge.class.isAssignableFrom(projectile)) { -+ launch = EntityType.BREEZE_WIND_CHARGE.create(world); -+ } else { -+ launch = EntityType.WIND_CHARGE.create(world); -+ } -+ ((net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge) launch).setOwner(this.getHandle()); -+ ((net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge) launch).shootFromRotation(this.getHandle(), this.getHandle().getXRot(), this.getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // Paper - copied from net.minecraft.world.item.WindChargeItem.use -+ // Paper end - more projectile API - correctly launch wind charges - } else { - launch = new LargeFireball(world, this.getHandle(), vec, 1); - } @@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { } else if (Firework.class.isAssignableFrom(projectile)) { Location location = this.getEyeLocation(); @@ -880,116 +859,38 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public T launchProjectile(Class projectile, Vector velocity, java.util.function.Consumer function) { + // Paper end - launchProjectile consumer Preconditions.checkArgument(this.getBlock().getType() == Material.DISPENSER, "Block is no longer dispenser"); -- // Copied from BlockDispenser.dispense() -- BlockSource sourceblock = new BlockSource((ServerLevel) this.dispenserBlock.getLevel(), this.dispenserBlock.getBlockPos(), this.dispenserBlock.getBlockState(), this.dispenserBlock); -- // Copied from DispenseBehaviorProjectile -- Position iposition = DispenserBlock.getDispensePosition(sourceblock); -- Direction enumdirection = (Direction) sourceblock.state().getValue(DispenserBlock.FACING); -- net.minecraft.world.level.Level world = this.dispenserBlock.getLevel(); -- net.minecraft.world.entity.Entity launch = null; - -+ // Paper start - rewrite whole method to match ProjectileDispenseBehavior -+ net.minecraft.world.item.Item item = null; - if (Snowball.class.isAssignableFrom(projectile)) { -- launch = new net.minecraft.world.entity.projectile.Snowball(world, iposition.x(), iposition.y(), iposition.z()); -+ item = net.minecraft.world.item.Items.SNOWBALL; - } else if (Egg.class.isAssignableFrom(projectile)) { -- launch = new ThrownEgg(world, iposition.x(), iposition.y(), iposition.z()); -- } else if (EnderPearl.class.isAssignableFrom(projectile)) { -- launch = new ThrownEnderpearl(world, null); -- launch.setPos(iposition.x(), iposition.y(), iposition.z()); -+ item = net.minecraft.world.item.Items.EGG; - } else if (ThrownExpBottle.class.isAssignableFrom(projectile)) { -- launch = new ThrownExperienceBottle(world, iposition.x(), iposition.y(), iposition.z()); -+ item = net.minecraft.world.item.Items.EXPERIENCE_BOTTLE; - } else if (ThrownPotion.class.isAssignableFrom(projectile)) { - if (LingeringPotion.class.isAssignableFrom(projectile)) { -- launch = new net.minecraft.world.entity.projectile.ThrownPotion(world, iposition.x(), iposition.y(), iposition.z()); -- ((net.minecraft.world.entity.projectile.ThrownPotion) launch).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.LINGERING_POTION, 1))); -+ item = net.minecraft.world.item.Items.LINGERING_POTION; - } else { -- launch = new net.minecraft.world.entity.projectile.ThrownPotion(world, iposition.x(), iposition.y(), iposition.z()); -- ((net.minecraft.world.entity.projectile.ThrownPotion) launch).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.SPLASH_POTION, 1))); -+ item = net.minecraft.world.item.Items.SPLASH_POTION; - } - } else if (AbstractArrow.class.isAssignableFrom(projectile)) { -- if (TippedArrow.class.isAssignableFrom(projectile)) { -- launch = new net.minecraft.world.entity.projectile.Arrow(world, iposition.x(), iposition.y(), iposition.z(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.ARROW), null); -- ((Arrow) launch.getBukkitEntity()).setBasePotionType(PotionType.WATER); -- } else if (SpectralArrow.class.isAssignableFrom(projectile)) { -- launch = new net.minecraft.world.entity.projectile.SpectralArrow(world, iposition.x(), iposition.y(), iposition.z(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.SPECTRAL_ARROW), null); -+ if (SpectralArrow.class.isAssignableFrom(projectile)) { -+ item = net.minecraft.world.item.Items.SPECTRAL_ARROW; - } else { -- launch = new net.minecraft.world.entity.projectile.Arrow(world, iposition.x(), iposition.y(), iposition.z(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.ARROW), null); -- } -- ((net.minecraft.world.entity.projectile.AbstractArrow) launch).pickup = net.minecraft.world.entity.projectile.AbstractArrow.Pickup.ALLOWED; -- ((net.minecraft.world.entity.projectile.AbstractArrow) launch).projectileSource = this; -- } else if (Fireball.class.isAssignableFrom(projectile)) { -- double d0 = iposition.x() + (double) ((float) enumdirection.getStepX() * 0.3F); -- double d1 = iposition.y() + (double) ((float) enumdirection.getStepY() * 0.3F); -- double d2 = iposition.z() + (double) ((float) enumdirection.getStepZ() * 0.3F); -- RandomSource random = world.random; -- double d3 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepX(); -- double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepY(); -- double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepZ(); -- -- if (SmallFireball.class.isAssignableFrom(projectile)) { -- launch = new net.minecraft.world.entity.projectile.SmallFireball(world, null, new Vec3(d0, d1, d2)); -- } else if (WitherSkull.class.isAssignableFrom(projectile)) { -- launch = EntityType.WITHER_SKULL.create(world); -- launch.setPos(d0, d1, d2); -- -- ((AbstractHurtingProjectile) launch).assignDirectionalMovement(new Vec3(d3, d4, d5), 0.1D); ++ + // Copied from BlockDispenser.dispense() + BlockSource sourceblock = new BlockSource((ServerLevel) this.dispenserBlock.getLevel(), this.dispenserBlock.getBlockPos(), this.dispenserBlock.getBlockState(), this.dispenserBlock); + // Copied from DispenseBehaviorProjectile +@@ -0,0 +0,0 @@ public class CraftBlockProjectileSource implements BlockProjectileSource { + } else if (Fireball.class.isAssignableFrom(projectile)) { + if (AbstractWindCharge.class.isAssignableFrom(projectile)) { + item = Items.WIND_CHARGE; - } else { -- launch = EntityType.FIREBALL.create(world); -- launch.setPos(d0, d1, d2); -- -- ((AbstractHurtingProjectile) launch).assignDirectionalMovement(new Vec3(d3, d4, d5), 0.1D); -+ item = net.minecraft.world.item.Items.ARROW; ++ } else if (org.bukkit.entity.SmallFireball.class.isAssignableFrom(projectile)) { // Paper - more projectile API - only allow firing fire charges. + item = Items.FIRE_CHARGE; } -+ } else if (org.bukkit.entity.WindCharge.class.isAssignableFrom(projectile)) { -+ item = net.minecraft.world.item.Items.WIND_CHARGE; -+ } else if (org.bukkit.entity.Firework.class.isAssignableFrom(projectile)) { -+ item = net.minecraft.world.item.Items.FIREWORK_ROCKET; -+ } else if (SmallFireball.class.isAssignableFrom(projectile)) { -+ item = net.minecraft.world.item.Items.FIRE_CHARGE; -+ } + } else if (Firework.class.isAssignableFrom(projectile)) { +@@ -0,0 +0,0 @@ public class CraftBlockProjectileSource implements BlockProjectileSource { + Position iposition = dispenseConfig.positionFunction().getDispensePosition(sourceblock, enumdirection); + net.minecraft.world.entity.projectile.Projectile launch = projectileItem.asProjectile(world, iposition, itemstack, enumdirection); -- ((AbstractHurtingProjectile) launch).projectileSource = this; -+ if (!(item instanceof net.minecraft.world.item.ProjectileItem projectileItem)) { -+ throw new IllegalArgumentException("Projectile '%s' is not supported".formatted(projectile.getSimpleName())); +- if (Fireball.class.isAssignableFrom(projectile)) { ++ if (false && Fireball.class.isAssignableFrom(projectile)) { // Paper - more project API - dispensers cannot launch anything but fire charges. + AbstractHurtingProjectile customFireball = null; + if (WitherSkull.class.isAssignableFrom(projectile)) { + launch = customFireball = EntityType.WITHER_SKULL.create(world); +@@ -0,0 +0,0 @@ public class CraftBlockProjectileSource implements BlockProjectileSource { + } } -- Preconditions.checkArgument(launch != null, "Projectile not supported"); -+ net.minecraft.world.item.ProjectileItem.DispenseConfig config = projectileItem.createDispenseConfig(); -+ net.minecraft.world.level.block.state.BlockState state = this.dispenserBlock.getBlockState(); -+ net.minecraft.world.level.Level world = this.dispenserBlock.getLevel(); -+ BlockSource pointer = new BlockSource((ServerLevel) world, this.dispenserBlock.getBlockPos(), state, this.dispenserBlock); // copied from DispenseBlock#dispenseFrom -+ Direction facing = state.getValue(DispenserBlock.FACING); -+ Position pos = config.positionFunction().getDispensePosition(pointer, facing); - -- if (launch instanceof net.minecraft.world.entity.projectile.Projectile) { -- if (launch instanceof ThrowableProjectile) { -- ((ThrowableProjectile) launch).projectileSource = this; -- } -- // Values from DispenseBehaviorProjectile -- float a = 6.0F; -- float b = 1.1F; -- if (launch instanceof net.minecraft.world.entity.projectile.ThrownPotion || launch instanceof ThrownExpBottle) { -- // Values from respective DispenseBehavior classes -- a *= 0.5F; -- b *= 1.25F; -- } -- // Copied from DispenseBehaviorProjectile -- ((net.minecraft.world.entity.projectile.Projectile) launch).shoot((double) enumdirection.getStepX(), (double) ((float) enumdirection.getStepY() + 0.1F), (double) enumdirection.getStepZ(), b, a); -- } -+ net.minecraft.world.entity.projectile.Projectile launch = projectileItem.asProjectile(world, pos, new net.minecraft.world.item.ItemStack(item), facing); -+ // some projectile are not shoot and doesn't rely on the config for power/uncertainty -+ projectileItem.shoot(launch, facing.getStepX(), facing.getStepY(), facing.getStepZ(), config.power(), config.uncertainty()); -+ launch.projectileSource = this; -+ // Paper end - +- if (launch instanceof net.minecraft.world.entity.projectile.AbstractArrow arrow) { ++ if (false && launch instanceof net.minecraft.world.entity.projectile.AbstractArrow arrow) { // Paper - more projectile API - this is set by the respective ArrowItem when constructing the projectile + arrow.pickup = net.minecraft.world.entity.projectile.AbstractArrow.Pickup.ALLOWED; + } + launch.projectileSource = this; +@@ -0,0 +0,0 @@ public class CraftBlockProjectileSource implements BlockProjectileSource { if (velocity != null) { ((T) launch.getBukkitEntity()).setVelocity(velocity); } diff --git a/patches/server/Option-to-prevent-data-components-copy-in-smithing-r.patch b/patches/server/Option-to-prevent-data-components-copy-in-smithing-r.patch index 35aa037fd9..352f85151a 100644 --- a/patches/server/Option-to-prevent-data-components-copy-in-smithing-r.patch +++ b/patches/server/Option-to-prevent-data-components-copy-in-smithing-r.patch @@ -108,8 +108,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void addToCraftingManager() { ItemStack result = this.getResult(); -- MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTransformRecipe(this.toNMS(this.getTemplate(), true), this.toNMS(this.getBase(), true), this.toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result)))); -+ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTransformRecipe(this.toNMS(this.getTemplate(), true), this.toNMS(this.getBase(), true), this.toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result), this.willCopyDataComponents()))); // Paper - Option to prevent data components copy +- MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTransformRecipe(this.toNMS(this.getTemplate(), false), this.toNMS(this.getBase(), false), this.toNMS(this.getAddition(), false), CraftItemStack.asNMSCopy(result)))); ++ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTransformRecipe(this.toNMS(this.getTemplate(), false), this.toNMS(this.getBase(), false), this.toNMS(this.getAddition(), false), CraftItemStack.asNMSCopy(result), this.willCopyDataComponents()))); // Paper - Option to prevent data components copy } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java @@ -137,7 +137,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void addToCraftingManager() { -- MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTrimRecipe(this.toNMS(this.getTemplate(), true), this.toNMS(this.getBase(), true), this.toNMS(this.getAddition(), true)))); -+ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTrimRecipe(this.toNMS(this.getTemplate(), true), this.toNMS(this.getBase(), true), this.toNMS(this.getAddition(), true), this.willCopyDataComponents()))); // Paper - Option to prevent data components copy +- MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTrimRecipe(this.toNMS(this.getTemplate(), false), this.toNMS(this.getBase(), false), this.toNMS(this.getAddition(), false)))); ++ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTrimRecipe(this.toNMS(this.getTemplate(), false), this.toNMS(this.getBase(), false), this.toNMS(this.getAddition(), false), this.willCopyDataComponents()))); // Paper - Option to prevent data components copy } } diff --git a/patches/server/Paper-Plugins.patch b/patches/server/Paper-Plugins.patch index a054bd0435..b4d013e11f 100644 --- a/patches/server/Paper-Plugins.patch +++ b/patches/server/Paper-Plugins.patch @@ -7532,12 +7532,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import io.papermc.paper.plugin.entrypoint.dependency.MetaDependencyTree; +import io.papermc.paper.plugin.entrypoint.dependency.SimpleMetaDependencyTree; ++import org.bukkit.support.environment.Normal; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static org.hamcrest.MatcherAssert.assertThat; + ++@Normal +public class PluginDependencyValidationTest { + + private static final TestPluginMeta MAIN; @@ -7602,6 +7604,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import io.papermc.paper.plugin.entrypoint.strategy.modern.ModernPluginLoadingStrategy; +import io.papermc.paper.plugin.entrypoint.strategy.ProviderConfiguration; +import io.papermc.paper.plugin.provider.PluginProvider; ++import org.bukkit.support.environment.Normal; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; @@ -7612,6 +7615,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; + ++@Normal +public class PluginLoadOrderTest { + + private static List> REGISTERED_PROVIDERS = new ArrayList<>(); @@ -7754,14 +7758,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Event; +import org.bukkit.permissions.Permission; +import org.bukkit.plugin.PluginManager; -+import org.bukkit.support.AbstractTestingBase; ++import org.bukkit.support.environment.Normal; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; -+import static org.hamcrest.Matchers.*; ++import static org.hamcrest.Matchers.empty; ++import static org.hamcrest.Matchers.is; ++import static org.hamcrest.Matchers.nullValue; + -+public class PluginManagerTest extends AbstractTestingBase { ++@Normal ++public class PluginManagerTest { + + private static final PluginManager pm = Bukkit.getPluginManager(); + @@ -7832,9 +7839,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +package io.papermc.paper.plugin; + +import io.papermc.paper.plugin.provider.configuration.PaperPluginMeta; ++import org.bukkit.support.environment.Normal; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + ++@Normal +public class PluginNamingTest { + private static final String TEST_NAME = "Test_Plugin"; + private static final String TEST_VERSION = "1.0"; @@ -7870,9 +7879,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Event; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; ++import org.bukkit.support.environment.Normal; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + ++@Normal +public class SyntheticEventTest { + + @Test @@ -8142,16 +8153,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return "null"; + } +} -diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java +diff --git a/src/test/java/org/bukkit/support/DummyServerHelper.java b/src/test/java/org/bukkit/support/DummyServerHelper.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/test/java/org/bukkit/support/DummyServer.java -+++ b/src/test/java/org/bukkit/support/DummyServer.java -@@ -0,0 +0,0 @@ public final class DummyServer { - final Thread currentThread = Thread.currentThread(); - when(instance.isPrimaryThread()).thenAnswer(ignored -> Thread.currentThread().equals(currentThread)); - -- final org.bukkit.plugin.PluginManager pluginManager = new org.bukkit.plugin.SimplePluginManager(instance, new org.bukkit.command.SimpleCommandMap(instance)); -+ final org.bukkit.plugin.PluginManager pluginManager = new io.papermc.paper.plugin.manager.PaperPluginManagerImpl(instance, new org.bukkit.command.SimpleCommandMap(instance), null); - when(instance.getPluginManager()).thenReturn(pluginManager); - // paper end - testing additions +--- a/src/test/java/org/bukkit/support/DummyServerHelper.java ++++ b/src/test/java/org/bukkit/support/DummyServerHelper.java +@@ -0,0 +0,0 @@ public final class DummyServerHelper { + // Paper start - testing additions + final Thread currentThread = Thread.currentThread(); + when(instance.isPrimaryThread()).thenAnswer(ignored -> Thread.currentThread().equals(currentThread)); +- final org.bukkit.plugin.PluginManager pluginManager = new org.bukkit.plugin.SimplePluginManager(instance, new org.bukkit.command.SimpleCommandMap(instance)); ++ final org.bukkit.plugin.PluginManager pluginManager = new io.papermc.paper.plugin.manager.PaperPluginManagerImpl(instance, new org.bukkit.command.SimpleCommandMap(instance), null); + when(instance.getPluginManager()).thenReturn(pluginManager); + // Paper end - testing additions diff --git a/patches/server/Paper-config-files.patch b/patches/server/Paper-config-files.patch index 67392ccae7..f01a9e6a8c 100644 --- a/patches/server/Paper-config-files.patch +++ b/patches/server/Paper-config-files.patch @@ -21,7 +21,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ dependencies { implementation("jline:jline:2.12.1") implementation("org.apache.logging.log4j:log4j-iostreams:2.22.1") // Paper - remove exclusion - implementation("org.ow2.asm:asm-commons:9.7") + implementation("org.ow2.asm:asm-commons:9.7.1") + implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") // Paper - config files implementation("commons-lang:commons-lang:2.6") runtimeOnly("org.xerial:sqlite-jdbc:3.46.0.0") @@ -5362,15 +5362,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + } +} -diff --git a/src/test/java/org/bukkit/support/AbstractTestingBase.java b/src/test/java/org/bukkit/support/AbstractTestingBase.java +diff --git a/src/test/java/org/bukkit/support/DummyServerHelper.java b/src/test/java/org/bukkit/support/DummyServerHelper.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/test/java/org/bukkit/support/AbstractTestingBase.java -+++ b/src/test/java/org/bukkit/support/AbstractTestingBase.java -@@ -0,0 +0,0 @@ public abstract class AbstractTestingBase { - BIOMES = REGISTRY_CUSTOM.registryOrThrow(Registries.BIOME); - - DummyServer.setup(); -+ io.papermc.paper.configuration.GlobalConfigTestingBase.setupGlobalConfigForTest(); // Paper - - CraftRegistry.setMinecraftRegistry(REGISTRY_CUSTOM); +--- a/src/test/java/org/bukkit/support/DummyServerHelper.java ++++ b/src/test/java/org/bukkit/support/DummyServerHelper.java +@@ -0,0 +0,0 @@ public final class DummyServerHelper { + when(instance.getPluginManager()).thenReturn(pluginManager); + // Paper end - testing additions ++ io.papermc.paper.configuration.GlobalConfigTestingBase.setupGlobalConfigForTest(); // Paper - configuration files - setup global configuration test base + return instance; + } + } diff --git a/patches/server/Plugin-remapping.patch b/patches/server/Plugin-remapping.patch index d1b66f5766..c03bd394eb 100644 --- a/patches/server/Plugin-remapping.patch +++ b/patches/server/Plugin-remapping.patch @@ -10,7 +10,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -0,0 +0,0 @@ dependencies { - testImplementation("org.ow2.asm:asm-tree:9.7") + testImplementation("org.ow2.asm:asm-tree:9.7.1") testImplementation("org.junit-pioneer:junit-pioneer:2.2.0") // Paper - CartesianTest implementation("net.neoforged:srgutils:1.0.9") // Paper - mappings handling + implementation("net.neoforged:AutoRenamingTool:2.0.3") // Paper - remap plugins diff --git a/patches/server/Properly-destroy-placed-blocks-on-the-end-platform.patch b/patches/server/Properly-destroy-placed-blocks-on-the-end-platform.patch index 2ce4c22f67..d76758496b 100644 --- a/patches/server/Properly-destroy-placed-blocks-on-the-end-platform.patch +++ b/patches/server/Properly-destroy-placed-blocks-on-the-end-platform.patch @@ -24,17 +24,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } blockList.setBlock(blockposition_mutableblockposition1, block.defaultBlockState(), 3); -@@ -0,0 +0,0 @@ public class EndPlatformFeature extends Feature { - - worldaccess.getLevel().getCraftServer().getPluginManager().callEvent(portalEvent); - if (!portalEvent.isCancelled()) { -+ // Paper start - Properly destroy placed blocks on the end platform -+ if (flag) { -+ for (org.bukkit.craftbukkit.block.CraftBlockState state : blockList.getList()) { -+ worldaccess.destroyBlock(state.getPosition(), true); -+ } -+ } -+ // Paper end - Properly destroy placed blocks on the end platform - blockList.updateList(); - } - // CraftBukkit end diff --git a/patches/server/Properly-handle-BlockBreakEvent-isDropItems.patch b/patches/server/Properly-handle-BlockBreakEvent-isDropItems.patch index 071f4ecb43..4942b5a102 100644 --- a/patches/server/Properly-handle-BlockBreakEvent-isDropItems.patch +++ b/patches/server/Properly-handle-BlockBreakEvent-isDropItems.patch @@ -123,13 +123,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; -+import org.bukkit.support.AbstractTestingBase; ++import org.bukkit.support.environment.Normal; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; + -+public class BlockPlayerDestroyOverrideTest extends AbstractTestingBase { ++@Normal ++public class BlockPlayerDestroyOverrideTest { + + public static Stream parameters() { + final List classInfo = new ArrayList<>(); diff --git a/patches/server/Proxy-ItemStack-to-CraftItemStack.patch b/patches/server/Proxy-ItemStack-to-CraftItemStack.patch index 47d84f51ef..799a838349 100644 --- a/patches/server/Proxy-ItemStack-to-CraftItemStack.patch +++ b/patches/server/Proxy-ItemStack-to-CraftItemStack.patch @@ -233,7 +233,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.Material; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.inventory.ItemStack; -+import org.bukkit.support.AbstractTestingBase; ++import org.bukkit.support.environment.VanillaFeature; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; @@ -241,7 +241,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + -+public abstract class ConfigurationSectionTest extends AbstractTestingBase { ++public abstract class ConfigurationSectionTest { + public abstract ConfigurationSection getConfigurationSection(); + + @Test @@ -291,7 +291,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.MemoryConfiguration; ++import org.bukkit.support.environment.Normal; + ++@Normal +public class MemorySectionTest extends ConfigurationSectionTest { + @Override + public ConfigurationSection getConfigurationSection() { diff --git a/patches/server/Registry-Modification-API.patch b/patches/server/Registry-Modification-API.patch index 8d5a26c33e..b9425d5f14 100644 --- a/patches/server/Registry-Modification-API.patch +++ b/patches/server/Registry-Modification-API.patch @@ -946,6 +946,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import java.util.Iterator; import java.util.function.Supplier; import java.util.stream.Stream; +@@ -0,0 +0,0 @@ import net.kyori.adventure.key.Key; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; import org.bukkit.Registry; @@ -1403,7 +1404,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.minecraft.core.Registry; +import net.minecraft.resources.RegistryOps; +import net.minecraft.resources.ResourceKey; -+import org.bukkit.support.AbstractTestingBase; ++import org.bukkit.support.RegistryHelper; ++import org.bukkit.support.environment.AllFeatures; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; @@ -1411,7 +1413,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import static org.junit.jupiter.api.Assertions.assertEquals; + -+class RegistryBuilderTest extends AbstractTestingBase { ++@AllFeatures ++class RegistryBuilderTest { + + static List registries() { + return List.of( @@ -1422,10 +1425,74 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @ParameterizedTest + @MethodSource("registries") + void testEquality(final ResourceKey> resourceKey, final PaperRegistryBuilder.Filler filler) { -+ final Registry registry = AbstractTestingBase.REGISTRY_CUSTOM.registryOrThrow(resourceKey); ++ final Registry registry = RegistryHelper.getRegistry().registryOrThrow(resourceKey); + for (final Map.Entry, M> entry : registry.entrySet()) { -+ final M built = filler.fill(new Conversions(new RegistryOps.HolderLookupAdapter(AbstractTestingBase.REGISTRY_CUSTOM)), PaperRegistries.fromNms(entry.getKey()), entry.getValue()).build(); ++ final M built = filler.fill(new Conversions(new RegistryOps.HolderLookupAdapter(RegistryHelper.getRegistry())), PaperRegistries.fromNms(entry.getKey()), entry.getValue()).build(); + assertEquals(entry.getValue(), built); + } + } +} +diff --git a/src/test/java/org/bukkit/registry/RegistryClassTest.java b/src/test/java/org/bukkit/registry/RegistryClassTest.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/test/java/org/bukkit/registry/RegistryClassTest.java ++++ b/src/test/java/org/bukkit/registry/RegistryClassTest.java +@@ -0,0 +0,0 @@ public class RegistryClassTest { + outsideRequest.clear(); + MockUtil.resetMock(spyRegistry); + doAnswer(invocation -> { +- Keyed item = realRegistry.get(invocation.getArgument(0)); ++ Keyed item = realRegistry.get((NamespacedKey) invocation.getArgument(0)); // Paper - registry modification api - specifically call namespaced key overload + + if (item == null) { + nullValue.add(invocation.getArgument(0)); +@@ -0,0 +0,0 @@ public class RegistryClassTest { + nullAble.add(invocation.getArgument(0)); + + return item; +- }).when(spyRegistry).get(any()); ++ }).when(spyRegistry).get((NamespacedKey) any()); // Paper - registry modification api - specifically call namespaced key overload + + doAnswer(invocation -> { +- Keyed item = realRegistry.get(invocation.getArgument(0)); ++ Keyed item = realRegistry.get((NamespacedKey) invocation.getArgument(0)); // Paper - registry modification api - specifically call namespaced key overload + + if (item == null) { + nullValue.add(invocation.getArgument(0)); +@@ -0,0 +0,0 @@ public class RegistryClassTest { + notNullAble.add(invocation.getArgument(0)); + + return item; +- }).when(spyRegistry).getOrThrow(any()); ++ }).when(spyRegistry).getOrThrow((NamespacedKey) any()); // Paper - registry modification api - specifically call namespaced key overload + + // Load class + try { +@@ -0,0 +0,0 @@ public class RegistryClassTest { + outsideRequest + .computeIfAbsent(type, ty -> new ArrayList<>()).add(invocation.getArgument(0)); + return mock(type); +- }).when(spyRegistry).get(any()); ++ }).when(spyRegistry).get((NamespacedKey) any()); // Paper - registry modification api - specifically call namespaced key overload + + doAnswer(invocation -> { + outsideRequest + .computeIfAbsent(type, ty -> new ArrayList<>()).add(invocation.getArgument(0)); + return mock(type); +- }).when(spyRegistry).getOrThrow(any()); ++ }).when(spyRegistry).getOrThrow((NamespacedKey) any()); // Paper - registry modification api - specifically call namespaced key overload + } + + private static void initFieldDataCache() { +diff --git a/src/test/java/org/bukkit/support/extension/NormalExtension.java b/src/test/java/org/bukkit/support/extension/NormalExtension.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/test/java/org/bukkit/support/extension/NormalExtension.java ++++ b/src/test/java/org/bukkit/support/extension/NormalExtension.java +@@ -0,0 +0,0 @@ public class NormalExtension extends BaseExtension { + + doAnswer(invocation -> + mocks.computeIfAbsent(invocation.getArgument(0), k -> mock(RegistryHelper.updateClass(keyed, invocation.getArgument(0)), withSettings().stubOnly().defaultAnswer(DEFAULT_ANSWER))) +- ).when(registry).get(any()); // Allow static classes to fill there fields, so that it does not error out, just by loading them ++ ).when(registry).get((NamespacedKey) any()); // Allow static classes to fill there fields, so that it does not error out, just by loading them // Paper - registry modification api - specifically call namespaced key overload + + return registry; + } diff --git a/patches/server/Remap-fixes.patch b/patches/server/Remap-fixes.patch index db2b065511..fe1d8ae127 100644 --- a/patches/server/Remap-fixes.patch +++ b/patches/server/Remap-fixes.patch @@ -82,10 +82,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import static org.hamcrest.Matchers.*; -import net.minecraft.world.item.DyeColor; - import org.bukkit.support.AbstractTestingBase; + import org.bukkit.support.environment.Normal; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; -@@ -0,0 +0,0 @@ public class DyeColorsTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class DyeColorsTest { @EnumSource(DyeColor.class) public void checkColor(DyeColor dye) { Color color = dye.getColor(); @@ -94,7 +94,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Color nmsColor = Color.fromARGB(nmsColorArray); assertThat(color, is(nmsColor)); } -@@ -0,0 +0,0 @@ public class DyeColorsTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class DyeColorsTest { @EnumSource(org.bukkit.DyeColor.class) public void checkFireworkColor(org.bukkit.DyeColor dye) { Color color = dye.getFireworkColor(); @@ -107,7 +107,7 @@ diff --git a/src/test/java/org/bukkit/ParticleTest.java b/src/test/java/org/bukk index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/test/java/org/bukkit/ParticleTest.java +++ b/src/test/java/org/bukkit/ParticleTest.java -@@ -0,0 +0,0 @@ public class ParticleTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class ParticleTest { Check in CraftParticle if the conversion is still correct. """, bukkit.getKey())); @@ -125,10 +125,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.entity.EntityType; - import org.bukkit.support.AbstractTestingBase; + import org.bukkit.support.environment.AllFeatures; import org.junit.jupiter.api.Test; -@@ -0,0 +0,0 @@ public class EntityTypesTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class EntityTypesTest { public void testMaps() { Set allBukkit = Arrays.stream(EntityType.values()).filter((b) -> b.getName() != null).collect(Collectors.toSet()); @@ -149,8 +149,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 -import net.minecraft.world.entity.animal.Panda; import org.bukkit.craftbukkit.entity.CraftPanda; + import org.bukkit.support.environment.Normal; import org.junit.jupiter.api.Test; - @@ -0,0 +0,0 @@ public class PandaGeneTest { @Test @@ -175,7 +175,7 @@ diff --git a/src/test/java/org/bukkit/registry/RegistryConstantsTest.java b/src/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/test/java/org/bukkit/registry/RegistryConstantsTest.java +++ b/src/test/java/org/bukkit/registry/RegistryConstantsTest.java -@@ -0,0 +0,0 @@ public class RegistryConstantsTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class RegistryConstantsTest { @Test public void testTrimMaterial() { @@ -200,7 +200,7 @@ diff --git a/src/test/java/org/bukkit/registry/RegistryLoadOrderTest.java b/src/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/test/java/org/bukkit/registry/RegistryLoadOrderTest.java +++ b/src/test/java/org/bukkit/registry/RegistryLoadOrderTest.java -@@ -0,0 +0,0 @@ public class RegistryLoadOrderTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class RegistryLoadOrderTest { private static boolean initInterface = false; private static boolean initAbstract = false; diff --git a/patches/server/Remap-reflection-calls-in-plugins-using-internals.patch b/patches/server/Remap-reflection-calls-in-plugins-using-internals.patch index 7a4e23f960..b8c3855e17 100644 --- a/patches/server/Remap-reflection-calls-in-plugins-using-internals.patch +++ b/patches/server/Remap-reflection-calls-in-plugins-using-internals.patch @@ -649,7 +649,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java +++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java @@ -0,0 +0,0 @@ public class Commodore { - private static final Map ENUM_METHOD_REROUTE = Commodore.createReroutes(EnumEvil.class); + } // Paper start - Plugin rewrites - private static final Map SEARCH_AND_REMOVE = initReplacementsMap(); @@ -711,10 +711,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ import org.bukkit.potion.PotionType; @SuppressWarnings("deprecation") public final class CraftMagicNumbers implements UnsafeValues { - public static final UnsafeValues INSTANCE = new CraftMagicNumbers(); + public static final CraftMagicNumbers INSTANCE = new CraftMagicNumbers(); + public static final boolean DISABLE_OLD_API_SUPPORT = Boolean.getBoolean("paper.disableOldApiSupport"); // Paper - private CraftMagicNumbers() {} + private final Commodore commodore = new Commodore(); @@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues { throw new InvalidPluginException("Plugin API version " + pdf.getAPIVersion() + " is lower than the minimum allowed version. Please update or replace it."); @@ -736,5 +736,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end try { - clazz = Commodore.convert(clazz, pdf.getName(), ApiVersion.getOrCreateVersion(pdf.getAPIVersion()), ((CraftServer) Bukkit.getServer()).activeCompatibilities); + clazz = this.commodore.convert(clazz, pdf.getName(), ApiVersion.getOrCreateVersion(pdf.getAPIVersion()), ((CraftServer) Bukkit.getServer()).activeCompatibilities); } catch (Exception ex) { diff --git a/patches/server/Setup-Gradle-project.patch b/patches/server/Setup-Gradle-project.patch index b772730947..7f7671ec22 100644 --- a/patches/server/Setup-Gradle-project.patch +++ b/patches/server/Setup-Gradle-project.patch @@ -45,7 +45,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + implementation("org.apache.logging.log4j:log4j-iostreams:2.22.1") { + exclude(group = "org.apache.logging.log4j", module = "log4j-api") + } -+ implementation("org.ow2.asm:asm-commons:9.7") ++ implementation("org.ow2.asm:asm-commons:9.7.1") + implementation("commons-lang:commons-lang:2.6") + runtimeOnly("org.xerial:sqlite-jdbc:3.46.0.0") + runtimeOnly("com.mysql:mysql-connector-j:8.4.0") @@ -55,9 +55,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.18") + + testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") ++ testImplementation("org.junit.platform:junit-platform-suite-engine:1.10.0") + testImplementation("org.hamcrest:hamcrest:2.2") -+ testImplementation("org.mockito:mockito-core:5.11.0") -+ testImplementation("org.ow2.asm:asm-tree:9.7") ++ testImplementation("org.mockito:mockito-core:5.14.1") ++ testImplementation("org.ow2.asm:asm-tree:9.7.1") +} + +paperweight { @@ -93,8 +94,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +} + +tasks.test { -+ exclude("org/bukkit/craftbukkit/inventory/ItemStack*Test.class") -+ useJUnitPlatform() ++ include("**/**TestSuite.class") ++ workingDir = temporaryDir ++ useJUnitPlatform { ++ forkEvery = 1 ++ excludeTags("Slow") ++ } +} + +fun TaskContainer.registerRunTask( @@ -183,6 +188,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - - true +- AllFeatures,Bundle,Legacy,Normal,VanillaFeature - UTF-8 - unknown - git @@ -226,7 +232,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - org.ow2.asm - asm-commons -- 9.7 +- 9.7.1 - compile - - @@ -448,6 +454,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - test - - +- org.junit.platform +- junit-platform-suite-engine +- 1.10.0 +- test +- +- - org.hamcrest - hamcrest - 2.2 @@ -456,13 +468,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - org.mockito - mockito-core -- 5.11.0 +- 5.14.1 - test - - - org.ow2.asm - asm-tree -- 9.7 +- 9.7.1 - test - - @@ -675,9 +687,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - 3.2.5 - - ${basedir}/target/test-server -- -- org/bukkit/craftbukkit/inventory/ItemStack*Test.java -- +- false +- +- **/*TestSuite.java +- - - - diff --git a/patches/server/Test-changes.patch b/patches/server/Test-changes.patch index 08a464df56..a64a56f34f 100644 --- a/patches/server/Test-changes.patch +++ b/patches/server/Test-changes.patch @@ -11,8 +11,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/build.gradle.kts @@ -0,0 +0,0 @@ dependencies { testImplementation("org.hamcrest:hamcrest:2.2") - testImplementation("org.mockito:mockito-core:5.11.0") - testImplementation("org.ow2.asm:asm-tree:9.7") + testImplementation("org.mockito:mockito-core:5.14.1") + testImplementation("org.ow2.asm:asm-tree:9.7.1") + testImplementation("org.junit-pioneer:junit-pioneer:2.2.0") // Paper - CartesianTest } @@ -50,7 +50,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import static org.junit.jupiter.api.Assertions.assertTrue; + -+class RegistryKeyTest extends AbstractTestingBase { ++@AllFeatures ++class RegistryKeyTest { + + @BeforeAll + static void before() throws ClassNotFoundException { @@ -64,7 +65,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @ParameterizedTest + @MethodSource("data") + void testApiRegistryKeysExist(final RegistryKey key) { -+ final Optional> registry = AbstractTestingBase.REGISTRY_CUSTOM.registry(ResourceKey.createRegistryKey(ResourceLocation.parse(key.key().asString()))); ++ final Optional> registry = RegistryHelper.getRegistry().registry(ResourceKey.createRegistryKey(ResourceLocation.parse(key.key().asString()))); + assertTrue(registry.isPresent(), "Missing vanilla registry for " + key.key().asString()); + + } @@ -338,11 +339,35 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +public @interface MethodParameterSource { + String[] value() default {}; +} +diff --git a/src/test/java/org/bukkit/ExplosionResultTest.java b/src/test/java/org/bukkit/ExplosionResultTest.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/test/java/org/bukkit/ExplosionResultTest.java ++++ b/src/test/java/org/bukkit/ExplosionResultTest.java +@@ -0,0 +0,0 @@ import net.minecraft.world.level.Explosion; + import org.bukkit.craftbukkit.CraftExplosionResult; + import org.junit.jupiter.api.Test; + ++@org.bukkit.support.environment.Normal // Paper - test changes - missing test suite annotation + public class ExplosionResultTest { + + @Test +diff --git a/src/test/java/org/bukkit/registry/RegistryClassTest.java b/src/test/java/org/bukkit/registry/RegistryClassTest.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/test/java/org/bukkit/registry/RegistryClassTest.java ++++ b/src/test/java/org/bukkit/registry/RegistryClassTest.java +@@ -0,0 +0,0 @@ import org.objectweb.asm.Type; + * Note: This test class assumes that feature flags only enable more features and do not disable vanilla ones. + */ + @AllFeatures ++@org.junit.jupiter.api.Disabled // Paper - disabled for now as it constructs a second root registry, which is not supported on paper + public class RegistryClassTest { + + private static final Map, Data> INIT_DATA = new HashMap<>(); diff --git a/src/test/java/org/bukkit/registry/RegistryConstantsTest.java b/src/test/java/org/bukkit/registry/RegistryConstantsTest.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/test/java/org/bukkit/registry/RegistryConstantsTest.java +++ b/src/test/java/org/bukkit/registry/RegistryConstantsTest.java -@@ -0,0 +0,0 @@ public class RegistryConstantsTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class RegistryConstantsTest { @Test public void testDamageType() { this.testExcessConstants(DamageType.class, Registry.DAMAGE_TYPE); @@ -351,68 +376,67 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } @Test -diff --git a/src/test/java/org/bukkit/support/AbstractTestingBase.java b/src/test/java/org/bukkit/support/AbstractTestingBase.java +diff --git a/src/test/java/org/bukkit/support/DummyServerHelper.java b/src/test/java/org/bukkit/support/DummyServerHelper.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/test/java/org/bukkit/support/AbstractTestingBase.java -+++ b/src/test/java/org/bukkit/support/AbstractTestingBase.java -@@ -0,0 +0,0 @@ public abstract class AbstractTestingBase { - MultiPackResourceManager resourceManager = new MultiPackResourceManager(PackType.SERVER_DATA, resourceRepository.getAvailablePacks().stream().map(Pack::open).toList()); +--- a/src/test/java/org/bukkit/support/DummyServerHelper.java ++++ b/src/test/java/org/bukkit/support/DummyServerHelper.java +@@ -0,0 +0,0 @@ public final class DummyServerHelper { + when(instance.getTag(any(), any(), any())).then(mock -> { + String registry = mock.getArgument(0); + Class clazz = mock.getArgument(2); +- MinecraftKey key = CraftNamespacedKey.toMinecraft(mock.getArgument(1)); ++ net.minecraft.resources.ResourceLocation key = CraftNamespacedKey.toMinecraft(mock.getArgument(1)); // Paper - address remapping issues + + switch (registry) { + case org.bukkit.Tag.REGISTRY_BLOCKS -> { +@@ -0,0 +0,0 @@ public final class DummyServerHelper { + } + case org.bukkit.Tag.REGISTRY_FLUIDS -> { + Preconditions.checkArgument(clazz == org.bukkit.Fluid.class, "Fluid namespace must have fluid type"); +- TagKey fluidTagKey = TagKey.create(Registries.FLUID, key); ++ TagKey fluidTagKey = TagKey.create(Registries.FLUID, key); // Paper - address remapping issues + if (BuiltInRegistries.FLUID.getTag(fluidTagKey).isPresent()) { + return new CraftFluidTag(BuiltInRegistries.FLUID, fluidTagKey); + } + } + case org.bukkit.Tag.REGISTRY_ENTITY_TYPES -> { + Preconditions.checkArgument(clazz == org.bukkit.entity.EntityType.class, "Entity type namespace must have entity type"); +- TagKey> entityTagKey = TagKey.create(Registries.ENTITY_TYPE, key); ++ TagKey> entityTagKey = TagKey.create(Registries.ENTITY_TYPE, key); // Paper - address remapping issues + if (BuiltInRegistries.ENTITY_TYPE.getTag(entityTagKey).isPresent()) { + return new CraftEntityTag(BuiltInRegistries.ENTITY_TYPE, entityTagKey); + } + } +- default -> throw new IllegalArgumentException(); ++ default -> new io.papermc.paper.util.EmptyTag(); // Paper - testing additions + } + + return null; + }); + ++ // Paper start - testing additions ++ final Thread currentThread = Thread.currentThread(); ++ when(instance.isPrimaryThread()).thenAnswer(ignored -> Thread.currentThread().equals(currentThread)); ++ final org.bukkit.plugin.PluginManager pluginManager = new org.bukkit.plugin.SimplePluginManager(instance, new org.bukkit.command.SimpleCommandMap(instance)); ++ when(instance.getPluginManager()).thenReturn(pluginManager); ++ // Paper end - testing additions ++ + return instance; + } + } +diff --git a/src/test/java/org/bukkit/support/RegistryHelper.java b/src/test/java/org/bukkit/support/RegistryHelper.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/test/java/org/bukkit/support/RegistryHelper.java ++++ b/src/test/java/org/bukkit/support/RegistryHelper.java +@@ -0,0 +0,0 @@ public final class RegistryHelper { + private static LayeredRegistryAccess createLayers(MultiPackResourceManager resourceManager) { // add tags and loot tables for unit tests LayeredRegistryAccess layers = RegistryLayer.createRegistryAccess(); + // Paper start - load registry here to ensure bukkit object registry are correctly delayed if needed + try { + Class.forName("org.bukkit.Registry"); -+ } catch (ClassNotFoundException ignored) {} ++ } catch (final ClassNotFoundException ignored) {} + // Paper end - load registry here to ensure bukkit object registry are correctly delayed if needed layers = WorldLoader.loadAndReplaceLayer(resourceManager, layers, RegistryLayer.WORLDGEN, RegistryDataLoader.WORLDGEN_REGISTRIES); - REGISTRY_CUSTOM = layers.compositeAccess().freeze(); - // Register vanilla pack -diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/test/java/org/bukkit/support/DummyServer.java -+++ b/src/test/java/org/bukkit/support/DummyServer.java -@@ -0,0 +0,0 @@ public final class DummyServer { - when(instance.getTag(any(), any(), any())).then(mock -> { - String registry = mock.getArgument(0); - Class clazz = mock.getArgument(2); -- MinecraftKey key = CraftNamespacedKey.toMinecraft(mock.getArgument(1)); -+ net.minecraft.resources.ResourceLocation key = CraftNamespacedKey.toMinecraft(mock.getArgument(1)); // Paper - address remapping issues - switch (registry) { - case org.bukkit.Tag.REGISTRY_BLOCKS -> { -@@ -0,0 +0,0 @@ public final class DummyServer { - } - case org.bukkit.Tag.REGISTRY_FLUIDS -> { - Preconditions.checkArgument(clazz == org.bukkit.Fluid.class, "Fluid namespace must have fluid type"); -- TagKey fluidTagKey = TagKey.create(Registries.FLUID, key); -+ TagKey fluidTagKey = TagKey.create(Registries.FLUID, key); // Paper - address remapping issues - if (BuiltInRegistries.FLUID.getTag(fluidTagKey).isPresent()) { - return new CraftFluidTag(BuiltInRegistries.FLUID, fluidTagKey); - } - } - case org.bukkit.Tag.REGISTRY_ENTITY_TYPES -> { - Preconditions.checkArgument(clazz == org.bukkit.entity.EntityType.class, "Entity type namespace must have entity type"); -- TagKey> entityTagKey = TagKey.create(Registries.ENTITY_TYPE, key); -+ TagKey> entityTagKey = TagKey.create(Registries.ENTITY_TYPE, key); // Paper - address remapping issues - if (BuiltInRegistries.ENTITY_TYPE.getTag(entityTagKey).isPresent()) { - return new CraftEntityTag(BuiltInRegistries.ENTITY_TYPE, entityTagKey); - } - } -- default -> throw new IllegalArgumentException(); -+ default -> new io.papermc.paper.util.EmptyTag(); // Paper - testing additions - } - - return null; - }); - -+ // Paper start - testing additions -+ final Thread currentThread = Thread.currentThread(); -+ when(instance.isPrimaryThread()).thenAnswer(ignored -> Thread.currentThread().equals(currentThread)); -+ -+ final org.bukkit.plugin.PluginManager pluginManager = new org.bukkit.plugin.SimplePluginManager(instance, new org.bukkit.command.SimpleCommandMap(instance)); -+ when(instance.getPluginManager()).thenReturn(pluginManager); -+ // paper end - testing additions -+ - Bukkit.setServer(instance); - } catch (Throwable t) { - throw new Error(t); + return layers; diff --git a/patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch b/patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch index d1c4fbb497..7e023950fb 100644 --- a/patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch +++ b/patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch @@ -57,7 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + alsoShade(log4jPlugins.output) + // Paper end implementation("org.apache.logging.log4j:log4j-iostreams:2.22.1") // Paper - remove exclusion - implementation("org.ow2.asm:asm-commons:9.7") + implementation("org.ow2.asm:asm-commons:9.7.1") implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") // Paper - config files @@ -0,0 +0,0 @@ tasks.check { dependsOn(scanJar) @@ -78,7 +78,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +// Paper end - use TCA for console improvements tasks.test { - exclude("org/bukkit/craftbukkit/inventory/ItemStack*Test.class") + include("**/**TestSuite.class") diff --git a/src/log4jPlugins/java/io/papermc/paper/console/StripANSIConverter.java b/src/log4jPlugins/java/io/papermc/paper/console/StripANSIConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 diff --git a/patches/server/fix-Instruments.patch b/patches/server/fix-Instruments.patch index 7b74139c22..baa0e657e9 100644 --- a/patches/server/fix-Instruments.patch +++ b/patches/server/fix-Instruments.patch @@ -35,13 +35,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.Instrument; +import org.bukkit.craftbukkit.CraftSound; +import org.bukkit.craftbukkit.block.data.CraftBlockData; -+import org.bukkit.support.AbstractTestingBase; ++import org.bukkit.support.environment.AllFeatures; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; + -+class InstrumentSoundTest extends AbstractTestingBase { ++@AllFeatures ++class InstrumentSoundTest { + + static Stream bukkitInstruments() { + return Arrays.stream(Instrument.values()).filter(i -> i.getSound() != null); diff --git a/patches/server/fix-item-meta-for-tadpole-buckets.patch b/patches/server/fix-item-meta-for-tadpole-buckets.patch index 4dd562928b..53329f3cbd 100644 --- a/patches/server/fix-item-meta-for-tadpole-buckets.patch +++ b/patches/server/fix-item-meta-for-tadpole-buckets.patch @@ -33,7 +33,7 @@ diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java b/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java +++ b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java -@@ -0,0 +0,0 @@ public class ItemMetaTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class ItemMetaTest { } } diff --git a/patches/server/improve-checking-handled-tags-in-itemmeta.patch b/patches/server/improve-checking-handled-tags-in-itemmeta.patch index 162ac964b4..19f0240ffa 100644 --- a/patches/server/improve-checking-handled-tags-in-itemmeta.patch +++ b/patches/server/improve-checking-handled-tags-in-itemmeta.patch @@ -295,7 +295,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java @@ -0,0 +0,0 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta - this.blockEntityTag = te.blockEntityTag; + this.position = te.position; } - CraftMetaBlockState(DataComponentPatch tag, Material material) { @@ -304,7 +304,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + super(tag, extraHandledDcts); // Paper this.material = material; - getOrEmpty(tag, CraftMetaBlockState.BLOCK_ENTITY_TAG).ifPresent((nbt) -> { + getOrEmpty(tag, CraftMetaBlockState.BLOCK_ENTITY_TAG).ifPresent((blockTag) -> { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java @@ -792,7 +792,7 @@ diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/DeprecatedItemMetaCu index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/DeprecatedItemMetaCustomValueTest.java +++ b/src/test/java/org/bukkit/craftbukkit/inventory/DeprecatedItemMetaCustomValueTest.java -@@ -0,0 +0,0 @@ public class DeprecatedItemMetaCustomValueTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class DeprecatedItemMetaCustomValueTest { CraftMetaItem.Applicator compound = new CraftMetaItem.Applicator(); itemMeta.applyToItem(compound); @@ -813,14 +813,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import io.github.classgraph.ClassInfo; +import io.github.classgraph.ClassInfoList; +import io.github.classgraph.ScanResult; -+import org.bukkit.support.AbstractTestingBase; ++import org.bukkit.support.environment.AllFeatures; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +// in cb package because of package-private stuff -+class MetaHandledTagsTest extends AbstractTestingBase { ++@AllFeatures ++class MetaHandledTagsTest { + + @Test + public void checkAllMetasHaveHandledTags() { @@ -843,7 +844,7 @@ diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/PersistentDataContai index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/PersistentDataContainerTest.java +++ b/src/test/java/org/bukkit/craftbukkit/inventory/PersistentDataContainerTest.java -@@ -0,0 +0,0 @@ public class PersistentDataContainerTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class PersistentDataContainerTest { CraftMetaItem.Applicator compound = new CraftMetaItem.Applicator(); itemMeta.applyToItem(compound); @@ -852,7 +853,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } @Test -@@ -0,0 +0,0 @@ public class PersistentDataContainerTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class PersistentDataContainerTest { @Test public void testEmptyListApplicationToAnyType() throws IOException { @@ -861,7 +862,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 final PersistentDataContainer container = craftItem.getPersistentDataContainer(); container.set(PersistentDataContainerTest.requestKey("list"), PersistentDataType.LIST.strings(), List.of()); -@@ -0,0 +0,0 @@ public class PersistentDataContainerTest extends AbstractTestingBase { +@@ -0,0 +0,0 @@ public class PersistentDataContainerTest { final CraftMetaItem.Applicator storage = new CraftMetaItem.Applicator(); craftItem.applyToItem(storage); diff --git a/work/Bukkit b/work/Bukkit index 1fc1020ad0..bb4e97c60d 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit 1fc1020ad0d91a1cf6bfaae6f0441c24be701fbf +Subproject commit bb4e97c60d2978a1d008f21295a5234228341e14 diff --git a/work/CraftBukkit b/work/CraftBukkit index bbb30e7a85..0a7bd6c81a 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit bbb30e7a853eb15c00dfea1bd46715101c777c8b +Subproject commit 0a7bd6c81a33cfaaa2f4d2456c6b237792f38fe6