Search in sources :

Example 11 with ISoliniaClass

use of com.solinia.solinia.Interfaces.ISoliniaClass in project solinia3-core by mixxit.

the class CommandAddRaceClass method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player) && !(sender instanceof CommandSender)) {
        sender.sendMessage("This is a Player/Console only command");
        return false;
    }
    if (sender instanceof Player) {
        Player player = (Player) sender;
        if (!player.isOp()) {
            player.sendMessage("This is an operator only command");
            return true;
        }
    }
    if (args.length < 2)
        return false;
    String racename = args[0];
    String classname = args[1];
    try {
        ISoliniaRace race = StateManager.getInstance().getConfigurationManager().getRace(racename);
        ISoliniaClass classobj = StateManager.getInstance().getConfigurationManager().getClassObj(classname);
        if (race == null) {
            sender.sendMessage("Race does not exist");
            return false;
        }
        if (classobj == null) {
            sender.sendMessage("Class does not exist");
            return false;
        }
        if (classobj.getValidRaces() != null)
            if (classobj.getValidRaces().contains(race.getId())) {
                sender.sendMessage("Race already contains class");
                return false;
            }
        StateManager.getInstance().getConfigurationManager().addRaceClass(race.getId(), classobj.getId());
        sender.sendMessage("* Race class combination added");
        return true;
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return true;
}
Also used : ISoliniaClass(com.solinia.solinia.Interfaces.ISoliniaClass) Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) CommandSender(org.bukkit.command.CommandSender) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender) ISoliniaRace(com.solinia.solinia.Interfaces.ISoliniaRace)

Aggregations

ISoliniaClass (com.solinia.solinia.Interfaces.ISoliniaClass)11 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)7 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)5 Player (org.bukkit.entity.Player)5 ArrayList (java.util.ArrayList)4 CommandSender (org.bukkit.command.CommandSender)4 SoliniaItemException (com.solinia.solinia.Exceptions.SoliniaItemException)2 ISoliniaRace (com.solinia.solinia.Interfaces.ISoliniaRace)2 ISoliniaSpell (com.solinia.solinia.Interfaces.ISoliniaSpell)2 SoliniaSpellClass (com.solinia.solinia.Models.SoliniaSpellClass)2 Gson (com.google.gson.Gson)1 InvalidClassSettingException (com.solinia.solinia.Exceptions.InvalidClassSettingException)1 InvalidCraftSettingException (com.solinia.solinia.Exceptions.InvalidCraftSettingException)1 SoliniaClassCreationException (com.solinia.solinia.Exceptions.SoliniaClassCreationException)1 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)1 ISoliniaLootDrop (com.solinia.solinia.Interfaces.ISoliniaLootDrop)1 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)1 SoliniaClass (com.solinia.solinia.Models.SoliniaClass)1 DiscordAdminChannelCommandSender (com.solinia.solinia.Providers.DiscordAdminChannelCommandSender)1 DiscordDefaultChannelCommandSender (com.solinia.solinia.Providers.DiscordDefaultChannelCommandSender)1