From 6c30e5b15b856c45a6d4d554f15e5b894f185bfe Mon Sep 17 00:00:00 2001
From: Malfrador <malfrador@gmail.com>
Date: Wed, 31 May 2023 23:30:00 +0200
Subject: [PATCH] Add transient modifier API

---
 .../paper/attribute/UnmodifiableAttributeInstance.java    | 5 +++++
 .../craftbukkit/attribute/CraftAttributeInstance.java     | 8 ++++++++
 2 files changed, 13 insertions(+)

diff --git a/paper-server/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeInstance.java b/paper-server/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeInstance.java
index 12135ffeac..52439f4b95 100644
--- a/paper-server/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeInstance.java
+++ b/paper-server/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeInstance.java
@@ -23,6 +23,11 @@ public class UnmodifiableAttributeInstance extends CraftAttributeInstance {
         throw new UnsupportedOperationException("Cannot modify default attributes");
     }
 
+    @Override
+    public void addTransientModifier(AttributeModifier modifier) {
+        throw new UnsupportedOperationException("Cannot modify default attributes");
+    }
+
     @Override
     public void removeModifier(AttributeModifier modifier) {
         throw new UnsupportedOperationException("Cannot modify default attributes");
diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java b/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java
index 3b171a08bd..cd6a492f56 100644
--- a/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java
+++ b/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java
@@ -51,6 +51,14 @@ public class CraftAttributeInstance implements AttributeInstance {
         this.handle.addPermanentModifier(CraftAttributeInstance.convert(modifier));
     }
 
+    // Paper start - Transient modifier API
+    @Override
+    public void addTransientModifier(AttributeModifier modifier) {
+        Preconditions.checkArgument(modifier != null, "modifier");
+        this.handle.addTransientModifier(CraftAttributeInstance.convert(modifier));
+    }
+    // Paper end
+
     @Override
     public void removeModifier(AttributeModifier modifier) {
         Preconditions.checkArgument(modifier != null, "modifier");