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();
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<Entity, Location> entry) {
return entity.getTicksLived() > Config.ArrowTechhiderCollision ||
((AbstractArrow) entity).isInBlock() ||
entity.getLocation().equals(entry.getValue());
}
}