From 656cc3915f6897ccf69b766a21f62679caba6e07 Mon Sep 17 00:00:00 2001 From: Malfrador Date: Mon, 15 Jul 2024 12:31:41 +0200 Subject: [PATCH] Add AttributeModifier constructor without EquipmentSlotGroup (#11079) --- patches/api/Add-transient-modifier-API.patch | 27 ----------------- ...Attribute-Modifier-API-improvements.patch} | 30 ++++++++++++++++++- patches/api/Fix-upstream-javadocs.patch | 14 +++++++++ 3 files changed, 43 insertions(+), 28 deletions(-) delete mode 100644 patches/api/Add-transient-modifier-API.patch rename patches/api/{Add-UUID-attribute-modifier-API.patch => Attribute-Modifier-API-improvements.patch} (77%) diff --git a/patches/api/Add-transient-modifier-API.patch b/patches/api/Add-transient-modifier-API.patch deleted file mode 100644 index 421c5edf19..0000000000 --- a/patches/api/Add-transient-modifier-API.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Malfrador -Date: Wed, 31 May 2023 21:25:01 +0200 -Subject: [PATCH] Add transient modifier API - - -diff --git a/src/main/java/org/bukkit/attribute/AttributeInstance.java b/src/main/java/org/bukkit/attribute/AttributeInstance.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/attribute/AttributeInstance.java -+++ b/src/main/java/org/bukkit/attribute/AttributeInstance.java -@@ -0,0 +0,0 @@ public interface AttributeInstance { - */ - void addModifier(@NotNull AttributeModifier modifier); - -+ // Paper start - Transient modifier API -+ /** -+ * Add a transient modifier to this instance. -+ * Transient modifiers are not persisted (saved with the NBT data) -+ * -+ * @param modifier to add -+ */ -+ void addTransientModifier(@NotNull AttributeModifier modifier); -+ // Paper end -+ - /** - * Remove a modifier from this instance. - * diff --git a/patches/api/Add-UUID-attribute-modifier-API.patch b/patches/api/Attribute-Modifier-API-improvements.patch similarity index 77% rename from patches/api/Add-UUID-attribute-modifier-API.patch rename to patches/api/Attribute-Modifier-API-improvements.patch index 23ebbbce2c..1c13b51260 100644 --- a/patches/api/Add-UUID-attribute-modifier-API.patch +++ b/patches/api/Attribute-Modifier-API-improvements.patch @@ -1,8 +1,9 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: TonytheMacaroni Date: Thu, 9 Nov 2023 20:35:35 -0500 -Subject: [PATCH] Add UUID attribute modifier API +Subject: [PATCH] Attribute Modifier API improvements +Co-authored-by: Malfrador diff --git a/src/main/java/org/bukkit/attribute/AttributeInstance.java b/src/main/java/org/bukkit/attribute/AttributeInstance.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -51,6 +52,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 /** * Add a modifier to this instance. * +@@ -0,0 +0,0 @@ public interface AttributeInstance { + */ + void addModifier(@NotNull AttributeModifier modifier); + ++ // Paper start - Transient modifier API ++ /** ++ * Add a transient modifier to this instance. ++ * Transient modifiers are not persisted (saved with the NBT data) ++ * ++ * @param modifier to add ++ */ ++ void addTransientModifier(@NotNull AttributeModifier modifier); ++ // Paper end ++ + /** + * Remove a modifier from this instance. + * diff --git a/src/main/java/org/bukkit/attribute/AttributeModifier.java b/src/main/java/org/bukkit/attribute/AttributeModifier.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/attribute/AttributeModifier.java @@ -82,6 +100,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public AttributeModifier(@NotNull UUID uuid, @NotNull String name, double amount, @NotNull Operation operation, @NotNull EquipmentSlotGroup slot) { this(NamespacedKey.fromString(uuid.toString()), amount, operation, slot); } + ++ // Paper start - Add constructor without EquipmentSlotGroup ++ public AttributeModifier(@NotNull NamespacedKey key, double amount, @NotNull Operation operation) { ++ this(key, amount, operation, EquipmentSlotGroup.ANY); ++ } ++ // Paper end ++ + public AttributeModifier(@NotNull NamespacedKey key, double amount, @NotNull Operation operation, @NotNull EquipmentSlotGroup slot) { + Preconditions.checkArgument(key != null, "Key cannot be null"); + Preconditions.checkArgument(operation != null, "Operation cannot be null"); @@ -0,0 +0,0 @@ public class AttributeModifier implements ConfigurationSerializable, Keyed { * @deprecated attributes are now identified by keys */ diff --git a/patches/api/Fix-upstream-javadocs.patch b/patches/api/Fix-upstream-javadocs.patch index f12cc97985..347918afb9 100644 --- a/patches/api/Fix-upstream-javadocs.patch +++ b/patches/api/Fix-upstream-javadocs.patch @@ -185,6 +185,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 * temporarily freezing while locating an unexplored structure. *

* The {@code radius} is not a rigid square radius. Each structure may alter +diff --git a/src/main/java/org/bukkit/attribute/AttributeModifier.java b/src/main/java/org/bukkit/attribute/AttributeModifier.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/attribute/AttributeModifier.java ++++ b/src/main/java/org/bukkit/attribute/AttributeModifier.java +@@ -0,0 +0,0 @@ public class AttributeModifier implements ConfigurationSerializable, Keyed { + } + + /** +- * Get the {@link EquipmentSlot} this AttributeModifier is active on, +- * or null if this modifier is applicable for any slot. ++ * Get the {@link EquipmentSlotGroup} this AttributeModifier is active on. + * + * @return the slot + */ diff --git a/src/main/java/org/bukkit/block/Bed.java b/src/main/java/org/bukkit/block/Bed.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/block/Bed.java