From 3b18d7c1655d6c4a9b852cc86c641eac64c145f6 Mon Sep 17 00:00:00 2001 From: ceze88 Date: Sat, 23 Mar 2024 19:18:30 +0100 Subject: [PATCH 1/3] Update AdvancedChestsAPI --- EpicHoppers-Plugin/pom.xml | 2 +- .../containers/impl/AdvancedChestImpl.java | 25 +++++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/EpicHoppers-Plugin/pom.xml b/EpicHoppers-Plugin/pom.xml index 5039cad..c079534 100644 --- a/EpicHoppers-Plugin/pom.xml +++ b/EpicHoppers-Plugin/pom.xml @@ -175,7 +175,7 @@ com.github.DeadSilenceIV AdvancedChestsAPI - 2.4 + 3.2-BETA provided diff --git a/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/containers/impl/AdvancedChestImpl.java b/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/containers/impl/AdvancedChestImpl.java index 487531c..31b7238 100644 --- a/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/containers/impl/AdvancedChestImpl.java +++ b/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/containers/impl/AdvancedChestImpl.java @@ -2,10 +2,17 @@ package com.craftaro.epichoppers.containers.impl; import com.craftaro.epichoppers.containers.CustomContainer; import com.craftaro.epichoppers.containers.IContainer; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.inventory.ItemStack; import us.lynuxcraft.deadsilenceiv.advancedchests.AdvancedChestsAPI; import us.lynuxcraft.deadsilenceiv.advancedchests.chest.AdvancedChest; +import us.lynuxcraft.deadsilenceiv.advancedchests.utils.inventory.InteractiveInventory; + +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; public class AdvancedChestImpl implements IContainer { @Override @@ -14,7 +21,7 @@ public class AdvancedChestImpl implements IContainer { } static class Container extends CustomContainer { - private final AdvancedChest advancedChest; + private final AdvancedChest advancedChest; public Container(Block block) { this.advancedChest = AdvancedChestsAPI.getChestManager().getAdvancedChest(block.getLocation()); @@ -22,17 +29,25 @@ public class AdvancedChestImpl implements IContainer { @Override public boolean addToContainer(ItemStack itemToMove) { - return AdvancedChestsAPI.addItemToChest(this.advancedChest, itemToMove); +// return AdvancedChestsAPI.addItemToChest(this.advancedChest, itemToMove); + if (advancedChest != null) { + Optional inv = advancedChest.getSubInventories().stream().filter(subInventory -> subInventory.getBukkitInventory().firstEmpty() != -1).findFirst(); + if (inv.isPresent()) { + return inv.get().getBukkitInventory().addItem(itemToMove).isEmpty(); + } + } + return false; } @Override public ItemStack[] getItems() { - return this.advancedChest.getAllItems().toArray(new ItemStack[0]); +// return this.advancedChest.getAllItems().toArray(new ItemStack[0]); + return this.advancedChest.getSubInventories().stream().map(subInventory -> subInventory.getBukkitInventory().getContents()).collect(Collectors.toList()).stream().flatMap(Arrays::stream).toArray(ItemStack[]::new); } @Override public void removeFromContainer(ItemStack itemToMove, int amountToMove) { - for (ItemStack item : this.advancedChest.getAllItems()) { + for (ItemStack item : getItems()) { if (item == null) { return; } @@ -41,7 +56,7 @@ public class AdvancedChestImpl implements IContainer { item.setAmount(item.getAmount() - amountToMove); if (item.getAmount() <= 0) { - this.advancedChest.getAllItems().remove(item); + item.setType(Material.AIR); } return; } From 1467ab0e2ed755d24726a35fa3138728cce17671 Mon Sep 17 00:00:00 2001 From: Brianna O'Keefe Date: Fri, 29 Mar 2024 11:49:49 -0500 Subject: [PATCH 2/3] Black listing and white listing are not compatible. --- EpicHoppers-Plugin/src/main/resources/en_US.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EpicHoppers-Plugin/src/main/resources/en_US.lang b/EpicHoppers-Plugin/src/main/resources/en_US.lang index 8b5276c..2f118c0 100644 --- a/EpicHoppers-Plugin/src/main/resources/en_US.lang +++ b/EpicHoppers-Plugin/src/main/resources/en_US.lang @@ -58,7 +58,7 @@ interface: filter: infotitle: '&aFilter Guide' - infolore: '&7Items placed in the leftmost column|&7space will be whitelisted.||&7Items placed in the rightmost column|&7will be void.||&7Items placed in the middle column|&7will be blacklisted.' + infolore: '&7Items placed in the leftmost column|&7space will be whitelisted.||&7Items placed in the middle column|&7will be blacklisted.||&7Items placed in the rightmost column|&7will be void.|||&cThe whitelist and blacklist|&ccannot be used at the same time.' whitelist: '&f&lWhite List' blacklist: '&8&lBlack List' void: '&c&lVoid' From c6c8fd592493084c99b32d5c62304c146e2fc6a1 Mon Sep 17 00:00:00 2001 From: Brianna O'Keefe Date: Fri, 29 Mar 2024 11:50:45 -0500 Subject: [PATCH 3/3] version 5.0.3 --- EpicHoppers-API/pom.xml | 2 +- EpicHoppers-Plugin/pom.xml | 2 +- pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/EpicHoppers-API/pom.xml b/EpicHoppers-API/pom.xml index 6479178..959e033 100644 --- a/EpicHoppers-API/pom.xml +++ b/EpicHoppers-API/pom.xml @@ -7,7 +7,7 @@ com.craftaro EpicHoppers-Parent - 5.0.2 + 5.0.3 ../pom.xml EpicHoppers-API diff --git a/EpicHoppers-Plugin/pom.xml b/EpicHoppers-Plugin/pom.xml index c079534..641d180 100644 --- a/EpicHoppers-Plugin/pom.xml +++ b/EpicHoppers-Plugin/pom.xml @@ -7,7 +7,7 @@ com.craftaro EpicHoppers-Parent - 5.0.2 + 5.0.3 ../pom.xml EpicHoppers-Plugin diff --git a/pom.xml b/pom.xml index 572b6ac..81d4d68 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ com.craftaro EpicHoppers-Parent pom - 5.0.2 + 5.0.3