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 47e256d31c werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -28,10 +28,11 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;
import java.util.*;
import java.util.EnumSet;
public class ArrowStopper extends BasicListener {
@ -43,18 +44,20 @@ public class ArrowStopper extends BasicListener {
}
private void run() {
Iterator<Arrow> iterator = Bukkit.getWorlds().get(0).getEntitiesByClass(Arrow.class).iterator();
while (iterator.hasNext()) {
Arrow arrow = iterator.next();
if(isValidEntity(arrow))
for (Arrow arrow : Bukkit.getWorlds().get(0).getEntitiesByClass(Arrow.class)) {
if (invalidEntity(arrow))
continue;
Location prevLocation = arrow.getLocation().toVector().subtract(arrow.getVelocity()).toLocation(arrow.getWorld());
if(arrow.getTicksLived() == 0)
if (arrow.getTicksLived() == 0){
ProjectileSource projSource = arrow.getShooter();
if(projSource instanceof Player)
prevLocation = ((Player) arrow.getShooter()).getEyeLocation();
else
continue;
}
if (checkBlocks(arrow.getLocation().getBlock(), prevLocation.getBlock())) {
arrow.remove();
iterator.remove();
}
}
}
@ -97,7 +100,7 @@ public class ArrowStopper extends BasicListener {
return Config.HiddenBlockTags.contains(block.getType().name());
}
private boolean isValidEntity(Arrow entity) {
private boolean invalidEntity(Arrow entity) {
boolean teamFrom = entity.getVelocity().getZ() > 0;
boolean overMid = entity.getLocation().getZ() > Config.SpecSpawn.getZ();
boolean otherSide = teamFrom == overMid;