package io.github.vayleryn.vaylerynessentials.command;

import io.github.vayleryn.vaylerynessentials.VaylerynEssentials;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class SpeedCommand implements CommandExecutor {
	
	private VaylerynEssentials plugin;
	
	public SpeedCommand(VaylerynEssentials plugin) {
		this.plugin = plugin;
	}
	
	@Override
	public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
		if (sender.hasPermission("vayleryn.essentials.command.speed")) {
			Player player = null;
			if (sender instanceof Player) {
				player = (Player) sender;
			}
			int speed = 0;
			if (args.length >= 2 && plugin.getServer().getPlayer(args[0]) != null) {
				player = plugin.getServer().getPlayer(args[0]);
				try {
					speed = Integer.parseInt(args[1]);
				} catch (NumberFormatException exception) {
					sender.sendMessage(plugin.getPrefix() + ChatColor.RED + "Speed must be an integer."); 
				}
			} else {
				try {
					speed = Integer.parseInt(args[0]);
				} catch (NumberFormatException exception) {
					sender.sendMessage(plugin.getPrefix() + ChatColor.RED + "Speed must be an integer.");
				}
			}
			if (player != null) {
				player.setFlySpeed(speed);
				sender.sendMessage(plugin.getPrefix() + ChatColor.GREEN + "Set " + player.getName() + "'s fly speed to " + speed);
				player.sendMessage(plugin.getPrefix() + ChatColor.GREEN + "Your flyspeed was set to " + speed + " by " + sender.getName());
			} else {
				sender.sendMessage(plugin.getPrefix() + ChatColor.RED + "You must specify a player if you're using this command from console.");
			}
		}
		return true;
	}
	
}

@@ -743,18 +743,20 @@
 %09%09%09%7D%0A%09%09%09
-in
+floa
 t speed 
@@ -907,39 +907,39 @@
 %09%09%09%09speed = 
-Integer
+Float
 .parse
-In
+Floa
 t(args%5B1%5D);%0A
@@ -1059,31 +1059,29 @@
 ed must be a
-n integ
+ numb
 er.%22); %0A%09%09%09%09
@@ -1121,23 +1121,23 @@
 d = 
-Integer
+Float
 .parse
-In
+Floa
 t(ar
@@ -1273,15 +1273,13 @@
 be a
-n integ
+ numb
 er.%22
@@ -1309,32 +1309,69 @@
 ayer != null) %7B%0A
+%09%09%09%09if (speed %3E= 0 && speed %3C= 1) %7B%0A%09
 %09%09%09%09player.setFl
@@ -1381,24 +1381,25 @@
 eed(speed);%0A
+%09
 %09%09%09%09sender.s
@@ -1505,24 +1505,25 @@
 speed);%0A%09%09%09%09
+%09
 player.sendM
@@ -1634,16 +1634,130 @@
 ame());%0A
+%09%09%09%09%7D else %7B%0A%09%09%09%09%09sender.sendMessage(plugin.getPrefix() + ChatColor.RED + %22Speed must be between 0 and 1%22);%0A%09%09%09%09%7D%0A
 %09%09%09%7D els

Change speed command to use floats