package com.crystalcraftmc.allyouneed.Commands;

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

import com.crystalcraftmc.allyouneed.Main;

public class AYNHeal implements CommandExecutor {
	Main plugin;
	public AYNHeal(Main main){
		this.plugin = main;
	}
	public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
		if(args.length < 1){
			Player pl = (Player) sender;
			pl.setHealth(20);
			pl.setFoodLevel(20);
			return true;
		}
		else{
			if(plugin.getServer().getPlayer(args[0]) != null){
				Player pl = plugin.getServer().getPlayer(args[0]);
				pl.setHealth(20);
				pl.setFoodLevel(20);
				pl.sendMessage("You got healed by "+sender.getName());
				return true;
			}
			else{
				sender.sendMessage("Player not existing");
				return false;
			}
		}
		
	}

}

@@ -357,16 +357,35 @@
 in;%0A%09%7D%0A%09
+%0A    @Override%0A    
 public b
@@ -468,14 +468,22 @@
 rgs)
+ 
 %7B%0A
-%09%09
+        
 if
+ 
 (arg
@@ -495,21 +495,31 @@
 gth %3C 1)
+ 
 %7B%0A
-%09%09%09
+            
 Player p
@@ -543,56 +543,49 @@
 er;%0A
-%09%09%09pl.setHealth(20);%0A%09%09%09pl.setFoodLevel(20);%0A%09%09%09
+            pl = doHeal(pl);%0A            
 retu
@@ -597,25 +597,40 @@
 ue;%0A
-%09%09%7D%0A%09%09
+        %7D 
 else
+ 
 %7B%0A
-%09%09%09
+            
 if
+ 
 (plu
@@ -676,131 +676,798 @@
 ull)
+ 
 %7B%0A
-%09%09%09%09Player pl = plugin.getServer().getPlayer(args%5B0%5D);%0A%09%09%09%09pl.setHealth(20);%0A%09%09%09%09pl.setFoodLevel(20);%0A%09%09%09%09pl.sendMessage(
+                String tmp = ChatColor.translateAlternateColorCodes('&', args%5B0%5D);%0A                if (tmp.length() %3E 16) %7B%0A                    sender.sendMessage(ChatColor.RED + %22Error: %22 + %22%22 + ChatColor.AQUA + tmp + ChatColor.RED + %22 name has more than 16 characters or did not exist%22);)%0A                %7D else %7B%0A                    try %7B%0A                        Player pl = plugin.getServer().getPlayer(args%5B0%5D);%0A                    %7D catch (Exception e) %7B%0A                    %09sender.sendMessage(ChatColor.RED + %22Unknown error see logs%22);%0A                        plugin.getLogger().log(Level.SEVERE, e.getStackTrace().toString());%0A                        return false;%0A                    %7D%0A%0A                    pl = doHeal(pl);%0A                    pl.sendMessage(ChatColor.GREEN + 
 %22You
@@ -1482,17 +1482,19 @@
 led by %22
-+
+ + 
 sender.g
@@ -1505,120 +1505,367 @@
 me()
-);%0A%09%09%09%09return true;%0A%09%09%09%7D%0A%09%09%09else%7B%0A%09%09%09%09sender.sendMessage(%22Player not existing%22);%0A%09%09%09%09return false;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09
+.toString());%0A                %7D%0A                return true;%0A            %7D%0A%0A        %7D%0A%0A    %7D%0A%0A    private Player doHeal(Player player)%7B%0A%0A        %0A        player.setHealth(player.getMaxHealth());%0A        player.setFoodLevel(20);%0A        //This should also remove poition effects to.%0A        player.getActivePotionEffects().clear();%0A%0A        return player;%0A    
 %7D%0A%0A%7D

Remove Dupe Code and Add More Error Checking