some more ItemType/BlockType api replacements

This commit is contained in:
Jake Potrebic 2023-06-20 10:56:49 -07:00
parent 3fa4ea6668
commit cbc8941088
No known key found for this signature in database
GPG Key ID: ECE0B3C133C016C5
19 changed files with 180 additions and 127 deletions

View File

@ -2080,7 +2080,7 @@ index 2417f0d5077b51a7649503d57c48b0614f532904..9cebad10eb06f42cd0428d80940fa8e2
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index a18e0377b68100d37ea171f80fe7f7e18e0a4593..9d8ddb2656d22c287ee1338fe4ab79fac0e8488a 100644
index a18e0377b68100d37ea171f80fe7f7e18e0a4593..5b5802be082f70a015b4a20c0ccdec1ee6f479f6 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -43,7 +43,41 @@ import org.jetbrains.annotations.Nullable;
@ -2281,7 +2281,7 @@ index a18e0377b68100d37ea171f80fe7f7e18e0a4593..9d8ddb2656d22c287ee1338fe4ab79fa
+ * a certain location. This will not actually change the world in any way.
+ * This method will use a sign at the location's block or a faked sign
+ * sent via
+ * {@link #sendBlockChange(org.bukkit.Location, org.bukkit.Material, byte)}.
+ * {@link #sendBlockChange(Location, BlockData)}.
+ * <p>
+ * If the client does not have a sign at the given location it will
+ * display an error message to the user.
@ -2300,7 +2300,7 @@ index a18e0377b68100d37ea171f80fe7f7e18e0a4593..9d8ddb2656d22c287ee1338fe4ab79fa
+ * a certain location. This will not actually change the world in any way.
+ * This method will use a sign at the location's block or a faked sign
+ * sent via
+ * {@link #sendBlockChange(org.bukkit.Location, org.bukkit.Material, byte)}.
+ * {@link #sendBlockChange(Location, BlockData)}.
+ * <p>
+ * If the client does not have a sign at the given location it will
+ * display an error message to the user.
@ -2321,7 +2321,7 @@ index a18e0377b68100d37ea171f80fe7f7e18e0a4593..9d8ddb2656d22c287ee1338fe4ab79fa
+ * a certain location. This will not actually change the world in any way.
+ * This method will use a sign at the location's block or a faked sign
+ * sent via
+ * {@link #sendBlockChange(org.bukkit.Location, org.bukkit.Material, byte)}.
+ * {@link #sendBlockChange(Location, BlockData)}.
+ * <p>
+ * If the client does not have a sign at the given location it will
+ * display an error message to the user.
@ -2342,7 +2342,7 @@ index a18e0377b68100d37ea171f80fe7f7e18e0a4593..9d8ddb2656d22c287ee1338fe4ab79fa
+ * a certain location. This will not actually change the world in any way.
+ * This method will use a sign at the location's block or a faked sign
+ * sent via
+ * {@link #sendBlockChange(org.bukkit.Location, org.bukkit.Material, byte)}.
+ * {@link #sendBlockChange(Location, BlockData)}.
+ * <p>
+ * If the client does not have a sign at the given location it will
+ * display an error message to the user.

View File

@ -27,7 +27,7 @@ index 0000000000000000000000000000000000000000..9db0056ab94145819628b3ad8d8d2613
+
+}
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index 2d334dbdd9e2c9a020899097e0620152758dc078..cd00a831cd4c6030082aa8107d25c78d8ee67d8f 100644
index 2d334dbdd9e2c9a020899097e0620152758dc078..639d275b8318d19afd18996e1daa4e800927a84d 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -5,6 +5,7 @@ import org.bukkit.advancement.Advancement;
@ -42,7 +42,7 @@ index 2d334dbdd9e2c9a020899097e0620152758dc078..cd00a831cd4c6030082aa8107d25c78d
Material fromLegacy(MaterialData material, boolean itemPriority);
Material toMaterial(ItemType itemType);
+ Material toMaterial(BlockType<?> blockType); // Paper
+ Material blockTypeToMaterial(BlockType<?> blockType); // Paper
BlockData fromLegacy(Material material, byte data);

View File

@ -6,12 +6,13 @@ Subject: [PATCH] Add PlayerArmorChangeEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerArmorChangeEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerArmorChangeEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..e406ce639a2e88b78f82f25e71678a669d0a958b
index 0000000000000000000000000000000000000000..b1985f57d0e52df49304964797dfbbe9a7578ddd
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerArmorChangeEvent.java
@@ -0,0 +1,137 @@
@@ -0,0 +1,189 @@
+package com.destroystokyo.paper.event.player;
+
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList;
@ -22,10 +23,12 @@ index 0000000000000000000000000000000000000000..e406ce639a2e88b78f82f25e71678a66
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import org.bukkit.inventory.ItemType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.Unmodifiable;
+
+import static org.bukkit.Material.*;
+import static org.bukkit.inventory.ItemType.*;
+
+/**
+ * Called when the player themselves change their armor items
@ -98,10 +101,12 @@ index 0000000000000000000000000000000000000000..e406ce639a2e88b78f82f25e71678a66
+ LEGS(NETHERITE_LEGGINGS, DIAMOND_LEGGINGS, GOLDEN_LEGGINGS, IRON_LEGGINGS, CHAINMAIL_LEGGINGS, LEATHER_LEGGINGS),
+ FEET(NETHERITE_BOOTS, DIAMOND_BOOTS, GOLDEN_BOOTS, IRON_BOOTS, CHAINMAIL_BOOTS, LEATHER_BOOTS);
+
+ private final Set<Material> mutableTypes = new HashSet<>();
+ private Set<Material> immutableTypes;
+ private final Set<ItemType> mutableTypes = new HashSet<>();
+ private Set<ItemType> immutableTypes;
+ @Deprecated
+ private Set<Material> legacyTypes;
+
+ SlotType(Material... types) {
+ SlotType(ItemType... types) {
+ this.mutableTypes.addAll(Arrays.asList(types));
+ }
+
@ -110,14 +115,32 @@ index 0000000000000000000000000000000000000000..e406ce639a2e88b78f82f25e71678a66
+ * armor slot.
+ *
+ * @return immutable set of material types
+ * @deprecated use {@link #getItemTypes()}
+ */
+ @Deprecated
+ public @NotNull @Unmodifiable Set<Material> getTypes() {
+ if (this.legacyTypes == null) {
+ this.legacyTypes = new HashSet<>();
+ for (final ItemType itemType : this.getItemTypes()) {
+ this.legacyTypes.add(Bukkit.getUnsafe().toMaterial(itemType));
+ }
+ }
+ return Collections.unmodifiableSet(this.legacyTypes);
+ }
+
+ /**
+ * Gets an immutable set of all allowed item types that can be placed in an
+ * armor slot.
+ *
+ * @return immutable set of item types
+ */
+ @NotNull
+ public Set<Material> getTypes() {
+ if (immutableTypes == null) {
+ immutableTypes = Collections.unmodifiableSet(mutableTypes);
+ public @Unmodifiable Set<ItemType> getItemTypes() {
+ if (this.immutableTypes == null) {
+ this.immutableTypes = Collections.unmodifiableSet(this.mutableTypes);
+ }
+
+ return immutableTypes;
+ return this.immutableTypes;
+ }
+
+ /**
@ -125,8 +148,10 @@ index 0000000000000000000000000000000000000000..e406ce639a2e88b78f82f25e71678a66
+ *
+ * @param material material to get slot by
+ * @return slot type the material will go in, or null if it won't
+ * @deprecated use {@link #getByItemType(ItemType)}
+ */
+ @Nullable
+ @Deprecated
+ public static SlotType getByMaterial(@NotNull Material material) {
+ for (SlotType slotType : values()) {
+ if (slotType.getTypes().contains(material)) {
@ -137,13 +162,40 @@ index 0000000000000000000000000000000000000000..e406ce639a2e88b78f82f25e71678a66
+ }
+
+ /**
+ * Gets whether or not this material can be equipped to a slot
+ * Gets the type of slot via the specified item type
+ *
+ * @param itemType item type to get slot by
+ * @return slot type the item type will go in, or null if it won't
+ */
+ @Nullable
+ public static SlotType getByItemType(@NotNull ItemType itemType) {
+ for (SlotType slotType : values()) {
+ if (slotType.getItemTypes().contains(itemType)) {
+ return slotType;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Gets whether this material can be equipped to a slot
+ *
+ * @param material material to check
+ * @return whether or not this material can be equipped
+ * @return whether this material can be equipped
+ */
+ @Deprecated
+ public static boolean isEquipable(@NotNull Material material) {
+ return getByMaterial(material) != null;
+ }
+
+ /**
+ * Gets whether this item type can be equipped to a slot
+ *
+ * @param itemType item type to check
+ * @return whether this item type can be equipped
+ */
+ public static boolean isEquipable(@NotNull ItemType itemType) {
+ return getByItemType(itemType) != null;
+ }
+ }
+}

View File

@ -7,18 +7,18 @@ Control what potion the witch readies to use
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/WitchReadyPotionEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/WitchReadyPotionEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..57f93af14acc6346c5a343e05fe8f5d44d6adbc6
index 0000000000000000000000000000000000000000..af74dcd5dccd26661787219eb8873c5be2f981a7
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/WitchReadyPotionEvent.java
@@ -0,0 +1,80 @@
+package com.destroystokyo.paper.event.entity;
+
+import org.bukkit.Material;
+import org.bukkit.entity.Witch;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.ItemType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
@ -40,7 +40,7 @@ index 0000000000000000000000000000000000000000..57f93af14acc6346c5a343e05fe8f5d4
+ public static ItemStack process(@NotNull Witch witch, @Nullable ItemStack potion) {
+ WitchReadyPotionEvent event = new WitchReadyPotionEvent(witch, potion);
+ if (!event.callEvent() || event.getPotion() == null) {
+ return new ItemStack(Material.AIR);
+ return ItemStack.of(ItemType.AIR);
+ }
+ return event.getPotion();
+ }

View File

@ -6,7 +6,7 @@ Subject: [PATCH] EntityShootBowEvent consumeArrow and getArrowItem API
Adds ability to get what arrow was shot, and control if it should be consumed.
diff --git a/src/main/java/org/bukkit/event/entity/EntityShootBowEvent.java b/src/main/java/org/bukkit/event/entity/EntityShootBowEvent.java
index d4d7ad9c3c953680342c121f39ddaef476549047..719d0d878320c1903b44076053989ba99fa0e92a 100644
index d4d7ad9c3c953680342c121f39ddaef476549047..6c27a3149b17162cc38206147c759df066186af0 100644
--- a/src/main/java/org/bukkit/event/entity/EntityShootBowEvent.java
+++ b/src/main/java/org/bukkit/event/entity/EntityShootBowEvent.java
@@ -22,7 +22,32 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable {
@ -31,7 +31,7 @@ index d4d7ad9c3c953680342c121f39ddaef476549047..719d0d878320c1903b44076053989ba9
+
+ @Deprecated
+ public EntityShootBowEvent(@NotNull final LivingEntity shooter, @Nullable final ItemStack bow, @NotNull final Entity projectile, final float force) {
+ this(shooter, bow, new ItemStack(org.bukkit.Material.AIR), projectile, force);
+ this(shooter, bow, ItemStack.of(org.bukkit.inventory.ItemType.AIR), projectile, force);
+ }
+ @Deprecated

View File

@ -6,7 +6,7 @@ Subject: [PATCH] AnvilDamageEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/block/AnvilDamagedEvent.java b/src/main/java/com/destroystokyo/paper/event/block/AnvilDamagedEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..4b90dc67f75b05cb8a766025781b9eaa2fef2606
index 0000000000000000000000000000000000000000..8174787e87433084035bb3cbc88e041937c56430
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/block/AnvilDamagedEvent.java
@@ -0,0 +1,171 @@
@ -124,7 +124,7 @@ index 0000000000000000000000000000000000000000..4b90dc67f75b05cb8a766025781b9eaa
+ */
+ @Deprecated
+ public @NotNull Material getMaterial() {
+ return Bukkit.getUnsafe().toMaterial(this.blockType);
+ return Bukkit.getUnsafe().blockTypeToMaterial(this.blockType);
+ }
+
+ /**

View File

@ -11,7 +11,7 @@ Co-authored by: Lena Kolb <lenakolb2204@gmail.com>
diff --git a/src/main/java/com/destroystokyo/paper/MaterialSetTag.java b/src/main/java/com/destroystokyo/paper/MaterialSetTag.java
new file mode 100644
index 0000000000000000000000000000000000000000..64dd5e6674f83075be0f0868f66f114ff71dbe24
index 0000000000000000000000000000000000000000..8f5530188e340336dfffb3054c1743b068bc9342
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/MaterialSetTag.java
@@ -0,0 +1,119 @@
@ -100,7 +100,7 @@ index 0000000000000000000000000000000000000000..64dd5e6674f83075be0f0868f66f114f
+ public MaterialSetTag addTags(@NotNull Tag<BlockType>...tags) {
+ for (Tag<BlockType> tag : tags) {
+ for (final BlockType<?> value : tag.getValues()) {
+ this.add(Bukkit.getUnsafe().toMaterial(value));
+ this.add(Bukkit.getUnsafe().blockTypeToMaterial(value));
+ }
+ }
+ return this;
@ -127,7 +127,7 @@ index 0000000000000000000000000000000000000000..64dd5e6674f83075be0f0868f66f114f
+ }
+
+ public boolean isTagged(@NotNull BlockType<?> itemType) {
+ return this.isTagged(Bukkit.getUnsafe().toMaterial(itemType));
+ return this.isTagged(Bukkit.getUnsafe().blockTypeToMaterial(itemType));
+ }
+
+ public boolean isTagged(@NotNull Material material) {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Player elytra boost API
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index c6ee16a347dc10c718c2d277dba1eff76f7edbbf..873a7bafe2631d012d00eb813889b31ec02d0e30 100644
index c1225aa642eba0e0553131034ee7c55e78b13d10..cfdf406f9b65710438949cc8effe8c3641fe69b7 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -2717,6 +2717,19 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
@ -18,10 +18,10 @@ index c6ee16a347dc10c718c2d277dba1eff76f7edbbf..873a7bafe2631d012d00eb813889b31e
+ * If the creation of the entity is cancelled, no boosting is done.
+ * This method does not fire {@link com.destroystokyo.paper.event.player.PlayerElytraBoostEvent}.
+ *
+ * @param firework The {@link Material#FIREWORK_ROCKET} to boost the player with
+ * @param firework The {@link ItemType#FIREWORK_ROCKET} to boost the player with
+ * @return The {@link Firework} boosting the Player or null if the spawning of the entity was cancelled
+ * @throws IllegalArgumentException if {@link #isGliding()} is false
+ * or if the {@code firework} isn't a {@link Material#FIREWORK_ROCKET}
+ * or if the {@code firework} isn't a {@link ItemType#FIREWORK_ROCKET}
+ */
+ @Nullable
+ Firework boostElytra(@NotNull ItemStack firework);

View File

@ -6,18 +6,20 @@ Subject: [PATCH] Add PlayerItemCooldownEvent
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerItemCooldownEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerItemCooldownEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..58d18f05af13d836ddc62fcd30befcb06f07c57c
index 0000000000000000000000000000000000000000..74fb75e153f027cd04df160943322341c205129e
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/PlayerItemCooldownEvent.java
@@ -0,0 +1,77 @@
@@ -0,0 +1,90 @@
+package io.papermc.paper.event.player;
+
+import com.google.common.base.Preconditions;
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.inventory.ItemType;
+import org.jetbrains.annotations.NotNull;
+
+/**
@ -26,11 +28,11 @@ index 0000000000000000000000000000000000000000..58d18f05af13d836ddc62fcd30befcb0
+public class PlayerItemCooldownEvent extends PlayerEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ @NotNull
+ private final Material type;
+ private final ItemType type;
+ private boolean cancelled;
+ private int cooldown;
+
+ public PlayerItemCooldownEvent(@NotNull Player player, @NotNull Material type, int cooldown) {
+ public PlayerItemCooldownEvent(@NotNull Player player, @NotNull ItemType type, int cooldown) {
+ super(player);
+ this.type = type;
+ this.cooldown = cooldown;
@ -40,10 +42,21 @@ index 0000000000000000000000000000000000000000..58d18f05af13d836ddc62fcd30befcb0
+ * Get the material affected by the cooldown.
+ *
+ * @return material affected by the cooldown
+ * @deprecated use {@link #getItemType()}
+ */
+ @NotNull
+ @Deprecated
+ public Material getType() {
+ return type;
+ return Bukkit.getUnsafe().toMaterial(this.type);
+ }
+
+ /**
+ * Get the item type affected by the cooldown.
+ *
+ * @return item type affected by the cooldown
+ */
+ public @NotNull ItemType getItemType() {
+ return this.type;
+ }
+
+ /**

View File

@ -6,19 +6,19 @@ Subject: [PATCH] Add PlayerItemFrameChangeEvent
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerItemFrameChangeEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerItemFrameChangeEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..451fb94a5802755c255e04aebb40f178bbfbf996
index 0000000000000000000000000000000000000000..23d0eecda1b83346880d1db4c87e94fc05dba018
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/PlayerItemFrameChangeEvent.java
@@ -0,0 +1,97 @@
+package io.papermc.paper.event.player;
+
+import org.bukkit.Material;
+import org.bukkit.entity.ItemFrame;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.ItemType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
@ -67,7 +67,7 @@ index 0000000000000000000000000000000000000000..451fb94a5802755c255e04aebb40f178
+ * @param itemStack {@link ItemFrame} item
+ */
+ public void setItemStack(@Nullable ItemStack itemStack) {
+ this.itemStack = itemStack == null ? new ItemStack(Material.AIR) : itemStack;
+ this.itemStack = itemStack == null ? ItemStack.of(ItemType.AIR) : itemStack;
+ }
+
+ /**

View File

@ -0,0 +1,54 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Tue, 20 Jun 2023 10:52:44 -0700
Subject: [PATCH] enum javadoc fixes
diff --git a/src/main/java/org/bukkit/block/data/BlockData.java b/src/main/java/org/bukkit/block/data/BlockData.java
index 55f5d09664a7858a67b795465282adcf481a2a65..5cafa1bccfbeaa8a6a5573e993635b935f448985 100644
--- a/src/main/java/org/bukkit/block/data/BlockData.java
+++ b/src/main/java/org/bukkit/block/data/BlockData.java
@@ -211,8 +211,8 @@ public interface BlockData extends Cloneable {
* This is identical to {@link BlockType#getItemType()}.
* For example:
* <pre>
- * {@link ItemType#REDSTONE_WIRE} -> {@link BlockType#REDSTONE}
- * {@link ItemType#CARROTS} -> {@link BlockType#CARROT}
+ * {@link ItemType#REDSTONE} -> {@link BlockType#REDSTONE_WIRE}
+ * {@link ItemType#CARROT} -> {@link BlockType#CARROTS}
* </pre>
* @return placement item type or {@link ItemType#AIR} if it doesn't have one
*/
diff --git a/src/main/java/org/bukkit/inventory/meta/trim/TrimPattern.java b/src/main/java/org/bukkit/inventory/meta/trim/TrimPattern.java
index 170ebe3edf9fa6ac62cbc1825ea46721ecb961d2..695502ef8b30822e679b5e94d498b3fa18478fc6 100644
--- a/src/main/java/org/bukkit/inventory/meta/trim/TrimPattern.java
+++ b/src/main/java/org/bukkit/inventory/meta/trim/TrimPattern.java
@@ -55,23 +55,23 @@ public interface TrimPattern extends Keyed {
*/
public static final TrimPattern SPIRE = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("spire"));
/**
- * {@link Material#WAYFINDER_ARMOR_TRIM_SMITHING_TEMPLATE}.
+ * {@link ItemType#WAYFINDER_ARMOR_TRIM_SMITHING_TEMPLATE}.
*/
public static final TrimPattern WAYFINDER = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("wayfinder"));
/**
- * {@link Material#SHAPER_ARMOR_TRIM_SMITHING_TEMPLATE}.
+ * {@link ItemType#SHAPER_ARMOR_TRIM_SMITHING_TEMPLATE}.
*/
public static final TrimPattern SHAPER = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("shaper"));
/**
- * {@link Material#SILENCE_ARMOR_TRIM_SMITHING_TEMPLATE}.
+ * {@link ItemType#SILENCE_ARMOR_TRIM_SMITHING_TEMPLATE}.
*/
public static final TrimPattern SILENCE = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("silence"));
/**
- * {@link Material#RAISER_ARMOR_TRIM_SMITHING_TEMPLATE}.
+ * {@link ItemType#RAISER_ARMOR_TRIM_SMITHING_TEMPLATE}.
*/
public static final TrimPattern RAISER = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("raiser"));
/**
- * {@link Material#HOST_ARMOR_TRIM_SMITHING_TEMPLATE}.
+ * {@link ItemType#HOST_ARMOR_TRIM_SMITHING_TEMPLATE}.
*/
public static final TrimPattern HOST = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("host"));
}

View File

@ -1,19 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Tue, 20 Jun 2023 09:37:42 -0700
Subject: [PATCH] fixup! Paper Utils
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index 26006c3241efc76f0bbf9ba80bfada4bbf52c278..f04e2c955c03e3c2bf05935c7650356705b2c869 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -49,7 +49,7 @@ public interface UnsafeValues {
Material fromLegacy(MaterialData material, boolean itemPriority);
Material toMaterial(ItemType itemType);
- Material toMaterial(BlockType<?> blockType); // Paper
+ Material blockTypeToMaterial(BlockType<?> blockType); // Paper
BlockData fromLegacy(Material material, byte data);

View File

@ -1,28 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Tue, 20 Jun 2023 09:37:53 -0700
Subject: [PATCH] fixup! Add Material Tags
diff --git a/src/main/java/com/destroystokyo/paper/MaterialSetTag.java b/src/main/java/com/destroystokyo/paper/MaterialSetTag.java
index 64dd5e6674f83075be0f0868f66f114ff71dbe24..8f5530188e340336dfffb3054c1743b068bc9342 100644
--- a/src/main/java/com/destroystokyo/paper/MaterialSetTag.java
+++ b/src/main/java/com/destroystokyo/paper/MaterialSetTag.java
@@ -83,7 +83,7 @@ public class MaterialSetTag extends BaseTag<Material, MaterialSetTag> {
public MaterialSetTag addTags(@NotNull Tag<BlockType>...tags) {
for (Tag<BlockType> tag : tags) {
for (final BlockType<?> value : tag.getValues()) {
- this.add(Bukkit.getUnsafe().toMaterial(value));
+ this.add(Bukkit.getUnsafe().blockTypeToMaterial(value));
}
}
return this;
@@ -110,7 +110,7 @@ public class MaterialSetTag extends BaseTag<Material, MaterialSetTag> {
}
public boolean isTagged(@NotNull BlockType<?> itemType) {
- return this.isTagged(Bukkit.getUnsafe().toMaterial(itemType));
+ return this.isTagged(Bukkit.getUnsafe().blockTypeToMaterial(itemType));
}
public boolean isTagged(@NotNull Material material) {

View File

@ -1,19 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Tue, 20 Jun 2023 09:38:01 -0700
Subject: [PATCH] fixup! AnvilDamageEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/block/AnvilDamagedEvent.java b/src/main/java/com/destroystokyo/paper/event/block/AnvilDamagedEvent.java
index 4b90dc67f75b05cb8a766025781b9eaa2fef2606..8174787e87433084035bb3cbc88e041937c56430 100644
--- a/src/main/java/com/destroystokyo/paper/event/block/AnvilDamagedEvent.java
+++ b/src/main/java/com/destroystokyo/paper/event/block/AnvilDamagedEvent.java
@@ -112,7 +112,7 @@ public class AnvilDamagedEvent extends InventoryEvent implements Cancellable {
*/
@Deprecated
public @NotNull Material getMaterial() {
- return Bukkit.getUnsafe().toMaterial(this.blockType);
+ return Bukkit.getUnsafe().blockTypeToMaterial(this.blockType);
}
/**

View File

@ -24,7 +24,7 @@ index 73e5a7f7aa6021715d0d936935470e7f81ada5fa..a30ccb1ff3a02ce482ce2b0d40c76dd0
static boolean hasItemMeta(net.minecraft.world.item.ItemStack item) {
diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java
index 76106ce9aa33dec5ad3768c4a7077dc5f0b48523..f501fe0207d78162789c619857eca69ea9a79304 100644
index 76106ce9aa33dec5ad3768c4a7077dc5f0b48523..d3aebaf4e3f1e17b717011bba04e4c28969411ce 100644
--- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java
+++ b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java
@@ -110,6 +110,34 @@ public class ItemMetaTest extends AbstractTestingBase {
@ -52,7 +52,7 @@ index 76106ce9aa33dec5ad3768c4a7077dc5f0b48523..f501fe0207d78162789c619857eca69e
+
+ @Test
+ public void testHasItemMeta() {
+ ItemStack itemStack = new ItemStack(Material.SHEARS);
+ ItemStack itemStack = ItemStack.of(ItemType.SHEARS);
+
+ testItemMeta(itemStack);
+ testItemMeta(CraftItemStack.asCraftCopy(itemStack));

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Add PlayerItemCooldownEvent
diff --git a/src/main/java/net/minecraft/world/item/ServerItemCooldowns.java b/src/main/java/net/minecraft/world/item/ServerItemCooldowns.java
index 47283d2a49209839002212e663a503a82ea86587..ce026600b3b5c846d991a0dfe599708caf2a2962 100644
index 47283d2a49209839002212e663a503a82ea86587..c59771530ef8d57e8d6aaf353dcbdb834fe35495 100644
--- a/src/main/java/net/minecraft/world/item/ServerItemCooldowns.java
+++ b/src/main/java/net/minecraft/world/item/ServerItemCooldowns.java
@@ -10,6 +10,16 @@ public class ServerItemCooldowns extends ItemCooldowns {
@ -15,7 +15,7 @@ index 47283d2a49209839002212e663a503a82ea86587..ce026600b3b5c846d991a0dfe599708c
+ // Paper start
+ @Override
+ public void addCooldown(Item item, int duration) {
+ io.papermc.paper.event.player.PlayerItemCooldownEvent event = new io.papermc.paper.event.player.PlayerItemCooldownEvent(this.player.getBukkitEntity(), org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), duration);
+ io.papermc.paper.event.player.PlayerItemCooldownEvent event = new io.papermc.paper.event.player.PlayerItemCooldownEvent(this.player.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemType.minecraftToBukkit(item), duration);
+ if (event.callEvent()) {
+ super.addCooldown(item, event.getCooldown());
+ }

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Implement PlayerFlowerPotManipulateEvent
diff --git a/src/main/java/net/minecraft/world/level/block/FlowerPotBlock.java b/src/main/java/net/minecraft/world/level/block/FlowerPotBlock.java
index 9a8fc69de43fcfeebcb31c895fa4b5868952fa0a..db05c1ea847d60ad45d33cd798cb34ad3f5cfd75 100644
index 9a8fc69de43fcfeebcb31c895fa4b5868952fa0a..430ddc8f75730b854d7a0cc43ebcdda2f9e33fa5 100644
--- a/src/main/java/net/minecraft/world/level/block/FlowerPotBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FlowerPotBlock.java
@@ -52,6 +52,26 @@ public class FlowerPotBlock extends Block {
@@ -52,6 +52,25 @@ public class FlowerPotBlock extends Block {
boolean bl = blockState.is(Blocks.AIR);
boolean bl2 = this.isEmpty();
if (bl != bl2) {
@ -17,8 +17,7 @@ index 9a8fc69de43fcfeebcb31c895fa4b5868952fa0a..db05c1ea847d60ad45d33cd798cb34ad
+ boolean placing = bl2;
+ org.bukkit.block.Block bukkitblock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos);
+ org.bukkit.inventory.ItemStack bukkititemstack = org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemStack);
+ org.bukkit.Material mat = org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(content);
+ org.bukkit.inventory.ItemStack bukkititemstack1 = new org.bukkit.inventory.ItemStack(mat, 1);
+ org.bukkit.inventory.ItemStack bukkititemstack1 = org.bukkit.inventory.ItemStack.of(org.bukkit.craftbukkit.inventory.CraftItemType.minecraftToBukkit(this.content.asItem()));
+ org.bukkit.inventory.ItemStack whichitem = placing ? bukkititemstack : bukkititemstack1;
+
+ io.papermc.paper.event.player.PlayerFlowerPotManipulateEvent event = new io.papermc.paper.event.player.PlayerFlowerPotManipulateEvent(player1, bukkitblock, whichitem, placing);

View File

@ -25,16 +25,17 @@ index 259c4f0f85c79bf5f0e81520937aedff73f929a5..43264db3a2ff9ad25522df9abbbf0069
@Override
diff --git a/src/test/java/io/papermc/paper/inventory/CraftMetaTropicalFishBucketTest.java b/src/test/java/io/papermc/paper/inventory/CraftMetaTropicalFishBucketTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..2e7f8ef88ae74c7cbfdb7f397951cbc8479a995f
index 0000000000000000000000000000000000000000..54537b7d425a40f4c02d356d7d85535a94e3d617
--- /dev/null
+++ b/src/test/java/io/papermc/paper/inventory/CraftMetaTropicalFishBucketTest.java
@@ -0,0 +1,40 @@
@@ -0,0 +1,41 @@
+package io.papermc.paper.inventory;
+
+import org.bukkit.DyeColor;
+import org.bukkit.Material;
+import org.bukkit.entity.TropicalFish;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.ItemType;
+import org.bukkit.inventory.meta.ItemMeta;
+import org.bukkit.inventory.meta.TropicalFishBucketMeta;
+import org.bukkit.support.AbstractTestingBase;
+import org.junit.Assert;
@ -44,14 +45,14 @@ index 0000000000000000000000000000000000000000..2e7f8ef88ae74c7cbfdb7f397951cbc8
+
+ @Test
+ public void testAllCombinations() {
+ final var rawMeta = new ItemStack(Material.TROPICAL_FISH_BUCKET).getItemMeta();
+ final ItemMeta rawMeta = ItemStack.of(ItemType.TROPICAL_FISH_BUCKET).getItemMeta();
+ Assert.assertTrue("Meta was not a tropical fish bucket", rawMeta instanceof TropicalFishBucketMeta);
+
+ final var meta = (TropicalFishBucketMeta) rawMeta;
+ final TropicalFishBucketMeta meta = (TropicalFishBucketMeta) rawMeta;
+
+ for (final var bodyColor : DyeColor.values()) {
+ for (final var pattern : TropicalFish.Pattern.values()) {
+ for (final var patternColor : DyeColor.values()) {
+ for (final DyeColor bodyColor : DyeColor.values()) {
+ for (final TropicalFish.Pattern pattern : TropicalFish.Pattern.values()) {
+ for (final DyeColor patternColor : DyeColor.values()) {
+ meta.setBodyColor(bodyColor);
+ Assert.assertEquals("Body color did not match post body color!", bodyColor, meta.getBodyColor());
+

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Make some itemstacks nonnull
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java
index f89a1b1c1902b16f6640c9a95f5b72351b60ceda..0c80dea986b0b63b2182c4ca0d23d6534f753cb0 100644
index f89a1b1c1902b16f6640c9a95f5b72351b60ceda..3eb85fa40a6b55d5f820ca436c47b8e883ebae90 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java
@@ -155,13 +155,13 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i
@ -13,16 +13,16 @@ index f89a1b1c1902b16f6640c9a95f5b72351b60ceda..0c80dea986b0b63b2182c4ca0d23d653
return this.getItemInOffHand();
case FEET:
- return this.getBoots();
+ return java.util.Objects.requireNonNullElseGet(this.getBoots(), () -> new ItemStack(org.bukkit.Material.AIR)); // Paper - make nonnull
+ return java.util.Objects.requireNonNullElseGet(this.getBoots(), () -> ItemStack.of(org.bukkit.inventory.ItemType.AIR)); // Paper - make nonnull
case LEGS:
- return this.getLeggings();
+ return java.util.Objects.requireNonNullElseGet(this.getLeggings(), () -> new ItemStack(org.bukkit.Material.AIR)); // Paper - make nonnull
+ return java.util.Objects.requireNonNullElseGet(this.getLeggings(), () -> ItemStack.of(org.bukkit.inventory.ItemType.AIR)); // Paper - make nonnull
case CHEST:
- return this.getChestplate();
+ return java.util.Objects.requireNonNullElseGet(this.getChestplate(), () -> new ItemStack(org.bukkit.Material.AIR)); // Paper - make nonnull
+ return java.util.Objects.requireNonNullElseGet(this.getChestplate(), () -> ItemStack.of(org.bukkit.inventory.ItemType.AIR)); // Paper - make nonnull
case HEAD:
- return this.getHelmet();
+ return java.util.Objects.requireNonNullElseGet(this.getHelmet(), () -> new ItemStack(org.bukkit.Material.AIR)); // Paper - make nonnull
+ return java.util.Objects.requireNonNullElseGet(this.getHelmet(), () -> ItemStack.of(org.bukkit.inventory.ItemType.AIR)); // Paper - make nonnull
default:
throw new IllegalArgumentException("Not implemented. This is a bug");
}