Search in sources :

Example 6 with ISoliniaClass

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

the class ConfigurationManager method getSpellsByClassIdAndMaxLevel.

@Override
public List<ISoliniaSpell> getSpellsByClassIdAndMaxLevel(int classId, int level) {
    List<ISoliniaSpell> returnSpells = new ArrayList<ISoliniaSpell>();
    ISoliniaClass classObj;
    try {
        classObj = StateManager.getInstance().getConfigurationManager().getClassObj(classId);
    } catch (CoreStateInitException e) {
        return returnSpells;
    }
    for (ISoliniaSpell spell : getSpells()) {
        boolean addSpell = false;
        for (SoliniaSpellClass spellclass : spell.getAllowedClasses()) {
            if (spellclass.getMinlevel() > level)
                continue;
            if (spellclass.getClassname().toUpperCase().equals(classObj.getName().toUpperCase())) {
                addSpell = true;
                break;
            }
        }
        if (addSpell == true)
            returnSpells.add(spell);
    }
    return returnSpells;
}
Also used : ISoliniaClass(com.solinia.solinia.Interfaces.ISoliniaClass) ISoliniaSpell(com.solinia.solinia.Interfaces.ISoliniaSpell) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ArrayList(java.util.ArrayList) SoliniaSpellClass(com.solinia.solinia.Models.SoliniaSpellClass)

Example 7 with ISoliniaClass

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

the class SoliniaCraft method editSetting.

public void editSetting(String setting, String value) throws InvalidCraftSettingException, NumberFormatException, CoreStateInitException {
    switch(setting.toLowerCase()) {
        case "recipename":
            if (value.equals(""))
                throw new InvalidCraftSettingException("Name is empty");
            if (StateManager.getInstance().getConfigurationManager().getCraft(value.toUpperCase()) != null)
                throw new InvalidCraftSettingException("Recipe already exists with this name");
            setRecipeName(value.toUpperCase());
            break;
        case "classid":
            ISoliniaClass classObj = StateManager.getInstance().getConfigurationManager().getClassObj(Integer.parseInt(value));
            if (classObj == null)
                throw new InvalidCraftSettingException("Class does not exist");
            setClassId(Integer.parseInt(value));
            break;
        case "skilltype":
            setSkilltype(SkillType.valueOf(value));
            break;
        case "minskill":
            if (Integer.parseInt(value) < 0)
                throw new InvalidCraftSettingException("Skill must be greater than or equal to 0");
            setMinSkill(Integer.parseInt(value));
            break;
        case "item1":
            int itemId1 = Integer.parseInt(value);
            ISoliniaItem solitem1 = StateManager.getInstance().getConfigurationManager().getItem(itemId1);
            if (solitem1 == null) {
                throw new InvalidCraftSettingException("Invalid item id (in item 1)");
            }
            setItem1(itemId1);
            break;
        case "item2":
            int itemId2 = Integer.parseInt(value);
            ISoliniaItem solitem2 = StateManager.getInstance().getConfigurationManager().getItem(itemId2);
            if (solitem2 == null) {
                throw new InvalidCraftSettingException("Invalid item id (in item 2)");
            }
            setItem2(itemId2);
            break;
        case "outputitem":
            int outputitem = Integer.parseInt(value);
            ISoliniaItem soloutitem = StateManager.getInstance().getConfigurationManager().getItem(outputitem);
            if (soloutitem == null) {
                throw new InvalidCraftSettingException("Invalid item id (out item)");
            }
            setOutputItem(outputitem);
            break;
        default:
            throw new InvalidCraftSettingException("Invalid zone setting. Valid Options are: recipename,item1,item2,outputitem");
    }
}
Also used : ISoliniaClass(com.solinia.solinia.Interfaces.ISoliniaClass) ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) InvalidCraftSettingException(com.solinia.solinia.Exceptions.InvalidCraftSettingException)

Example 8 with ISoliniaClass

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

the class Utils method sendRaceInfo.

public static void sendRaceInfo(CommandSender sender) throws CoreStateInitException {
    List<ISoliniaClass> classes = StateManager.getInstance().getConfigurationManager().getClasses();
    for (ISoliniaRace race : StateManager.getInstance().getConfigurationManager().getRaces()) {
        if (race.isAdmin())
            continue;
        String classBuilder = "";
        for (ISoliniaClass solclass : classes) {
            if (solclass.getValidRaces().contains(race.getId()))
                classBuilder += solclass.getName() + " ";
        }
        TextComponent tc = new TextComponent();
        tc.setText(ChatColor.RED + "~ RACE: " + ChatColor.GOLD + race.getName().toUpperCase() + ChatColor.GRAY + " [" + race.getId() + "] - " + ChatColor.RESET);
        TextComponent tc2 = new TextComponent();
        tc2.setText("Hover for more details");
        String details = ChatColor.GOLD + race.getName() + ChatColor.RESET + "\nRecommended Alignment: " + ChatColor.GOLD + race.getAlignment() + ChatColor.RESET + "\n" + race.getDescription() + "\nSTR: " + ChatColor.GOLD + race.getStrength() + ChatColor.RESET + " STA: " + ChatColor.GOLD + race.getStamina() + ChatColor.RESET + " AGI: " + ChatColor.GOLD + race.getAgility() + ChatColor.RESET + " DEX: " + ChatColor.GOLD + race.getDexterity() + ChatColor.RESET + " INT: " + ChatColor.GOLD + race.getIntelligence() + ChatColor.RESET + " WIS: " + ChatColor.GOLD + race.getWisdom() + ChatColor.RESET + " CHA: " + ChatColor.GOLD + race.getCharisma() + ChatColor.GOLD + " \nClasses: " + ChatColor.RESET + classBuilder;
        tc2.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(details).create()));
        tc.addExtra(tc2);
        sender.spigot().sendMessage(tc);
    }
}
Also used : ISoliniaClass(com.solinia.solinia.Interfaces.ISoliniaClass) TextComponent(net.md_5.bungee.api.chat.TextComponent) HoverEvent(net.md_5.bungee.api.chat.HoverEvent) ISoliniaRace(com.solinia.solinia.Interfaces.ISoliniaRace) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder)

Example 9 with ISoliniaClass

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

the class CommandCreateAllArmourSets method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player) && !(sender instanceof CommandSender))
        return false;
    try {
        if (sender instanceof Player) {
            Player player = (Player) sender;
            if (!player.isOp() && !player.hasPermission("solinia.createallarmorsets")) {
                player.sendMessage("You do not have permission to access this command");
                return false;
            }
        }
        if (args.length < 3) {
            return false;
        }
        // args
        // lootdropid
        // armourtier
        // chance
        // suffixname
        int lootdropid = Integer.parseInt(args[0]);
        int armourtier = Integer.parseInt(args[1]);
        ISoliniaLootDrop lootdrop = StateManager.getInstance().getConfigurationManager().getLootDrop(lootdropid);
        if (lootdrop == null) {
            sender.sendMessage("Lootdrop ID does not exist");
            return true;
        }
        if (lootdrop.isOperatorCreated() && !sender.isOp()) {
            sender.sendMessage("This lootdrop was op created and you are not an op. Only ops can edit op lootdrop items");
            return false;
        }
        int chance = Integer.parseInt(args[2]);
        if (chance < 1 || chance > 100) {
            sender.sendMessage("Chance must be between 1 and 100");
            return true;
        }
        String partialname = "";
        int count = 0;
        for (String entry : args) {
            if (count < 3) {
                count++;
                continue;
            }
            partialname += entry + " ";
            count++;
        }
        partialname = partialname.trim();
        if (partialname.equals("")) {
            sender.sendMessage("Blank suffix name not allowed when creating armour set");
            return false;
        }
        String itemscreated = "";
        for (ISoliniaClass classEntry : StateManager.getInstance().getConfigurationManager().getClasses()) {
            List<Integer> items = SoliniaItemFactory.CreateClassItemSet(classEntry, armourtier, partialname, true, sender.isOp());
            for (Integer item : items) {
                SoliniaLootFactory.CreateLootDropItem(lootdropid, item, 1, false, chance, sender.isOp());
                itemscreated += item + " ";
            }
        }
        sender.sendMessage("Created items as IDs: " + itemscreated + " with " + chance + "% chance in lootdrop: " + lootdropid);
    } catch (CoreStateInitException e) {
        sender.sendMessage(e.getMessage());
    } catch (SoliniaItemException e) {
        // TODO Auto-generated catch block
        sender.sendMessage(e.getMessage());
    }
    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) SoliniaItemException(com.solinia.solinia.Exceptions.SoliniaItemException) ISoliniaLootDrop(com.solinia.solinia.Interfaces.ISoliniaLootDrop)

Example 10 with ISoliniaClass

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

the class CommandCreateArmourSet method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player) && !(sender instanceof CommandSender))
        return false;
    try {
        if (sender instanceof Player) {
            Player player = (Player) sender;
            if (!player.isOp()) {
                player.sendMessage("This is an operator only command");
                return false;
            }
        }
        if (args.length < 2) {
            return false;
        }
        // args
        // classid
        // armourtier
        // suffixname
        int classid = Integer.parseInt(args[0]);
        int armourtier = Integer.parseInt(args[1]);
        ISoliniaClass classtype = StateManager.getInstance().getConfigurationManager().getClassObj(classid);
        if (classtype == null) {
            sender.sendMessage("Class ID does not exist");
            return true;
        }
        String partialname = "";
        int count = 0;
        for (String entry : args) {
            if (count < 2) {
                count++;
                continue;
            }
            partialname += entry + " ";
            count++;
        }
        partialname = partialname.trim();
        if (partialname.equals("")) {
            sender.sendMessage("Blank suffix name not allowed when creating armour set");
            return false;
        }
        List<Integer> items = SoliniaItemFactory.CreateClassItemSet(classtype, armourtier, partialname, false, sender.isOp());
        String itemscreated = "";
        for (Integer item : items) {
            itemscreated += item + " ";
        }
        sender.sendMessage("Created items as IDs: " + itemscreated);
    } catch (CoreStateInitException e) {
        sender.sendMessage(e.getMessage());
    } catch (SoliniaItemException e) {
        // TODO Auto-generated catch block
        sender.sendMessage(e.getMessage());
    }
    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) SoliniaItemException(com.solinia.solinia.Exceptions.SoliniaItemException)

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