Search in sources :

Example 71 with CoreStateInitException

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

the class SoliniaLivingEntity method ACSum.

@Override
public int ACSum() {
    double ac = 0;
    ac += getTotalItemAC();
    double shield_ac = 0;
    // EQ math
    ac = (ac * 4) / 3;
    // anti-twink
    if (isPlayer() && getLevel() < 50)
        ac = Math.min(ac, 25 + 6 * getLevel());
    ac = Math.max(0, ac + getClassRaceACBonus());
    if (isNPC()) {
        try {
            ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
            ac += npc.getAC();
        } catch (CoreStateInitException e) {
        // dont get ac from npc type
        }
        // TODO Pet avoidance
        ac += getSkill("DEFENSE") / 5;
        double spell_aa_ac = 0;
        // TODO AC AA and Spell bonuses
        spell_aa_ac += getSpellBonuses(SpellEffectType.ArmorClass);
        spell_aa_ac += Utils.getTotalAAEffectEffectType(getBukkitLivingEntity(), SpellEffectType.ArmorClass);
        if (getClassObj() != null) {
            if (getClassObj().getName().equals("ENCHANTER") || getClassObj().getName().equals("ENCHANTER")) {
                ac += spell_aa_ac / 3;
            } else {
                ac += spell_aa_ac / 4;
            }
        } else {
            ac += spell_aa_ac / 4;
        }
    } else {
        double spell_aa_ac = 0;
        // TODO AC AA and Spell bonuses
        spell_aa_ac += getSpellBonuses(SpellEffectType.ArmorClass);
        spell_aa_ac += Utils.getTotalAAEffectEffectType(getBukkitLivingEntity(), SpellEffectType.ArmorClass);
        if (getClassObj() != null) {
            if (getClassObj().getName().equals("ENCHANTER") || getClassObj().getName().equals("ENCHANTER")) {
                ac += getSkill("DEFENSE") / 2 + spell_aa_ac / 3;
            } else {
                ac += getSkill("DEFENSE") / 3 + spell_aa_ac / 4;
            }
        } else {
            ac += getSkill("DEFENSE") / 3 + spell_aa_ac / 4;
        }
    }
    if (getAgility() > 70)
        ac += getAgility() / 20;
    if (ac < 0)
        ac = 0;
    if (isPlayer()) {
        double softcap = getACSoftcap();
        double returns = getSoftcapReturns();
        // TODO itembonuses
        int total_aclimitmod = 0;
        total_aclimitmod += getSpellBonuses(SpellEffectType.CombatStability);
        total_aclimitmod += Utils.getTotalAAEffectEffectType(getBukkitLivingEntity(), SpellEffectType.CombatStability);
        if (total_aclimitmod > 0)
            softcap = (softcap * (100 + total_aclimitmod)) / 100;
        softcap += shield_ac;
        if (ac > softcap) {
            double over_cap = ac - softcap;
            ac = softcap + (over_cap * returns);
        }
    }
    return (int) ac;
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC)

Example 72 with CoreStateInitException

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

the class CommandEditZone method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player) && !(sender instanceof CommandSender))
        return false;
    if (sender instanceof Player) {
        Player player = (Player) sender;
        if (!player.isOp() && !player.hasPermission("solinia.editzone")) {
            player.sendMessage("You do not have permission to access this command");
            return false;
        }
    }
    if (args.length < 1) {
        sender.sendMessage("Insufficient arguments: zoneid");
        return false;
    }
    if (args.length == 0) {
        return false;
    }
    int zoneid = Integer.parseInt(args[0]);
    if (args.length == 1) {
        try {
            SoliniaZone zone = StateManager.getInstance().getConfigurationManager().getZone(zoneid);
            if (zone != null) {
                zone.sendZoneSettingsToSender(sender);
            } else {
                sender.sendMessage("Zone ID doesnt exist");
            }
            return true;
        } catch (CoreStateInitException e) {
            sender.sendMessage(e.getMessage());
        }
    }
    if (args.length < 3) {
        sender.sendMessage("Insufficient arguments: zoneid setting value");
        return false;
    }
    String setting = args[1];
    String value = args[2];
    if (zoneid < 1) {
        sender.sendMessage("Invalid zoneid");
        return false;
    }
    try {
        if (StateManager.getInstance().getConfigurationManager().getZone(zoneid) == null) {
            sender.sendMessage("Cannot locate zone id: " + zoneid);
            return false;
        }
        /*if (StateManager.getInstance().getConfigurationManager().getZone(zoneid).isOperatorCreated() && !sender.isOp())
			{
				sender.sendMessage("This zone was op created and you are not an op. Only ops can edit op zone items");
				return false;
			}*/
        StateManager.getInstance().getConfigurationManager().editZone(zoneid, setting, value);
        sender.sendMessage("Updating setting on Zone");
    } catch (InvalidZoneSettingException ne) {
        sender.sendMessage("Invalid zone setting: " + ne.getMessage());
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        sender.sendMessage(e.getMessage());
    }
    return true;
}
Also used : InvalidZoneSettingException(com.solinia.solinia.Exceptions.InvalidZoneSettingException) Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) CommandSender(org.bukkit.command.CommandSender) SoliniaZone(com.solinia.solinia.Models.SoliniaZone)

