Search in sources :

Example 91 with CoreStateInitException

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

the class SoliniaActiveSpell method applySenseDead.

private void applySenseDead(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
    try {
        for (Entity e : this.getLivingEntity().getNearbyEntities(100, 100, 100)) {
            if (!(e instanceof LivingEntity))
                continue;
            ISoliniaLivingEntity solEntity = SoliniaLivingEntityAdapter.Adapt((LivingEntity) e);
            if (!solEntity.isUndead())
                continue;
            Vector dir = ((LivingEntity) e).getLocation().clone().subtract(getLivingEntity().getEyeLocation()).toVector();
            Location loc = getLivingEntity().getLocation().setDirection(dir);
            getLivingEntity().teleport(loc);
            return;
        }
    } catch (CoreStateInitException e) {
    }
}
Also used : CraftLivingEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) CraftLivingEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) Entity(org.bukkit.entity.Entity) CraftEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity) LivingEntity(org.bukkit.entity.LivingEntity) PathEntity(net.minecraft.server.v1_12_R1.PathEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location)

Example 92 with CoreStateInitException

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

the class SoliniaActiveSpell method applySuccor.

private void applySuccor(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
    if (!(getLivingEntity() instanceof Player))
        return;
    ISoliniaPlayer solPlayer;
    try {
        solPlayer = SoliniaPlayerAdapter.Adapt((Player) getLivingEntity());
        SoliniaZone zone = solPlayer.getZone();
        if (zone == null) {
            getLivingEntity().sendMessage("Succor failed! Your body could not be pulled by an astral anchor (not found in a zone)!");
            return;
        }
        if (zone.getSuccorx() == 0 && zone.getSuccory() == 0 && zone.getSuccorz() == 0) {
            getLivingEntity().sendMessage("Succor failed! Your body could not be pulled by an astral anchor (zone has no succor point)!");
            return;
        }
        double x = (zone.getSuccorx());
        double y = (zone.getSuccory());
        double z = (zone.getSuccorz());
        Location loc = new Location(Bukkit.getWorld("world"), x, y, z);
        getLivingEntity().teleport(loc);
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
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) Location(org.bukkit.Location)

Example 93 with CoreStateInitException

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

the class SoliniaActiveSpell method applyReclaimPet.

private void applyReclaimPet(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
    if (!(getLivingEntity() instanceof Wolf))
        return;
    LivingEntity owner = (LivingEntity) ((Wolf) getLivingEntity()).getOwner();
    if (owner == null)
        return;
    if (!(owner instanceof Player))
        return;
    try {
        ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) owner);
        LivingEntity pet = StateManager.getInstance().getEntityManager().getPet((Player) owner);
        if (pet == null)
            return;
        solplayer.killAllPets();
        SoliniaPlayerAdapter.Adapt((Player) owner).increasePlayerMana(20);
    } catch (CoreStateInitException e) {
    // do nothing
    }
}
Also used : CraftLivingEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) Wolf(org.bukkit.entity.Wolf) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 94 with CoreStateInitException

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

the class SoliniaLivingEntity method doAttack.

private DamageHitInfo doAttack(Plugin plugin, ISoliniaLivingEntity defender, DamageHitInfo hit) {
    if (defender == null)
        return hit;
    // for riposte
    int originalDamage = hit.damage_done;
    hit = defender.avoidDamage(this, hit);
    if (hit.avoided == true) {
        if (hit.riposted == true && originalDamage > 0) {
            if (defender.isPlayer()) {
                ((Player) defender.getBukkitLivingEntity()).sendMessage(ChatColor.GRAY + "* You riposte the attack!");
                defender.tryIncreaseSkill("RIPOSTE", 1);
            }
            if (isPlayer()) {
                ((Player) getBukkitLivingEntity()).sendMessage(ChatColor.GRAY + "* " + defender.getBukkitLivingEntity().getCustomName() + " ripostes your attack!");
                damage(plugin, originalDamage, getBukkitLivingEntity());
            }
        }
        if (hit.dodged == true) {
            if (defender.isPlayer()) {
                ((Player) defender.getBukkitLivingEntity()).sendMessage(ChatColor.GRAY + "* You dodge the attack!");
                defender.tryIncreaseSkill("DODGE", 1);
            }
            if (isPlayer()) {
                ((Player) getBukkitLivingEntity()).sendMessage(ChatColor.GRAY + "* " + defender.getBukkitLivingEntity().getCustomName() + " dodges your attack!");
            }
        }
    }
    if (hit.damage_done >= 0) {
        if (defender.checkHitChance(this, hit)) {
            hit = defender.meleeMitigation(this, hit);
            if (hit.damage_done > 0) {
                hit = applyDamageTable(hit);
                hit = commonOutgoingHitSuccess(defender, hit);
            }
        } else {
            if (getBukkitLivingEntity() instanceof Player) {
                ((Player) getBukkitLivingEntity()).spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("You tried to hit " + defender.getBukkitLivingEntity().getCustomName() + ", but missed!"));
            }
            if (defender.getBukkitLivingEntity() instanceof Player) {
                ((Player) defender.getBukkitLivingEntity()).spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(getBukkitLivingEntity().getCustomName() + " tried to hit you, but missed!"));
                try {
                    ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) defender.getBukkitLivingEntity());
                    solplayer.tryIncreaseSkill("DEFENSE", 1);
                } catch (CoreStateInitException e) {
                // skip
                }
            }
            hit.damage_done = 0;
        }
    }
    return hit;
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 95 with CoreStateInitException

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

the class SoliniaLivingEntity method getProcChancePct.

@Override
public int getProcChancePct() {
    // (Dexterity / 35) / 25
    int dexterity = 75;
    if (this.getBukkitLivingEntity() instanceof Player) {
        try {
            ISoliniaPlayer player = SoliniaPlayerAdapter.Adapt((Player) this.getBukkitLivingEntity());
            if (player != null)
                dexterity = getDexterity();
        } catch (CoreStateInitException e) {
        }
    }
    if (this.getNpcid() > 0)
        dexterity = getDexterity();
    float dexdiv = (dexterity / 35);
    float fina = ((dexdiv / 25) * 100);
    return (int) Math.floor(fina);
}
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)

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