From f8eeaed1fc4dd37926ed513207be435507e5d114 Mon Sep 17 00:00:00 2001 From: mathiascode Date: Mon, 16 Dec 2019 02:05:15 +0200 Subject: [PATCH] Clean up spidey command code --- .../pw/kaboom/extras/commands/CommandSpidey.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/pw/kaboom/extras/commands/CommandSpidey.java b/src/main/java/pw/kaboom/extras/commands/CommandSpidey.java index cd02647..8a9b4ca 100644 --- a/src/main/java/pw/kaboom/extras/commands/CommandSpidey.java +++ b/src/main/java/pw/kaboom/extras/commands/CommandSpidey.java @@ -2,6 +2,7 @@ package pw.kaboom.extras; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.World; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -19,12 +20,19 @@ class CommandSpidey implements CommandExecutor { sender.sendMessage("Command has to be run by a player"); } else { final Player player = (Player) sender; - final Location eyePos = player.getEyeLocation(); - final Vector playerPos = new Vector(eyePos.getX(), eyePos.getY(), eyePos.getZ()); - final Vector direction = eyePos.getDirection(); + final World world = player.getWorld(); + final Vector start = player.getEyeLocation().toVector(); + final Vector direction = player.getEyeLocation().getDirection(); + final int yOffset = 0; 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() && (blockIterator.next().getType() == Material.AIR ||