diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3c686f0..b70f56c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ stages: variables: name: "EpicHoppers" path: "/builds/$CI_PROJECT_PATH" - version: "4.1.5" + version: "4.1.6" build: stage: build diff --git a/src/main/java/com/songoda/epichoppers/tasks/HopTask.java b/src/main/java/com/songoda/epichoppers/tasks/HopTask.java index ea9d69a..b57d4e9 100644 --- a/src/main/java/com/songoda/epichoppers/tasks/HopTask.java +++ b/src/main/java/com/songoda/epichoppers/tasks/HopTask.java @@ -8,6 +8,9 @@ import com.songoda.epichoppers.utils.HopperDirection; import com.songoda.epichoppers.utils.Methods; import com.songoda.epichoppers.utils.ServerVersion; import com.songoda.epichoppers.utils.settings.Setting; +import me.goodandevil.skyblock.SkyBlock; +import me.goodandevil.skyblock.stackable.Stackable; +import me.goodandevil.skyblock.stackable.StackableManager; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -119,7 +122,8 @@ public class HopTask extends BukkitRunnable { // Add linked container that the hopper is attached to physically. HopperDirection hopperDirection = HopperDirection.getDirection(hopperState.getRawData()); - linkedContainers.add(hopperDirection.getLocation(location)); + Location pointingLocation = hopperDirection.getLocation(location); + linkedContainers.add(pointingLocation); // Amount to be moved. BoostData boostData = plugin.getBoostManager().getBoost(hopper.getPlacedBy()); @@ -234,11 +238,35 @@ public class HopTask extends BukkitRunnable { // Add storage/hopper minecarts the hopper is pointing into to the list if there aren't any destinations if (destinationContainers.size() < 2) { - destinationContainers.addAll(block.getWorld().getNearbyEntities(hopperDirection.getLocation(location).clone().add(0.5, 0.5, 0.5), 0.5, 0.5, 0.5) + destinationContainers.addAll(block.getWorld().getNearbyEntities(pointingLocation.clone().add(0.5, 0.5, 0.5), 0.5, 0.5, 0.5) .stream().filter(e -> e.getType() == EntityType.MINECART_CHEST || e.getType() == EntityType.MINECART_HOPPER) .map(e -> (InventoryHolder) e).collect(Collectors.toSet())); } + // Support for FabledSkyBlock stackables. + if (Bukkit.getPluginManager().isPluginEnabled("FabledSkyBlock")) { + StackableManager stackableManager = SkyBlock.getInstance().getStackableManager(); + if (stackableManager != null && stackableManager.isStacked(pointingLocation)) { + Stackable stackable = stackableManager.getStack(pointingLocation, pointingLocation.getBlock().getType()); + + for (int i = 0; i < 5; i++) { + if (hopperContents[i] == null) continue; + ItemStack item = hopperContents[i].clone(); + + if (item.getType() == stackable.getMaterial()) { + stackable.addOne(); + if (item.getAmount() == 1) { + hopperState.getInventory().setItem(i, null); + } else { + item.setAmount(item.getAmount() - 1); + hopperState.getInventory().setItem(i, item); + } + return; + } + } + } + } + // Loop through our destination list. for (InventoryHolder currentDestination : destinationContainers) {