diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowStopper.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowStopper.java index 8f61a9b..46581b4 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowStopper.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowStopper.java @@ -56,12 +56,10 @@ public class ArrowStopper extends BasicListener { Entity entity = e.getKey(); if(checkBlocks(entity.getLocation().getBlock(), e.getValue().getBlock())){ entity.remove(); - LAST_LOCATION.remove(entity); - } - else { - if(entity.getTicksLived() > Config.ArrowTechhiderCollision || - ((AbstractArrow) entity).isInBlock() || entity.getLocation().equals(e.getValue())) { - LAST_LOCATION.remove(entity); + iterator.remove(); + } else { + if(isValidEntity(entity, e)) { + iterator.remove(); }else { LAST_LOCATION.replace(e.getKey(), e.getKey().getLocation()); } @@ -77,7 +75,7 @@ public class ArrowStopper extends BasicListener { @Override public void enable() { super.enable(); - task = Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), this::run, 1, 1); + task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::run, 1, 1); } @Override @@ -120,4 +118,10 @@ public class ArrowStopper extends BasicListener { private boolean checkBlock(Block block) { return Config.HiddenBlockTags.contains(block.getType().name()); } + + private boolean isValidEntity(Entity entity, Map.Entry entry) { + return entity.getTicksLived() > Config.ArrowTechhiderCollision || + ((AbstractArrow) entity).isInBlock() || + entity.getLocation().equals(entry.getValue()); + } }