SteamWar/FightSystem
Archiviert
13
1
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2021-01-02 09:20:19 +01:00
Ursprung 7b055a37be
Commit 47e256d31c

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();
if(checkBlocks(arrow.getLocation().getBlock(), prevLocation.getBlock())) {
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;