SteamWar/FightSystem
Archiviert
13
1

Arrows Stopping in Techhider Blocks #208

Manuell gemergt
Lixfel hat 17 Commits von arrow-in-techhider nach master 2021-01-02 09:20:42 +01:00 zusammengeführt
Nur Änderungen aus Commit 250c429a51 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -56,12 +56,10 @@ public class ArrowStopper extends BasicListener {
Entity entity = e.getKey(); Entity entity = e.getKey();
if(checkBlocks(entity.getLocation().getBlock(), e.getValue().getBlock())){ if(checkBlocks(entity.getLocation().getBlock(), e.getValue().getBlock())){
entity.remove(); entity.remove();
LAST_LOCATION.remove(entity); iterator.remove();
} } else {
else { if(isValidEntity(entity, e)) {
if(entity.getTicksLived() > Config.ArrowTechhiderCollision || iterator.remove();
((AbstractArrow) entity).isInBlock() || entity.getLocation().equals(e.getValue())) {
LAST_LOCATION.remove(entity);
}else { }else {
LAST_LOCATION.replace(e.getKey(), e.getKey().getLocation()); LAST_LOCATION.replace(e.getKey(), e.getKey().getLocation());
} }
@ -77,7 +75,7 @@ public class ArrowStopper extends BasicListener {
@Override @Override
public void enable() { public void enable() {
super.enable(); super.enable();
task = Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), this::run, 1, 1); task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::run, 1, 1);
} }
@Override @Override
@ -120,4 +118,10 @@ public class ArrowStopper extends BasicListener {
private boolean checkBlock(Block block) { private boolean checkBlock(Block block) {
return Config.HiddenBlockTags.contains(block.getType().name()); return Config.HiddenBlockTags.contains(block.getType().name());
} }
private boolean isValidEntity(Entity entity, Map.Entry<Entity, Location> entry) {
return entity.getTicksLived() > Config.ArrowTechhiderCollision ||
((AbstractArrow) entity).isInBlock() ||
entity.getLocation().equals(entry.getValue());
}
} }