Arrows Stopping in Techhider Blocks #208
@ -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;
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren