Search in sources :

Example 6 with SourceLocation

use of com.elmakers.mine.bukkit.magic.SourceLocation in project MagicPlugin by elBukkit.

the class EffectPlayer method performEffects.

@SuppressWarnings("deprecation")
protected void performEffects(DynamicLocation source, DynamicLocation target) {
    Location sourceLocation = source == null ? null : source.getLocation();
    if (sourceLocation == null)
        return;
    Entity sourceEntity = source == null ? null : source.getEntity();
    if (requireEntity && sourceEntity == null)
        return;
    if (effectLib != null && effectLibConfig != null) {
        EffectLibPlay play = new EffectLibPlay(effectLib.play(effectLibConfig, this, source, target, parameterMap));
        if (currentEffects != null) {
            currentEffects.add(play);
        }
    }
    if (effect != null) {
        int data = effectData == null ? 0 : effectData;
        if ((effect == Effect.STEP_SOUND) && effectData == null) {
            Material material = getWorkingMaterial().getMaterial();
            // Check for potential bad materials, this can get really hairy (client crashes)
            if (!material.isSolid()) {
                return;
            }
            data = material.getId();
        }
        sourceLocation.getWorld().playEffect(sourceLocation, effect, data);
    }
    if (entityEffect != null && sourceEntity != null) {
        sourceEntity.playEffect(entityEffect);
    }
    if (sound != null) {
        if (broadcastSound) {
            sound.play(plugin, sourceLocation);
        } else if (sourceEntity != null) {
            sound.play(plugin, sourceEntity);
        }
    }
    if (fireworkEffect != null) {
        EffectUtils.spawnFireworkEffect(plugin.getServer(), sourceLocation, fireworkEffect, fireworkPower, fireworkSilent);
    }
    if (particleType != null) {
        ParticleEffect useEffect = overrideParticle(particleType);
        Material material = getWorkingMaterial().getMaterial();
        Byte blockData = getWorkingMaterial().getBlockData();
        ParticleEffect.ParticleData data = useEffect.getData(material, blockData);
        if (data != null) {
            try {
                useEffect.display(data, sourceLocation, getColor1(), PARTICLE_RANGE, particleXOffset, particleYOffset, particleZOffset, particleData, particleCount);
            } catch (Exception ex) {
                if (effectLib.isDebugEnabled()) {
                    ex.printStackTrace();
                }
            }
        } else {
            if (!useEffect.requiresData()) {
                try {
                    useEffect.display(data, sourceLocation, getColor1(), PARTICLE_RANGE, particleXOffset, particleYOffset, particleZOffset, particleData, particleCount);
                } catch (Exception ex) {
                    if (effectLib.isDebugEnabled()) {
                        ex.printStackTrace();
                    }
                }
            }
        }
    }
}
Also used : ParticleEffect(de.slikey.effectlib.util.ParticleEffect) Entity(org.bukkit.entity.Entity) Material(org.bukkit.Material) Location(org.bukkit.Location) SourceLocation(com.elmakers.mine.bukkit.magic.SourceLocation) DynamicLocation(de.slikey.effectlib.util.DynamicLocation)

Aggregations

SourceLocation (com.elmakers.mine.bukkit.magic.SourceLocation)6 ActionHandler (com.elmakers.mine.bukkit.action.ActionHandler)1 TargetType (com.elmakers.mine.bukkit.api.spell.TargetType)1 DynamicLocation (de.slikey.effectlib.util.DynamicLocation)1 ParticleEffect (de.slikey.effectlib.util.ParticleEffect)1 Location (org.bukkit.Location)1 Material (org.bukkit.Material)1 Entity (org.bukkit.entity.Entity)1