Paper/patches/api/0105-PotionEffect-clone-methods.patch
Jake Potrebic 7af4cd3647
Updated Upstream (Bukkit/CraftBukkit) (#9013)
* Updated Upstream (Bukkit/CraftBukkit)

Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
150a2861 PR-827: Add BlockData#getPlacementMaterial
58c9c8ce SPIGOT-7301: Prevent creating non-openable inventories
3741079b PR-824: Expand upon PotionEffect API to better accommodate infinite durations

CraftBukkit Changes:
e5a7921f0 PR-1149: Add BlockData#getPlacementMaterial
58504fa61 SPIGOT-7302: Fix more issues with EntityDamageByEntity - Fix Projectile damage by dispenser - Fix cases where only exists a direct entity damager
48394703d Increase outdated build delay

* Improve docs for BlockData#getPlacementMaterial
2023-03-20 01:47:10 -07:00

45 lines
1.9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 3 Jun 2018 04:10:13 -0400
Subject: [PATCH] PotionEffect clone methods
diff --git a/src/main/java/org/bukkit/potion/PotionEffect.java b/src/main/java/org/bukkit/potion/PotionEffect.java
index 66dfed07bfb44e99a94fb02dc056e8601115994a..ccdca0d75868135dc7b96daeff2236b225c4add1 100644
--- a/src/main/java/org/bukkit/potion/PotionEffect.java
+++ b/src/main/java/org/bukkit/potion/PotionEffect.java
@@ -106,6 +106,33 @@ public class PotionEffect implements ConfigurationSerializable {
this(getEffectType(map), getInt(map, DURATION), getInt(map, AMPLIFIER), getBool(map, AMBIENT, false), getBool(map, PARTICLES, true), getBool(map, ICON, getBool(map, PARTICLES, true)));
}
+ // Paper start
+ @NotNull
+ public PotionEffect withType(@NotNull PotionEffectType type) {
+ return new PotionEffect(type, duration, amplifier, ambient, particles, icon);
+ }
+ @NotNull
+ public PotionEffect withDuration(int duration) {
+ return new PotionEffect(this.type, duration, amplifier, ambient, particles, icon);
+ }
+ @NotNull
+ public PotionEffect withAmplifier(int amplifier) {
+ return new PotionEffect(this.type, duration, amplifier, ambient, particles, icon);
+ }
+ @NotNull
+ public PotionEffect withAmbient(boolean ambient) {
+ return new PotionEffect(this.type, duration, amplifier, ambient, particles, icon);
+ }
+ @NotNull
+ public PotionEffect withParticles(boolean particles) {
+ return new PotionEffect(this.type, duration, amplifier, ambient, particles, icon);
+ }
+ @NotNull
+ public PotionEffect withIcon(boolean icon) {
+ return new PotionEffect(this.type, duration, amplifier, ambient, particles, icon);
+ }
+ // Paper end
+
@NotNull
private static PotionEffectType getEffectType(@NotNull Map<?, ?> map) {
int type = getInt(map, TYPE);