Search in sources :

Example 21 with ISoliniaLivingEntity

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

the class SoliniaActiveSpell method applySenseAnimal.

private void applySenseAnimal(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.isAnimal())
                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 22 with ISoliniaLivingEntity

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

the class SoliniaActiveSpell method applyCurrentMpSpellEffect.

private void applyCurrentMpSpellEffect(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
    if (!isOwnerPlayer())
        return;
    Entity sourceEntity = Bukkit.getEntity(getSourceUuid());
    if (sourceEntity == null)
        return;
    if (!(sourceEntity instanceof LivingEntity))
        return;
    LivingEntity sourceLivingEntity = (LivingEntity) sourceEntity;
    int instrument_mod = 0;
    try {
        ISoliniaLivingEntity sourceSoliniaLivingEntity = SoliniaLivingEntityAdapter.Adapt(sourceLivingEntity);
        if (sourceSoliniaLivingEntity != null) {
            instrument_mod = sourceSoliniaLivingEntity.getInstrumentMod(this.getSpell());
        }
    } catch (CoreStateInitException e) {
    // just skip it
    }
    int mpToRemove = soliniaSpell.calcSpellEffectValue(spellEffect, sourceLivingEntity, getLivingEntity(), casterLevel, getTicksLeft(), instrument_mod);
    try {
        ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(Bukkit.getPlayer(this.getOwnerUuid()));
        ISoliniaLivingEntity solentity = SoliniaLivingEntityAdapter.Adapt(Bukkit.getPlayer(this.getOwnerUuid()));
        int amount = (int) Math.round(solplayer.getMana()) + mpToRemove;
        if (amount > solentity.getMaxMP()) {
            amount = (int) Math.round(solentity.getMaxMP());
        }
        if (amount < 0)
            amount = 0;
        solplayer.setMana(amount);
    } catch (CoreStateInitException e) {
        e.printStackTrace();
    }
}
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) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 23 with ISoliniaLivingEntity

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

the class SoliniaActiveSpell method setActiveSpellEffects.

private void setActiveSpellEffects() {
    activeSpellEffects = new ArrayList<ActiveSpellEffect>();
    try {
        ISoliniaLivingEntity solOwner = SoliniaLivingEntityAdapter.Adapt((LivingEntity) Bukkit.getEntity(ownerUuid));
        ISoliniaLivingEntity solSource = SoliniaLivingEntityAdapter.Adapt((LivingEntity) Bukkit.getEntity(sourceUuid));
        if (solOwner == null)
            return;
        if (solSource == null)
            return;
        for (SpellEffect spellEffect : getSpell().getBaseSpellEffects()) {
            ActiveSpellEffect activeSpellEffect = new ActiveSpellEffect(getSpell(), spellEffect, solSource.getBukkitLivingEntity(), solOwner.getBukkitLivingEntity(), solSource.getLevel(), getTicksLeft());
            activeSpellEffects.add(activeSpellEffect);
        }
    } catch (CoreStateInitException e) {
    }
}
Also used : ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException)

Example 24 with ISoliniaLivingEntity

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

the class EntityManager method doNPCRandomChat.

@Override
public void doNPCRandomChat() {
    List<Integer> completedNpcsIds = new ArrayList<Integer>();
    for (Player player : Bukkit.getOnlinePlayers()) {
        for (Entity entity : player.getNearbyEntities(50, 50, 50)) {
            if (entity instanceof Player)
                continue;
            if (!(entity instanceof LivingEntity))
                continue;
            LivingEntity le = (LivingEntity) entity;
            if (!Utils.isLivingEntityNPC(le))
                continue;
            try {
                ISoliniaLivingEntity solle = SoliniaLivingEntityAdapter.Adapt(le);
                if (completedNpcsIds.contains(solle.getNpcid()))
                    continue;
                completedNpcsIds.add(solle.getNpcid());
                solle.doRandomChat();
            } catch (CoreStateInitException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
}
Also used : ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) SoliniaLivingEntity(com.solinia.solinia.Models.SoliniaLivingEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) SoliniaLivingEntity(com.solinia.solinia.Models.SoliniaLivingEntity) Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ArrayList(java.util.ArrayList)

Example 25 with ISoliniaLivingEntity

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

the class EntityManager method doNPCSpellCast.

@Override
public void doNPCSpellCast(Plugin plugin) {
    List<Integer> completedNpcsIds = new ArrayList<Integer>();
    for (Player player : Bukkit.getOnlinePlayers()) {
        for (Entity entityThatWillCast : player.getNearbyEntities(50, 50, 50)) {
            if (entityThatWillCast instanceof Player)
                continue;
            if (!(entityThatWillCast instanceof LivingEntity))
                continue;
            LivingEntity livingEntityThatWillCast = (LivingEntity) entityThatWillCast;
            if (!(entityThatWillCast instanceof Creature))
                continue;
            if (entityThatWillCast.isDead())
                continue;
            Creature creatureThatWillCast = (Creature) entityThatWillCast;
            if (creatureThatWillCast.getTarget() == null)
                continue;
            if (!Utils.isLivingEntityNPC(livingEntityThatWillCast))
                continue;
            try {
                ISoliniaLivingEntity solLivingEntityThatWillCast = SoliniaLivingEntityAdapter.Adapt(livingEntityThatWillCast);
                if (completedNpcsIds.contains(solLivingEntityThatWillCast.getNpcid()))
                    continue;
                completedNpcsIds.add(solLivingEntityThatWillCast.getNpcid());
                if (Utils.isEntityInLineOfSight(livingEntityThatWillCast, creatureThatWillCast.getTarget()))
                    solLivingEntityThatWillCast.doSpellCast(plugin, creatureThatWillCast.getTarget());
            } catch (CoreStateInitException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
}
Also used : ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) SoliniaLivingEntity(com.solinia.solinia.Models.SoliniaLivingEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) SoliniaLivingEntity(com.solinia.solinia.Models.SoliniaLivingEntity) Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Creature(org.bukkit.entity.Creature) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ArrayList(java.util.ArrayList)

Aggregations

ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)38 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)32 LivingEntity (org.bukkit.entity.LivingEntity)24 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)20 Player (org.bukkit.entity.Player)18 Entity (org.bukkit.entity.Entity)16 CraftEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity)8 ArrayList (java.util.ArrayList)7 PathEntity (net.minecraft.server.v1_12_R1.PathEntity)7 CraftLivingEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity)7 Creature (org.bukkit.entity.Creature)7 ISoliniaNPC (com.solinia.solinia.Interfaces.ISoliniaNPC)6 SoliniaLivingEntity (com.solinia.solinia.Models.SoliniaLivingEntity)6 Timestamp (java.sql.Timestamp)6 ISoliniaSpell (com.solinia.solinia.Interfaces.ISoliniaSpell)5 Wolf (org.bukkit.entity.Wolf)5 EventHandler (org.bukkit.event.EventHandler)5 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)4 LocalDateTime (java.time.LocalDateTime)3 TextComponent (net.md_5.bungee.api.chat.TextComponent)3