From 9e1db9974946f0a7521fe56eb00da7c576720016 Mon Sep 17 00:00:00 2001 From: Sefiraat Date: Wed, 22 Dec 2021 15:57:06 +0000 Subject: [PATCH 01/67] DistinctiveItem/isSimilar + Backpack isSame --- .../core/attributes/DistinctiveItem.java | 31 +++++++++++++++++++ .../items/backpacks/SlimefunBackpack.java | 15 ++++++++- .../slimefun4/utils/SlimefunUtils.java | 13 ++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java new file mode 100644 index 0000000000..6d82b57992 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java @@ -0,0 +1,31 @@ +package io.github.thebusybiscuit.slimefun4.core.attributes; + +import org.bukkit.inventory.meta.ItemMeta; + +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; + +import javax.annotation.Nonnull; + +/** + * Implement this interface for any {@link SlimefunItem} to prevent + * cargo using only it's ID when comparing. #isSame is used when + * comparing stacks + * + * @author Sefiraat + */ +public interface DistinctiveItem extends ItemAttribute { + + /** + * This method is called by SlimefunUtil#isItemSimilar when two SlimefunItemStack + * IDs match on a DistinctiveItem and should return if the two items can stack + * with one another. + * + * @param sfItemMeta + * The {@link ItemMeta} of the first stack being compared. + * @param itemMeta + * The {@link ItemMeta} of the second stack being compared. + * + * @return Whether the two {@link ItemMeta}s are distinct + */ + boolean canStack(@Nonnull ItemMeta sfItemMeta, @Nonnull ItemMeta itemMeta); +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SlimefunBackpack.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SlimefunBackpack.java index 4ba451149b..58d01198ca 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SlimefunBackpack.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SlimefunBackpack.java @@ -6,16 +6,19 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.attributes.DistinctiveItem; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import io.github.thebusybiscuit.slimefun4.implementation.listeners.BackpackListener; +import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; /** @@ -28,7 +31,7 @@ * @see PlayerBackpack * */ -public class SlimefunBackpack extends SimpleSlimefunItem { +public class SlimefunBackpack extends SimpleSlimefunItem implements DistinctiveItem { private final int size; @@ -82,4 +85,14 @@ public ItemUseHandler getItemHandler() { }; } + @Override + public boolean canStack(@Nonnull ItemMeta sfItemMeta, @Nonnull ItemMeta itemMeta) { + boolean hasLoreItem = itemMeta.hasLore(); + boolean hasLoreSfItem = sfItemMeta.hasLore(); + + if (hasLoreItem && hasLoreSfItem && SlimefunUtils.equalsLore(itemMeta.getLore(), sfItemMeta.getLore())) { + return true; + } + return !hasLoreItem && !hasLoreSfItem; + } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java index 94de18c642..f18bac017e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java @@ -36,6 +36,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemSpawnReason; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun4.core.attributes.DistinctiveItem; import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive; import io.github.thebusybiscuit.slimefun4.core.attributes.Soulbound; import io.github.thebusybiscuit.slimefun4.core.debug.Debug; @@ -304,6 +305,18 @@ public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStac // Prioritize SlimefunItem id comparison over ItemMeta comparison if (Slimefun.getItemDataService().hasEqualItemData(possibleSfItemMeta, itemMeta)) { Debug.log(TestCase.CARGO_INPUT_TESTING, " Item IDs matched!"); + + /* + * Some items can't rely on just IDs matching and will implement Distinctive Item + * in which case we want to use the method provided to compare + */ + Optional id = Slimefun.getItemDataService().getItemData(itemMeta); + if (id.isPresent()) { + SlimefunItem slimefunItem = SlimefunItem.getById(id.get()); + if (slimefunItem instanceof DistinctiveItem) { + return ((DistinctiveItem) slimefunItem).canStack(possibleSfItemMeta, itemMeta); + } + } return true; } else { Debug.log(TestCase.CARGO_INPUT_TESTING, " Item IDs don't match, checking meta {} == {} (lore: {})", itemMeta, possibleSfItemMeta, checkLore); From 69d1c4503e35bca8efd134a206f218796b710f00 Mon Sep 17 00:00:00 2001 From: Sefiraat Date: Thu, 23 Dec 2021 10:42:34 +0000 Subject: [PATCH 02/67] Typo --- .../slimefun4/core/attributes/DistinctiveItem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java index 6d82b57992..80b915a067 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java @@ -8,7 +8,7 @@ /** * Implement this interface for any {@link SlimefunItem} to prevent - * cargo using only it's ID when comparing. #isSame is used when + * cargo using only its ID when comparing. #canStack is used when * comparing stacks * * @author Sefiraat From 92b45ad4e8c6cbd12a486d8670ce266df499a6bd Mon Sep 17 00:00:00 2001 From: Sefiraat Date: Thu, 23 Dec 2021 10:44:00 +0000 Subject: [PATCH 03/67] call getItemData once only --- .../slimefun4/utils/SlimefunUtils.java | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java index f18bac017e..946d0ad3c6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java @@ -282,11 +282,14 @@ public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStac Debug.log(TestCase.CARGO_INPUT_TESTING, "SlimefunUtils#isItemSimilar - item.hasItemMeta()"); ItemMeta itemMeta = item.getItemMeta(); + // Grab ID here as it is used for all but one of the remaining branches + Optional optionalId = Slimefun.getItemDataService().getItemData(itemMeta); + String id = optionalId.orElse(null); + if (sfitem instanceof SlimefunItemStack) { - Optional id = Slimefun.getItemDataService().getItemData(itemMeta); - if (id.isPresent()) { - return id.get().equals(((SlimefunItemStack) sfitem).getItemId()); + if (id != null) { + return id.equals(((SlimefunItemStack) sfitem).getItemId()); } ItemMetaSnapshot meta = ((SlimefunItemStack) sfitem).getItemMetaSnapshot(); @@ -303,19 +306,16 @@ public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStac Debug.log(TestCase.CARGO_INPUT_TESTING, " sfitem is ItemStackWrapper - possible SF Item: {}", sfitem); // Prioritize SlimefunItem id comparison over ItemMeta comparison - if (Slimefun.getItemDataService().hasEqualItemData(possibleSfItemMeta, itemMeta)) { + if (Slimefun.getItemDataService().getItemData(possibleSfItemMeta).orElse("").equals(id)) { Debug.log(TestCase.CARGO_INPUT_TESTING, " Item IDs matched!"); /* - * Some items can't rely on just IDs matching and will implement Distinctive Item - * in which case we want to use the method provided to compare + * Some items can't rely on just IDs matching and will implement Distinctive Item + * in which case we want to use the method provided to compare */ - Optional id = Slimefun.getItemDataService().getItemData(itemMeta); - if (id.isPresent()) { - SlimefunItem slimefunItem = SlimefunItem.getById(id.get()); - if (slimefunItem instanceof DistinctiveItem) { - return ((DistinctiveItem) slimefunItem).canStack(possibleSfItemMeta, itemMeta); - } + Optional optionalDistinctive = getDistinctiveItem(id); + if (optionalDistinctive.isPresent()) { + return optionalDistinctive.get().canStack(possibleSfItemMeta, itemMeta); } return true; } else { @@ -334,6 +334,14 @@ public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStac } } + private static @Nonnull Optional getDistinctiveItem(@Nonnull String id) { + SlimefunItem slimefunItem = SlimefunItem.getById(id); + if (slimefunItem instanceof DistinctiveItem) { + return Optional.of((DistinctiveItem) slimefunItem); + } + return Optional.empty(); + } + private static boolean equalsItemMeta(@Nonnull ItemMeta itemMeta, @Nonnull ItemMetaSnapshot meta, boolean checkLore) { Optional displayName = meta.getDisplayName(); @@ -523,7 +531,7 @@ public static boolean canPlayerUseItem(@Nonnull Player p, @Nullable ItemStack it * * @param inventory * The {@link Inventory} to check. - * + * * @return True if the inventory is empty and false otherwise */ public static boolean isInventoryEmpty(@Nonnull Inventory inventory) { From 259a9e6faf515fea7efbb8f1edca364cee036645 Mon Sep 17 00:00:00 2001 From: Sefiraat Date: Thu, 23 Dec 2021 20:11:09 +0000 Subject: [PATCH 04/67] Applying feedback --- .../thebusybiscuit/slimefun4/utils/SlimefunUtils.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java index 946d0ad3c6..4410f88b46 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java @@ -282,11 +282,8 @@ public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStac Debug.log(TestCase.CARGO_INPUT_TESTING, "SlimefunUtils#isItemSimilar - item.hasItemMeta()"); ItemMeta itemMeta = item.getItemMeta(); - // Grab ID here as it is used for all but one of the remaining branches - Optional optionalId = Slimefun.getItemDataService().getItemData(itemMeta); - String id = optionalId.orElse(null); - if (sfitem instanceof SlimefunItemStack) { + String id = getMetaId(itemMeta); if (id != null) { return id.equals(((SlimefunItemStack) sfitem).getItemId()); @@ -304,6 +301,7 @@ public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStac */ ItemMeta possibleSfItemMeta = sfitem.getItemMeta(); Debug.log(TestCase.CARGO_INPUT_TESTING, " sfitem is ItemStackWrapper - possible SF Item: {}", sfitem); + String id = getMetaId(itemMeta); // Prioritize SlimefunItem id comparison over ItemMeta comparison if (Slimefun.getItemDataService().getItemData(possibleSfItemMeta).orElse("").equals(id)) { @@ -334,6 +332,11 @@ public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStac } } + private static @Nullable String getMetaId(ItemMeta itemMeta) { + Optional optionalId = Slimefun.getItemDataService().getItemData(itemMeta); + return optionalId.orElse(null); + } + private static @Nonnull Optional getDistinctiveItem(@Nonnull String id) { SlimefunItem slimefunItem = SlimefunItem.getById(id); if (slimefunItem instanceof DistinctiveItem) { From 7bad43ca0de85bb4d982b0f36b53e74b1fa02a5e Mon Sep 17 00:00:00 2001 From: Sefiraat Date: Fri, 21 Jan 2022 08:20:50 +0000 Subject: [PATCH 05/67] Added Distinctive check to other arms --- .../slimefun4/utils/SlimefunUtils.java | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java index 4410f88b46..a07d3c0935 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java @@ -277,15 +277,36 @@ public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStac } else if (checkAmount && item.getAmount() < sfitem.getAmount()) { return false; } else if (sfitem instanceof SlimefunItemStack && item instanceof SlimefunItemStack) { - return ((SlimefunItemStack) item).getItemId().equals(((SlimefunItemStack) sfitem).getItemId()); + SlimefunItemStack sfItemStack = (SlimefunItemStack) sfitem; + SlimefunItemStack itemStack = (SlimefunItemStack) item; + if (sfItemStack.getItemId().equals(itemStack.getItemId())) { + /* + * Some items can't rely on just IDs matching and will implement Distinctive Item + * in which case we want to use the method provided to compare + */ + if (sfItemStack instanceof DistinctiveItem && itemStack instanceof DistinctiveItem) { + return ((DistinctiveItem) sfItemStack).canStack(sfItemStack.getItemMeta(), itemStack.getItemMeta()); + } + return true; + } + return false; } else if (item.hasItemMeta()) { Debug.log(TestCase.CARGO_INPUT_TESTING, "SlimefunUtils#isItemSimilar - item.hasItemMeta()"); ItemMeta itemMeta = item.getItemMeta(); if (sfitem instanceof SlimefunItemStack) { - String id = getMetaId(itemMeta); + String id = Slimefun.getItemDataService().getItemData(itemMeta).orElse(null); if (id != null) { + /* + * Some items can't rely on just IDs matching and will implement Distinctive Item + * in which case we want to use the method provided to compare + */ + Optional optionalDistinctive = getDistinctiveItem(id); + if (optionalDistinctive.isPresent()) { + ItemMeta possibleSfItemMeta = sfitem.getItemMeta(); + return optionalDistinctive.get().canStack(possibleSfItemMeta, itemMeta); + } return id.equals(((SlimefunItemStack) sfitem).getItemId()); } @@ -301,7 +322,7 @@ public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStac */ ItemMeta possibleSfItemMeta = sfitem.getItemMeta(); Debug.log(TestCase.CARGO_INPUT_TESTING, " sfitem is ItemStackWrapper - possible SF Item: {}", sfitem); - String id = getMetaId(itemMeta); + String id = Slimefun.getItemDataService().getItemData(itemMeta).orElse(null); // Prioritize SlimefunItem id comparison over ItemMeta comparison if (Slimefun.getItemDataService().getItemData(possibleSfItemMeta).orElse("").equals(id)) { @@ -332,11 +353,6 @@ public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStac } } - private static @Nullable String getMetaId(ItemMeta itemMeta) { - Optional optionalId = Slimefun.getItemDataService().getItemData(itemMeta); - return optionalId.orElse(null); - } - private static @Nonnull Optional getDistinctiveItem(@Nonnull String id) { SlimefunItem slimefunItem = SlimefunItem.getById(id); if (slimefunItem instanceof DistinctiveItem) { From 69318777e472aef53d3da11ccb2c62732e0806fa Mon Sep 17 00:00:00 2001 From: Sefiraat Date: Sat, 22 Jan 2022 17:06:25 +0000 Subject: [PATCH 06/67] Update src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java Co-authored-by: Daniel Walsh --- .../slimefun4/core/attributes/DistinctiveItem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java index 80b915a067..c120eedc75 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java @@ -16,7 +16,7 @@ public interface DistinctiveItem extends ItemAttribute { /** - * This method is called by SlimefunUtil#isItemSimilar when two SlimefunItemStack + * This method is called by {@link SlimefunUtils#isItemSimilar} when two {@link SlimefunItemStack} * IDs match on a DistinctiveItem and should return if the two items can stack * with one another. * From 224262b322617a3de29919c7b399a26af6bd3b5f Mon Sep 17 00:00:00 2001 From: Sefiraat Date: Sat, 22 Jan 2022 17:36:56 +0000 Subject: [PATCH 07/67] Walshy feedback --- .../core/attributes/DistinctiveItem.java | 6 ++--- .../items/backpacks/SlimefunBackpack.java | 8 +++--- .../slimefun4/utils/SlimefunUtils.java | 27 ++++++++++++------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java index 80b915a067..50ddbff007 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java @@ -20,12 +20,12 @@ public interface DistinctiveItem extends ItemAttribute { * IDs match on a DistinctiveItem and should return if the two items can stack * with one another. * - * @param sfItemMeta + * @param itemMetaOne * The {@link ItemMeta} of the first stack being compared. - * @param itemMeta + * @param itemMetaTwo * The {@link ItemMeta} of the second stack being compared. * * @return Whether the two {@link ItemMeta}s are distinct */ - boolean canStack(@Nonnull ItemMeta sfItemMeta, @Nonnull ItemMeta itemMeta); + boolean canStack(@Nonnull ItemMeta itemMetaOne, @Nonnull ItemMeta itemMetaTwo); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SlimefunBackpack.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SlimefunBackpack.java index 58d01198ca..4f2a0e3500 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SlimefunBackpack.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SlimefunBackpack.java @@ -86,11 +86,11 @@ public ItemUseHandler getItemHandler() { } @Override - public boolean canStack(@Nonnull ItemMeta sfItemMeta, @Nonnull ItemMeta itemMeta) { - boolean hasLoreItem = itemMeta.hasLore(); - boolean hasLoreSfItem = sfItemMeta.hasLore(); + public boolean canStack(@Nonnull ItemMeta itemMetaOne, @Nonnull ItemMeta itemMetaTwo) { + boolean hasLoreItem = itemMetaTwo.hasLore(); + boolean hasLoreSfItem = itemMetaOne.hasLore(); - if (hasLoreItem && hasLoreSfItem && SlimefunUtils.equalsLore(itemMeta.getLore(), sfItemMeta.getLore())) { + if (hasLoreItem && hasLoreSfItem && SlimefunUtils.equalsLore(itemMetaTwo.getLore(), itemMetaOne.getLore())) { return true; } return !hasLoreItem && !hasLoreSfItem; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java index f214d45cb4..a7da36b1c5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java @@ -279,15 +279,17 @@ public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStac } else if (checkAmount && item.getAmount() < sfitem.getAmount()) { return false; } else if (sfitem instanceof SlimefunItemStack && item instanceof SlimefunItemStack) { - SlimefunItemStack sfItemStack = (SlimefunItemStack) sfitem; - SlimefunItemStack itemStack = (SlimefunItemStack) item; - if (sfItemStack.getItemId().equals(itemStack.getItemId())) { + SlimefunItemStack stackOne = (SlimefunItemStack) sfitem; + SlimefunItemStack stackTwo = (SlimefunItemStack) item; + if (stackOne.getItemId().equals(stackTwo.getItemId())) { /* + * PR #3417 + * * Some items can't rely on just IDs matching and will implement Distinctive Item * in which case we want to use the method provided to compare */ - if (sfItemStack instanceof DistinctiveItem && itemStack instanceof DistinctiveItem) { - return ((DistinctiveItem) sfItemStack).canStack(sfItemStack.getItemMeta(), itemStack.getItemMeta()); + if (stackOne instanceof DistinctiveItem && stackTwo instanceof DistinctiveItem) { + return ((DistinctiveItem) stackOne).canStack(stackOne.getItemMeta(), stackTwo.getItemMeta()); } return true; } @@ -301,13 +303,15 @@ public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStac if (id != null) { /* + * PR #3417 + * * Some items can't rely on just IDs matching and will implement Distinctive Item * in which case we want to use the method provided to compare */ Optional optionalDistinctive = getDistinctiveItem(id); if (optionalDistinctive.isPresent()) { - ItemMeta possibleSfItemMeta = sfitem.getItemMeta(); - return optionalDistinctive.get().canStack(possibleSfItemMeta, itemMeta); + ItemMeta sfItemMeta = sfitem.getItemMeta(); + return optionalDistinctive.get().canStack(sfItemMeta, itemMeta); } return id.equals(((SlimefunItemStack) sfitem).getItemId()); } @@ -322,15 +326,18 @@ public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStac * Slimefun items may be ItemStackWrapper's in the context of cargo * so let's try to do an ID comparison before meta comparison */ - ItemMeta possibleSfItemMeta = sfitem.getItemMeta(); Debug.log(TestCase.CARGO_INPUT_TESTING, " sfitem is ItemStackWrapper - possible SF Item: {}", sfitem); - String id = Slimefun.getItemDataService().getItemData(itemMeta).orElse(null); + ItemMeta possibleSfItemMeta = sfitem.getItemMeta(); + String id = Slimefun.getItemDataService().getItemData(itemMeta).orElse(null); + String possibleItemId = Slimefun.getItemDataService().getItemData(possibleSfItemMeta).orElse(null); // Prioritize SlimefunItem id comparison over ItemMeta comparison - if (Slimefun.getItemDataService().getItemData(possibleSfItemMeta).orElse("").equals(id)) { + if (id != null && id.equals(possibleItemId)) { Debug.log(TestCase.CARGO_INPUT_TESTING, " Item IDs matched!"); /* + * PR #3417 + * * Some items can't rely on just IDs matching and will implement Distinctive Item * in which case we want to use the method provided to compare */ From 45b4268871356df527e55055441bf87e099d8d3a Mon Sep 17 00:00:00 2001 From: FN-FAL113 <88238718+FN-FAL113@users.noreply.github.com> Date: Mon, 31 Jan 2022 09:16:17 +0800 Subject: [PATCH 08/67] Industrial miner fix --- .../items/multiblocks/miner/MiningTask.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MiningTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MiningTask.java index 60a15a4b7f..0cbebe1091 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MiningTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MiningTask.java @@ -312,10 +312,17 @@ private int grabFuelFrom(@Nonnull Inventory inv) { ItemStack item = inv.getContents()[i]; if (fuelType.test(item)) { - ItemUtils.consumeItem(item, false); - - if (miner instanceof AdvancedIndustrialMiner) { - inv.addItem(new ItemStack(Material.BUCKET)); + /* + * Fixes #3336 + * Respects the state of the miner if there are + * no any errors during #setPistonState + */ + if (running) { + ItemUtils.consumeItem(item, false); + + if (miner instanceof AdvancedIndustrialMiner) { + inv.addItem(new ItemStack(Material.BUCKET)); + } } return fuelType.getTicks(); From 6cc4695e8cc8792da4a5a082be161aa2e79c52d8 Mon Sep 17 00:00:00 2001 From: FN-FAL113 <88238718+FN-FAL113@users.noreply.github.com> Date: Mon, 31 Jan 2022 10:11:00 +0800 Subject: [PATCH 09/67] Remove nested condition --- .../items/multiblocks/miner/MiningTask.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MiningTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MiningTask.java index 0cbebe1091..8db4e13755 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MiningTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MiningTask.java @@ -311,18 +311,16 @@ private int grabFuelFrom(@Nonnull Inventory inv) { for (MachineFuel fuelType : miner.fuelTypes) { ItemStack item = inv.getContents()[i]; - if (fuelType.test(item)) { - /* - * Fixes #3336 - * Respects the state of the miner if there are - * no any errors during #setPistonState - */ - if (running) { - ItemUtils.consumeItem(item, false); - - if (miner instanceof AdvancedIndustrialMiner) { - inv.addItem(new ItemStack(Material.BUCKET)); - } + /* + * Fixes #3336 + * Respects the state of the miner if there are + * no any errors during #setPistonState + */ + if (fuelType.test(item) && running) { + ItemUtils.consumeItem(item, false); + + if (miner instanceof AdvancedIndustrialMiner) { + inv.addItem(new ItemStack(Material.BUCKET)); } return fuelType.getTicks(); From b00286e6072bc050bc2a93cfdf5582dda07aa99f Mon Sep 17 00:00:00 2001 From: FN-FAL113 <88238718+FN-FAL113@users.noreply.github.com> Date: Mon, 31 Jan 2022 18:12:56 +0800 Subject: [PATCH 10/67] Update src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MiningTask.java Co-authored-by: TheBusyBiscuit --- .../implementation/items/multiblocks/miner/MiningTask.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MiningTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MiningTask.java index 8db4e13755..da31690ede 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MiningTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MiningTask.java @@ -314,7 +314,7 @@ private int grabFuelFrom(@Nonnull Inventory inv) { /* * Fixes #3336 * Respects the state of the miner if there are - * no any errors during #setPistonState + * no errors during #setPistonState */ if (fuelType.test(item) && running) { ItemUtils.consumeItem(item, false); From 23984e970fb01a3c69c5299ce23d537f5ce41c14 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Mar 2022 11:22:25 +0000 Subject: [PATCH 11/67] =?UTF-8?q?=F0=9F=94=A7=20Bump=20mockito-core=20from?= =?UTF-8?q?=204.3.1=20to=204.4.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [mockito-core](https://github.com/mockito/mockito) from 4.3.1 to 4.4.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.3.1...v4.4.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 193d2f0acf..637dbac37e 100644 --- a/pom.xml +++ b/pom.xml @@ -267,7 +267,7 @@ org.mockito mockito-core - 4.3.1 + 4.4.0 test From b32e4ce9bc6353182b2736f23dc4055851aea69e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Mar 2022 11:19:32 +0000 Subject: [PATCH 12/67] =?UTF-8?q?=F0=9F=94=A7=20Bump=20orebfuscator-api=20?= =?UTF-8?q?from=205.2.4=20to=205.2.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps orebfuscator-api from 5.2.4 to 5.2.6. --- updated-dependencies: - dependency-name: net.imprex:orebfuscator-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 36f8a08e0f..d8b3c79a4b 100644 --- a/pom.xml +++ b/pom.xml @@ -374,7 +374,7 @@ net.imprex orebfuscator-api - 5.2.4 + 5.2.6 provided From 83caafe112576f5b1dbbdba212d0d5842586b544 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Mar 2022 05:05:16 +0000 Subject: [PATCH 13/67] =?UTF-8?q?=F0=9F=94=A7=20Bump=20maven-compiler-plug?= =?UTF-8?q?in=20from=203.10.0=20to=203.10.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.10.0 to 3.10.1. - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.10.0...maven-compiler-plugin-3.10.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-compiler-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 36f8a08e0f..d65ebce3de 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.10.0 + 3.10.1 @@ -374,7 +374,7 @@ net.imprex orebfuscator-api - 5.2.4 + 5.2.6 provided From c5f4d55b27b04b8cb031b16c8becc7cc3512bfc6 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 11 Mar 2022 12:14:04 +0100 Subject: [PATCH 14/67] [CI skip] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fd5d80239..40a83931b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,6 +70,7 @@ * Fixed #3469 * Fixed #3476 * Fixed #3487 +* Fixed #3336 (again) ## Release Candidate 30 (31 Dec 2021) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#30 From 54cb571e1be85ae86efdbc6954e57fd9b87e6170 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 11 Mar 2022 20:05:24 +0100 Subject: [PATCH 15/67] [CI skip] Update dependency org.apache.maven.plugins:maven-compiler-plugin to v3.10.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 30e05be735..cd158c0d3e 100644 --- a/pom.xml +++ b/pom.xml @@ -115,7 +115,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.10.0 + 3.10.1 From 9b43b7f91b560eb44c33a8f74449c45619a47dfa Mon Sep 17 00:00:00 2001 From: ybw0014 Date: Fri, 11 Mar 2022 17:10:20 -0500 Subject: [PATCH 16/67] =?UTF-8?q?trans(guide):=20=E6=81=A2=E5=A4=8D?= =?UTF-8?q?=E6=8C=87=E5=8D=97=E4=B9=A6=E7=89=A9=E5=93=81=E7=9A=84=E7=BF=BB?= =?UTF-8?q?=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../slimefun4/implementation/guide/SurvivalSlimefunGuide.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java index 07d1a7d5dc..6a6c6cc3a9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java @@ -79,7 +79,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation { public SurvivalSlimefunGuide(boolean showVanillaRecipes, boolean showHiddenItemGroupsInSearch) { this.showVanillaRecipes = showVanillaRecipes; this.showHiddenItemGroupsInSearch = showHiddenItemGroupsInSearch; - item = new SlimefunGuideItem(this, "&aSlimefun Guide &7(Chest GUI)"); + item = new SlimefunGuideItem(this, "&aSlimefun 指南 &7(箱子界面)"); } /** From 78e7fc05c59792e77def26a8d4cae1df9f3c2474 Mon Sep 17 00:00:00 2001 From: ybw0014 Date: Fri, 11 Mar 2022 17:11:01 -0500 Subject: [PATCH 17/67] =?UTF-8?q?trans(guide):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=8C=87=E5=8D=97=E4=B9=A6=E6=A0=B7=E5=BC=8F=E7=9A=84=E7=BF=BB?= =?UTF-8?q?=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/guide/SlimefunGuideMode.java | 21 +++++++++++++++++-- .../core/guide/options/GuideModeOption.java | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideMode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideMode.java index 5b269f96e4..59597bd66a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideMode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideMode.java @@ -2,6 +2,8 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import javax.annotation.Nonnull; + /** * This enum holds the different designs a {@link SlimefunGuide} can have. * Each constant corresponds to a {@link SlimefunGuideImplementation}. @@ -17,12 +19,27 @@ public enum SlimefunGuideMode { /** * This design is the standard layout used in survival mode. */ - SURVIVAL_MODE, + SURVIVAL_MODE("普通模式"), /** * This is an admin-only design which creates a {@link SlimefunGuide} that allows * you to spawn in any {@link SlimefunItem} */ - CHEAT_MODE; + CHEAT_MODE("作弊模式"); + + private final String displayName; + + SlimefunGuideMode(@Nonnull String displayName) { + this.displayName = displayName; + } + + /** + * 获取指南书样式的显示名称 + * + * @return 指南书样式的显示名称 + */ + public @Nonnull String getDisplayName() { + return displayName; + } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java index 832cbb58d1..cd9e331278 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java @@ -56,7 +56,7 @@ public Optional getDisplayItem(Player p, ItemStack guide) { } ItemMeta meta = item.getItemMeta(); - meta.setDisplayName(ChatColor.GRAY + "Slimefun 指南样式: " + ChatColor.YELLOW + ChatUtils.humanize(selectedMode.name())); + meta.setDisplayName(ChatColor.GRAY + "Slimefun 指南样式: " + ChatColor.YELLOW + selectedMode.getDisplayName()); List lore = new ArrayList<>(); lore.add(""); lore.add((selectedMode == SlimefunGuideMode.SURVIVAL_MODE ? ChatColor.GREEN : ChatColor.GRAY) + "普通模式"); From f5935a57e077eb1d0e03c2c2e427f550159932e6 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sat, 12 Mar 2022 22:30:47 +0800 Subject: [PATCH 18/67] :bug: fix(altar): fix pedestal will give extra item --- .../implementation/listeners/AncientAltarListener.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java index fccfab7f57..6867bc1a83 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java @@ -157,8 +157,6 @@ private void usePedestal(@Nonnull Block pedestal, @Nonnull Player p) { Slimefun.runSync(() -> removedItems.remove(uuid), 30L); pedestalItem.removeVirtualItem(pedestal.getLocation(), entity); - - p.getInventory().addItem(pedestalItem.getOriginalItemStack(entity)); p.playSound(pedestal.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1F, 1F); /* From e818597b0bed83788429850730b4aac85356887d Mon Sep 17 00:00:00 2001 From: ybw0014 Date: Sat, 12 Mar 2022 16:36:22 -0500 Subject: [PATCH 19/67] Add shulker box to ColoredMaterial --- .../slimefun4/utils/ColoredMaterial.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java index 8992a76a10..9fe766e5e0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java @@ -177,6 +177,28 @@ public enum ColoredMaterial { Material.GREEN_CONCRETE, Material.RED_CONCRETE, Material.BLACK_CONCRETE + }), + + /** + * This {@link List} contains all shulker box colors ordered by their appearance ingame. + */ + SHULKER_BOX(new Material[] { + Material.WHITE_SHULKER_BOX, + Material.ORANGE_SHULKER_BOX, + Material.MAGENTA_SHULKER_BOX, + Material.LIGHT_BLUE_SHULKER_BOX, + Material.YELLOW_SHULKER_BOX, + Material.LIME_SHULKER_BOX, + Material.PINK_SHULKER_BOX, + Material.GRAY_SHULKER_BOX, + Material.LIGHT_GRAY_SHULKER_BOX, + Material.CYAN_SHULKER_BOX, + Material.PURPLE_SHULKER_BOX, + Material.BLUE_SHULKER_BOX, + Material.BROWN_SHULKER_BOX, + Material.GREEN_SHULKER_BOX, + Material.RED_SHULKER_BOX, + Material.BLACK_SHULKER_BOX }); // @formatter:on From 495208a089155e5c26935a43747ed30ad8aca461 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 14 Mar 2022 18:19:48 +0100 Subject: [PATCH 20/67] [CI skip] Updated changelog --- CHANGELOG.md | 5 +++-- .../slimefun4/core/guide/options/SlimefunGuideOption.java | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40a83931b3..0d9640f35e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # Table of contents -- [Release Candidate 31 (TBD)](#release-candidate-31-tbd) +- [Release Candidate 31 (14 Mar 2022)](#release-candidate-31-14-mar-2022) - [Release Candidate 30 (31 Dec 2021)](#release-candidate-30-31-dec-2021) - [Release Candidate 29 (07 Nov 2021)](#release-candidate-29-07-nov-2021) - [Release Candidate 28 (06 Sep 2021)](#release-candidate-28-06-sep-2021) @@ -31,7 +31,7 @@ - [Release Candidate 2 (29 Sep 2019)](#release-candidate-2-29-sep-2019) - [Release Candidate 1 (26 Sep 2019)](#release-candidate-1-26-sep-2019) -## Release Candidate 31 (TBD) +## Release Candidate 31 (14 Mar 2022) #### Additions * Added Armored Jetpack @@ -49,6 +49,7 @@ * You can now pick up Slimefun blocks in creative mode using the middle mouse button * `/sf search` no longer shows items in hidden item groups (can be overidden by a config setting) * Fluid Pumps can now fill bottles with water +* (API) Added Shulker boxes to `ColoredMaterial` enum #### Changes * (API) `BiomeMapParser` is now `public` diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideOption.java index a1318fedfb..1caeb02826 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideOption.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideOption.java @@ -2,6 +2,8 @@ import java.util.Optional; +import javax.annotation.Nonnull; + import org.bukkit.Keyed; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -24,6 +26,7 @@ public interface SlimefunGuideOption extends Keyed { * * @return The registering {@link SlimefunAddon} */ + @Nonnull SlimefunAddon getAddon(); Optional getDisplayItem(Player p, ItemStack guide); From 91a184a400efa2bb4de9154fa897b59587e2d24a Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 14 Mar 2022 18:21:54 +0100 Subject: [PATCH 21/67] [CI skip] New changelog entry --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d9640f35e..97a30dff4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # Table of contents +- [Release Candidate 32 (TBD)](#release-candidate-32-tbd) - [Release Candidate 31 (14 Mar 2022)](#release-candidate-31-14-mar-2022) - [Release Candidate 30 (31 Dec 2021)](#release-candidate-30-31-dec-2021) - [Release Candidate 29 (07 Nov 2021)](#release-candidate-29-07-nov-2021) @@ -31,7 +32,17 @@ - [Release Candidate 2 (29 Sep 2019)](#release-candidate-2-29-sep-2019) - [Release Candidate 1 (26 Sep 2019)](#release-candidate-1-26-sep-2019) + +## Release Candidate 32 (TBD) + +#### Additions + +#### Changes + +#### Fixes + ## Release Candidate 31 (14 Mar 2022) +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#31 #### Additions * Added Armored Jetpack From 114de62942c9c50bf2e4c7d038ea0c1b5d0448d7 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 14 Mar 2022 18:44:48 +0100 Subject: [PATCH 22/67] Fixed #3445 --- CHANGELOG.md | 1 + .../items/blocks/HologramProjector.java | 25 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97a30dff4c..cb9caf8428 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ #### Changes #### Fixes +* Fixed #3445 ## Release Candidate 31 (14 Mar 2022) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#31 diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/HologramProjector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/HologramProjector.java index 5751f976fb..26d117b855 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/HologramProjector.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/HologramProjector.java @@ -55,8 +55,7 @@ public HologramProjector(ItemGroup itemGroup, SlimefunItemStack item, RecipeType addItemHandler(onPlace(), onRightClick(), onBreak()); } - @Nonnull - private BlockPlaceHandler onPlace() { + private @Nonnull BlockPlaceHandler onPlace() { return new BlockPlaceHandler(false) { @Override @@ -72,8 +71,7 @@ public void onPlayerPlace(BlockPlaceEvent e) { }; } - @Nonnull - private BlockBreakHandler onBreak() { + private @Nonnull BlockBreakHandler onBreak() { return new SimpleBlockBreakHandler() { @Override @@ -83,8 +81,7 @@ public void onBlockBreak(@Nonnull Block b) { }; } - @Nonnull - public BlockUseHandler onRightClick() { + public @Nonnull BlockUseHandler onRightClick() { return e -> { e.cancel(); @@ -97,15 +94,22 @@ public BlockUseHandler onRightClick() { }; } - private static void openEditor(@Nonnull Player p, @Nonnull Block projector) { + private void openEditor(@Nonnull Player p, @Nonnull Block projector) { ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "machines.HOLOGRAM_PROJECTOR.inventory-title")); - menu.addItem(0, new CustomItemStack(Material.NAME_TAG, "&7Text &e(Click to edit)", "", "&r" + ChatColors.color(BlockStorage.getLocationInfo(projector.getLocation(), "text")))); + menu.addItem(0, new CustomItemStack(Material.NAME_TAG, "&7Text &e(Click to edit)", "", "&f" + ChatColors.color(BlockStorage.getLocationInfo(projector.getLocation(), "text")))); menu.addMenuClickHandler(0, (pl, slot, item, action) -> { pl.closeInventory(); Slimefun.getLocalization().sendMessage(pl, "machines.HOLOGRAM_PROJECTOR.enter-text", true); ChatUtils.awaitInput(pl, message -> { + // Fixes #3445 - Make sure the projector is not broken + if (!BlockStorage.check(projector, getId())) { + // Hologram projector no longer exists. + // TODO: Add a chat message informing the player that their message was ignored. + return; + } + ArmorStand hologram = getArmorStand(projector, true); hologram.setCustomName(ChatColors.color(message)); BlockStorage.addBlockInfo(projector, "text", hologram.getCustomName()); @@ -115,7 +119,7 @@ private static void openEditor(@Nonnull Player p, @Nonnull Block projector) { return false; }); - menu.addItem(1, new CustomItemStack(Material.CLOCK, "&7Offset: &e" + NumberUtils.roundDecimalNumber(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), OFFSET_PARAMETER)) + 1.0D), "", "&rLeft Click: &7+0.1", "&rRight Click: &7-0.1")); + menu.addItem(1, new CustomItemStack(Material.CLOCK, "&7Offset: &e" + NumberUtils.roundDecimalNumber(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), OFFSET_PARAMETER)) + 1.0D), "", "&fLeft Click: &7+0.1", "&fRight Click: &7-0.1")); menu.addMenuClickHandler(1, (pl, slot, item, action) -> { double offset = NumberUtils.reparseDouble(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), OFFSET_PARAMETER)) + (action.isRightClicked() ? -0.1F : 0.1F)); ArmorStand hologram = getArmorStand(projector, true); @@ -154,8 +158,7 @@ private static ArmorStand getArmorStand(@Nonnull Block projector, boolean create return hologram; } - @Nonnull - private static ArmorStand spawnArmorStand(@Nonnull Location l) { + private static @Nonnull ArmorStand spawnArmorStand(@Nonnull Location l) { ArmorStand armorStand = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND); armorStand.setVisible(false); armorStand.setSilent(true); From af2ba5c70e45e991f746edd08c26726d20e1b163 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Tue, 15 Mar 2022 12:48:53 +0800 Subject: [PATCH 23/67] :bug: fix(hercules): fix #474 --- .mvn/maven-git-versioning-extension.xml | 6 +++--- .../items/tools/HerculesPickaxe.java | 21 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.mvn/maven-git-versioning-extension.xml b/.mvn/maven-git-versioning-extension.xml index 8334857058..bae0b12800 100644 --- a/.mvn/maven-git-versioning-extension.xml +++ b/.mvn/maven-git-versioning-extension.xml @@ -3,15 +3,15 @@ master - 4.9-canary-${commit.short} + ${commit.short}-canary release - 4.9-release-${commit.timestamp.year}.${commit.timestamp.month} + ${commit.timestamp.year}.${commit.timestamp.month}-release test/(.+) - 4.9-${1}-${commit.short} + ${1}-${commit.short} v([0-9].*)> diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java index a2cfc1b8c8..a5b9eac614 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java @@ -4,6 +4,7 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; @@ -30,35 +31,33 @@ public HerculesPickaxe(ItemGroup itemGroup, SlimefunItemStack item, RecipeType r Material mat = e.getBlock().getType(); if (SlimefunTag.ORES.isTagged(mat)) { + if (tool.getEnchantments().containsKey(Enchantment.SILK_TOUCH)) { + return; + } + if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { switch (mat) { case DEEPSLATE_IRON_ORE: drops.add(new CustomItemStack(SlimefunItems.IRON_DUST, 2)); - break; + return; case DEEPSLATE_GOLD_ORE: drops.add(new CustomItemStack(SlimefunItems.GOLD_DUST, 2)); - break; + return; case COPPER_ORE: case DEEPSLATE_COPPER_ORE: drops.add(new CustomItemStack(SlimefunItems.COPPER_DUST, 2)); - break; + return; default: - break; + return; } } switch (mat) { case IRON_ORE: drops.add(new CustomItemStack(SlimefunItems.IRON_DUST, 2)); - break; + return; case GOLD_ORE: drops.add(new CustomItemStack(SlimefunItems.GOLD_DUST, 2)); - break; - default: - for (ItemStack drop : e.getBlock().getDrops(tool)) { - drops.add(new CustomItemStack(drop, drop.getAmount() * 2)); - } - break; } } }; From 51bcf3d8b9de2bafa725f5fd93152477c51482b1 Mon Sep 17 00:00:00 2001 From: haiman <83174104+haiman233@users.noreply.github.com> Date: Tue, 15 Mar 2022 21:50:44 +0800 Subject: [PATCH 24/67] Update ColoredMaterial.java --- .../slimefun4/utils/ColoredMaterial.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java index 9fe766e5e0..0b487585b7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java @@ -201,6 +201,28 @@ public enum ColoredMaterial { Material.BLACK_SHULKER_BOX }); + /** + * This {@link List} contains all shulker box colors ordered by their appearance ingame. + */ + CANDLE(new Material[] { + Material.WHITE_CANDLE, + Material.ORANGE_CANDLE, + Material.MAGENTA_CANDLE, + Material.LIGHT_BLUE_CANDLE, + Material.YELLOW_CANDLE, + Material.LIME_CANDLE, + Material.PINK_CANDLE, + Material.GRAY_CANDLE, + Material.LIGHT_GRAY_CANDLE, + Material.CYAN_CANDLE, + Material.PURPLE_CANDLE, + Material.BLUE_CANDLE, + Material.BROWN_CANDLE, + Material.GREEN_CANDLE, + Material.RED_CANDLE, + Material.BLACK_CANDLE + }); + // @formatter:on /** From 6ac9d68070086e2b1831994dd7773d28770b4f0a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 15 Mar 2022 17:49:11 +0100 Subject: [PATCH 25/67] [CI skip] Update dependency com.github.seeseemelk:MockBukkit-v1.18 to v1.24.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cd158c0d3e..db30f820e0 100644 --- a/pom.xml +++ b/pom.xml @@ -390,7 +390,7 @@ com.github.seeseemelk MockBukkit-v1.18 - 1.18.1 + 1.24.1 test From d31275c9cae791b41078c1c47e2751b510b3c48a Mon Sep 17 00:00:00 2001 From: haiman <83174104+haiman233@users.noreply.github.com> Date: Wed, 16 Mar 2022 07:41:05 +0800 Subject: [PATCH 26/67] Update ColoredMaterial.java --- .../thebusybiscuit/slimefun4/utils/ColoredMaterial.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java index 0b487585b7..423ba890ea 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java @@ -199,10 +199,10 @@ public enum ColoredMaterial { Material.GREEN_SHULKER_BOX, Material.RED_SHULKER_BOX, Material.BLACK_SHULKER_BOX - }); + }), /** - * This {@link List} contains all shulker box colors ordered by their appearance ingame. + * This {@link List} contains all candle colors ordered by their appearance ingame. */ CANDLE(new Material[] { Material.WHITE_CANDLE, From fa896a1f296fb62c9ab36db6e5821606b6e74908 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 16 Mar 2022 15:00:32 +0000 Subject: [PATCH 27/67] Update dependency com.konghq:unirest-java to v3.13.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index db30f820e0..485d99f183 100644 --- a/pom.xml +++ b/pom.xml @@ -362,7 +362,7 @@ com.konghq unirest-java - 3.13.6 + 3.13.7 compile From 67be314df1320faf72ac66737dd0ad20366dca15 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 20 Mar 2022 00:36:29 +0100 Subject: [PATCH 28/67] [CI skip] Update dependency com.gmail.nossr50.mcMMO:mcMMO to v2.1.211 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 485d99f183..973b88d7d2 100644 --- a/pom.xml +++ b/pom.xml @@ -435,7 +435,7 @@ com.gmail.nossr50.mcMMO mcMMO - 2.1.209 + 2.1.211 provided From e52a9435c242307051f6df42e538c07aa5a361d1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 20 Mar 2022 00:37:06 +0100 Subject: [PATCH 29/67] [CI skip] Update thollander/actions-comment-pull-request action to v1.1.0 --- .github/workflows/pr-labels.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-labels.yml b/.github/workflows/pr-labels.yml index 8b7a4129e8..3d7d7ef4be 100644 --- a/.github/workflows/pr-labels.yml +++ b/.github/workflows/pr-labels.yml @@ -27,7 +27,7 @@ jobs: api: '🔧 API' compatibility: '🤝 Compatibility' - - uses: thollander/actions-comment-pull-request@v1.0.4 + - uses: thollander/actions-comment-pull-request@v1.1.0 name: Leave a comment about the applied label if: ${{ steps.labeller.outputs.applied != 0 }} with: @@ -36,7 +36,7 @@ jobs: Your Pull Request was automatically labelled as: "${{ steps.labeller.outputs.applied }}" Thank you for contributing to this project! ❤️ - - uses: thollander/actions-comment-pull-request@v1.0.4 + - uses: thollander/actions-comment-pull-request@v1.1.0 name: Leave a comment about our branch naming convention if: ${{ steps.labeller.outputs.applied == 0 }} with: From d3cf518f7472c5b4e63a7df6d75b4db8672bd430 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 20 Mar 2022 11:21:27 +0100 Subject: [PATCH 30/67] Refactored ItemGroups --- .../slimefun4/api/items/ItemGroup.java | 77 ++++++++++++++----- .../slimefun4/api/items/SlimefunItem.java | 4 + .../api/items/groups/FlexItemGroup.java | 30 +++++--- .../api/items/groups/SeasonalItemGroup.java | 8 +- .../api/items/groups/SubItemGroup.java | 17 +++- .../guide/SurvivalSlimefunGuide.java | 18 +---- 6 files changed, 105 insertions(+), 49 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemGroup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemGroup.java index c4d89d64f5..49a7d40876 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemGroup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemGroup.java @@ -90,8 +90,7 @@ public ItemGroup(NamespacedKey key, ItemStack item, int tier) { } @Override - @Nonnull - public final NamespacedKey getKey() { + public final @Nonnull NamespacedKey getKey() { return key; } @@ -157,8 +156,7 @@ private void sortCategoriesByTier() { * * @return The {@link SlimefunAddon} or null if unregistered */ - @Nullable - public final SlimefunAddon getAddon() { + public final @Nullable SlimefunAddon getAddon() { return addon; } @@ -176,6 +174,10 @@ public void add(@Nonnull SlimefunItem item) { return; } + if (this.addon != null && !item.getAddon().getName().equals(this.addon.getName())) { + item.warn("This item does not belong into ItemGroup " + this + " as that group belongs to " + this.addon.getName()); + } + items.add(item); } @@ -199,8 +201,7 @@ public void remove(@Nonnull SlimefunItem item) { * * @return A localized display item for this {@link ItemGroup} */ - @Nonnull - public ItemStack getItem(@Nonnull Player p) { + public @Nonnull ItemStack getItem(@Nonnull Player p) { return new CustomItemStack(item, meta -> { String name = Slimefun.getLocalization().getItemGroupName(p, getKey()); @@ -224,8 +225,7 @@ public ItemStack getItem(@Nonnull Player p) { * * @return The unlocalized name of this {@link ItemGroup} */ - @Nonnull - public String getUnlocalizedName() { + public @Nonnull String getUnlocalizedName() { return ChatColor.stripColor(item.getItemMeta().getDisplayName()); } @@ -238,8 +238,7 @@ public String getUnlocalizedName() { * * @return The localized name of this {@link ItemGroup} */ - @Nonnull - public String getDisplayName(@Nonnull Player p) { + public @Nonnull String getDisplayName(@Nonnull Player p) { String localized = Slimefun.getLocalization().getItemGroupName(p, getKey()); if (localized != null) { @@ -254,8 +253,7 @@ public String getDisplayName(@Nonnull Player p) { * * @return the list of SlimefunItems bound to this {@link ItemGroup} */ - @Nonnull - public List getItems() { + public @Nonnull List getItems() { return items; } @@ -271,6 +269,52 @@ public boolean contains(@Nullable SlimefunItem item) { return item != null && items.contains(item); } + /** + * This method returns whether this {@link ItemGroup} can be accessed + * by the given {@link Player}. If an {@link ItemGroup} is not accessible, + * it will not show up in the {@link SlimefunGuide} nor will items from this + * {@link ItemGroup} show up in the guide search. + * + * @param p + * The {@link Player} to check for + * + * @return Whether this {@link ItemGroup} is accessible by the given {@link Player} + */ + public boolean isAccessible(@Nonnull Player p) { + return true; + } + + /** + * This method returns whether this {@link ItemGroup} can be viewed + * by the given {@link Player}. Empty {@link ItemGroup ItemGroups} will not + * be visible. This includes {@link ItemGroup ItemGroups} where every {@link SlimefunItem} + * is disabled. If an {@link ItemGroup} is not accessible by the {@link Player}, + * see {@link #isAccessible(Player)}, this method will also return false. + * + * @param p + * The {@link Player} to check for + * + * @return Whether this {@link ItemGroup} is visible to the given {@link Player} + */ + public boolean isVisible(@Nonnull Player p) { + if (items.isEmpty() || !isAccessible(p)) { + return false; + } + + for (SlimefunItem slimefunItem : getItems()) { + /* + * If any item for this item group is visible, + * the item group itself is also visible. + * Empty item groups are not displayed. + */ + if (!slimefunItem.isHidden() && !slimefunItem.isDisabledIn(p.getWorld())) { + return true; + } + } + + return false; + } + @Override public final boolean equals(Object obj) { if (obj instanceof ItemGroup) { @@ -301,14 +345,9 @@ public String toString() { * * @return Whether this {@link ItemGroup} will be hidden to the given {@link Player} */ + @Deprecated public boolean isHidden(@Nonnull Player p) { - for (SlimefunItem slimefunItem : getItems()) { - if (!slimefunItem.isHidden() && !slimefunItem.isDisabledIn(p.getWorld())) { - return false; - } - } - - return true; + return !isVisible(p); } /** diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java index 9de3953092..cebed9b49d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java @@ -694,6 +694,10 @@ public void setRecipeType(@Nonnull RecipeType type) { public void setItemGroup(@Nonnull ItemGroup itemGroup) { Validate.notNull(itemGroup, "The ItemGroup is not allowed to be null!"); + if (addon == null) { + throw new UnregisteredItemException(this); + } + this.itemGroup.remove(this); itemGroup.add(this); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/FlexItemGroup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/FlexItemGroup.java index 56d065b8b7..52436c77ea 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/FlexItemGroup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/FlexItemGroup.java @@ -36,6 +36,26 @@ protected FlexItemGroup(NamespacedKey key, ItemStack item, int tier) { super(key, item, tier); } + @Override + public final boolean isAccessible(@Nonnull Player p) { + /* + * We can stop this method right here. + * We provide a custom method with more parameters for this. + * See isVisible(...) + */ + return true; + } + + @Override + public final boolean isVisible(@Nonnull Player p) { + /* + * We can stop this method right here. + * We provide a custom method with more parameters for this. + * See isVisible(...) + */ + return true; + } + /** * This method returns whether this {@link FlexItemGroup} is visible under the given context. * Implementing this method gives full flexibility over who can see the ItemGroup when and where. @@ -66,16 +86,6 @@ protected FlexItemGroup(NamespacedKey key, ItemStack item, int tier) { */ public abstract void open(Player p, PlayerProfile profile, SlimefunGuideMode layout); - @Override - public final boolean isHidden(@Nonnull Player p) { - /* - * We can stop this method right here. - * We provide a custom method with more parameters for this. - * See isVisible(...) - */ - return false; - } - @Override public final void add(@Nonnull SlimefunItem item) { throw new UnsupportedOperationException("You cannot add items to a FlexItemGroup!"); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SeasonalItemGroup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SeasonalItemGroup.java index be726b119d..c61212c265 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SeasonalItemGroup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SeasonalItemGroup.java @@ -56,12 +56,12 @@ public SeasonalItemGroup(NamespacedKey key, Month month, int tier, ItemStack ite } @Override - public boolean isHidden(@Nonnull Player p) { - // Hide this ItemGroup if the month differs + public boolean isAccessible(@Nonnull Player p) { + // Block this ItemGroup if the month differs if (month != LocalDate.now().getMonth()) { - return true; + return false; } - return super.isHidden(p); + return super.isAccessible(p); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SubItemGroup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SubItemGroup.java index 0505123228..4797867b35 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SubItemGroup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SubItemGroup.java @@ -40,14 +40,29 @@ public SubItemGroup(NamespacedKey key, NestedItemGroup parent, ItemStack item, i } @Override - public final boolean isHidden(@Nonnull Player p) { + public final boolean isVisible(@Nonnull Player p) { /* * Sub Categories are always hidden, * they won't show up in the normal guide view. */ + return false; + } + + @Override + public final boolean isAccessible(@Nonnull Player p) { + /* + * Sub Categories are accessible, they are invisible + * but their items are available to the guide search. + */ return true; } + /** + * This method returns the parent {@link NestedItemGroup} which this + * {@link SubItemGroup} belongs to. + * + * @return The parent {@link NestedItemGroup} + */ public final @Nonnull NestedItemGroup getParent() { return parentItemGroup; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java index 047a696a6b..26c85ca3ed 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java @@ -33,7 +33,6 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.items.groups.FlexItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.groups.SubItemGroup; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.api.researches.Research; @@ -361,7 +360,7 @@ public void openSearch(PlayerProfile profile, String input, boolean addToHistory break; } - if (!slimefunItem.isHidden() && !isItemGroupHidden(p, slimefunItem) && isSearchFilterApplicable(slimefunItem, searchTerm)) { + if (!slimefunItem.isHidden() && isItemGroupAccessible(p, slimefunItem) && isSearchFilterApplicable(slimefunItem, searchTerm)) { ItemStack itemstack = new CustomItemStack(slimefunItem.getItem(), meta -> { ItemGroup itemGroup = slimefunItem.getItemGroup(); meta.setLore(Arrays.asList("", ChatColor.DARK_GRAY + "\u21E8 " + ChatColor.WHITE + itemGroup.getDisplayName(p))); @@ -391,19 +390,8 @@ public void openSearch(PlayerProfile profile, String input, boolean addToHistory } @ParametersAreNonnullByDefault - private boolean isItemGroupHidden(Player p, SlimefunItem slimefunItem) { - if (showHiddenItemGroupsInSearch) { - return false; - } - - ItemGroup itemGroup = slimefunItem.getItemGroup(); - - // Fixes #3487 - SubItemGroups are "pseudo-hidden" - if (itemGroup instanceof SubItemGroup) { - return false; - } else { - return itemGroup.isHidden(p); - } + private boolean isItemGroupAccessible(Player p, SlimefunItem slimefunItem) { + return showHiddenItemGroupsInSearch || slimefunItem.getItemGroup().isAccessible(p); } @ParametersAreNonnullByDefault From 020094e04e6af200dd57aa97184a1e4b6a7a0d71 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 20 Mar 2022 11:38:20 +0100 Subject: [PATCH 31/67] Fixed unit tests --- .../slimefun4/api/items/ItemGroup.java | 22 +++++++++---------- .../slimefun4/api/items/SlimefunItem.java | 4 ---- .../api/items/groups/FlexItemGroup.java | 10 --------- .../registration/TestItemGroups.java | 14 ++++++------ .../slimefun4/utils/TestFireworkUtils.java | 6 ++++- 5 files changed, 23 insertions(+), 33 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemGroup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemGroup.java index 49a7d40876..66b9b78fa1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemGroup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemGroup.java @@ -116,6 +116,16 @@ public void register(@Nonnull SlimefunAddon addon) { sortCategoriesByTier(); } + /** + * This method returns whether this {@link ItemGroup} has been registered yet. + * More specifically: Whether {@link #register(SlimefunAddon)} was called or not. + * + * @return Whether this {@link ItemGroup} has been registered + */ + public boolean isRegistered() { + return this.addon != null && Slimefun.getRegistry().getAllItemGroups().contains(this); + } + /** * Returns the tier of this {@link ItemGroup}. * The tier determines the position of this {@link ItemGroup} in the {@link SlimefunGuide}. @@ -174,7 +184,7 @@ public void add(@Nonnull SlimefunItem item) { return; } - if (this.addon != null && !item.getAddon().getName().equals(this.addon.getName())) { + if (isRegistered() && !item.getAddon().getName().equals(this.addon.getName())) { item.warn("This item does not belong into ItemGroup " + this + " as that group belongs to " + this.addon.getName()); } @@ -350,14 +360,4 @@ public boolean isHidden(@Nonnull Player p) { return !isVisible(p); } - /** - * This method returns whether this {@link ItemGroup} has been registered yet. - * More specifically: Whether {@link #register(SlimefunAddon)} was called or not. - * - * @return Whether this {@link ItemGroup} has been registered - */ - public boolean isRegistered() { - return Slimefun.getRegistry().getAllItemGroups().contains(this); - } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java index cebed9b49d..9de3953092 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java @@ -694,10 +694,6 @@ public void setRecipeType(@Nonnull RecipeType type) { public void setItemGroup(@Nonnull ItemGroup itemGroup) { Validate.notNull(itemGroup, "The ItemGroup is not allowed to be null!"); - if (addon == null) { - throw new UnregisteredItemException(this); - } - this.itemGroup.remove(this); itemGroup.add(this); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/FlexItemGroup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/FlexItemGroup.java index 52436c77ea..92f137dcfc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/FlexItemGroup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/FlexItemGroup.java @@ -36,16 +36,6 @@ protected FlexItemGroup(NamespacedKey key, ItemStack item, int tier) { super(key, item, tier); } - @Override - public final boolean isAccessible(@Nonnull Player p) { - /* - * We can stop this method right here. - * We provide a custom method with more parameters for this. - * See isVisible(...) - */ - return true; - } - @Override public final boolean isVisible(@Nonnull Player p) { /* diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestItemGroups.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestItemGroups.java index 359473066d..d290992ff9 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestItemGroups.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestItemGroups.java @@ -87,7 +87,7 @@ void testHidden() { Player player = server.addPlayer(); // Empty Item Groups are also hidden - Assertions.assertTrue(group.isHidden(player)); + Assertions.assertFalse(group.isVisible(player)); SlimefunItem disabledItem = TestUtilities.mockSlimefunItem(plugin, "DISABLED_ITEM_GROUP_ITEM", new CustomItemStack(Material.BEETROOT, "&4Disabled")); Slimefun.getItemCfg().setValue("DISABLED_ITEM_GROUP_ITEM.enabled", false); @@ -96,7 +96,7 @@ void testHidden() { disabledItem.load(); // A disabled Item should also make the ItemGroup hide - Assertions.assertTrue(group.isHidden(player)); + Assertions.assertFalse(group.isVisible(player)); SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_GROUP_HIDDEN_TEST", new CustomItemStack(Material.BAMBOO, "&6Test Bamboo")); item.setItemGroup(group); @@ -105,10 +105,10 @@ void testHidden() { item.load(); // A hidden Item should also make the ItemGroup hide - Assertions.assertTrue(group.isHidden(player)); + Assertions.assertFalse(group.isVisible(player)); item.setHidden(false); - Assertions.assertFalse(group.isHidden(player)); + Assertions.assertTrue(group.isVisible(player)); } @Test @@ -201,11 +201,11 @@ void ItemGroups() { Player player = server.addPlayer(); Assertions.assertEquals(month, group.getMonth()); - Assertions.assertFalse(group.isHidden(player)); + Assertions.assertTrue(group.isVisible(player)); // ItemGroup with future Month SeasonalItemGroup itemGroup2 = new SeasonalItemGroup(group.getKey(), month.plus(6), 1, new CustomItemStack(Material.MILK_BUCKET, "&dSeasonal Test")); - Assertions.assertTrue(itemGroup2.isHidden(player)); + Assertions.assertFalse(itemGroup2.isVisible(player)); } @Test @@ -225,7 +225,7 @@ public boolean isVisible(Player p, PlayerProfile profile, SlimefunGuideMode layo }; Player player = server.addPlayer(); - Assertions.assertFalse(group.isHidden(player)); + Assertions.assertTrue(group.isVisible(player)); Assertions.assertThrows(UnsupportedOperationException.class, () -> group.add(null)); Assertions.assertThrows(UnsupportedOperationException.class, () -> group.contains(null)); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestFireworkUtils.java b/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestFireworkUtils.java index 302124f0a5..c979f740e2 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestFireworkUtils.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestFireworkUtils.java @@ -7,6 +7,7 @@ import org.bukkit.Color; import org.bukkit.FireworkEffect; import org.bukkit.Location; +import org.bukkit.World; import org.bukkit.entity.Firework; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; @@ -20,10 +21,13 @@ import be.seeseemelk.mockbukkit.WorldMock; class TestFireworkUtils { + + private static World world; @BeforeAll public static void load() { MockBukkit.mock(); + world = new WorldMock(); } @AfterAll @@ -35,7 +39,7 @@ public static void unload() { @MethodSource("getColors") @DisplayName("Test colored Fireworks") void testColoredFirework(Color color) { - Location l = new Location(new WorldMock(), 50, 50, 50); + Location l = new Location(world, 50, 50, 50); Firework firework = FireworkUtils.createFirework(l, color); Assertions.assertEquals(l, firework.getLocation()); From 14704b7503771408b368e21968a54987d7cd2cd9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Mar 2022 11:25:36 +0000 Subject: [PATCH 32/67] =?UTF-8?q?=F0=9F=94=A7=20Bump=20itemsadder-api=20fr?= =?UTF-8?q?om=203.0.0=20to=203.0.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [itemsadder-api](https://github.com/LoneDev6/API-ItemsAdder) from 3.0.0 to 3.0.5. - [Release notes](https://github.com/LoneDev6/API-ItemsAdder/releases) - [Commits](https://github.com/LoneDev6/API-ItemsAdder/compare/3.0.0...3.0.5) --- updated-dependencies: - dependency-name: com.github.LoneDev6:itemsadder-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 21815d93e8..6e2228267d 100644 --- a/pom.xml +++ b/pom.xml @@ -360,7 +360,7 @@ com.github.LoneDev6 itemsadder-api - 3.0.0 + 3.0.5 provided From 46cb4acb40aa0c4302164432915e937eaf352946 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Mar 2022 11:32:10 +0000 Subject: [PATCH 33/67] =?UTF-8?q?=F0=9F=94=A7=20Bump=20QuickShop=20from=20?= =?UTF-8?q?5.1.0.3=20to=205.1.0.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps QuickShop from 5.1.0.3 to 5.1.0.6. --- updated-dependencies: - dependency-name: org.maxgamer:QuickShop dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 21815d93e8..0184cafcff 100644 --- a/pom.xml +++ b/pom.xml @@ -415,7 +415,7 @@ org.maxgamer QuickShop - 5.1.0.3 + 5.1.0.6 provided From ae8574f385db7f95a49112f703a46eadae7f3ebf Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 1 Apr 2022 14:18:10 +0200 Subject: [PATCH 34/67] [CI skip] Update actions/setup-java action to v3.1.0 --- .github/workflows/discord-webhook.yml | 2 +- .github/workflows/maven-compiler.yml | 2 +- .github/workflows/sonarcloud.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/discord-webhook.yml b/.github/workflows/discord-webhook.yml index b963153298..8b838e2764 100644 --- a/.github/workflows/discord-webhook.yml +++ b/.github/workflows/discord-webhook.yml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@v3.0.0 - name: Set up Java JDK 17 - uses: actions/setup-java@v3.0.0 + uses: actions/setup-java@v3.1.0 with: distribution: 'adopt' java-version: '17' diff --git a/.github/workflows/maven-compiler.yml b/.github/workflows/maven-compiler.yml index 5f7ba783b0..ead8075d55 100644 --- a/.github/workflows/maven-compiler.yml +++ b/.github/workflows/maven-compiler.yml @@ -24,7 +24,7 @@ jobs: uses: actions/checkout@v3 - name: Set up JDK 17 - uses: actions/setup-java@v3.0.0 + uses: actions/setup-java@v3.1.0 with: distribution: 'adopt' java-version: '17' diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index d602fd492c..1193546d53 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -21,7 +21,7 @@ jobs: fetch-depth: 0 - name: Set up JDK 17 - uses: actions/setup-java@v3.0.0 + uses: actions/setup-java@v3.1.0 with: distribution: 'adopt' java-version: '17' From 89eaaffcf24b7b2596d08d8b6258dff7c10cce93 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 1 Apr 2022 14:18:48 +0200 Subject: [PATCH 35/67] [CI skip] Update dependency org.apache.maven.plugins:maven-shade-plugin to v3.3.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 973b88d7d2..a752a25ecf 100644 --- a/pom.xml +++ b/pom.xml @@ -191,7 +191,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.2.4 + 3.3.0 From 47cb2ce4fd8fd07ea43f41b5b77c4ccfd559237d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 1 Apr 2022 14:19:18 +0200 Subject: [PATCH 36/67] [CI skip] Update actions/cache action to v3 --- .github/workflows/discord-webhook.yml | 2 +- .github/workflows/maven-compiler.yml | 2 +- .github/workflows/sonarcloud.yml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/discord-webhook.yml b/.github/workflows/discord-webhook.yml index 8b838e2764..fc69172066 100644 --- a/.github/workflows/discord-webhook.yml +++ b/.github/workflows/discord-webhook.yml @@ -29,7 +29,7 @@ jobs: architecture: x64 - name: Cache Maven packages - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} diff --git a/.github/workflows/maven-compiler.yml b/.github/workflows/maven-compiler.yml index ead8075d55..919f8fcd5a 100644 --- a/.github/workflows/maven-compiler.yml +++ b/.github/workflows/maven-compiler.yml @@ -32,7 +32,7 @@ jobs: architecture: x64 - name: Cache Maven packages - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 1193546d53..2f89546527 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -29,14 +29,14 @@ jobs: architecture: x64 - name: Cache SonarCloud packages - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar - name: Cache Maven packages - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} From 77b2618ad7700037ff3149b2d395b52da6a17a7b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 1 Apr 2022 14:19:47 +0200 Subject: [PATCH 37/67] [CI skip] Update dependency com.github.LoneDev6:itemsadder-api to v3.0.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a752a25ecf..b71a91d339 100644 --- a/pom.xml +++ b/pom.xml @@ -477,7 +477,7 @@ com.github.LoneDev6 itemsadder-api - 3.0.0 + 3.0.5 provided From 91f46d483b715fabe9d4cf231a1da0cbbda2881e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 1 Apr 2022 14:20:14 +0200 Subject: [PATCH 38/67] [CI skip] Update pascalgn/automerge-action action to v0.15.2 --- .github/workflows/auto-squash.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto-squash.yml b/.github/workflows/auto-squash.yml index c52e88947c..36fb35e14b 100644 --- a/.github/workflows/auto-squash.yml +++ b/.github/workflows/auto-squash.yml @@ -22,7 +22,7 @@ jobs: steps: - name: Auto squash - uses: pascalgn/automerge-action@v0.14.3 + uses: pascalgn/automerge-action@v0.15.2 env: GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} UPDATE_RETRIES: 0 @@ -42,7 +42,7 @@ jobs: steps: - name: Auto squash - uses: pascalgn/automerge-action@v0.14.3 + uses: pascalgn/automerge-action@v0.15.2 env: GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} UPDATE_RETRIES: 0 From f805e3dc4998eea356834e1f4a64ab0387cd9842 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 3 Apr 2022 21:16:59 +0200 Subject: [PATCH 39/67] [CI skip] Update hmarr/auto-approve-action action to v2.2.0 --- .github/workflows/auto-approve.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml index 3dd7a4b507..47fce9c617 100644 --- a/.github/workflows/auto-approve.yml +++ b/.github/workflows/auto-approve.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Approve via actions - uses: hmarr/auto-approve-action@v2.1.0 + uses: hmarr/auto-approve-action@v2.2.0 if: github.actor == 'TheBusyBot' || github.actor == 'renovate[bot]' with: github-token: "${{ secrets.GITHUB_TOKEN }}" From 7f656a1b0d0c6d10b2929b0840dce14fb32a5497 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 8 Apr 2022 16:48:55 +0200 Subject: [PATCH 40/67] [CI skip] Update dependency org.apache.maven.plugins:maven-surefire-plugin to v3.0.0-M6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b71a91d339..c96d1e8364 100644 --- a/pom.xml +++ b/pom.xml @@ -146,7 +146,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M5 + 3.0.0-M6 org.junit.jupiter:junit-jupiter From e198135cf668dae4007a1771ffe93785d0721c03 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 8 Apr 2022 16:49:08 +0200 Subject: [PATCH 41/67] [CI skip] Update dependency org.jacoco:jacoco-maven-plugin to v0.8.8 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c96d1e8364..2e8014829d 100644 --- a/pom.xml +++ b/pom.xml @@ -165,7 +165,7 @@ org.jacoco jacoco-maven-plugin - 0.8.7 + 0.8.8 From d3757661399a9c1c6c8771bf70660824b491afd8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 8 Apr 2022 16:49:22 +0200 Subject: [PATCH 42/67] [CI skip] Update hmarr/auto-approve-action action to v2.2.1 --- .github/workflows/auto-approve.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml index 47fce9c617..9b7ea42c60 100644 --- a/.github/workflows/auto-approve.yml +++ b/.github/workflows/auto-approve.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Approve via actions - uses: hmarr/auto-approve-action@v2.2.0 + uses: hmarr/auto-approve-action@v2.2.1 if: github.actor == 'TheBusyBot' || github.actor == 'renovate[bot]' with: github-token: "${{ secrets.GITHUB_TOKEN }}" From 92317c1e84b0ee58ad20f8c0421dd1af0786a76b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 8 Apr 2022 16:49:33 +0200 Subject: [PATCH 43/67] [CI skip] Update dependency com.github.LoneDev6:itemsadder-api to v3.1.0b --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2e8014829d..9d47086c76 100644 --- a/pom.xml +++ b/pom.xml @@ -477,7 +477,7 @@ com.github.LoneDev6 itemsadder-api - 3.0.5 + 3.1.0b provided From 429ff5062490dbfcd34d8708ce56eef374a1daef Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 8 Apr 2022 18:02:45 +0200 Subject: [PATCH 44/67] Fixed #3504 --- CHANGELOG.md | 1 + .../slimefun4/utils/ColoredMaterial.java | 22 ------------------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb9caf8428..c9f229ad6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ #### Fixes * Fixed #3445 +* Fixed #3504 ## Release Candidate 31 (14 Mar 2022) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#31 diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java index 423ba890ea..9fe766e5e0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java @@ -199,28 +199,6 @@ public enum ColoredMaterial { Material.GREEN_SHULKER_BOX, Material.RED_SHULKER_BOX, Material.BLACK_SHULKER_BOX - }), - - /** - * This {@link List} contains all candle colors ordered by their appearance ingame. - */ - CANDLE(new Material[] { - Material.WHITE_CANDLE, - Material.ORANGE_CANDLE, - Material.MAGENTA_CANDLE, - Material.LIGHT_BLUE_CANDLE, - Material.YELLOW_CANDLE, - Material.LIME_CANDLE, - Material.PINK_CANDLE, - Material.GRAY_CANDLE, - Material.LIGHT_GRAY_CANDLE, - Material.CYAN_CANDLE, - Material.PURPLE_CANDLE, - Material.BLUE_CANDLE, - Material.BROWN_CANDLE, - Material.GREEN_CANDLE, - Material.RED_CANDLE, - Material.BLACK_CANDLE }); // @formatter:on From 1f40619a51ab6329c4797a0ce4fd40252b2cd726 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 9 Apr 2022 03:17:59 +0000 Subject: [PATCH 45/67] =?UTF-8?q?=F0=9F=94=A7=20Bump=20maven-surefire-plug?= =?UTF-8?q?in=20from=203.0.0-M5=20to=203.0.0-M6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.0.0-M5 to 3.0.0-M6. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.0.0-M5...surefire-3.0.0-M6) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 21815d93e8..174a4d7215 100644 --- a/pom.xml +++ b/pom.xml @@ -169,7 +169,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M5 + 3.0.0-M6 org.junit.jupiter:junit-jupiter @@ -415,7 +415,7 @@ org.maxgamer QuickShop - 5.1.0.3 + 5.1.0.6 provided From 818ce04822642b59a018f614adaf44b258d9b726 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 9 Apr 2022 03:18:20 +0000 Subject: [PATCH 46/67] =?UTF-8?q?=F0=9F=94=A7=20Bump=20maven-git-versionin?= =?UTF-8?q?g-extension=20from=207.2.3=20to=207.3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [maven-git-versioning-extension](https://github.com/qoomon/maven-git-versioning-extension) from 7.2.3 to 7.3.0. - [Release notes](https://github.com/qoomon/maven-git-versioning-extension/releases) - [Changelog](https://github.com/qoomon/maven-git-versioning-extension/blob/master/CHANGELOG.md) - [Commits](https://github.com/qoomon/maven-git-versioning-extension/compare/v7.2.3...v7.3.0) --- updated-dependencies: - dependency-name: me.qoomon:maven-git-versioning-extension dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .mvn/extensions.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml index 4f9a3c58c4..8b5b10a7c2 100644 --- a/.mvn/extensions.xml +++ b/.mvn/extensions.xml @@ -4,7 +4,7 @@ me.qoomon maven-git-versioning-extension - 7.2.3 + 7.3.0 \ No newline at end of file From 8754cce4948a15bddfb630f0873c67cb05814caa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 9 Apr 2022 03:18:27 +0000 Subject: [PATCH 47/67] =?UTF-8?q?=F0=9F=94=A7=20Bump=20maven-shade-plugin?= =?UTF-8?q?=20from=203.2.4=20to=203.3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [maven-shade-plugin](https://github.com/apache/maven-shade-plugin) from 3.2.4 to 3.3.0. - [Release notes](https://github.com/apache/maven-shade-plugin/releases) - [Commits](https://github.com/apache/maven-shade-plugin/compare/maven-shade-plugin-3.2.4...maven-shade-plugin-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-shade-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 21815d93e8..23c888b356 100644 --- a/pom.xml +++ b/pom.xml @@ -125,7 +125,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.2.4 + 3.3.0 @@ -415,7 +415,7 @@ org.maxgamer QuickShop - 5.1.0.3 + 5.1.0.6 provided From 6b9a71f934af793548015d39fcdf4b00525e2181 Mon Sep 17 00:00:00 2001 From: Jeffrey Kosse Date: Wed, 6 Apr 2022 01:34:06 +0800 Subject: [PATCH 48/67] did requested changes --- .../slimefun4/implementation/listeners/BeeWingsListener.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingsListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingsListener.java index 245710939d..f79a74349d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingsListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingsListener.java @@ -36,7 +36,8 @@ public BeeWingsListener(@Nonnull Slimefun plugin, @Nonnull BeeWings wings) { @EventHandler(ignoreCancelled = true) public void onApproachGround(EntityToggleGlideEvent e) { - if (!e.isGliding() || wings.isDisabled() || !(e.getEntity() instanceof Player)) { + + if (wings == null || !e.isGliding() || wings.isDisabled() || !(e.getEntity() instanceof Player)) { return; } From 4bb5ce5b2485bb98b23c041192853d1d822a0fbd Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sat, 9 Apr 2022 11:44:47 +0800 Subject: [PATCH 49/67] :wrench: chores: minor change for maven --- .mvn/maven-git-versioning-extension.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/maven-git-versioning-extension.xml b/.mvn/maven-git-versioning-extension.xml index bae0b12800..45512d6bb7 100644 --- a/.mvn/maven-git-versioning-extension.xml +++ b/.mvn/maven-git-versioning-extension.xml @@ -14,7 +14,7 @@ ${1}-${commit.short} - v([0-9].*)> + ([0-9].*)> ${1} From 1802199eb677f24279ed359dd026a46f7176c80c Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sat, 9 Apr 2022 12:23:24 +0800 Subject: [PATCH 50/67] :bug: fix(backpack): bypass distinctive check when upgrading backpack --- .../multiblocks/EnhancedCraftingTable.java | 4 +-- .../slimefun4/utils/SlimefunUtils.java | 30 +++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/EnhancedCraftingTable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/EnhancedCraftingTable.java index 7a0bb1a3b6..b799e420e7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/EnhancedCraftingTable.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/EnhancedCraftingTable.java @@ -91,9 +91,9 @@ private void craft(Inventory inv, Block dispenser, Player p, Block b, ItemStack private boolean isCraftable(Inventory inv, ItemStack[] recipe) { for (int j = 0; j < inv.getContents().length; j++) { - if (!SlimefunUtils.isItemSimilar(inv.getContents()[j], recipe[j], true)) { + if (!SlimefunUtils.isItemSimilar(inv.getContents()[j], recipe[j], true, true, false)) { if (SlimefunItem.getByItem(recipe[j]) instanceof SlimefunBackpack) { - if (!SlimefunUtils.isItemSimilar(inv.getContents()[j], recipe[j], false)) { + if (!SlimefunUtils.isItemSimilar(inv.getContents()[j], recipe[j], false, true, false)) { return false; } } else { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java index 60dadf8f70..96db7b95a3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java @@ -266,10 +266,14 @@ public static boolean containsSimilarItem(Inventory inventory, ItemStack item, b } public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStack sfitem, boolean checkLore) { - return isItemSimilar(item, sfitem, checkLore, true); + return isItemSimilar(item, sfitem, checkLore, true, true); } public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStack sfitem, boolean checkLore, boolean checkAmount) { + return isItemSimilar(item, sfitem, checkLore, checkAmount, true); + } + + public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStack sfitem, boolean checkLore, boolean checkAmount, boolean checkDistinctiveItem) { if (item == null) { return sfitem == null; } else if (sfitem == null) { @@ -278,7 +282,7 @@ public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStac return false; } else if (checkAmount && item.getAmount() < sfitem.getAmount()) { return false; - } else if (sfitem instanceof SlimefunItemStack && item instanceof SlimefunItemStack) { + } else if (checkDistinctiveItem && sfitem instanceof SlimefunItemStack && item instanceof SlimefunItemStack) { SlimefunItemStack stackOne = (SlimefunItemStack) sfitem; SlimefunItemStack stackTwo = (SlimefunItemStack) item; if (stackOne.getItemId().equals(stackTwo.getItemId())) { @@ -302,16 +306,18 @@ public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStac String id = Slimefun.getItemDataService().getItemData(itemMeta).orElse(null); if (id != null) { - /* - * PR #3417 - * - * Some items can't rely on just IDs matching and will implement Distinctive Item - * in which case we want to use the method provided to compare - */ - Optional optionalDistinctive = getDistinctiveItem(id); - if (optionalDistinctive.isPresent()) { - ItemMeta sfItemMeta = sfitem.getItemMeta(); - return optionalDistinctive.get().canStack(sfItemMeta, itemMeta); + if (checkDistinctiveItem) { + /* + * PR #3417 + * + * Some items can't rely on just IDs matching and will implement Distinctive Item + * in which case we want to use the method provided to compare + */ + Optional optionalDistinctive = getDistinctiveItem(id); + if (optionalDistinctive.isPresent()) { + ItemMeta sfItemMeta = sfitem.getItemMeta(); + return optionalDistinctive.get().canStack(sfItemMeta, itemMeta); + } } return id.equals(((SlimefunItemStack) sfitem).getItemId()); } From 7400faa94be40fc47bdb5dac21931ffac4838332 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sat, 9 Apr 2022 12:25:38 +0800 Subject: [PATCH 51/67] :bug: fix(talisman): cherry pick https://github.com/Slimefun/Slimefun4/commit/5c6a8d0ea24619cddb9596ed9989538bb09f2011 --- .../implementation/listeners/TalismanListener.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java index 207176f9ba..ef2af27a75 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java @@ -21,6 +21,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; +import org.bukkit.entity.Ravager; import org.bukkit.entity.Trident; import org.bukkit.event.Event; import org.bukkit.event.EventHandler; @@ -201,6 +202,15 @@ private Collection getExtraDrops(LivingEntity entity, Collection item.getType() == Material.SADDLE); + } + /* * WARNING: This check is broken as entities now set their * equipment to NULL before calling the event! From 715d92b157a19e53769bc1389b057112175ddf97 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sat, 9 Apr 2022 12:27:18 +0800 Subject: [PATCH 52/67] :speech_balloon: chores(trans): re-added lost translation --- .../thebusybiscuit/slimefun4/api/player/PlayerBackpack.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java index 5d942114f7..dc9c4dd53b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java @@ -76,7 +76,7 @@ public PlayerBackpack(@Nonnull PlayerProfile profile, int id, int size) { cfg.setValue(CONFIG_PREFIX + id + ".size", size); markDirty(); - inventory = Bukkit.createInventory(null, size, "Backpack [" + size + " Slots]"); + inventory = Bukkit.createInventory(null, size, "背包 [大小 " + size + "]"); } /** From 8760aeead08be7ed42e07f48f0039bf557906a23 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sat, 9 Apr 2022 12:27:57 +0800 Subject: [PATCH 53/67] :speech_balloon: chores(trans): re-added lost translation --- .../thebusybiscuit/slimefun4/api/player/PlayerBackpack.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java index dc9c4dd53b..883447d7e4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java @@ -146,7 +146,7 @@ public void setSize(int size) { this.size = size; cfg.setValue(CONFIG_PREFIX + id + ".size", size); - Inventory inv = Bukkit.createInventory(null, size, "Backpack [" + size + " Slots]"); + Inventory inv = Bukkit.createInventory(null, size, "背包 [大小 " + size + "]"); for (int slot = 0; slot < this.inventory.getSize(); slot++) { inv.setItem(slot, this.inventory.getItem(slot)); From fff19fc346729420dc84b7559fbd0a71dd58e775 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sat, 9 Apr 2022 12:59:32 +0800 Subject: [PATCH 54/67] fix --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 4c01fbb45a..2f44418cc0 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -50,4 +50,4 @@ jobs: prerelease: true title: "Slimefun 自动构建版本" files: | - target/Slimefun-v4.9-*.jar + target/Slimefun-*.jar From d1826c09b595eab7cc5ec1d946fc097aedfb8d25 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sun, 10 Apr 2022 11:21:59 +0800 Subject: [PATCH 55/67] :beer: chores: trigger github actions --- jitpack.yml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 jitpack.yml diff --git a/jitpack.yml b/jitpack.yml deleted file mode 100644 index 3dcd4f7383..0000000000 --- a/jitpack.yml +++ /dev/null @@ -1,6 +0,0 @@ -before_install: - - sdk install java 17.0.1-open - - sdk use java 17.0.1-open - -jdk: - - openjdk17 From 207459f62683241831c50e697e541b69bfdd9902 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sun, 10 Apr 2022 11:24:25 +0800 Subject: [PATCH 56/67] Update maven.yml --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 2f44418cc0..d4d0240768 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -50,4 +50,4 @@ jobs: prerelease: true title: "Slimefun 自动构建版本" files: | - target/Slimefun-*.jar + target/Slimefun*.jar From 333ab07a570b79a70c03c7cc57bf53e8addf1ef9 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sun, 10 Apr 2022 16:20:30 +0800 Subject: [PATCH 57/67] why you just not run --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index d4d0240768..2f44418cc0 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -50,4 +50,4 @@ jobs: prerelease: true title: "Slimefun 自动构建版本" files: | - target/Slimefun*.jar + target/Slimefun-*.jar From 84d7bd50c646029d40e2c3d0c5ecb7811a96d5a4 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sun, 10 Apr 2022 16:23:17 +0800 Subject: [PATCH 58/67] :zap: refactor(updater): ignore non-stable version --- .../ren/natsuyuk1/slimefunextra/UpdateChecker.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/ren/natsuyuk1/slimefunextra/UpdateChecker.java b/src/main/java/ren/natsuyuk1/slimefunextra/UpdateChecker.java index 0aa12f6eba..e475537359 100644 --- a/src/main/java/ren/natsuyuk1/slimefunextra/UpdateChecker.java +++ b/src/main/java/ren/natsuyuk1/slimefunextra/UpdateChecker.java @@ -12,6 +12,13 @@ public class UpdateChecker { private static final String UPDATE_CHECK_URL = "https://gitee.com/api/v5/repos/StarWishsama/Slimefun4/releases/latest"; public static void checkUpdate() { + String currentVersion = Slimefun.getVersion(); + + // Only available for release user + if (!currentVersion.contains("release")) { + return; + } + try { HttpResponse response = Unirest.get(UPDATE_CHECK_URL) .header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36") @@ -22,12 +29,6 @@ public static void checkUpdate() { if (Slimefun.instance() != null) { String latestVersionCode = node.getObject().getString("tag_name"); - String currentVersion = Slimefun.getVersion(); - - // Only available for release user - if (!currentVersion.contains("release")) { - return; - } String currentYear = latestVersionCode.split("\\.")[0]; String currentMonth = latestVersionCode.split("\\.")[1]; From c4317a23a0d66968b708fd798e74d8844cf5d5c1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 12 Apr 2022 09:52:07 +0200 Subject: [PATCH 59/67] [CI skip] Update actions/setup-java action to v3.1.1 --- .github/workflows/discord-webhook.yml | 2 +- .github/workflows/maven-compiler.yml | 2 +- .github/workflows/sonarcloud.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/discord-webhook.yml b/.github/workflows/discord-webhook.yml index fc69172066..47de6d6c16 100644 --- a/.github/workflows/discord-webhook.yml +++ b/.github/workflows/discord-webhook.yml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@v3.0.0 - name: Set up Java JDK 17 - uses: actions/setup-java@v3.1.0 + uses: actions/setup-java@v3.1.1 with: distribution: 'adopt' java-version: '17' diff --git a/.github/workflows/maven-compiler.yml b/.github/workflows/maven-compiler.yml index 919f8fcd5a..a5743d9798 100644 --- a/.github/workflows/maven-compiler.yml +++ b/.github/workflows/maven-compiler.yml @@ -24,7 +24,7 @@ jobs: uses: actions/checkout@v3 - name: Set up JDK 17 - uses: actions/setup-java@v3.1.0 + uses: actions/setup-java@v3.1.1 with: distribution: 'adopt' java-version: '17' diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 2f89546527..b8486bc107 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -21,7 +21,7 @@ jobs: fetch-depth: 0 - name: Set up JDK 17 - uses: actions/setup-java@v3.1.0 + uses: actions/setup-java@v3.1.1 with: distribution: 'adopt' java-version: '17' From f78c22ad037e44dde0fc631a928ffa22156ae6f3 Mon Sep 17 00:00:00 2001 From: Xzavier0722 Date: Thu, 14 Apr 2022 00:02:22 +0800 Subject: [PATCH 60/67] fix(lang): add missing msg, closes #522 --- src/main/resources/languages/zh-CN/messages.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/resources/languages/zh-CN/messages.yml b/src/main/resources/languages/zh-CN/messages.yml index 71eb78dc18..f204de9c6e 100644 --- a/src/main/resources/languages/zh-CN/messages.yml +++ b/src/main/resources/languages/zh-CN/messages.yml @@ -9,6 +9,8 @@ commands: search: 搜索 Slimefun 物品 open_guide: 使用命令打开 Slimefun 指南 stats: 查看玩家的统计数据 + transform: 将物品转换为英文物品 + id: 获取手持物品的 Slimefun ID research: description: 解锁/重置玩家的研究进度 reset: '&c你已重置了 %player% 的研究进度' From 4e4cc24fef76de9b9a7454ff2addf6c3c62cd3a8 Mon Sep 17 00:00:00 2001 From: Xzavier0722 Date: Mon, 18 Apr 2022 13:13:32 +0800 Subject: [PATCH 61/67] fix(protection): add protection check for move/attack actions of android --- .../items/androids/ButcherAndroid.java | 10 ++++++++++ .../items/androids/ProgrammableAndroid.java | 14 ++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ButcherAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ButcherAndroid.java index 3b9aed0a2f..1c0f4abb1c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ButcherAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ButcherAndroid.java @@ -1,7 +1,12 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.androids; +import java.util.UUID; import java.util.function.Predicate; +import io.github.bakedlibs.dough.protection.Interaction; +import me.mrCookieSlime.Slimefun.api.BlockStorage; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.ArmorStand; @@ -59,6 +64,11 @@ protected void attack(Block b, BlockFace face, Predicate predicate n.removeMetadata(METADATA_KEY, Slimefun.instance()); } + OfflinePlayer owner = Bukkit.getOfflinePlayer(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner"))); + if (!Slimefun.getProtectionManager().hasPermission(owner, n.getLocation(), Interaction.ATTACK_ENTITY)) { + return; + } + n.setMetadata(METADATA_KEY, new FixedMetadataValue(Slimefun.instance(), new AndroidInstance(this, b))); ((LivingEntity) n).damage(damage); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java index 2f29327539..a0522fa495 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java @@ -901,10 +901,16 @@ public void addItems(Block b, ItemStack... items) { protected void move(Block b, BlockFace face, Block block) { Player p = Bukkit.getPlayer(IntegrationHelper.getOwnerFromJson(BlockStorage.getBlockInfoAsJson(b.getLocation()))); - if (p != null && !IntegrationHelper.checkPermission(p, block, Interaction.PLACE_BLOCK)) { - BlockStorage.addBlockInfo(b, "paused", "false"); - Slimefun.getLocalization().sendMessage(p, "messages.android-no-permission", true); - return; + if (p != null) { + if (!Slimefun.getProtectionManager().hasPermission(p, block, Interaction.PLACE_BLOCK)) { + return; + } + + if (!IntegrationHelper.checkPermission(p, block, Interaction.PLACE_BLOCK)) { + BlockStorage.addBlockInfo(b, "paused", "false"); + Slimefun.getLocalization().sendMessage(p, "messages.android-no-permission", true); + return; + } } if (block.getY() > WorldUtils.getMinHeight(block.getWorld()) && block.getY() < block.getWorld().getMaxHeight() && block.isEmpty()) { From 3e0a1b05101d5b94f299fa82dcc46d97cda0087d Mon Sep 17 00:00:00 2001 From: Xzavier0722 Date: Mon, 18 Apr 2022 16:49:53 +0800 Subject: [PATCH 62/67] fix(protection): add protection check for farm action of android --- .../implementation/items/androids/FarmerAndroid.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FarmerAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FarmerAndroid.java index 9834237ea7..7412bca7eb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FarmerAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FarmerAndroid.java @@ -1,13 +1,18 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.androids; import java.util.Random; +import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.bakedlibs.dough.protection.Interaction; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import me.mrCookieSlime.Slimefun.api.BlockStorage; import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; +import org.bukkit.OfflinePlayer; import org.bukkit.block.Block; import org.bukkit.block.data.Ageable; import org.bukkit.block.data.BlockData; @@ -34,6 +39,12 @@ public AndroidType getAndroidType() { @Override protected void farm(Block b, BlockMenu menu, Block block, boolean isAdvanced) { + + OfflinePlayer owner = Bukkit.getOfflinePlayer(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner"))); + if (!Slimefun.getProtectionManager().hasPermission(owner, block, Interaction.BREAK_BLOCK)) { + return; + } + Material blockType = block.getType(); BlockData data = block.getBlockData(); ItemStack drop = null; From c97d6a56497249b36f56b142af43e3e79b206d23 Mon Sep 17 00:00:00 2001 From: Xzavier0722 Date: Tue, 19 Apr 2022 12:33:41 +0800 Subject: [PATCH 63/67] improve(command): add click to copy action for /sf id --- .../commands/subcommands/ItemIdCommand.java | 23 +++++++++++++++---- .../resources/languages/zh-CN/messages.yml | 1 + 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ItemIdCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ItemIdCommand.java index 694b4a2413..cf24fbf04a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ItemIdCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ItemIdCommand.java @@ -5,18 +5,25 @@ import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.chat.hover.content.Text; import org.bukkit.Material; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import javax.annotation.Nonnull; + class ItemIdCommand extends SubCommand { protected ItemIdCommand(Slimefun plugin, SlimefunCommand cmd) { super(plugin, cmd, "id", false); } @Override - public void onExecute(CommandSender sender, String[] args) { + public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { if (sender instanceof Player) { if (sender.hasPermission("slimefun.command.id")) { Player p = (Player) sender; @@ -24,12 +31,20 @@ public void onExecute(CommandSender sender, String[] args) { if (item.getType() != Material.AIR) { SlimefunItem sfItem = SlimefunItem.getByItem(item); if (sfItem != null) { - sender.sendMessage(ChatColors.color("The item's id: " + sfItem.getId())); + String sfId = sfItem.getId(); + TextComponent msg = new TextComponent("该物品的ID为: "); + TextComponent idMsg = new TextComponent(sfId); + idMsg.setUnderlined(true); + idMsg.setItalic(true); + idMsg.setColor(ChatColor.GRAY); + idMsg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("点击复制到剪贴板"))); + idMsg.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, sfId)); + sender.spigot().sendMessage(msg, idMsg); } else { - Slimefun.getLocalization().sendMessage(sender, "messages.not-valid-item", true); + Slimefun.getLocalization().sendMessage(sender, "messages.invalid-item-in-hand", true); } } else { - sender.sendMessage(ChatColors.color("&bYou have nothing in your main hand!")); + sender.sendMessage(ChatColors.color("&b请将需要查看的物品拿在主手!")); } } else { Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true); diff --git a/src/main/resources/languages/zh-CN/messages.yml b/src/main/resources/languages/zh-CN/messages.yml index f204de9c6e..00f525393d 100644 --- a/src/main/resources/languages/zh-CN/messages.yml +++ b/src/main/resources/languages/zh-CN/messages.yml @@ -143,6 +143,7 @@ messages: not-online: '&4%player% &c不在线' invalid-item: '&4%item% &c不是一个有效的物品名!' invalid-amount: '&4%amount% &ci不是一个有效的数字 : 它必须大于 0!' + invalid-item-in-hand: '&e你手中拿的不是粘液科技的物品!' given-item: '&b你获得了 &a%amount% &7"%item%&7"' give-item: '&b成功给予玩家 %player% &a%amount% &7"%item%&7"' invalid-research: '&4%research% &c不是一个有效的研究名!' From b5e2b2160c08e0f398b44faafeaa5bc3417c2a21 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 19 Apr 2022 19:23:17 +0200 Subject: [PATCH 64/67] [CI skip] Update actions/checkout action to v3.0.1 --- .github/workflows/discord-webhook.yml | 2 +- .github/workflows/sonarcloud.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/discord-webhook.yml b/.github/workflows/discord-webhook.yml index 47de6d6c16..2fb1812b28 100644 --- a/.github/workflows/discord-webhook.yml +++ b/.github/workflows/discord-webhook.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3.0.0 + uses: actions/checkout@v3.0.1 - name: Set up Java JDK 17 uses: actions/setup-java@v3.1.1 diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index b8486bc107..02d8c33fab 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3.0.0 + uses: actions/checkout@v3.0.1 with: fetch-depth: 0 From 5d093822de1340fd96c692b237a33a9efbd4174a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 19 Apr 2022 19:23:40 +0200 Subject: [PATCH 65/67] [CI skip] Update dependency com.konghq:unirest-java to v3.13.8 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9d47086c76..b05b167391 100644 --- a/pom.xml +++ b/pom.xml @@ -362,7 +362,7 @@ com.konghq unirest-java - 3.13.7 + 3.13.8 compile From 217196c137bb2b22d1fc4232ee733d6dcfe01102 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Tue, 19 Apr 2022 20:51:13 +0200 Subject: [PATCH 66/67] Fixed #3534 --- CHANGELOG.md | 1 + .../thebusybiscuit/slimefun4/utils/ChestMenuUtils.java | 2 +- .../Objects/SlimefunItem/abstractItems/AContainer.java | 6 +++++- .../thebusybiscuit/slimefun4/utils/TestFireworkUtils.java | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9f229ad6d..21524f31de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ #### Fixes * Fixed #3445 * Fixed #3504 +* Fixed #3534 ## Release Candidate 31 (14 Mar 2022) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#31 diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java index 8397512390..85f20f08fe 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java @@ -142,7 +142,7 @@ public static void updateProgressbar(@Nonnull ChestMenu menu, int slot, int time } im.setDisplayName(" "); - im.setLore(Arrays.asList(getProgressBar(timeLeft, time), "", ChatColor.GRAY + NumberUtils.getTimeLeft(timeLeft / 2) + " left")); + im.setLore(Arrays.asList(getProgressBar(timeLeft, time), "", ChatColor.GRAY + NumberUtils.getTimeLeft(timeLeft / 2))); item.setItemMeta(im); menu.replaceExistingItem(slot, item); diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java index e9b74f3985..be71fbe598 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java @@ -372,7 +372,11 @@ protected void tick(Block b) { MachineRecipe next = findNextRecipe(inv); if (next != null) { - processor.startOperation(b, new CraftingOperation(next)); + currentOperation = new CraftingOperation(next); + processor.startOperation(b, currentOperation); + + // Fixes #3534 - Update indicator immediately + processor.updateProgressBar(inv, 22, currentOperation); } } } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestFireworkUtils.java b/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestFireworkUtils.java index c979f740e2..a32183d663 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestFireworkUtils.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestFireworkUtils.java @@ -21,7 +21,7 @@ import be.seeseemelk.mockbukkit.WorldMock; class TestFireworkUtils { - + private static World world; @BeforeAll From 020af6743cf67af44682f8fa6906e31be3997d12 Mon Sep 17 00:00:00 2001 From: Xzavier0722 Date: Wed, 20 Apr 2022 09:23:01 +0800 Subject: [PATCH 67/67] improve(updater): optimize version checking --- .../slimefunextra/UpdateChecker.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main/java/ren/natsuyuk1/slimefunextra/UpdateChecker.java b/src/main/java/ren/natsuyuk1/slimefunextra/UpdateChecker.java index e475537359..010eaed92d 100644 --- a/src/main/java/ren/natsuyuk1/slimefunextra/UpdateChecker.java +++ b/src/main/java/ren/natsuyuk1/slimefunextra/UpdateChecker.java @@ -30,23 +30,30 @@ public static void checkUpdate() { if (Slimefun.instance() != null) { String latestVersionCode = node.getObject().getString("tag_name"); - String currentYear = latestVersionCode.split("\\.")[0]; - String currentMonth = latestVersionCode.split("\\.")[1]; - - // Get last string String[] versionCodeSplit = currentVersion.split("-"); - String actualVersionCode = versionCodeSplit[versionCodeSplit.length - 1]; + String version = null; + for (String str : versionCodeSplit) { + if (str.startsWith("20")) { + String[] code = str.split("\\."); + if (code.length < 2) { + Slimefun.logger().warning("无法识别当前版本: " + currentVersion); + return; + } + version = code[0] + "." + code[1]; + } + } - String year = actualVersionCode.split("\\.")[0]; - String month = actualVersionCode.split("\\.")[1]; + if (version == null) { + Slimefun.logger().warning("无法识别当前版本: " + currentVersion); + return; + } - if (Integer.parseInt(currentYear) > Integer.parseInt(year) - || (Integer.parseInt(year) == Integer.parseInt(currentYear) - && Integer.parseInt(currentMonth) > Integer.parseInt(month))) { + if (latestVersionCode.compareTo(version) > 0) { Slimefun.logger().info("新版本 " + latestVersionCode + " 已发布,请前往 https://gitee.com/StarWishsama/Slimefun4/releases 更新."); } else { Slimefun.logger().info("你正在使用最新版本 " + currentVersion + "."); } + } } } catch (Exception e) {