Add TopCommand

This commit is contained in:
Spencer 2017-12-30 17:05:56 -05:00 committed by Alexander Meech
parent 1e3648358b
commit 069ee177eb
1 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,39 @@
package mineplex.mapparser.command.teleport;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.common.util.C;
import mineplex.mapparser.command.BaseCommand;
public class TopCommand extends BaseCommand
{
private TeleportManager _teleportManager;
public TopCommand(TeleportManager teleportManager)
{
super(teleportManager.getPlugin(), "top");
_teleportManager = teleportManager;
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
Location destination = player.getLocation().clone();
while (destination.getBlock().getType() != Material.AIR
&& destination.add(0, 1, 0).getBlock().getType() != Material.AIR)
{
if (destination.getY() > 256)
{
break;
}
}
_teleportManager.teleportPlayer(player, destination);
message(player, "You have been teleported to Y = " + C.cYellow + destination.getY());
return true;
}
}