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();
}
}
}
}
}
}
Aggregations