Search in sources :

Example 46 with ISoliniaPlayer

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

the class SoliniaLivingEntity method getWisdom.

@Override
public int getWisdom() {
    if (getNpcid() < 1 && !isPlayer())
        return 1;
    try {
        if (getNpcid() > 0) {
            ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
            if (npc == null)
                return 1;
            int stat = npc.getLevel() * 5;
            stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "WISDOM");
            if (stat > getMaxStat("WISDOM"))
                stat = getMaxStat("WISDOM");
            return stat;
        }
        if (isPlayer()) {
            ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
            if (solplayer == null)
                return 1;
            int stat = 1;
            if (solplayer.getRace() != null)
                stat += solplayer.getRace().getWisdom();
            stat += solplayer.getTotalItemStat("WISDOM");
            stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "WISDOM");
            stat += Utils.getTotalAAEffectStat(this.getBukkitLivingEntity(), "WISDOM");
            if (stat > getMaxStat("WISDOM"))
                stat = getMaxStat("WISDOM");
            return stat;
        }
    } catch (CoreStateInitException e) {
        return 1;
    }
    return 1;
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 47 with ISoliniaPlayer

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

the class SoliniaLivingEntity method getStamina.

@Override
public int getStamina() {
    if (getNpcid() < 1 && !isPlayer())
        return 1;
    try {
        if (getNpcid() > 0) {
            ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
            if (npc == null)
                return 1;
            int stat = npc.getLevel() * 5;
            stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "STAMINA");
            if (stat > getMaxStat("STAMINA"))
                stat = getMaxStat("STAMINA");
            return stat;
        }
        if (isPlayer()) {
            ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
            if (solplayer == null)
                return 1;
            int stat = 1;
            if (solplayer.getRace() != null)
                stat += solplayer.getRace().getStamina();
            stat += solplayer.getTotalItemStat("STAMINA");
            stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "STAMINA");
            stat += Utils.getTotalAAEffectStat(this.getBukkitLivingEntity(), "STAMINA");
            if (stat > getMaxStat("STAMINA"))
                stat = getMaxStat("STAMINA");
            return stat;
        }
    } catch (CoreStateInitException e) {
        return 1;
    }
    return 1;
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 48 with ISoliniaPlayer

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

the class SoliniaLivingEntity method getCharisma.

@Override
public int getCharisma() {
    if (getNpcid() < 1 && !isPlayer())
        return 1;
    try {
        if (getNpcid() > 0) {
            ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
            if (npc == null)
                return 1;
            int stat = npc.getLevel() * 5;
            stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "CHARISMA");
            if (stat > getMaxStat("CHARISMA"))
                stat = getMaxStat("CHARISMA");
            return stat;
        }
        if (isPlayer()) {
            ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
            if (solplayer == null)
                return 1;
            int stat = 1;
            if (solplayer.getRace() != null)
                stat += solplayer.getRace().getCharisma();
            stat += solplayer.getTotalItemStat("CHARISMA");
            stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "CHARISMA");
            stat += Utils.getTotalAAEffectStat(this.getBukkitLivingEntity(), "CHARISMA");
            if (stat > getMaxStat("CHARISMA"))
                stat = getMaxStat("CHARISMA");
            return stat;
        }
    } catch (CoreStateInitException e) {
        return 1;
    }
    return 1;
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 49 with ISoliniaPlayer

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

the class PlayerRegenTickTimer method grantPlayerRegenBonuses.

