package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class CommandSpeed implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player))
return false;
Player player = (Player) sender;
if (args.length == 0){
player.sendMessage(BauSystem.PREFIX + "/speed [Geschwindigkeit]");
}
float speed;
try{
speed = Float.parseFloat(args[0]);
}catch(NumberFormatException e){
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an");
if (speed < 0 || speed > 10) {
player.sendMessage("§aGeschwindigkeit wurde auf §6" + speed + " §agesetzt");
player.setFlySpeed(speed / 10);
player.setWalkSpeed((speed >= 9 ? speed : speed + 1) / 10);