Skip to content

Commit 5a60ffb

Browse files
committed
Make custom potion names not conflict with item custom names
1 parent 46f9735 commit 5a60ffb

File tree

2 files changed

+115
-0
lines changed

2 files changed

+115
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Nassim Jahnke <[email protected]>
3+
Date: Mon, 23 Dec 2024 19:53:19 +0100
4+
Subject: [PATCH] Fix dumb PotionMeta names
5+
6+
7+
diff --git a/src/main/java/org/bukkit/inventory/meta/PotionMeta.java b/src/main/java/org/bukkit/inventory/meta/PotionMeta.java
8+
index b61d2e322f80fcabae5e286cba8df9701ebcf5ea..355257ae899dc5d90965295ecb8cf8fe888ce9f0 100644
9+
--- a/src/main/java/org/bukkit/inventory/meta/PotionMeta.java
10+
+++ b/src/main/java/org/bukkit/inventory/meta/PotionMeta.java
11+
@@ -146,30 +146,69 @@ public interface PotionMeta extends ItemMeta {
12+
*/
13+
void setColor(@Nullable Color color);
14+
15+
+ // Paper start - fix dumb names
16+
/**
17+
* Checks for existence of a custom potion name translation suffix.
18+
*
19+
+ * @deprecated conflicting name, use {@link #hasCustomPotionName()}
20+
* @return true if this has a custom potion name
21+
*/
22+
- boolean hasCustomName();
23+
+ @Deprecated(forRemoval = true)
24+
+ default boolean hasCustomName() {
25+
+ return this.hasCustomPotionName();
26+
+ }
27+
28+
/**
29+
* Gets the potion name translation suffix that is set.
30+
* <p>
31+
- * Plugins should check that hasCustomName() returns <code>true</code>
32+
+ * Plugins should check that {@link #hasCustomPotionName()} returns {@code true}
33+
* before calling this method.
34+
*
35+
+ * @deprecated conflicting name, use {@link #getCustomPotionName()}
36+
* @return the potion name that is set
37+
*/
38+
+ @Deprecated(forRemoval = true)
39+
@Nullable
40+
- String getCustomName();
41+
+ default String getCustomName() {
42+
+ return this.getCustomPotionName();
43+
+ }
44+
45+
/**
46+
* Sets the potion name translation suffix.
47+
*
48+
+ * @deprecated conflicting name, use {@link #setCustomPotionName(String)}
49+
* @param name the name to set
50+
*/
51+
- void setCustomName(@Nullable String name);
52+
+ @Deprecated(forRemoval = true)
53+
+ default void setCustomName(@Nullable String name) {
54+
+ this.setCustomPotionName(name);
55+
+ }
56+
+
57+
+ /**
58+
+ * Checks for existence of a custom potion name translation suffix.
59+
+ *
60+
+ * @return true if this has a custom potion name
61+
+ */
62+
+ boolean hasCustomPotionName();
63+
+
64+
+ /**
65+
+ * Gets the potion name translation suffix that is set.
66+
+ * <p>
67+
+ * Plugins should check that {@link #hasCustomPotionName()} returns {@code true}
68+
+ * before calling this method.
69+
+ *
70+
+ * @return the potion name that is set
71+
+ */
72+
+ @Nullable
73+
+ String getCustomPotionName();
74+
+
75+
+ /**
76+
+ * Sets the potion name translation suffix.
77+
+ *
78+
+ * @param name the name to set
79+
+ */
80+
+ void setCustomPotionName(@Nullable String name);
81+
+ // Paper end - fix dumb names
82+
83+
@Override
84+
PotionMeta clone();
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Nassim Jahnke <[email protected]>
3+
Date: Mon, 23 Dec 2024 19:52:31 +0100
4+
Subject: [PATCH] Fix dumb PotionMeta names
5+
6+
7+
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java
8+
index 49690dab508b07f9f56b2fb21eeb5f20172b5bd3..8cdb91a81de7c67ec6d27efabd5bcef4dd8ac169 100644
9+
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java
10+
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java
11+
@@ -306,17 +306,17 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta {
12+
}
13+
14+
@Override
15+
- public boolean hasCustomName() {
16+
+ public boolean hasCustomPotionName() { // Paper
17+
return this.customName != null;
18+
}
19+
20+
@Override
21+
- public String getCustomName() {
22+
+ public String getCustomPotionName() { // Paper
23+
return this.customName;
24+
}
25+
26+
@Override
27+
- public void setCustomName(String customName) {
28+
+ public void setCustomPotionName(String customName) { // Paper
29+
Preconditions.checkArgument(customName == null || customName.length() <= 32767, "Custom name is longer than 32767 characters");
30+
this.customName = customName;
31+
}

0 commit comments

Comments
 (0)