mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 15:17:17 +01:00
deprecate our ItemRarity API
This commit is contained in:
parent
6a4974b1b9
commit
c38f96b0e5
540 changed files with 210 additions and 252 deletions
131
patches/api/0262-Improve-Item-Rarity-API.patch
Normal file
131
patches/api/0262-Improve-Item-Rarity-API.patch
Normal file
|
@ -0,0 +1,131 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 12 Mar 2021 17:09:40 -0800
|
||||
Subject: [PATCH] Improve Item Rarity API
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/inventory/ItemRarity.java b/src/main/java/io/papermc/paper/inventory/ItemRarity.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..f1cd5a4f37eee8975ac3d0421b524afcf644fafd
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/inventory/ItemRarity.java
|
||||
@@ -0,0 +1,32 @@
|
||||
+package io.papermc.paper.inventory;
|
||||
+
|
||||
+import net.kyori.adventure.text.format.NamedTextColor;
|
||||
+import net.kyori.adventure.text.format.TextColor;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * @deprecated use {@link org.bukkit.inventory.ItemRarity} with {@link org.bukkit.inventory.meta.ItemMeta#getRarity()}
|
||||
+ */
|
||||
+@Deprecated(forRemoval = true, since = "1.20.5")
|
||||
+public enum ItemRarity {
|
||||
+
|
||||
+ COMMON(NamedTextColor.WHITE),
|
||||
+ UNCOMMON(NamedTextColor.YELLOW),
|
||||
+ RARE(NamedTextColor.AQUA),
|
||||
+ EPIC(NamedTextColor.LIGHT_PURPLE);
|
||||
+
|
||||
+ TextColor color;
|
||||
+
|
||||
+ ItemRarity(TextColor color) {
|
||||
+ this.color = color;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the color formatting associated with the rarity.
|
||||
+ * @return
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public TextColor getColor() {
|
||||
+ return color;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
|
||||
index 3ee36de0ee975dc300e594b17d0dc2c06edf2a16..2ce1d9239d08c799d53873563646f933211a902e 100644
|
||||
--- a/src/main/java/org/bukkit/Material.java
|
||||
+++ b/src/main/java/org/bukkit/Material.java
|
||||
@@ -4748,6 +4748,19 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
|
||||
return Bukkit.getUnsafe().getBlockTranslationKey(this);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the item rarity for the item. The Material <b>MUST</b> be an Item not a block.
|
||||
+ * Use {@link #isItem()} before this.
|
||||
+ *
|
||||
+ * @return the item rarity
|
||||
+ * @deprecated use {@link org.bukkit.inventory.meta.ItemMeta#hasRarity()} and {@link org.bukkit.inventory.meta.ItemMeta#getRarity()}
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ @Deprecated(forRemoval = true, since = "1.20.5")
|
||||
+ public io.papermc.paper.inventory.ItemRarity getItemRarity() {
|
||||
+ return new org.bukkit.inventory.ItemStack(this).getRarity();
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
/**
|
||||
diff --git a/src/main/java/org/bukkit/inventory/ItemRarity.java b/src/main/java/org/bukkit/inventory/ItemRarity.java
|
||||
index e7931f73f10fe35ebd5fe4a04b036d53bb117ebd..cbce835ed6d44e5b8c9aaae4e36a77f8e5bed45f 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/ItemRarity.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/ItemRarity.java
|
||||
@@ -9,17 +9,32 @@ public enum ItemRarity {
|
||||
/**
|
||||
* White item name.
|
||||
*/
|
||||
- COMMON,
|
||||
+ COMMON(net.kyori.adventure.text.format.NamedTextColor.WHITE), // Paper
|
||||
/**
|
||||
* Yellow item name.
|
||||
*/
|
||||
- UNCOMMON,
|
||||
+ UNCOMMON(net.kyori.adventure.text.format.NamedTextColor.YELLOW), // Paper
|
||||
/**
|
||||
* Aqua item name.
|
||||
*/
|
||||
- RARE,
|
||||
+ RARE(net.kyori.adventure.text.format.NamedTextColor.AQUA), // Paper
|
||||
/**
|
||||
* Light purple item name.
|
||||
*/
|
||||
- EPIC;
|
||||
+ EPIC(net.kyori.adventure.text.format.NamedTextColor.LIGHT_PURPLE); // Paper
|
||||
+ // Paper start - improve ItemRarity
|
||||
+ private final net.kyori.adventure.text.format.NamedTextColor color;
|
||||
+ ItemRarity(final net.kyori.adventure.text.format.NamedTextColor color) {
|
||||
+ this.color = color;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the color formatting associated with this rarity.
|
||||
+ *
|
||||
+ * @return the color
|
||||
+ */
|
||||
+ public net.kyori.adventure.text.format.@org.jetbrains.annotations.NotNull TextColor color() {
|
||||
+ return this.color;
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
index 96b6052c198454f06f877fc7cda85a98c0ddba7c..f9b0b463f9920524eab7f328bc456a30eebc6910 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
@@ -888,5 +888,17 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||
public @NotNull String translationKey() {
|
||||
return Bukkit.getUnsafe().getTranslationKey(this);
|
||||
}
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the item rarity of the itemstack. The rarity can change based on enchantments.
|
||||
+ *
|
||||
+ * @return the itemstack rarity
|
||||
+ * @deprecated Use {@link ItemMeta#hasRarity()} and {@link ItemMeta#getRarity()}
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ @Deprecated(forRemoval = true, since = "1.20.5")
|
||||
+ public io.papermc.paper.inventory.ItemRarity getRarity() {
|
||||
+ return io.papermc.paper.inventory.ItemRarity.valueOf(this.getItemMeta().getRarity().name());
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
|
@ -1,109 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 12 Mar 2021 17:09:40 -0800
|
||||
Subject: [PATCH] Item Rarity API
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/inventory/ItemRarity.java b/src/main/java/io/papermc/paper/inventory/ItemRarity.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..74ef8395cc040ce488c2acaa416db20272cc2734
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/inventory/ItemRarity.java
|
||||
@@ -0,0 +1,28 @@
|
||||
+package io.papermc.paper.inventory;
|
||||
+
|
||||
+import net.kyori.adventure.text.format.NamedTextColor;
|
||||
+import net.kyori.adventure.text.format.TextColor;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+public enum ItemRarity {
|
||||
+
|
||||
+ COMMON(NamedTextColor.WHITE),
|
||||
+ UNCOMMON(NamedTextColor.YELLOW),
|
||||
+ RARE(NamedTextColor.AQUA),
|
||||
+ EPIC(NamedTextColor.LIGHT_PURPLE);
|
||||
+
|
||||
+ TextColor color;
|
||||
+
|
||||
+ ItemRarity(TextColor color) {
|
||||
+ this.color = color;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the color formatting associated with the rarity.
|
||||
+ * @return
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public TextColor getColor() {
|
||||
+ return color;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
|
||||
index 3ee36de0ee975dc300e594b17d0dc2c06edf2a16..7c14a272156cefe6d69e41fec6892891646e0985 100644
|
||||
--- a/src/main/java/org/bukkit/Material.java
|
||||
+++ b/src/main/java/org/bukkit/Material.java
|
||||
@@ -4748,6 +4748,17 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
|
||||
return Bukkit.getUnsafe().getBlockTranslationKey(this);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the item rarity for the item. The Material <b>MUST</b> be an Item not a block.
|
||||
+ * Use {@link #isItem()} before this.
|
||||
+ *
|
||||
+ * @return the item rarity
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public io.papermc.paper.inventory.ItemRarity getItemRarity() {
|
||||
+ return Bukkit.getUnsafe().getItemRarity(this);
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
/**
|
||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
index 5de86f8cd3cc7f7e8ebc4a22d3921273378704f2..c423204eaf3252c9fc1a3af1214ec70ed712fb80 100644
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -169,5 +169,22 @@ public interface UnsafeValues {
|
||||
* Just don't use it.
|
||||
*/
|
||||
@org.jetbrains.annotations.NotNull String getMainLevelName();
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the item rarity of a material. The material <b>MUST</b> be an item.
|
||||
+ * Use {@link Material#isItem()} before this.
|
||||
+ *
|
||||
+ * @param material the material to get the rarity of
|
||||
+ * @return the item rarity
|
||||
+ */
|
||||
+ public io.papermc.paper.inventory.ItemRarity getItemRarity(Material material);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the item rarity of the itemstack. The rarity can change based on enchantements.
|
||||
+ *
|
||||
+ * @param itemStack the itemstack to get the rarity of
|
||||
+ * @return the itemstack rarity
|
||||
+ */
|
||||
+ public io.papermc.paper.inventory.ItemRarity getItemStackRarity(ItemStack itemStack);
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
index 96b6052c198454f06f877fc7cda85a98c0ddba7c..069c644f03286ba62d521754d825e81934e1e6d6 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
@@ -888,5 +888,15 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||
public @NotNull String translationKey() {
|
||||
return Bukkit.getUnsafe().getTranslationKey(this);
|
||||
}
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the item rarity of the itemstack. The rarity can change based on enchantements.
|
||||
+ *
|
||||
+ * @return the itemstack rarity
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public io.papermc.paper.inventory.ItemRarity getRarity() {
|
||||
+ return Bukkit.getUnsafe().getItemStackRarity(this);
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
|
@ -5,13 +5,13 @@ Subject: [PATCH] Expose protocol version
|
|||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
index c423204eaf3252c9fc1a3af1214ec70ed712fb80..42e4983051062f2fd3b595487cf8093440b41bba 100644
|
||||
index 5de86f8cd3cc7f7e8ebc4a22d3921273378704f2..a874faec93468c83fc475b60629fc36f933bd11c 100644
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -186,5 +186,12 @@ public interface UnsafeValues {
|
||||
* @return the itemstack rarity
|
||||
@@ -169,5 +169,12 @@ public interface UnsafeValues {
|
||||
* Just don't use it.
|
||||
*/
|
||||
public io.papermc.paper.inventory.ItemRarity getItemStackRarity(ItemStack itemStack);
|
||||
@org.jetbrains.annotations.NotNull String getMainLevelName();
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the server's protocol version.
|
||||
|
|
|
@ -5,13 +5,14 @@ Subject: [PATCH] ItemStack repair check API
|
|||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
index 42e4983051062f2fd3b595487cf8093440b41bba..057f4db9cb6b686ab941ec5d3e6ca23dcfbd845f 100644
|
||||
index a874faec93468c83fc475b60629fc36f933bd11c..4130481843c9e0b847bd656622b0c1107ac1297b 100644
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -187,6 +187,16 @@ public interface UnsafeValues {
|
||||
@@ -176,5 +176,15 @@ public interface UnsafeValues {
|
||||
* @return the server's protocol version
|
||||
*/
|
||||
public io.papermc.paper.inventory.ItemRarity getItemStackRarity(ItemStack itemStack);
|
||||
|
||||
int getProtocolVersion();
|
||||
+
|
||||
+ /**
|
||||
+ * Checks if an itemstack can be repaired with another itemstack.
|
||||
+ * Returns false if either argument's type is not an item ({@link Material#isItem()}).
|
||||
|
@ -21,17 +22,15 @@ index 42e4983051062f2fd3b595487cf8093440b41bba..057f4db9cb6b686ab941ec5d3e6ca23d
|
|||
+ * @return true if valid repair, false if not
|
||||
+ */
|
||||
+ public boolean isValidRepairItemStack(@org.jetbrains.annotations.NotNull ItemStack itemToBeRepaired, @org.jetbrains.annotations.NotNull ItemStack repairMaterial);
|
||||
+
|
||||
/**
|
||||
* Returns the server's protocol version.
|
||||
*
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
index 069c644f03286ba62d521754d825e81934e1e6d6..51f3f387af28bb733e2a20c7befd1070768103b2 100644
|
||||
index f9b0b463f9920524eab7f328bc456a30eebc6910..2fb521dc2b4d991f56288e2faba978d9d7d29a0b 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
@@ -898,5 +898,27 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||
@@ -900,5 +900,27 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||
public io.papermc.paper.inventory.ItemRarity getRarity() {
|
||||
return Bukkit.getUnsafe().getItemStackRarity(this);
|
||||
return io.papermc.paper.inventory.ItemRarity.valueOf(this.getItemMeta().getRarity().name());
|
||||
}
|
||||
+
|
||||
+ /**
|
||||
|
|
|
@ -5,7 +5,7 @@ Subject: [PATCH] ItemStack#editMeta
|
|||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
index 51f3f387af28bb733e2a20c7befd1070768103b2..0f3ef975293d0e970a35fd6845f8bf911e933169 100644
|
||||
index 2fb521dc2b4d991f56288e2faba978d9d7d29a0b..455e633edc19d29559e66b1d52c532ef1a0fa8df 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
@@ -558,6 +558,50 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||
|
|
|
@ -6,12 +6,12 @@ Subject: [PATCH] Attributes API for item defaults
|
|||
(Now replaced by upstream's API)
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
|
||||
index 7c14a272156cefe6d69e41fec6892891646e0985..eb9e0eb1aa6e203ff6f896b177ee60c8afacc62d 100644
|
||||
index 2ce1d9239d08c799d53873563646f933211a902e..401645f5e0dfe6c9a0d082b5a76112a882b058ee 100644
|
||||
--- a/src/main/java/org/bukkit/Material.java
|
||||
+++ b/src/main/java/org/bukkit/Material.java
|
||||
@@ -4759,6 +4759,21 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
|
||||
@@ -4761,6 +4761,21 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
|
||||
public io.papermc.paper.inventory.ItemRarity getItemRarity() {
|
||||
return Bukkit.getUnsafe().getItemRarity(this);
|
||||
return new org.bukkit.inventory.ItemStack(this).getRarity();
|
||||
}
|
||||
+
|
||||
+ /**
|
||||
|
|
|
@ -5,13 +5,13 @@ Subject: [PATCH] Get entity default attributes
|
|||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
index 057f4db9cb6b686ab941ec5d3e6ca23dcfbd845f..900b502a400bb99a2131305812e48acfeb8b94a1 100644
|
||||
index 4130481843c9e0b847bd656622b0c1107ac1297b..a846f3c6e8dceb90e42db903b8be2c248f2f9d5c 100644
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -203,5 +203,22 @@ public interface UnsafeValues {
|
||||
* @return the server's protocol version
|
||||
@@ -186,5 +186,22 @@ public interface UnsafeValues {
|
||||
* @return true if valid repair, false if not
|
||||
*/
|
||||
int getProtocolVersion();
|
||||
public boolean isValidRepairItemStack(@org.jetbrains.annotations.NotNull ItemStack itemToBeRepaired, @org.jetbrains.annotations.NotNull ItemStack repairMaterial);
|
||||
+
|
||||
+ /**
|
||||
+ * Checks if the entity represented by the namespaced key has default attributes.
|
||||
|
|
|
@ -5,10 +5,10 @@ Subject: [PATCH] Add isCollidable methods to various places
|
|||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
|
||||
index eb9e0eb1aa6e203ff6f896b177ee60c8afacc62d..137b4553636f31574c51960cada6eb07d80a02d9 100644
|
||||
index 401645f5e0dfe6c9a0d082b5a76112a882b058ee..8283eccf2578bae50a4c6fd86318e0d5f7cf09df 100644
|
||||
--- a/src/main/java/org/bukkit/Material.java
|
||||
+++ b/src/main/java/org/bukkit/Material.java
|
||||
@@ -4774,6 +4774,16 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
|
||||
@@ -4776,6 +4776,16 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
|
||||
public Multimap<Attribute, AttributeModifier> getItemAttributes(@NotNull EquipmentSlot equipmentSlot) {
|
||||
return this.getDefaultAttributeModifiers(equipmentSlot);
|
||||
}
|
||||
|
@ -26,10 +26,10 @@ index eb9e0eb1aa6e203ff6f896b177ee60c8afacc62d..137b4553636f31574c51960cada6eb07
|
|||
|
||||
/**
|
||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
index 900b502a400bb99a2131305812e48acfeb8b94a1..75c9569214321b3f23f3614722d7453020d095c3 100644
|
||||
index a846f3c6e8dceb90e42db903b8be2c248f2f9d5c..e1f9d80f0a6481824443339015049f96f3bf86f2 100644
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -220,5 +220,14 @@ public interface UnsafeValues {
|
||||
@@ -203,5 +203,14 @@ public interface UnsafeValues {
|
||||
* @throws IllegalArgumentException if the entity does not exist of have default attributes (use {@link #hasDefaultEntityAttributes(NamespacedKey)} first)
|
||||
*/
|
||||
@org.jetbrains.annotations.NotNull org.bukkit.attribute.Attributable getDefaultEntityAttributes(@org.jetbrains.annotations.NotNull NamespacedKey entityKey);
|
||||
|
|
|
@ -5,7 +5,7 @@ Subject: [PATCH] Add Raw Byte Entity Serialization
|
|||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
index 75c9569214321b3f23f3614722d7453020d095c3..bdfa60a764c13d82cd013335fb7b0c896abe74bd 100644
|
||||
index e1f9d80f0a6481824443339015049f96f3bf86f2..9245f50b2bac30e956ef6ddc11c551b9b68463ee 100644
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -158,6 +158,14 @@ public interface UnsafeValues {
|
||||
|
|
|
@ -70,7 +70,7 @@ index dbebaf8172ec6872f56958b9583affde4f8400a4..98a970a6582dca22e719a31559c7bece
|
|||
+ // Paper end - enchantWithLevels API
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
index 0f3ef975293d0e970a35fd6845f8bf911e933169..984b6e96a5ebebc38ab62790c4d6a9946c9c6944 100644
|
||||
index 455e633edc19d29559e66b1d52c532ef1a0fa8df..637b9067973aadece2806cc2b6200a4d3b8d97a1 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
@@ -667,6 +667,24 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||
|
|
|
@ -6,10 +6,10 @@ Subject: [PATCH] Add NamespacedKey biome methods
|
|||
Co-authored-by: Thonk <30448663+ExcessiveAmountsOfZombies@users.noreply.github.com>
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
index bdfa60a764c13d82cd013335fb7b0c896abe74bd..0eddda31e47e807551436ae834e89ea56141f163 100644
|
||||
index 9245f50b2bac30e956ef6ddc11c551b9b68463ee..5d862c9221d1ce6d577295a5181f951c2f71a631 100644
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -237,5 +237,32 @@ public interface UnsafeValues {
|
||||
@@ -220,5 +220,32 @@ public interface UnsafeValues {
|
||||
* @throws IllegalArgumentException if {@link Material#isBlock()} is false
|
||||
*/
|
||||
boolean isCollidable(@org.jetbrains.annotations.NotNull Material material);
|
||||
|
|
|
@ -66,10 +66,10 @@ index 6bfc8a2148f504370df938447f4f6b757f1a516b..208bab1f5a3200f54141c38ee4272629
|
|||
+ // Paper end - ItemStack damage API
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
index 984b6e96a5ebebc38ab62790c4d6a9946c9c6944..13648f2e810daa84af25c28a009b1f641791e2f7 100644
|
||||
index 637b9067973aadece2806cc2b6200a4d3b8d97a1..d2162e53cefb8f9dc5c52bc1904e860066f43a41 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
@@ -982,5 +982,19 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||
@@ -984,5 +984,19 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||
public boolean canRepair(@NotNull ItemStack toBeRepaired) {
|
||||
return Bukkit.getUnsafe().isValidRepairItemStack(toBeRepaired, this);
|
||||
}
|
||||
|
|
|
@ -5,10 +5,10 @@ Subject: [PATCH] Fix custom statistic criteria creation
|
|||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
index 0eddda31e47e807551436ae834e89ea56141f163..7b54ca313ce65f91932ee8ee968196f6091db86f 100644
|
||||
index 5d862c9221d1ce6d577295a5181f951c2f71a631..e19434a0f5065987be087b6bd531c88be33d2917 100644
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -264,5 +264,7 @@ public interface UnsafeValues {
|
||||
@@ -247,5 +247,7 @@ public interface UnsafeValues {
|
||||
* @throws IllegalStateException if no biome by the given key is registered.
|
||||
*/
|
||||
void setBiomeKey(RegionAccessor accessor, int x, int y, int z, NamespacedKey biomeKey);
|
||||
|
|
|
@ -6,10 +6,10 @@ Subject: [PATCH] Allow proper checking of empty item stacks
|
|||
This adds a method to check if an item stack is empty or not. This mirrors vanilla's implementation of the same method.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
index 13648f2e810daa84af25c28a009b1f641791e2f7..ff3929b4a497ff0ef0c7ea7f9ac3509764b80e0a 100644
|
||||
index d2162e53cefb8f9dc5c52bc1904e860066f43a41..db02c04a8e9a0b8e1e4518a629d5703398d4ef72 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
@@ -996,5 +996,24 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||
@@ -998,5 +998,24 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||
public @NotNull ItemStack damage(int amount, @NotNull org.bukkit.entity.LivingEntity livingEntity) {
|
||||
return livingEntity.damageItemStack(this, amount);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ By removing this check we avoid unnecessarily allocating useless `ItemMeta` obje
|
|||
This is a leftover from when checking for the item's durability was "free" because the durability was stored in the `ItemStack` itself, this [was changed in Minecraft 1.13](https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/commits/f8b2086d60942eb2cd7ac25a2a1408cb790c222c#src/main/java/org/bukkit/inventory/ItemStack.java).
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
index ff3929b4a497ff0ef0c7ea7f9ac3509764b80e0a..ee636c066d1f87873c1ddf52c60c77b1b86d6e90 100644
|
||||
index db02c04a8e9a0b8e1e4518a629d5703398d4ef72..0611f19bcdd8230b439b5055713221318dce98e2 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
@@ -295,7 +295,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||
|
|
|
@ -27,7 +27,7 @@ index 6b68c92ec894451d99ded3e3df5965cb31d68ed2..fd5e433f930963c102c9c977523a0036
|
|||
public static final FeatureFlag UPDATE_121 = Bukkit.getUnsafe().getFeatureFlag(NamespacedKey.minecraft("update_1_21"));
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
|
||||
index 137b4553636f31574c51960cada6eb07d80a02d9..cdbb67b677d5226d15df40339b7df02482561e3e 100644
|
||||
index 8283eccf2578bae50a4c6fd86318e0d5f7cf09df..6ebc5da2b47b005b836927621f3b929d2442a832 100644
|
||||
--- a/src/main/java/org/bukkit/Material.java
|
||||
+++ b/src/main/java/org/bukkit/Material.java
|
||||
@@ -146,54 +146,67 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
|
||||
|
|
|
@ -5,10 +5,10 @@ Subject: [PATCH] Add api for spawn egg texture colors
|
|||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
index 7b54ca313ce65f91932ee8ee968196f6091db86f..e1493ef58854e7bc929a2fa5aaba9da527dfd563 100644
|
||||
index e19434a0f5065987be087b6bd531c88be33d2917..80947c6862a906dec9c039b5dff993461d4d831b 100644
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -267,4 +267,17 @@ public interface UnsafeValues {
|
||||
@@ -250,4 +250,17 @@ public interface UnsafeValues {
|
||||
|
||||
String getStatisticCriteriaKey(@NotNull org.bukkit.Statistic statistic);
|
||||
// Paper end
|
||||
|
|
|
@ -528,10 +528,10 @@ index 0000000000000000000000000000000000000000..304f978e40e1759bb19704cc5cec3995
|
|||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
index e1493ef58854e7bc929a2fa5aaba9da527dfd563..887129a95ff2e299507bf870b1ef3212afe6563e 100644
|
||||
index 80947c6862a906dec9c039b5dff993461d4d831b..7e6bdf3333537491b3421d196779a4eb502f7314 100644
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -280,4 +280,12 @@ public interface UnsafeValues {
|
||||
@@ -263,4 +263,12 @@ public interface UnsafeValues {
|
||||
*/
|
||||
@Nullable org.bukkit.Color getSpawnEggLayerColor(org.bukkit.entity.EntityType entityType, int layer);
|
||||
// Paper end - spawn egg color visibility
|
||||
|
|
|
@ -108,10 +108,10 @@ index 0000000000000000000000000000000000000000..1d9bed6691f581529c53b577b26f1d0f
|
|||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
index 887129a95ff2e299507bf870b1ef3212afe6563e..c7d0cdd4778c329f09db6cea97ddb019690d6246 100644
|
||||
index 7e6bdf3333537491b3421d196779a4eb502f7314..a3ba9249e636d1fb8dad98fab413436009fe04df 100644
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -288,4 +288,6 @@ public interface UnsafeValues {
|
||||
@@ -271,4 +271,6 @@ public interface UnsafeValues {
|
||||
@org.jetbrains.annotations.ApiStatus.Internal
|
||||
io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager<org.bukkit.plugin.Plugin> createPluginLifecycleEventManager(final org.bukkit.plugin.java.JavaPlugin plugin, final java.util.function.BooleanSupplier registrationCheck);
|
||||
// Paper end - lifecycle event API
|
||||
|
@ -119,10 +119,10 @@ index 887129a95ff2e299507bf870b1ef3212afe6563e..c7d0cdd4778c329f09db6cea97ddb019
|
|||
+ @NotNull java.util.List<net.kyori.adventure.text.Component> computeTooltipLines(@NotNull ItemStack itemStack, @NotNull io.papermc.paper.inventory.tooltip.TooltipContext tooltipContext, @Nullable org.bukkit.entity.Player player); // Paper - expose itemstack tooltip lines
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
index ee636c066d1f87873c1ddf52c60c77b1b86d6e90..b04e7b9c3f631c0bb7734b809a58dbb988414fbb 100644
|
||||
index 0611f19bcdd8230b439b5055713221318dce98e2..9440cffffa1d7e75d2d76d55d5608bafd69b645b 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
@@ -1016,4 +1016,21 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||
@@ -1018,4 +1018,21 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||
return type.isAir() || amount <= 0;
|
||||
}
|
||||
// Paper end
|
||||
|
|
|
@ -5,7 +5,7 @@ Subject: [PATCH] Deprecate ItemStack#setType
|
|||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
index b04e7b9c3f631c0bb7734b809a58dbb988414fbb..df2d5ad5ff1bcb1488a94edde9cc4d53cacdd91d 100644
|
||||
index 9440cffffa1d7e75d2d76d55d5608bafd69b645b..91083a135a7e979e32cbb3531b5ef69b7a28f305 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
@@ -134,8 +134,18 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 12 Mar 2021 17:09:42 -0800
|
||||
Subject: [PATCH] Item Rarity API
|
||||
|
||||
== AT ==
|
||||
public net.minecraft.world.item.Item rarity
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
index c0592a85a1a0781b83232533b9ca1b30b116eb98..125ed63d8ae812284cd452b4387fd0d674c9c25a 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -542,6 +542,20 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
public String getMainLevelName() {
|
||||
return ((net.minecraft.server.dedicated.DedicatedServer) net.minecraft.server.MinecraftServer.getServer()).getProperties().levelName;
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public io.papermc.paper.inventory.ItemRarity getItemRarity(org.bukkit.Material material) {
|
||||
+ Item item = getItem(material);
|
||||
+ if (item == null) {
|
||||
+ throw new IllegalArgumentException(material + " is not an item, and rarity does not apply to blocks");
|
||||
+ }
|
||||
+ return io.papermc.paper.inventory.ItemRarity.values()[item.components().getOrDefault(net.minecraft.core.component.DataComponents.RARITY, net.minecraft.world.item.Rarity.COMMON).ordinal()];
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public io.papermc.paper.inventory.ItemRarity getItemStackRarity(org.bukkit.inventory.ItemStack itemStack) {
|
||||
+ return io.papermc.paper.inventory.ItemRarity.values()[itemStack.getRarity().ordinal()];
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
/**
|
||||
diff --git a/src/test/java/io/papermc/paper/inventory/ItemRarityTest.java b/src/test/java/io/papermc/paper/inventory/ItemRarityTest.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..8086e6a754cb94ce15428ac0cdbaa43590beb9fe
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/inventory/ItemRarityTest.java
|
||||
@@ -0,0 +1,24 @@
|
||||
+package io.papermc.paper.inventory;
|
||||
+
|
||||
+import io.papermc.paper.adventure.PaperAdventure;
|
||||
+import net.minecraft.world.item.Rarity;
|
||||
+import org.junit.jupiter.api.Test;
|
||||
+
|
||||
+import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
+
|
||||
+public class ItemRarityTest {
|
||||
+
|
||||
+ @Test
|
||||
+ public void testConvertFromNmsToBukkit() {
|
||||
+ for (Rarity nmsRarity : Rarity.values()) {
|
||||
+ assertEquals(ItemRarity.values()[nmsRarity.ordinal()].name(), nmsRarity.name(), "rarity names are mis-matched");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Test
|
||||
+ public void testRarityFormatting() {
|
||||
+ for (Rarity nmsRarity : Rarity.values()) {
|
||||
+ assertEquals(nmsRarity.color(), PaperAdventure.asVanilla(ItemRarity.values()[nmsRarity.ordinal()].color), "rarity formatting is mis-matched");
|
||||
+ }
|
||||
+ }
|
||||
+}
|
|
@ -5,12 +5,12 @@ Subject: [PATCH] Expose protocol version
|
|||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
index 125ed63d8ae812284cd452b4387fd0d674c9c25a..c4457bb46c3e66f5954383fb18b6109a5fe2772d 100644
|
||||
index c0592a85a1a0781b83232533b9ca1b30b116eb98..d11d0a9a2c6b13033437a22b7270e7d37bfe8046 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -556,6 +556,11 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
public io.papermc.paper.inventory.ItemRarity getItemStackRarity(org.bukkit.inventory.ItemStack itemStack) {
|
||||
return io.papermc.paper.inventory.ItemRarity.values()[itemStack.getRarity().ordinal()];
|
||||
@@ -542,6 +542,11 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
public String getMainLevelName() {
|
||||
return ((net.minecraft.server.dedicated.DedicatedServer) net.minecraft.server.MinecraftServer.getServer()).getProperties().levelName;
|
||||
}
|
||||
+
|
||||
+ @Override
|
|
@ -5,13 +5,14 @@ Subject: [PATCH] ItemStack repair check API
|
|||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
index c4457bb46c3e66f5954383fb18b6109a5fe2772d..a8ac14a908060aa656756ad728d0d1e826d3bbe7 100644
|
||||
index d11d0a9a2c6b13033437a22b7270e7d37bfe8046..c2a7801ee4f6642813778f5e8ae89db46a253a3d 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -557,6 +557,14 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
return io.papermc.paper.inventory.ItemRarity.values()[itemStack.getRarity().ordinal()];
|
||||
@@ -547,6 +547,14 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
public int getProtocolVersion() {
|
||||
return net.minecraft.SharedConstants.getCurrentVersion().getProtocolVersion();
|
||||
}
|
||||
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isValidRepairItemStack(org.bukkit.inventory.ItemStack itemToBeRepaired, org.bukkit.inventory.ItemStack repairMaterial) {
|
||||
+ if (!itemToBeRepaired.getType().isItem() || !repairMaterial.getType().isItem()) {
|
||||
|
@ -19,10 +20,9 @@ index c4457bb46c3e66f5954383fb18b6109a5fe2772d..a8ac14a908060aa656756ad728d0d1e8
|
|||
+ }
|
||||
+ return CraftMagicNumbers.getItem(itemToBeRepaired.getType()).isValidRepairItem(CraftItemStack.asNMSCopy(itemToBeRepaired), CraftItemStack.asNMSCopy(repairMaterial));
|
||||
+ }
|
||||
+
|
||||
@Override
|
||||
public int getProtocolVersion() {
|
||||
return net.minecraft.SharedConstants.getCurrentVersion().getProtocolVersion();
|
||||
// Paper end
|
||||
|
||||
/**
|
||||
diff --git a/src/test/java/io/papermc/paper/util/ItemStackRepairCheckTest.java b/src/test/java/io/papermc/paper/util/ItemStackRepairCheckTest.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..6b8d360ef86e181a680ad77f28b7dd7368dddfe7
|
|
@ -6,7 +6,7 @@ Subject: [PATCH] Fix item default attributes API
|
|||
(previously added this API but upstream also added it)
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
index a8ac14a908060aa656756ad728d0d1e826d3bbe7..991a63f1a7cbd5d2cb88784a59ed0085b7bdfbe2 100644
|
||||
index c2a7801ee4f6642813778f5e8ae89db46a253a3d..61686e63b2d1a98b9747e11058f450a51e2d4d01 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -396,9 +396,14 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue