Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
briannastatic committed Mar 29, 2024
2 parents 22e1de4 + c6c8fd5 commit dd5542a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion EpicHoppers-API/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.craftaro</groupId>
<artifactId>EpicHoppers-Parent</artifactId>
<version>5.0.2</version>
<version>5.0.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>EpicHoppers-API</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions EpicHoppers-Plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.craftaro</groupId>
<artifactId>EpicHoppers-Parent</artifactId>
<version>5.0.2</version>
<version>5.0.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>EpicHoppers-Plugin</artifactId>
Expand Down Expand Up @@ -175,7 +175,7 @@
<dependency>
<groupId>com.github.DeadSilenceIV</groupId>
<artifactId>AdvancedChestsAPI</artifactId>
<version>2.4</version>
<version>3.2-BETA</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@

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
Expand All @@ -14,25 +21,33 @@ public CustomContainer getCustomContainer(Block block) {
}

static class Container extends CustomContainer {
private final AdvancedChest advancedChest;
private final AdvancedChest<?, ?> advancedChest;

public Container(Block block) {
this.advancedChest = AdvancedChestsAPI.getChestManager().getAdvancedChest(block.getLocation());
}

@Override
public boolean addToContainer(ItemStack itemToMove) {
return AdvancedChestsAPI.addItemToChest(this.advancedChest, itemToMove);
// return AdvancedChestsAPI.addItemToChest(this.advancedChest, itemToMove);
if (advancedChest != null) {
Optional<InteractiveInventory> 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;
}
Expand All @@ -41,7 +56,7 @@ public void removeFromContainer(ItemStack itemToMove, int amountToMove) {
item.setAmount(item.getAmount() - amountToMove);

if (item.getAmount() <= 0) {
this.advancedChest.getAllItems().remove(item);
item.setType(Material.AIR);
}
return;
}
Expand Down
2 changes: 1 addition & 1 deletion EpicHoppers-Plugin/src/main/resources/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.craftaro</groupId>
<artifactId>EpicHoppers-Parent</artifactId>
<packaging>pom</packaging>
<version>5.0.2</version>
<version>5.0.3</version>
<!-- Run 'mvn versions:set -DgenerateBackupPoms=false -DnewVersion=X.Y.Z-DEV' to update version recursively -->

<modules>
Expand Down

0 comments on commit dd5542a

Please sign in to comment.