Example 73 with CoreStateInitException

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

the class CommandEffects method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (sender instanceof Player) {
        Player player = (Player) sender;
        try {
            SoliniaEntitySpells spells = StateManager.getInstance().getEntityManager().getActiveEntitySpells(player);
            if (spells == null)
                return true;
            if (args.length == 0) {
                player.sendMessage(ChatColor.GOLD + "Active Spell Effects on you:" + ChatColor.WHITE);
                ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
                if (solplayer.getExperienceBonusExpires() != null) {
                    System.out.println("Experience Bonus was not null: " + solplayer.getExperienceBonusExpires().toString());
                    LocalDateTime datetime = LocalDateTime.now();
                    Timestamp nowtimestamp = Timestamp.valueOf(datetime);
                    Timestamp expiretimestamp = solplayer.getExperienceBonusExpires();
                    if (expiretimestamp != null) {
                        System.out.println("Experience Bonus expire timestamp " + solplayer.getExperienceBonusExpires() + " vs Now: " + nowtimestamp.toString());
                        if (!nowtimestamp.after(expiretimestamp)) {
                            System.out.println("Experience bonus was after, displaying in effects");
                            int secondsleft = (int) Math.floor(Utils.compareTwoTimeStamps(expiretimestamp, nowtimestamp));
                            TextComponent tc = new TextComponent();
                            tc.setText("- " + ChatColor.GREEN + "100% Experience Potion" + ChatColor.RESET + " " + secondsleft + " seconds");
                            sender.spigot().sendMessage(tc);
                        }
                    }
                } else {
                    System.out.println("Experience Bonus was null");
                }
                for (SoliniaActiveSpell activeSpell : spells.getActiveSpells()) {
                    ISoliniaSpell spell = StateManager.getInstance().getConfigurationManager().getSpell(activeSpell.getSpellId());
                    String removetext = "";
                    ChatColor spellcolor = ChatColor.GREEN;
                    if (spell.isBeneficial()) {
                        removetext = "/effects remove " + spell.getId();
                    } 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);
                    if (spell.isBeneficial()) {
                        tc2.setText(ChatColor.GRAY + "Click here to remove" + ChatColor.RESET);
                        tc2.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, removetext));
                    }
                    tc.addExtra(tc2);
                    sender.spigot().sendMessage(tc);
                }
            } else {
                if (args.length < 2)
                    return true;
                int spellid = Integer.parseInt(args[1]);
                ISoliniaSpell spell = StateManager.getInstance().getConfigurationManager().getSpell(spellid);
                if (spell == null) {
                    player.sendMessage("That spell does not exist");
                    return true;
                }
                StateManager.getInstance().getEntityManager().removeSpellEffectsOfSpellId(plugin, player.getUniqueId(), spell.getId());
                if (!spell.isBeneficial()) {
                    player.sendMessage("Can only remove beneficial spells");
                    return true;
                }
                player.sendMessage("Spell Effect removed");
            }
        } catch (CoreStateInitException e) {
            player.sendMessage(e.getMessage());
        }
    }
    return true;
}
Also used : LocalDateTime(java.time.LocalDateTime) TextComponent(net.md_5.bungee.api.chat.TextComponent) Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ISoliniaSpell(com.solinia.solinia.Interfaces.ISoliniaSpell) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) SoliniaEntitySpells(com.solinia.solinia.Models.SoliniaEntitySpells) Timestamp(java.sql.Timestamp) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ChatColor(net.md_5.bungee.api.ChatColor) SoliniaActiveSpell(com.solinia.solinia.Models.SoliniaActiveSpell)

Example 74 with CoreStateInitException

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

the class CommandEmote method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (sender instanceof Player) {
        Player player = (Player) sender;
        if (args.length < 1) {
            player.sendMessage("Insufficient arguments (<emote>)");
            return false;
        }
        try {
            ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
            if (solplayer == null) {
                player.sendMessage("Failed to emote, player does not exist");
                return false;
            }
            StringBuilder builder = new StringBuilder();
            for (String value : args) {
                builder.append(value + " ");
            }
            String message = builder.toString();
            message = message.substring(0, message.length());
            if (message.equals("")) {
                return false;
            }
            message = message.replaceAll("(?i)fuck", "shelderhoof");
            message = message.replaceAll("(?i)shit", "qaraf");
            solplayer.emote(ChatColor.AQUA + "* " + solplayer.getFullName() + " " + message);
        } catch (CoreStateInitException e) {
            player.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 75 with CoreStateInitException

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

the class CommandIgnore method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (sender instanceof Player) {
        if (args.length < 1)
            return false;
        Player targetPlayer = Bukkit.getPlayer(args[0]);
        if (targetPlayer == null) {
            sender.sendMessage("Player is not online to ignore");
            return true;
        }
        if (targetPlayer.getUniqueId().equals(((Player) sender).getUniqueId())) {
            sender.sendMessage("Cannot ignore self");
            return true;
        }
        try {
            ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt((Player) sender);
            solPlayer.ignorePlayer(targetPlayer);
            sender.sendMessage("Done");
        } catch (CoreStateInitException e) {
            return false;
        }
        return true;
    }
    return false;
}
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)

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