3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-14 20:10:05 +01:00
Paper/patches/api/0399-API-for-updating-recipes-on-clients.patch
Nassim Jahnke 52a05907c7
Updated Upstream (Bukkit/CraftBukkit) (#11543)
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:
97c59261 PR-1073: Make Biome an interface
a38581aa Fix further javadoc errors
8271c490 Fix javadoc error
8a9ecf29 PR-1072: Fix bad naming for Vault State methods
6dd58108 PR-1071: Make Fluid an interface and add missing entry
ed2cdfc3 PR-1070: Make Attribute an interface and align names with the new minecraft ones
63472efb PR-1069: Add missing winter drop experimental annotation to pale boats

CraftBukkit Changes:
7235ad7b0 PR-1501: Make Biome an interface
602904003 PR-1500: Rename implementation for Vault State methods
75f26f79f PR-1499: Make Fluid an interface and add missing entry
4cfd87adc PR-1498: Make Attribute an interface and align names with the new minecraft ones
6bb0db5cb SPIGOT-7928: ExactChoice acts as MaterialChoice
3eaf3a13c SPIGOT-7929: Error when setting EquippableComponent
abbf57bac SPIGOT-7930: Fix spawning entities with SummonEntityEffect
92d6ab6cf PR-1497: Move boat field rename entries to below key renaming, so that keys are also renamed
abfe292aa PR-1496: Use correct Fluid class on Tags type check
c7aab7fa7 SPIGOT-7923: Fix Dispenser logic to avoid firing empty projectiles
2024-10-31 23:44:34 +01:00

170 Zeilen
6.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sat, 21 Aug 2021 17:25:54 -0700
Subject: [PATCH] API for updating recipes on clients
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 50efe16bb80c618c3dfae03b70c8c165183af8ec..52c601328bbf5c1642aa620c8bb466a9d2d231be 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -1004,6 +1004,26 @@ public final class Bukkit {
server.reloadData();
}
+ // Paper start - update reloadable data
+ /**
+ * Updates all advancement, tag, and recipe data for all connected clients.
+ * Useful for updating clients to new advancements/recipes/tags.
+ * @see #updateRecipes()
+ */
+ public static void updateResources() {
+ server.updateResources();
+ }
+
+ /**
+ * Updates recipe data and the recipe book for all connected clients. Useful for
+ * updating clients to new recipes.
+ * @see #updateResources()
+ */
+ public static void updateRecipes() {
+ server.updateRecipes();
+ }
+ // Paper end - update reloadable data
+
/**
* Returns the primary logger associated with this server instance.
*
@@ -1064,6 +1084,20 @@ public final class Bukkit {
return server.addRecipe(recipe);
}
+ // Paper start - method to send recipes immediately
+ /**
+ * Adds a recipe to the crafting manager.
+ *
+ * @param recipe the recipe to add
+ * @param resendRecipes true to update the client with the full set of recipes
+ * @return true if the recipe was added, false if it wasn't for some reason
+ */
+ @Contract("null, _ -> false")
+ public static boolean addRecipe(@Nullable Recipe recipe, boolean resendRecipes) {
+ return server.addRecipe(recipe, resendRecipes);
+ }
+ // Paper end - method to send recipes immediately
+
/**
* Get a list of all recipes for a given item. The stack size is ignored
* in comparisons. If the durability is -1, it will match any data value.
@@ -1255,6 +1289,24 @@ public final class Bukkit {
return server.removeRecipe(key);
}
+ // Paper start - method to resend recipes
+ /**
+ * Remove a recipe from the server.
+ * <p>
+ * <b>Note that removing a recipe may cause permanent loss of data
+ * associated with that recipe (eg whether it has been discovered by
+ * players).</b>
+ *
+ * @param key NamespacedKey of recipe to remove.
+ * @param resendRecipes true to update all clients on the new recipe list.
+ * Will only update if a recipe was actually removed
+ * @return True if recipe was removed
+ */
+ public static boolean removeRecipe(@NotNull NamespacedKey key, boolean resendRecipes) {
+ return server.removeRecipe(key, resendRecipes);
+ }
+ // Paper end - method to resend recipes
+
/**
* Gets a list of command aliases defined in the server properties.
*
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 1b8d6a3333a4fa9155b79644e683e2343c134e12..8ba2fbaab7428a42b506fd000fbc162f68ddaed1 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -853,6 +853,22 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*/
public void reloadData();
+ // Paper start - update reloadable data
+ /**
+ * Updates all advancement, tag, and recipe data to all connected clients.
+ * Useful for updating clients to new advancements/recipes/tags.
+ * @see #updateRecipes()
+ */
+ void updateResources();
+
+ /**
+ * Updates recipe data and the recipe book to each player. Useful for
+ * updating clients to new recipes.
+ * @see #updateResources()
+ */
+ void updateRecipes();
+ // Paper end - update reloadable data
+
/**
* Returns the primary logger associated with this server instance.
*
@@ -894,15 +910,34 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
public boolean dispatchCommand(@NotNull CommandSender sender, @NotNull String commandLine) throws CommandException;
/**
- * Adds a recipe to the crafting manager.
+ * Adds a recipe to the crafting manager. Recipes added with
+ * this method won't be sent to the client automatically. Use
+ * {@link #updateRecipes()} or {@link #updateResources()} to
+ * update clients to new recipes added.
+ * <p>
+ * Player's still have to discover recipes via {@link Player#discoverRecipe(NamespacedKey)}
+ * before seeing them in their recipe book.
*
* @param recipe the recipe to add
* @return true if the recipe was added, false if it wasn't for some
* reason
+ * @see #addRecipe(Recipe, boolean)
*/
@Contract("null -> false")
public boolean addRecipe(@Nullable Recipe recipe);
+ // Paper start - method to send recipes immediately
+ /**
+ * Adds a recipe to the crafting manager.
+ *
+ * @param recipe the recipe to add
+ * @param resendRecipes true to update the client with the full set of recipes
+ * @return true if the recipe was added, false if it wasn't for some reason
+ */
+ @Contract("null, _ -> false")
+ boolean addRecipe(@Nullable Recipe recipe, boolean resendRecipes);
+ // Paper end - method to send recipes immediately
+
/**
* Get a list of all recipes for a given item. The stack size is ignored
* in comparisons. If the durability is -1, it will match any data value.
@@ -1071,6 +1106,22 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*/
public boolean removeRecipe(@NotNull NamespacedKey key);
+ // Paper start - method to resend recipes
+ /**
+ * Remove a recipe from the server.
+ * <p>
+ * <b>Note that removing a recipe may cause permanent loss of data
+ * associated with that recipe (eg whether it has been discovered by
+ * players).</b>
+ *
+ * @param key NamespacedKey of recipe to remove.
+ * @param resendRecipes true to update all clients on the new recipe list.
+ * Will only update if a recipe was actually removed
+ * @return True if recipe was removed
+ */
+ boolean removeRecipe(@NotNull NamespacedKey key, boolean resendRecipes);
+ // Paper end - method to resend recipes
+
/**
* Gets a list of command aliases defined in the server properties.
*