diff --git a/src/main/java/com/songoda/epichoppers/EpicHoppers.java b/src/main/java/com/songoda/epichoppers/EpicHoppers.java index 816bca9..4ebf83b 100644 --- a/src/main/java/com/songoda/epichoppers/EpicHoppers.java +++ b/src/main/java/com/songoda/epichoppers/EpicHoppers.java @@ -185,6 +185,10 @@ public class EpicHoppers extends JavaPlugin { * Saves registered hoppers to file. */ private void saveToFile() { + // double-check that we're ok to save + if(EpicHoppers.getInstance().getLevelManager() == null) + return; + checkStorage(); for (Level level : EpicHoppers.getInstance().getLevelManager().getLevels().values()) diff --git a/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleSuction.java b/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleSuction.java index 39fdf98..8f1a3e8 100644 --- a/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleSuction.java +++ b/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleSuction.java @@ -48,6 +48,7 @@ public class ModuleSuction extends Module { Set itemsToSuck = hopper.getLocation().getWorld().getNearbyEntities(hopper.getLocation().add(0.5, 0.5, 0.5), radius, radius, radius) .stream() .filter(entity -> entity.getType() == EntityType.DROPPED_ITEM + && !entity.isDead() && entity.getTicksLived() >= ((Item) entity).getPickupDelay() && entity.getLocation().getBlock().getType() != Material.HOPPER) .map(entity -> (Item) entity) @@ -56,6 +57,7 @@ public class ModuleSuction extends Module { boolean filterEndpoint = hopper.getFilter().getEndPoint() != null; for (Item item : itemsToSuck) { + ItemStack itemStack = item.getItemStack(); if (item.getPickupDelay() == 0) {