private void grantPlayerRegenBonuses(Player player) {
    if (player.isDead())
        return;
    // Apply Crouch Mana Regen Bonus
    int manaregen = 1;
    ISoliniaPlayer solplayer = null;
    try {
        solplayer = SoliniaPlayerAdapter.Adapt(player);
    } catch (CoreStateInitException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    if (solplayer == null)
        return;
    // a players mana regen based on if they are meditating (sneaking)
    manaregen += getPlayerMeditatingManaBonus(solplayer);
    ISoliniaAAAbility aa = null;
    try {
        if (solplayer.getAARanks().size() > 0)
            aa = StateManager.getInstance().getConfigurationManager().getFirstAAAbilityBySysname("MENTALCLARITY");
    } catch (CoreStateInitException e) {
    }
    int aamanaregenrank = 0;
    if (aa != null) {
        if (solplayer.getAARanks().size() > 0)
            aamanaregenrank = Utils.getRankOfAAAbility(player, aa);
        manaregen += aamanaregenrank;
    }
    ISoliniaAAAbility emaa = null;
    try {
        if (solplayer.getAARanks().size() > 0)
            emaa = StateManager.getInstance().getConfigurationManager().getFirstAAAbilityBySysname("MENTALCLARITY");
    } catch (CoreStateInitException e) {
    }
    int emaamanaregenrank = 0;
    if (emaa != null) {
        if (solplayer.getAARanks().size() > 0)
            emaamanaregenrank = Utils.getRankOfAAAbility(player, emaa);
        manaregen += emaamanaregenrank;
    }
    manaregen += solplayer.getItemMpRegenBonuses();
    // Hp and Mana Regen from Items
    int hpregen = 0;
    ISoliniaAAAbility hpaa = null;
    try {
        hpaa = StateManager.getInstance().getConfigurationManager().getFirstAAAbilityBySysname("INNATEREGENERATION");
    } catch (CoreStateInitException e) {
    }
    int aahpregenrank = 0;
    if (hpaa != null) {
        aahpregenrank = Utils.getRankOfAAAbility(player, hpaa);
        hpregen += aahpregenrank;
    }
    hpregen += solplayer.getItemHpRegenBonuses();
    // Process HP Regeneration
    if (hpregen > 0) {
        int amount = (int) Math.round(player.getHealth()) + hpregen;
        if (amount > player.getMaxHealth()) {
            amount = (int) Math.round(player.getMaxHealth());
        }
        if (amount < 0)
            amount = 0;
        player.setHealth(amount);
    }
    // Process Mana Regeneration
    // System.out.println(player.getName() + " was found to have " + manaregen + " mana regen");
    solplayer.increasePlayerMana(manaregen);
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ISoliniaAAAbility(com.solinia.solinia.Interfaces.ISoliniaAAAbility)

Example 50 with ISoliniaPlayer

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

the class ScoreboardUtils method UpdateGroupScoreboard.

public static void UpdateGroupScoreboard(UUID uuid, ISoliniaGroup group) {
    if (StateManager.getInstance().getScoreboard(Bukkit.getPlayer(uuid)).getObjective("playercard") != null)
        StateManager.getInstance().getScoreboard(Bukkit.getPlayer(uuid)).getObjective("playercard").unregister();
    Objective objective = StateManager.getInstance().getScoreboard(Bukkit.getPlayer(uuid)).registerNewObjective("playercard", "dummy");
    objective.setDisplaySlot(DisplaySlot.SIDEBAR);
    objective.setDisplayName("Party");
    if (StateManager.getInstance().getScoreboard(Bukkit.getPlayer(uuid)).getObjective("health") != null)
        StateManager.getInstance().getScoreboard(Bukkit.getPlayer(uuid)).getObjective("health").unregister();
    Objective health = StateManager.getInstance().getScoreboard(Bukkit.getPlayer(uuid)).registerNewObjective("health", "health");
    health.setDisplayName(ChatColor.RED + "❤");
    health.setDisplaySlot(DisplaySlot.BELOW_NAME);
    if (group != null)
        for (UUID groupmemberuuid : group.getMembers()) {
            try {
                ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(Bukkit.getPlayer(groupmemberuuid));
                if (groupmemberuuid.equals(group.getOwner())) {
                    Score score = objective.getScore(ChatColor.GOLD + solplayer.getFullName() + "");
                    score.setScore(solplayer.getLevel());
                } else {
                    Score score = objective.getScore(ChatColor.WHITE + solplayer.getFullName() + "");
                    score.setScore(solplayer.getLevel());
                }
            } catch (CoreStateInitException e) {
                e.printStackTrace();
            }
        }
}
Also used : Objective(org.bukkit.scoreboard.Objective) Score(org.bukkit.scoreboard.Score) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) UUID(java.util.UUID)

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