package com.gildorymrp.professions;

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

import com.gildorymrp.api.plugin.professions.Profession;

public class SetProfessionCommand implements CommandExecutor {

	private GildorymProfessions plugin;

	public SetProfessionCommand(GildorymProfessions plugin) {
		this.plugin = plugin;
	}

	@Override
	public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
		Player player = (Player) sender;
		if (args.length >= 1) {
			try {
				Profession profession = Profession.valueOf(args[0].toUpperCase());
				plugin.setProfession(player, profession);
				sender.sendMessage(GildorymProfessions.PREFIX + ChatColor.GREEN + "Set profession to " + profession.toString());
			} catch (IllegalArgumentException exception) {
				sender.sendMessage(GildorymProfessions.PREFIX + ChatColor.RED + "That profession does not exist!");
			}
		} else {
			sender.sendMessage(GildorymProfessions.PREFIX + ChatColor.RED + "You must specify a profession!");
		}
		return true;
	}

}

@@ -601,45 +601,8 @@
 er;%0A
-%09%09if (args.length %3E= 1) %7B%0A%09%09%09try %7B%0A%09%09
 %09%09Pr
@@ -666,16 +666,81 @@
 ase());%0A
+%09%09if (profession == null)%7B%0A%09%09%09if (args.length %3E= 1) %7B%0A%09%09%09%09try %7B%0A%09
 %09%09%09%09plug
@@ -777,16 +777,17 @@
 ssion);%0A
+%09
 %09%09%09%09send
@@ -895,16 +895,17 @@
 ing());%0A
+%09
 %09%09%09%7D cat
@@ -946,24 +946,25 @@
 tion) %7B%0A%09%09%09%09
+%09
 sender.sendM
@@ -1054,18 +1054,20 @@
 !%22);%0A%09%09%09
+%09
 %7D%0A
+%09
 %09%09%7D else
@@ -1072,16 +1072,17 @@
 se %7B%0A%09%09%09
+%09
 sender.s
@@ -1174,19 +1174,138 @@
 n!%22);%0A%09%09
+%09
 %7D%0A%09
+%09%09%0A%09%09%7Delse%7B%0A%09%09%09sender.sendMessage(GildorymProfessions.PREFIX + ChatColor.RED + %22You may not change profession!%22);%0A%09%09%7D%0A
 %09return 
@@ -1313,11 +1313,12 @@
 rue;%0A%09%7D%0A
+%09
 %0A%7D%0A

Update SetProfessionCommand.java