Search in sources :

Example 1 with SoliniaEntitySpells

use of com.solinia.solinia.Models.SoliniaEntitySpells 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)

Example 2 with SoliniaEntitySpells

use of com.solinia.solinia.Models.SoliniaEntitySpells 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 3 with SoliniaEntitySpells

use of com.solinia.solinia.Models.SoliniaEntitySpells in project solinia3-core by mixxit.

the class Utils method getActiveSpellEffectsRemainingValue.

public static int getActiveSpellEffectsRemainingValue(LivingEntity livingEntity, SpellEffectType effectType) {
    int totalRemaining = 0;
    SoliniaEntitySpells effects;
    try {
        effects = StateManager.getInstance().getEntityManager().getActiveEntitySpells(livingEntity);
        for (SoliniaActiveSpell activeSpell : effects.getActiveSpells()) {
            for (ActiveSpellEffect effect : activeSpell.getActiveSpellEffects()) {
                if (!(effect.getSpellEffectType().equals(effectType)))
                    continue;
                totalRemaining += effect.getRemainingValue();
            }
        }
    } catch (CoreStateInitException e) {
    // skip
    }
    return totalRemaining;
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) SoliniaEntitySpells(com.solinia.solinia.Models.SoliniaEntitySpells) SoliniaActiveSpell(com.solinia.solinia.Models.SoliniaActiveSpell) ActiveSpellEffect(com.solinia.solinia.Models.ActiveSpellEffect)

Example 4 with SoliniaEntitySpells

use of com.solinia.solinia.Models.SoliniaEntitySpells in project solinia3-core by mixxit.

the class Utils method getActiveSpellEffects.

public static List<ActiveSpellEffect> getActiveSpellEffects(LivingEntity livingEntity, SpellEffectType effectType) {
    List<ActiveSpellEffect> returnEffects = new ArrayList<ActiveSpellEffect>();
    SoliniaEntitySpells effects;
    try {
        effects = StateManager.getInstance().getEntityManager().getActiveEntitySpells(livingEntity);
        for (SoliniaActiveSpell activeSpell : effects.getActiveSpells()) {
            for (ActiveSpellEffect effect : activeSpell.getActiveSpellEffects()) {
                if (!(effect.getSpellEffectType().equals(effectType)))
                    continue;
                returnEffects.add(effect);
            }
        }
    } catch (CoreStateInitException e) {
    // skip
    }
    return returnEffects;
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ArrayList(java.util.ArrayList) SoliniaEntitySpells(com.solinia.solinia.Models.SoliniaEntitySpells) ActiveSpellEffect(com.solinia.solinia.Models.ActiveSpellEffect) SoliniaActiveSpell(com.solinia.solinia.Models.SoliniaActiveSpell)

Aggregations

CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)4 SoliniaActiveSpell (com.solinia.solinia.Models.SoliniaActiveSpell)4 SoliniaEntitySpells (com.solinia.solinia.Models.SoliniaEntitySpells)4 ISoliniaSpell (com.solinia.solinia.Interfaces.ISoliniaSpell)2 ActiveSpellEffect (com.solinia.solinia.Models.ActiveSpellEffect)2 ChatColor (net.md_5.bungee.api.ChatColor)2 TextComponent (net.md_5.bungee.api.chat.TextComponent)2 Player (org.bukkit.entity.Player)2 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)1 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)1 SoliniaLivingEntity (com.solinia.solinia.Models.SoliniaLivingEntity)1 Timestamp (java.sql.Timestamp)1 LocalDateTime (java.time.LocalDateTime)1 ArrayList (java.util.ArrayList)1 ClickEvent (net.md_5.bungee.api.chat.ClickEvent)1 EntityInsentient (net.minecraft.server.v1_12_R1.EntityInsentient)1 LivingEntity (org.bukkit.entity.LivingEntity)1 Wolf (org.bukkit.entity.Wolf)1