fix rare double-crash + dead items

This commit is contained in:
jascotty2 2019-08-12 09:22:24 -05:00
parent 623c048f9c
commit 88f8d96b78
2 changed files with 6 additions and 0 deletions

View File

@ -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())

View File

@ -48,6 +48,7 @@ public class ModuleSuction extends Module {
Set<Item> 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) {