Improvements
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
7b055a37be
Commit
47e256d31c
@ -28,10 +28,11 @@ import org.bukkit.block.Block;
|
|||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.EnumSet;
|
||||||
|
|
||||||
public class ArrowStopper extends BasicListener {
|
public class ArrowStopper extends BasicListener {
|
||||||
|
|
||||||
@ -43,18 +44,20 @@ public class ArrowStopper extends BasicListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void run() {
|
private void run() {
|
||||||
Iterator<Arrow> iterator = Bukkit.getWorlds().get(0).getEntitiesByClass(Arrow.class).iterator();
|
for (Arrow arrow : Bukkit.getWorlds().get(0).getEntitiesByClass(Arrow.class)) {
|
||||||
while (iterator.hasNext()) {
|
if (invalidEntity(arrow))
|
||||||
Arrow arrow = iterator.next();
|
|
||||||
if(isValidEntity(arrow))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Location prevLocation = arrow.getLocation().toVector().subtract(arrow.getVelocity()).toLocation(arrow.getWorld());
|
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();
|
prevLocation = ((Player) arrow.getShooter()).getEyeLocation();
|
||||||
if(checkBlocks(arrow.getLocation().getBlock(), prevLocation.getBlock())) {
|
else
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (checkBlocks(arrow.getLocation().getBlock(), prevLocation.getBlock())) {
|
||||||
arrow.remove();
|
arrow.remove();
|
||||||
iterator.remove();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,7 +100,7 @@ public class ArrowStopper extends BasicListener {
|
|||||||
return Config.HiddenBlockTags.contains(block.getType().name());
|
return Config.HiddenBlockTags.contains(block.getType().name());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isValidEntity(Arrow entity) {
|
private boolean invalidEntity(Arrow entity) {
|
||||||
boolean teamFrom = entity.getVelocity().getZ() > 0;
|
boolean teamFrom = entity.getVelocity().getZ() > 0;
|
||||||
boolean overMid = entity.getLocation().getZ() > Config.SpecSpawn.getZ();
|
boolean overMid = entity.getLocation().getZ() > Config.SpecSpawn.getZ();
|
||||||
boolean otherSide = teamFrom == overMid;
|
boolean otherSide = teamFrom == overMid;
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren