Clean up spidey command code

This commit is contained in:
mathiascode 2019-12-16 02:05:15 +02:00
parent f3ce40261f
commit f8eeaed1fc

View file

@ -2,6 +2,7 @@ package pw.kaboom.extras;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -19,12 +20,19 @@ class CommandSpidey implements CommandExecutor {
sender.sendMessage("Command has to be run by a player"); sender.sendMessage("Command has to be run by a player");
} else { } else {
final Player player = (Player) sender; final Player player = (Player) sender;
final Location eyePos = player.getEyeLocation(); final World world = player.getWorld();
final Vector playerPos = new Vector(eyePos.getX(), eyePos.getY(), eyePos.getZ()); final Vector start = player.getEyeLocation().toVector();
final Vector direction = eyePos.getDirection(); final Vector direction = player.getEyeLocation().getDirection();
final int yOffset = 0;
final int distance = 50; final int distance = 50;
final BlockIterator blockIterator = new BlockIterator(player.getWorld(), playerPos, direction, 0, distance); final BlockIterator blockIterator = new BlockIterator(
world,
start,
direction,
yOffset,
distance
);
while (blockIterator.hasNext() && while (blockIterator.hasNext() &&
(blockIterator.next().getType() == Material.AIR || (blockIterator.next().getType() == Material.AIR ||