geforkt von Mirrors/Paper
de04cbced5
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: f29cb801 Separate checkstyle-suppressions file is not required 86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack 9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode() 994a6163 Attempt upgrade of resolver libraries CraftBukkit Changes: b3b43a6ad Add Checkstyle check for unused imports 13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names 3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API 2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor 1dbdbbed4 PR-1238: Remove unnecessary sign ticking 659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper e37e29ce0 Increase outdated build delay c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack 492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode() e11fbb9d7 Upgrade MySQL driver 9f3a0bd2a Attempt upgrade of resolver libraries 60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion Spigot Changes: 06d602e7 Rebuild patches
170 Zeilen
6.5 KiB
Diff
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 f98c8c41ad9685af327db9c44db5fc9e37e00590..adfaf27b872aa5614a31ff5f32cf9336c6f2ee49 100644
|
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
|
@@ -970,6 +970,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.
|
|
*
|
|
@@ -1024,6 +1044,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.
|
|
@@ -1215,6 +1249,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 f8f0a2b7fdd51c739c3f55801037a417872ce7d5..36a21c39f834faa6fec29a319588ddc58715a747 100644
|
|
--- a/src/main/java/org/bukkit/Server.java
|
|
+++ b/src/main/java/org/bukkit/Server.java
|
|
@@ -820,6 +820,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.
|
|
*
|
|
@@ -855,15 +871,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.
|
|
@@ -1032,6 +1067,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.
|
|
*
|