mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-01 04:31:58 +01:00
d8847bc1f3
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: fde5602a PR-927: Add PlayerRecipeBookSettingsChangeEvent 949ff217 PR-930: Add methods to get/set evoker fang attack delay f6f7c79d SPIGOT-7514, PR-929: Add "Enchantment Roll" API to enchant items according to Minecraft mechanics d40e22da PR-712: Add API to get full result of crafting items CraftBukkit Changes: c8feb0629 PR-1291: Improve precondition message in Entity#playEffect 482c56a00 PR-1285: Add PlayerRecipeBookSettingsChangeEvent cdf798800 PR-1290: Add methods to get/set evoker fang attack delay 2c1b5f78f SPIGOT-7514, PR-1289: Add "Enchantment Roll" API to enchant items according to Minecraft mechanics 6aa644ae9 PR-992: Add API to get full result of crafting items ffb1319bc PR-1287: Fix scoreboards not updating in Player#setStatistic
169 lines
6.5 KiB
Diff
169 lines
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 d1ddd924db3f781138696f49110953d10bf76d5f..14ec0bf4e811028bf3ca419ac85d1676f801a331 100644
|
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
|
@@ -960,6 +960,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.
|
|
*
|
|
@@ -1014,6 +1034,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.
|
|
@@ -1205,6 +1239,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 3d8a33563cb266fd784e264f6ce3850213a3838a..49b1f9596502c574638b58996fc8ca0bfde6826b 100644
|
|
--- a/src/main/java/org/bukkit/Server.java
|
|
+++ b/src/main/java/org/bukkit/Server.java
|
|
@@ -812,6 +812,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.
|
|
*
|
|
@@ -847,15 +863,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.
|
|
@@ -1024,6 +1059,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.
|
|
*
|