Search in sources :

Example 41 with ISoliniaPlayer

use of com.solinia.solinia.Interfaces.ISoliniaPlayer 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 42 with ISoliniaPlayer

use of com.solinia.solinia.Interfaces.ISoliniaPlayer 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 43 with ISoliniaPlayer

use of com.solinia.solinia.Interfaces.ISoliniaPlayer 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 44 with ISoliniaPlayer

use of com.solinia.solinia.Interfaces.ISoliniaPlayer 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)

Example 45 with ISoliniaPlayer

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

the class SoliniaLivingEntity method getMaxHP.

@Override
public double getMaxHP() {
    if (getNpcid() < 1 && !isPlayer())
        return 1;
    double statHp = Utils.getStatMaxHP(getClassObj(), getLevel(), getStamina());
    double itemHp = getItemHp();
    double totalHp = statHp + itemHp;
    try {
        if (getNpcid() > 0) {
            ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
            if (npc == null)
                return totalHp;
            totalHp += Utils.getTotalEffectTotalHP(this.getBukkitLivingEntity());
            if (npc.isBoss()) {
                totalHp += (Utils.getBossHPMultiplier() * npc.getLevel());
            }
            if (npc.isHeroic()) {
                totalHp += (Utils.getHeroicHPMultiplier() * npc.getLevel());
            }
            if (npc.isRaidboss()) {
                totalHp += (Utils.getRaidBossHPMultiplier() * npc.getLevel());
            }
            if (npc.isRaidheroic()) {
                totalHp += (Utils.getRaidHeroicHPMultiplier() * npc.getLevel());
            }
            return totalHp;
        }
        if (isPlayer()) {
            ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
            if (solplayer == null)
                return totalHp;
            totalHp += Utils.getTotalEffectTotalHP(this.getBukkitLivingEntity());
            // get AA hp bonus
            totalHp += Utils.getTotalAAEffectMaxHp(this.getBukkitLivingEntity());
            return totalHp;
        }
    } catch (CoreStateInitException e) {
        return totalHp;
    }
    return totalHp;
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Aggregations

ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)89 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)85 Player (org.bukkit.entity.Player)57 ISoliniaNPC (com.solinia.solinia.Interfaces.ISoliniaNPC)16 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)13 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)12 EventHandler (org.bukkit.event.EventHandler)11 LivingEntity (org.bukkit.entity.LivingEntity)10 ArrayList (java.util.ArrayList)9 UUID (java.util.UUID)9 SoliniaItemException (com.solinia.solinia.Exceptions.SoliniaItemException)8 TextComponent (net.md_5.bungee.api.chat.TextComponent)8 ItemStack (org.bukkit.inventory.ItemStack)8 CommandSender (org.bukkit.command.CommandSender)5 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)5 Entity (org.bukkit.entity.Entity)5 Timestamp (java.sql.Timestamp)4 LocalDateTime (java.time.LocalDateTime)4 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)4 HoverEvent (net.md_5.bungee.api.chat.HoverEvent)4