Change return type of ItemStack#editMeta to allow checking for successful vs non-successful edits

This commit is contained in:
Riley Park 2021-05-23 12:32:43 -07:00
parent 455960096d
commit 0edaf770ea

View file

@ -17,13 +17,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Edits the {@link ItemMeta} of this stack.
+ *
+ * @param consumer the meta consumer
+ * @return {@code true} if the edit was successful, {@code false} otherwise
+ */
+ public void editMeta(final @NotNull java.util.function.Consumer<? super ItemMeta> consumer) {
+ public boolean editMeta(final @NotNull java.util.function.Consumer<? super ItemMeta> consumer) {
+ final ItemMeta meta = this.getItemMeta();
+ if (meta != null) {
+ consumer.accept(meta);
+ this.setItemMeta(meta);
+ return true;
+ }
+ return false;
+ }
+ // Paper end
+