mirror of
https://github.com/songoda/EpicHoppers.git
synced 2024-11-26 12:16:18 +01:00
fix rare double-crash + dead items
This commit is contained in:
parent
623c048f9c
commit
88f8d96b78
@ -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())
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user