Search in sources :

Example 16 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class Solinia3CoreEntityListener method onEntityDamageEvent.

@EventHandler
public void onEntityDamageEvent(EntityDamageEvent event) {
    if (event.isCancelled())
        return;
    if ((event.getEntity() instanceof Player)) {
        if (!(event.getCause().equals(EntityDamageEvent.DamageCause.FALL)))
            return;
        Player player = (Player) event.getEntity();
        ISoliniaPlayer solplayer;
        try {
            solplayer = SoliniaPlayerAdapter.Adapt(player);
            if (solplayer == null)
                return;
            boolean cancelFall = solplayer.getSafefallCheck();
            if (cancelFall == true) {
                Utils.CancelEvent(event);
                ;
                solplayer.emote(ChatColor.GRAY + "* " + solplayer.getFullName() + " lands softly, breaking their fall");
                solplayer.tryIncreaseSkill("SAFEFALL", 1);
                return;
            }
        } catch (CoreStateInitException e) {
            return;
        }
    }
}
Also used : Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) EventHandler(org.bukkit.event.EventHandler)

Example 17 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class CommandVoteEmperor method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player)) {
        return false;
    }
    if (args.length < 1)
        return false;
    if (Bukkit.getPlayer(args[0]) == null) {
        sender.sendMessage("Cannot find player");
        return true;
    }
    try {
        Player fealtyTo = Bukkit.getPlayer(args[0]);
        ISoliniaPlayer sourcePlayer = SoliniaPlayerAdapter.Adapt((Player) sender);
        ISoliniaPlayer fealtyPlayer = SoliniaPlayerAdapter.Adapt(fealtyTo);
        if (!sourcePlayer.isMain()) {
            sender.sendMessage("You must be your main character to vote");
            return true;
        }
        if (!fealtyPlayer.isMain()) {
            sender.sendMessage("You can only vote for a main character");
            return true;
        }
        if (sourcePlayer.getRaceId() < 1 || fealtyPlayer.getRaceId() < 1) {
            sender.sendMessage("You and your target must both have a race set");
            return true;
        }
        if (!sourcePlayer.getRace().getAlignment().equals(fealtyPlayer.getRace().getAlignment())) {
            sender.sendMessage("You can only vote for an emperor of the same alignment");
            return true;
        }
        if (!sourcePlayer.isRacialKing()) {
            sender.sendMessage("Only a King may vote for an emperor");
            return true;
        }
        if (fealtyPlayer.isRacialKing()) {
            sender.sendMessage("A King may not be an Emperor");
        }
        sourcePlayer.setVoteEmperor(fealtyTo.getUniqueId());
        return true;
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        sender.sendMessage(e.getMessage());
        return true;
    }
}
Also used : ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 18 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class Utils method patchNpcClasses.

private static void patchNpcClasses() {
    try {
        for (ISoliniaPatch patch : StateManager.getInstance().getConfigurationManager().getPatches()) {
            // Lookup npc and edit class
            String npcName = patch.getClasses().get(0);
            int rawClassId = Integer.parseInt(patch.getClasses().get(1));
            int convertedClass = convertRawClassToClass(rawClassId);
            ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getPetNPCByName(npcName);
            if (npc == null)
                continue;
            npc.setClassid(convertedClass);
            System.out.println("Updated NPC: " + npc.getName() + " to class " + convertedClass);
        }
    } catch (CoreStateInitException e) {
    // skip
    }
}
Also used : ISoliniaPatch(com.solinia.solinia.Interfaces.ISoliniaPatch) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC)

