Added Support for FabledSkyBlock stackables.

This commit is contained in:
Brianna 2019-05-01 04:16:01 -04:00
parent ad43af14ae
commit 9a3356d204
2 changed files with 36 additions and 4 deletions

View File

@ -67,8 +67,8 @@
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>skyblockearth</artifactId>
<version>59</version>
<artifactId>fabledskyblock</artifactId>
<version>72</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -4,6 +4,9 @@ import com.songoda.epichoppers.EpicHoppersPlugin;
import com.songoda.epichoppers.api.hopper.levels.modules.Module;
import com.songoda.epichoppers.boost.BoostData;
import com.songoda.epichoppers.utils.SettingsManager;
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;
@ -25,6 +28,8 @@ import java.util.*;
*/
public class HopTask extends BukkitRunnable {
// Hop to the bop to the be bop top.
private static EpicHoppersPlugin plugin;
public HopTask(EpicHoppersPlugin plug) {
@ -68,12 +73,14 @@ public class HopTask extends BukkitRunnable {
// Fetch all hopper contents.
ItemStack[] hopperContents = hopperInventory.getContents();
// Get hopper orientation.
HopperDirection hopperDirection = HopperDirection.getDirection(hopperState.getRawData());
Location check = hopperDirection.getLocation(location);
Inventory override = null;
List<Location> linked = hopper.getLinkedBlocks();
if (hopper.getLinkedBlocks() == null || hopper.getLinkedBlocks().isEmpty()) {
HopperDirection hopperDirection = HopperDirection.getDirection(hopperState.getRawData());
Location check = hopperDirection.getLocation(location);
linked.add(check);
@ -89,6 +96,31 @@ public class HopTask extends BukkitRunnable {
if (linked.isEmpty()) continue;
}
// Support for FabledSkyBlock stackables.
if (Bukkit.getPluginManager().isPluginEnabled("FabledSkyBlock")) {
StackableManager stackableManager = SkyBlock.getInstance().getStackableManager();
if (stackableManager != null && stackableManager.isStacked(check)) {
Stackable stackable = stackableManager.getStack(check, check.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) {
hopperInventory.setItem(i, null);
} else {
item.setAmount(item.getAmount() - 1);
hopperInventory.setItem(i, item);
}
return;
}
}
}
}
for (Location destinationLocation : linked) {
Block destinationBlock = destinationLocation.getBlock();
Inventory destinationInventory = override;