41 Zeilen
1.3 KiB
Java
41 Zeilen
1.3 KiB
Java
|
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]");
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
float speed;
|
||
|
try{
|
||
|
speed = Float.valueOf(args[0]);
|
||
|
}catch(NumberFormatException e){
|
||
|
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an");
|
||
|
return false;
|
||
|
}
|
||
|
if (speed < 0 || speed > 10) {
|
||
|
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an");
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
player.sendMessage("§aGeschwindigkeit wurde auf §6" + speed + " §agesetzt");
|
||
|
|
||
|
player.setFlySpeed(speed / 10);
|
||
|
player.setWalkSpeed((speed >= 9 ? speed : speed + 1) / 10);
|
||
|
return false;
|
||
|
}
|
||
|
}
|