Example 19 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException 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 20 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class CommandPet method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    // TODO Auto-generated method stub
    if (sender instanceof Player) {
        try {
            Player player = (Player) sender;
            LivingEntity pet = StateManager.getInstance().getEntityManager().getPet(player);
            if (pet == null) {
                player.sendMessage("You don't have a pet");
                return true;
            }
            if (args.length > 0) {
                String petcommand = args[0];
                if (petcommand.equals("back")) {
                    Wolf c = (Wolf) pet;
                    player.setLastDamageCause(null);
                    player.sendMessage("* As you wish my master");
                    c.setTarget(null);
                }
            }
            player.sendMessage("Pet Name: " + pet.getName());
            player.sendMessage("Pet HP: " + pet.getHealth() + "/" + pet.getMaxHealth());
            ISoliniaLivingEntity petLivingEntity = SoliniaLivingEntityAdapter.Adapt(pet);
            EntityInsentient entityhandle = (EntityInsentient) ((org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity) pet).getHandle();
            double dmg = entityhandle.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).getValue();
            player.sendMessage("Pet DMG: " + dmg);
            player.sendMessage("STR: " + petLivingEntity.getStrength() + " STA: " + petLivingEntity.getStamina() + " AGI: " + petLivingEntity.getAgility() + " DEX: " + petLivingEntity.getDexterity() + " INT: " + petLivingEntity.getIntelligence() + " WIS: " + petLivingEntity.getWisdom() + " CHA: " + petLivingEntity.getCharisma());
            player.sendMessage("Pet Armour Class Mitigation : " + petLivingEntity.getMitigationAC());
            player.sendMessage("Pet Attack Value: " + petLivingEntity.getAttk());
            player.sendMessage("Pet Total Rune of: " + petLivingEntity.getRune());
            player.sendMessage("Active Effects:");
            SoliniaEntitySpells spells = StateManager.getInstance().getEntityManager().getActiveEntitySpells(pet);
            for (SoliniaActiveSpell activeSpell : spells.getActiveSpells()) {
                ISoliniaSpell spell = StateManager.getInstance().getConfigurationManager().getSpell(activeSpell.getSpellId());
                String removetext = "";
                ChatColor spellcolor = ChatColor.GREEN;
                if (spell.isBeneficial()) {
                    removetext = "Removable spell";
                } else {
                    removetext = "Unremovable spell";
                    spellcolor = ChatColor.RED;
                }
                TextComponent tc = new TextComponent();
                tc.setText("- " + spellcolor + spell.getName() + ChatColor.RESET + " " + activeSpell.getTicksLeft() + " ticks left - ");
                TextComponent tc2 = new TextComponent();
                tc2.setText(removetext);
                tc.addExtra(tc2);
                sender.spigot().sendMessage(tc);
            }
            return true;
        } catch (CoreStateInitException e) {
        }
    }
    return true;
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) Player(org.bukkit.entity.Player) ISoliniaSpell(com.solinia.solinia.Interfaces.ISoliniaSpell) EntityInsentient(net.minecraft.server.v1_12_R1.EntityInsentient) SoliniaEntitySpells(com.solinia.solinia.Models.SoliniaEntitySpells) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) SoliniaLivingEntity(com.solinia.solinia.Models.SoliniaLivingEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) Wolf(org.bukkit.entity.Wolf) ChatColor(net.md_5.bungee.api.ChatColor) SoliniaActiveSpell(com.solinia.solinia.Models.SoliniaActiveSpell)

Aggregations

CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)216 Player (org.bukkit.entity.Player)114 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)99 ISoliniaNPC (com.solinia.solinia.Interfaces.ISoliniaNPC)43 CommandSender (org.bukkit.command.CommandSender)42 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)41 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)36 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)36 LivingEntity (org.bukkit.entity.LivingEntity)32 ArrayList (java.util.ArrayList)31 Entity (org.bukkit.entity.Entity)21 ItemStack (org.bukkit.inventory.ItemStack)20 SoliniaItemException (com.solinia.solinia.Exceptions.SoliniaItemException)17 ISoliniaSpell (com.solinia.solinia.Interfaces.ISoliniaSpell)16 EventHandler (org.bukkit.event.EventHandler)16 Timestamp (java.sql.Timestamp)13 TextComponent (net.md_5.bungee.api.chat.TextComponent)12 CraftEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity)11 CraftLivingEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity)11 PathEntity (net.minecraft.server.v1_12_R1.PathEntity)10