Search in sources :

Example 1 with EffectPlayer

use of com.elmakers.mine.bukkit.effect.EffectPlayer in project MagicPlugin by elBukkit.

the class EffectVariable method play.

@Override
public void play() {
    playing.clear();
    if (brightnessMap.size() > 0) {
        double brightness = 0;
        Color color = getColor1();
        if (color != null) {
            brightness = color.getRed() / 255.0 + color.getBlue() / 255.0 + color.getGreen() / 255.0;
        }
        for (Map.Entry<Double, Collection<EffectPlayer>> entry : brightnessMap.entrySet()) {
            if (brightness < entry.getKey()) {
                for (EffectPlayer player : entry.getValue()) {
                    // Set scale
                    player.setScale(scale);
                    // Set material and color
                    player.setMaterial(getWorkingMaterial());
                    player.setColor(getColor1());
                    player.setParticleOverride(particleOverride == null ? null : particleOverride.name());
                    player.start(getOrigin(), getOriginEntity(), getTarget(), getTargetEntity());
                    playing.add(player);
                }
                break;
            }
        }
    }
}
Also used : Color(org.bukkit.Color) Collection(java.util.Collection) EffectPlayer(com.elmakers.mine.bukkit.effect.EffectPlayer) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 2 with EffectPlayer

use of com.elmakers.mine.bukkit.effect.EffectPlayer in project MagicPlugin by elBukkit.

the class WandUpgradePath method playEffects.

protected void playEffects(Mage mage, String effectType) {
    Collection<EffectPlayer> players = effects.get(effectType);
    if (players == null || mage == null)
        return;
    Entity sourceEntity = mage.getEntity();
    Location mageLocation = mage.getEyeLocation();
    for (EffectPlayer player : players) {
        player.setColor(mage.getEffectColor());
        player.start(mageLocation, sourceEntity, null, null);
    }
}
Also used : Entity(org.bukkit.entity.Entity) EffectPlayer(com.elmakers.mine.bukkit.effect.EffectPlayer) Location(org.bukkit.Location)

Example 3 with EffectPlayer

use of com.elmakers.mine.bukkit.effect.EffectPlayer in project MagicPlugin by elBukkit.

the class EffectVariable method load.

@Override
public void load(Plugin plugin, ConfigurationSection configuration) {
    super.load(plugin, configuration);
    playAtOrigin = false;
    playAtTarget = false;
    playAtAllTargets = false;
    ConfigurationSection brightness = ConfigurationUtils.getConfigurationSection(configuration, "brightness");
    Collection<String> keys = brightness.getKeys(false);
    for (String key : keys) {
        try {
            double level = Double.parseDouble(key);
            Collection<EffectPlayer> childPlayers = EffectPlayer.loadEffects(plugin, brightness, key);
            brightnessMap.put(level, childPlayers);
            for (EffectPlayer childPlayer : childPlayers) {
                playAtOrigin |= childPlayer.playsAtOrigin();
                playAtAllTargets |= childPlayer.playsAtAllTargets();
                playAtTarget |= childPlayer.playsAtTarget();
            }
        } catch (Exception ignored) {
        }
    }
}
Also used : EffectPlayer(com.elmakers.mine.bukkit.effect.EffectPlayer) ConfigurationSection(org.bukkit.configuration.ConfigurationSection)

Aggregations

EffectPlayer (com.elmakers.mine.bukkit.effect.EffectPlayer)3 Collection (java.util.Collection)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Color (org.bukkit.Color)1 Location (org.bukkit.Location)1 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)1 Entity (org.bukkit.entity.Entity)1