prepare for 1.21.3 update

This commit is contained in:
granny
2024-10-25 18:36:30 -07:00
parent d49ca07e00
commit a711b8929e
359 changed files with 7 additions and 7 deletions

View File

@@ -0,0 +1,189 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Sun, 19 Apr 2020 00:25:09 -0500
Subject: [PATCH] Anvil API
diff --git a/src/main/java/org/bukkit/inventory/AnvilInventory.java b/src/main/java/org/bukkit/inventory/AnvilInventory.java
index f1f97a85ec713c05c882d7588f4a3e4a017f4795..813f6cd253322538bdf96eb323dd23a7809a1c1e 100644
--- a/src/main/java/org/bukkit/inventory/AnvilInventory.java
+++ b/src/main/java/org/bukkit/inventory/AnvilInventory.java
@@ -138,4 +138,42 @@ public interface AnvilInventory extends Inventory {
setItem(2, result);
}
// Paper end
+
+ // Purpur start
+ /**
+ * Gets if the player viewing the anvil inventory can bypass experience cost
+ *
+ * @return whether the player viewing the anvil inventory can bypass the experience cost
+ * @deprecated use {@link AnvilView#canBypassCost()}.
+ */
+ @Deprecated(forRemoval = true, since = "1.21")
+ boolean canBypassCost();
+
+ /**
+ * Set if the player viewing the anvil inventory can bypass the experience cost
+ *
+ * @param bypassCost whether the player viewing the anvil inventory can bypass the experience cost
+ * @deprecated use {@link AnvilView#setBypassCost(boolean)}.
+ */
+ @Deprecated(forRemoval = true, since = "1.21")
+ void setBypassCost(boolean bypassCost);
+
+ /**
+ * Gets if the player viewing the anvil inventory can do unsafe enchants
+ *
+ * @return whether the player viewing the anvil inventory can do unsafe enchants
+ * @deprecated use {@link AnvilView#canDoUnsafeEnchants()}.
+ */
+ @Deprecated(forRemoval = true, since = "1.21")
+ boolean canDoUnsafeEnchants();
+
+ /**
+ * Set if the player viewing the anvil inventory can do unsafe enchants
+ *
+ * @param canDoUnsafeEnchants whether the player viewing the anvil inventory can do unsafe enchants
+ * @deprecated use {@link AnvilView#setDoUnsafeEnchants(boolean)}.
+ */
+ @Deprecated(forRemoval = true, since = "1.21")
+ void setDoUnsafeEnchants(boolean canDoUnsafeEnchants);
+ // Purpur end
}
diff --git a/src/main/java/org/bukkit/inventory/view/AnvilView.java b/src/main/java/org/bukkit/inventory/view/AnvilView.java
index 3c1aa1e036bee08304c1cdca59f6a5bc0ba306c0..709fb2d1c7e3253034a651a9f68c003601b598a4 100644
--- a/src/main/java/org/bukkit/inventory/view/AnvilView.java
+++ b/src/main/java/org/bukkit/inventory/view/AnvilView.java
@@ -89,4 +89,34 @@ public interface AnvilView extends InventoryView {
*/
void bypassEnchantmentLevelRestriction(boolean bypassEnchantmentLevelRestriction);
// Paper end - bypass anvil level restrictions
+
+ // Purpur start
+ /**
+ * Gets if the player viewing the anvil inventory can bypass experience cost
+ *
+ * @return whether the player viewing the anvil inventory can bypass the experience cost
+ */
+ boolean canBypassCost();
+
+ /**
+ * Set if the player viewing the anvil inventory can bypass the experience cost
+ *
+ * @param bypassCost whether the player viewing the anvil inventory can bypass the experience cost
+ */
+ void setBypassCost(boolean bypassCost);
+
+ /**
+ * Gets if the player viewing the anvil inventory can do unsafe enchants
+ *
+ * @return whether the player viewing the anvil inventory can do unsafe enchants
+ */
+ boolean canDoUnsafeEnchants();
+
+ /**
+ * Set if the player viewing the anvil inventory can do unsafe enchants
+ *
+ * @param canDoUnsafeEnchants whether the player viewing the anvil inventory can do unsafe enchants
+ */
+ void setDoUnsafeEnchants(boolean canDoUnsafeEnchants);
+ // Purpur end
}
diff --git a/src/main/java/org/purpurmc/purpur/event/inventory/AnvilTakeResultEvent.java b/src/main/java/org/purpurmc/purpur/event/inventory/AnvilTakeResultEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..b2199854b5c7e74a673cbadbe584e5aaebbe3883
--- /dev/null
+++ b/src/main/java/org/purpurmc/purpur/event/inventory/AnvilTakeResultEvent.java
@@ -0,0 +1,50 @@
+package org.purpurmc.purpur.event.inventory;
+
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.inventory.InventoryEvent;
+import org.bukkit.inventory.AnvilInventory;
+import org.bukkit.inventory.InventoryView;
+import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Called when a player takes the result item out of an anvil
+ */
+@NullMarked
+public class AnvilTakeResultEvent extends InventoryEvent {
+ private static final HandlerList handlers = new HandlerList();
+ private final Player player;
+ private final ItemStack result;
+
+ @ApiStatus.Internal
+ public AnvilTakeResultEvent(HumanEntity player, InventoryView view, ItemStack result) {
+ super(view);
+ this.player = (Player) player;
+ this.result = result;
+ }
+
+ public Player getPlayer() {
+ return player;
+ }
+
+ public ItemStack getResult() {
+ return result;
+ }
+
+ @Override
+ public AnvilInventory getInventory() {
+ return (AnvilInventory) super.getInventory();
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}
diff --git a/src/main/java/org/purpurmc/purpur/event/inventory/AnvilUpdateResultEvent.java b/src/main/java/org/purpurmc/purpur/event/inventory/AnvilUpdateResultEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..4293c4a57c1c054e8248b7712e8664bd4cb1a972
--- /dev/null
+++ b/src/main/java/org/purpurmc/purpur/event/inventory/AnvilUpdateResultEvent.java
@@ -0,0 +1,35 @@
+package org.purpurmc.purpur.event.inventory;
+
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.inventory.InventoryEvent;
+import org.bukkit.inventory.AnvilInventory;
+import org.bukkit.inventory.InventoryView;
+import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Called when anvil slots change, triggering the result slot to be updated
+ */
+@NullMarked
+public class AnvilUpdateResultEvent extends InventoryEvent {
+ private static final HandlerList handlers = new HandlerList();
+
+ @ApiStatus.Internal
+ public AnvilUpdateResultEvent(InventoryView view) {
+ super(view);
+ }
+
+ @Override
+ public AnvilInventory getInventory() {
+ return (AnvilInventory) super.getInventory();
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}