Arrows Stopping in Techhider Blocks #208
@ -34,10 +34,7 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class ArrowStopper implements StateDependent {
|
public class ArrowStopper implements StateDependent {
|
||||||
|
|
||||||
@ -55,20 +52,22 @@ public class ArrowStopper implements StateDependent {
|
|||||||
if(arrows.isEmpty())
|
if(arrows.isEmpty())
|
||||||
return;
|
return;
|
||||||
for (Entity entity : arrows) {
|
for (Entity entity : arrows) {
|
||||||
if(entity.getTicksLived() > Config.ArrowTechhiderCollision)
|
if(entity.getTicksLived() > Config.ArrowTechhiderCollision){
|
||||||
|
LAST_LOCATION.remove(entity);
|
||||||
continue;
|
continue;
|
||||||
if(((AbstractArrow) entity).isInBlock())
|
}
|
||||||
|
if(((AbstractArrow) entity).isInBlock()) {
|
||||||
|
LAST_LOCATION.remove(entity);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
if(!LAST_LOCATION.containsKey(entity))
|
if(!LAST_LOCATION.containsKey(entity))
|
||||||
LAST_LOCATION.put(entity, ((Player) ((AbstractArrow) entity).getShooter()).getEyeLocation());
|
LAST_LOCATION.put(entity, ((Player) ((AbstractArrow) entity).getShooter()).getEyeLocation());
|
||||||
int distance = (int) Math.ceil(entity.getLocation().toVector().distance(LAST_LOCATION.get(entity).toVector()) * 1.414213562);
|
Location last = LAST_LOCATION.get(entity);
|
||||||
try {
|
|
||||||
checkBlock(entity.getFacing().getOppositeFace(), entity.getLocation().getBlock(), LAST_LOCATION.get(entity).getBlock(), distance, entity.getLocation().getBlockY() - LAST_LOCATION.get(entity).getBlockY());
|
|
||||||
} catch (TechHiddenBlock techHiddenBlock) {
|
|
||||||
entity.remove();
|
|
||||||
}
|
|
||||||
LAST_LOCATION.remove(entity);
|
LAST_LOCATION.remove(entity);
|
||||||
LAST_LOCATION.put(entity, entity.getLocation());
|
if(checkBlocks(entity.getLocation().getBlock(), last.getBlock()))
|
||||||
|
entity.remove();
|
||||||
|
else
|
||||||
|
LAST_LOCATION.put(entity, entity.getLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,22 +100,39 @@ public class ArrowStopper implements StateDependent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkBlock(BlockFace face, Block block, Block start, int i, int lastdown) throws TechHiddenBlock {
|
private boolean checkBlocks(Block start, Block end) {
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> player.sendBlockChange(block.getLocation(), Material.RED_STAINED_GLASS.createBlockData()));
|
Bukkit.getOnlinePlayers().forEach(player -> player.sendBlockChange(start.getLocation(), Material.LIME_STAINED_GLASS.createBlockData()));
|
||||||
if(Config.HiddenBlocks.contains(blockToId(block)))
|
Block cursor = start;
|
||||||
throw new TechHiddenBlock();
|
|
||||||
|
|
||||||
if(lastdown != 0) {
|
while (cursor.getY() != end.getY()) {
|
||||||
boolean negativ = lastdown < 0;
|
boolean negativ = cursor.getY() - end.getY() < 0;
|
||||||
BlockFace toFace = negativ?BlockFace.UP:BlockFace.DOWN;
|
BlockFace face = negativ?BlockFace.UP:BlockFace.DOWN;
|
||||||
checkBlock(face, block.getRelative(toFace), start, i - 1, lastdown + (negativ?1:-1));
|
if(checkBlock(cursor))
|
||||||
return;
|
return true;
|
||||||
|
cursor = cursor.getRelative(face);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(i != 0) {
|
while (cursor.getX() != end.getX()) {
|
||||||
checkBlock(face, block.getRelative(face), start, i - 1, lastdown);
|
boolean negativ = cursor.getX() - end.getX() < 0;
|
||||||
|
BlockFace face = negativ?BlockFace.EAST:BlockFace.WEST;
|
||||||
|
if(checkBlock(cursor))
|
||||||
|
return true;
|
||||||
|
cursor = cursor.getRelative(face);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (cursor.getZ() != end.getZ()) {
|
||||||
|
boolean negativ = cursor.getZ() - end.getZ() < 0;
|
||||||
|
BlockFace face = negativ?BlockFace.SOUTH:BlockFace.NORTH;
|
||||||
|
if(checkBlock(cursor))
|
||||||
|
return true;
|
||||||
|
cursor = cursor.getRelative(face);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TechHiddenBlock extends Throwable {}
|
private boolean checkBlock(Block block) {
|
||||||
|
Bukkit.getOnlinePlayers().forEach(player -> player.sendBlockChange(block.getLocation(), Material.RED_STAINED_GLASS.createBlockData()));
|
||||||
|
return Config.HiddenBlocks.contains(blockToId(block));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren