Search in sources :

Example 1 with SoliniaSpellClass

use of com.solinia.solinia.Models.SoliniaSpellClass in project solinia3-core by mixxit.

the class Utils method RepairAllowedClasses.

public static void RepairAllowedClasses(ISoliniaSpell spell) {
    List<SoliniaSpellClass> allowedClasses = new ArrayList<SoliniaSpellClass>();
    if (spell.getClasses1() != null && spell.getClasses1() != 254 && spell.getClasses1() != 255) {
        SoliniaSpellClass spellClass = new SoliniaSpellClass();
        spellClass.setClassname("WARRIOR");
        spellClass.setMinlevel(spell.getClasses1());
        allowedClasses.add(spellClass);
    }
    if (spell.getClasses2() != null && spell.getClasses2() != 254 && spell.getClasses2() != 255) {
        SoliniaSpellClass spellClass = new SoliniaSpellClass();
        spellClass.setClassname("CLERIC");
        spellClass.setMinlevel(spell.getClasses2());
        allowedClasses.add(spellClass);
    }
    if (spell.getClasses3() != null && spell.getClasses3() != 254 && spell.getClasses3() != 255) {
        SoliniaSpellClass spellClass = new SoliniaSpellClass();
        spellClass.setClassname("PALADIN");
        spellClass.setMinlevel(spell.getClasses3());
        allowedClasses.add(spellClass);
    }
    if (spell.getClasses4() != null && spell.getClasses4() != 254 && spell.getClasses4() != 255) {
        SoliniaSpellClass spellClass = new SoliniaSpellClass();
        spellClass.setClassname("RANGER");
        spellClass.setMinlevel(spell.getClasses4());
        allowedClasses.add(spellClass);
    }
    if (spell.getClasses5() != null && spell.getClasses5() != 254 && spell.getClasses5() != 255) {
        SoliniaSpellClass spellClass = new SoliniaSpellClass();
        spellClass.setClassname("SHADOWKNIGHT");
        spellClass.setMinlevel(spell.getClasses5());
        allowedClasses.add(spellClass);
    }
    if (spell.getClasses6() != null && spell.getClasses6() != 254 && spell.getClasses6() != 255) {
        SoliniaSpellClass spellClass = new SoliniaSpellClass();
        spellClass.setClassname("DRUID");
        spellClass.setMinlevel(spell.getClasses6());
        allowedClasses.add(spellClass);
    }
    if (spell.getClasses7() != null && spell.getClasses7() != 254 && spell.getClasses7() != 255) {
        SoliniaSpellClass spellClass = new SoliniaSpellClass();
        spellClass.setClassname("MONK");
        spellClass.setMinlevel(spell.getClasses7());
        allowedClasses.add(spellClass);
    }
    if (spell.getClasses8() != null && spell.getClasses8() != 254 && spell.getClasses8() != 255) {
        SoliniaSpellClass spellClass = new SoliniaSpellClass();
        spellClass.setClassname("BARD");
        spellClass.setMinlevel(spell.getClasses8());
        allowedClasses.add(spellClass);
    }
    if (spell.getClasses9() != null && spell.getClasses9() != 254 && spell.getClasses9() != 255) {
        SoliniaSpellClass spellClass = new SoliniaSpellClass();
        spellClass.setClassname("ROGUE");
        spellClass.setMinlevel(spell.getClasses9());
        allowedClasses.add(spellClass);
    }
    if (spell.getClasses10() != null && spell.getClasses10() != 254 && spell.getClasses10() != 255) {
        SoliniaSpellClass spellClass = new SoliniaSpellClass();
        spellClass.setClassname("SHAMAN");
        spellClass.setMinlevel(spell.getClasses10());
        allowedClasses.add(spellClass);
    }
    if (spell.getClasses11() != null && spell.getClasses11() != 254 && spell.getClasses11() != 255) {
        SoliniaSpellClass spellClass = new SoliniaSpellClass();
        spellClass.setClassname("NECROMANCER");
        spellClass.setMinlevel(spell.getClasses11());
        allowedClasses.add(spellClass);
    }
    if (spell.getClasses12() != null && spell.getClasses12() != 254 && spell.getClasses12() != 255) {
        SoliniaSpellClass spellClass = new SoliniaSpellClass();
        spellClass.setClassname("WIZARD");
        spellClass.setMinlevel(spell.getClasses12());
        allowedClasses.add(spellClass);
    }
    if (spell.getClasses13() != null && spell.getClasses13() != 254 && spell.getClasses13() != 255) {
        SoliniaSpellClass spellClass = new SoliniaSpellClass();
        spellClass.setClassname("MAGICIAN");
        spellClass.setMinlevel(spell.getClasses13());
        allowedClasses.add(spellClass);
    }
    if (spell.getClasses14() != null && spell.getClasses14() != 254 && spell.getClasses14() != 255) {
        SoliniaSpellClass spellClass = new SoliniaSpellClass();
        spellClass.setClassname("ENCHANTER");
        spellClass.setMinlevel(spell.getClasses14());
        allowedClasses.add(spellClass);
    }
    if (spell.getClasses15() != null && spell.getClasses15() != 254 && spell.getClasses15() != 255) {
        SoliniaSpellClass spellClass = new SoliniaSpellClass();
        spellClass.setClassname("BEASTLORD");
        spellClass.setMinlevel(spell.getClasses15());
        allowedClasses.add(spellClass);
    }
    if (spell.getClasses16() != null && spell.getClasses16() != 254 && spell.getClasses16() != 255) {
        SoliniaSpellClass spellClass = new SoliniaSpellClass();
        spellClass.setClassname("BERSERKER");
        spellClass.setMinlevel(spell.getClasses16());
        allowedClasses.add(spellClass);
    }
    try {
        StateManager.getInstance().getConfigurationManager().getSpell(spell.getId()).setAllowedClasses(allowedClasses);
        System.out.println("Fixed spell " + spell.getName() + " with classe count: " + allowedClasses.size());
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ArrayList(java.util.ArrayList) SoliniaSpellClass(com.solinia.solinia.Models.SoliniaSpellClass)

Example 2 with SoliniaSpellClass

use of com.solinia.solinia.Models.SoliniaSpellClass in project solinia3-core by mixxit.

the class CommandRebuildSpellItems 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;
        }
    }
    int updated = 0;
    sender.sendMessage("Rebuilding Item Lists, this may take some time");
    try {
        for (ISoliniaSpell spell : StateManager.getInstance().getConfigurationManager().getSpells()) {
            int worth = 10;
            int minLevel = 1;
            int lowestLevel = 1000;
            for (SoliniaSpellClass spellClass : spell.getAllowedClasses()) {
                if (spellClass.getMinlevel() < lowestLevel)
                    lowestLevel = spellClass.getMinlevel();
            }
            if (lowestLevel > minLevel && lowestLevel < 100)
                minLevel = lowestLevel;
            worth = worth * minLevel;
            // Spell exists
            if (StateManager.getInstance().getConfigurationManager().getSpellItem(spell.getId()).size() > 0) {
                for (ISoliniaItem item : StateManager.getInstance().getConfigurationManager().getSpellItem(spell.getId())) {
                    item.setAbilityid(spell.getId());
                    item.setDisplayname("Spell: " + spell.getName());
                    item.setSpellscroll(true);
                    item.setAllowedClassNames(new ArrayList<String>());
                    item.setLore("This appears to be some sort of   magical spell that could be       learned");
                    item.setWorth(worth);
                    StateManager.getInstance().getConfigurationManager().updateItem(item);
                    updated++;
                }
            } else {
                // Doesnt exist, create it
                ISoliniaItem item = SoliniaItemFactory.CreateItem(new ItemStack(Material.ENCHANTED_BOOK), sender.isOp());
                item.setAbilityid(spell.getId());
                item.setDisplayname("Spell: " + spell.getName());
                item.setSpellscroll(true);
                item.setAllowedClassNames(new ArrayList<String>());
                item.setLore("This appears to be some sort of   magical spell that could be       learned");
                item.setWorth(worth);
                StateManager.getInstance().getConfigurationManager().updateItem(item);
                updated++;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        sender.sendMessage(e.getMessage());
    }
    sender.sendMessage("Updated " + updated + " items");
    return true;
}
Also used : Player(org.bukkit.entity.Player) ISoliniaSpell(com.solinia.solinia.Interfaces.ISoliniaSpell) ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) CommandSender(org.bukkit.command.CommandSender) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender) ItemStack(org.bukkit.inventory.ItemStack) SoliniaSpellClass(com.solinia.solinia.Models.SoliniaSpellClass)

Example 3 with SoliniaSpellClass

use of com.solinia.solinia.Models.SoliniaSpellClass in project solinia3-core by mixxit.

the class ItemStackAdapter method generateSpellLoreText.

private static List<String> generateSpellLoreText(ISoliniaItem soliniaItem) {
    List<String> loreTxt = new ArrayList<String>();
    ISoliniaSpell spell;
    try {
        spell = StateManager.getInstance().getConfigurationManager().getSpell(soliniaItem.getAbilityid());
        if (spell.getEffectid1() != 254 && !Utils.getSpellEffectType(spell.getEffectid1()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid1()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue1() == 0) && !Utils.getSpellEffectType(spell.getEffectid1()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue1() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid1()).name() + ChatColor.RESET);
        }
        if (spell.getEffectid2() != 254 && !Utils.getSpellEffectType(spell.getEffectid2()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid2()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue2() == 0) && !Utils.getSpellEffectType(spell.getEffectid2()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue2() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid2()).name() + ChatColor.RESET);
        }
        if (spell.getEffectid3() != 254 && !Utils.getSpellEffectType(spell.getEffectid3()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid3()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue3() == 0) && !Utils.getSpellEffectType(spell.getEffectid3()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue3() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid3()).name() + ChatColor.RESET);
        }
        if (spell.getEffectid4() != 254 && !Utils.getSpellEffectType(spell.getEffectid4()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid4()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue4() == 0) && !Utils.getSpellEffectType(spell.getEffectid4()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue4() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid4()).name() + ChatColor.RESET);
        }
        if (spell.getEffectid5() != 254 && !Utils.getSpellEffectType(spell.getEffectid5()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid5()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue5() == 0) && !Utils.getSpellEffectType(spell.getEffectid5()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue5() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid5()).name() + ChatColor.RESET);
        }
        if (spell.getEffectid6() != 254 && !Utils.getSpellEffectType(spell.getEffectid6()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid6()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue6() == 0) && !Utils.getSpellEffectType(spell.getEffectid6()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue6() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid6()).name() + ChatColor.RESET);
        }
        if (spell.getEffectid7() != 254 && !Utils.getSpellEffectType(spell.getEffectid7()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid7()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue7() == 0) && !Utils.getSpellEffectType(spell.getEffectid7()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue7() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid7()).name() + ChatColor.RESET);
        }
        if (spell.getEffectid8() != 254 && !Utils.getSpellEffectType(spell.getEffectid8()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid8()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue8() == 0) && !Utils.getSpellEffectType(spell.getEffectid8()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue8() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid8()).name() + ChatColor.RESET);
        }
        if (spell.getEffectid9() != 254 && !Utils.getSpellEffectType(spell.getEffectid9()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid9()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue9() == 0) && !Utils.getSpellEffectType(spell.getEffectid9()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue9() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid9()).name() + ChatColor.RESET);
        }
        if (spell.getEffectid10() != 254 && !Utils.getSpellEffectType(spell.getEffectid10()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid10()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue10() == 0) && !Utils.getSpellEffectType(spell.getEffectid10()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue10() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid10()).name() + ChatColor.RESET);
        }
        if (spell.getEffectid11() != 254 && !Utils.getSpellEffectType(spell.getEffectid11()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid11()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue11() == 0) && !Utils.getSpellEffectType(spell.getEffectid11()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue11() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid11()).name() + ChatColor.RESET);
        }
        if (spell.getEffectid12() != 254 && !Utils.getSpellEffectType(spell.getEffectid12()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid12()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue12() == 0) && !Utils.getSpellEffectType(spell.getEffectid12()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue12() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid12()).name() + ChatColor.RESET);
        }
        loreTxt.add(ChatColor.WHITE + "Mana/Power: " + ChatColor.YELLOW + spell.getMana() + ChatColor.RESET);
        loreTxt.add(ChatColor.WHITE + "Spell Skill: " + ChatColor.YELLOW + Utils.getSkillType(spell.getSkill()).name().toUpperCase() + ChatColor.RESET);
        loreTxt.add(ChatColor.WHITE + "Range: " + ChatColor.YELLOW + spell.getRange() + ChatColor.RESET);
        if (spell.isAASpell()) {
            loreTxt.add(ChatColor.WHITE + "This spell is an AA spell" + ChatColor.RESET);
        }
        if (spell.isBuffSpell() && spell.getBuffduration() > 0) {
            loreTxt.add(ChatColor.WHITE + "Buff Duration: " + ChatColor.YELLOW + (spell.getBuffduration() * 6) + " seconds" + ChatColor.RESET);
        }
        loreTxt.add(ChatColor.WHITE + "Target Type: " + ChatColor.YELLOW + Utils.getSpellTargetType(spell.getTargettype()).name() + ChatColor.RESET);
        String classesBuilder = "";
        List<SoliniaSpellClass> allowedSpellClasses = spell.getAllowedClasses();
        int rowcount = 0;
        for (SoliniaSpellClass spellclass : allowedSpellClasses) {
            if (StateManager.getInstance().getConfigurationManager().getClassObj(spellclass.getClassname().toUpperCase()) == null)
                continue;
            classesBuilder += ChatColor.WHITE + spellclass.getClassname() + " (" + ChatColor.YELLOW + spellclass.getMinlevel() + ChatColor.WHITE + ") " + ChatColor.RESET;
            rowcount++;
            if (rowcount > 2) {
                loreTxt.add(classesBuilder);
                classesBuilder = "";
            }
        }
        // If we never reached 2 classes on a row, handle the overspill here
        if (!classesBuilder.equals(""))
            loreTxt.add(classesBuilder);
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return loreTxt;
}
Also used : ISoliniaSpell(com.solinia.solinia.Interfaces.ISoliniaSpell) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ArrayList(java.util.ArrayList) NBTTagString(net.minecraft.server.v1_12_R1.NBTTagString) SoliniaSpellClass(com.solinia.solinia.Models.SoliniaSpellClass)

Example 4 with SoliniaSpellClass

use of com.solinia.solinia.Models.SoliniaSpellClass in project solinia3-core by mixxit.

the class ConfigurationManager method getSpellsByClassId.

@Override
public List<ISoliniaSpell> getSpellsByClassId(int classId) {
    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.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 5 with SoliniaSpellClass

use of com.solinia.solinia.Models.SoliniaSpellClass 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)

Aggregations

SoliniaSpellClass (com.solinia.solinia.Models.SoliniaSpellClass)5 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)4 ISoliniaSpell (com.solinia.solinia.Interfaces.ISoliniaSpell)4 ArrayList (java.util.ArrayList)4 ISoliniaClass (com.solinia.solinia.Interfaces.ISoliniaClass)2 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)1 NBTTagString (net.minecraft.server.v1_12_R1.NBTTagString)1 CommandSender (org.bukkit.command.CommandSender)1 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)1 Player (org.bukkit.entity.Player)1 ItemStack (org.bukkit.inventory.ItemStack)1