Search in sources :

Example 1 with Particle

use of org.bukkit.Particle in project InfernalMobs by NyaaCat.

the class ParticleEffect method parse.

public static ParticleEffect parse(String effect) {
    try {
        final String[] split = effect.split(":");
        Particle p = Particle.valueOf(split[0]);
        final int data1 = Integer.parseInt(split[1]);
        final int data2 = Integer.parseInt(split[2]);
        return new ParticleEffect(p, data1, data2);
    } catch (Exception ex) {
        InfernalMobs.instance.getLogger().warning("Invalid particle effect: " + effect);
        return new ParticleEffect(Particle.LAVA, 1, 10);
    }
}
Also used : Particle(org.bukkit.Particle)

Example 2 with Particle

use of org.bukkit.Particle in project CommandHelper by EngineHub.

the class BukkitMCWorld method spawnParticle.

@Override
public void spawnParticle(MCLocation l, MCParticle pa, int count, double offsetX, double offsetY, double offsetZ, double velocity, Object data) {
    try {
        Particle type = Particle.valueOf(pa.name());
        Location loc = ((BukkitMCLocation) l).asLocation();
        if (data != null && type.getDataType().equals(ItemStack.class) && data instanceof MCItemStack) {
            w.spawnParticle(type, loc, count, offsetX, offsetY, offsetZ, velocity, ((MCItemStack) data).getHandle());
        } else {
            w.spawnParticle(type, loc, count, offsetX, offsetY, offsetZ, velocity);
        }
    } catch (NoClassDefFoundError ex) {
    // probably prior to 1.9
    }
}
Also used : Particle(org.bukkit.Particle) MCItemStack(com.laytonsmith.abstraction.MCItemStack) Location(org.bukkit.Location) MCLocation(com.laytonsmith.abstraction.MCLocation)

Example 3 with Particle

use of org.bukkit.Particle in project CommandHelper by EngineHub.

the class BukkitMCPlayer method spawnParticle.

@Override
public void spawnParticle(MCLocation l, MCParticle pa, int count, double offsetX, double offsetY, double offsetZ, double velocity, Object data) {
    try {
        Particle type = Particle.valueOf(pa.name());
        Location loc = ((BukkitMCLocation) l).asLocation();
        if (data != null && type.getDataType().equals(ItemStack.class) && data instanceof MCItemStack) {
            p.spawnParticle(type, loc, count, offsetX, offsetY, offsetZ, velocity, ((MCItemStack) data).getHandle());
        } else {
            p.spawnParticle(type, loc, count, offsetX, offsetY, offsetZ, velocity);
        }
    } catch (NoClassDefFoundError ex) {
    // probably prior to 1.9
    }
}
Also used : MCParticle(com.laytonsmith.abstraction.enums.MCParticle) Particle(org.bukkit.Particle) BukkitMCItemStack(com.laytonsmith.abstraction.bukkit.BukkitMCItemStack) MCItemStack(com.laytonsmith.abstraction.MCItemStack) BukkitMCLocation(com.laytonsmith.abstraction.bukkit.BukkitMCLocation) Location(org.bukkit.Location) MCLocation(com.laytonsmith.abstraction.MCLocation) BukkitMCLocation(com.laytonsmith.abstraction.bukkit.BukkitMCLocation)

Example 4 with Particle

use of org.bukkit.Particle in project MyMaid2 by jaoafa.

the class Event_NOConcretePowderToConcrete method onBlockFormEvent.

@EventHandler
public void onBlockFormEvent(BlockFormEvent event) {
    Block block = event.getBlock();
    if (block.getType() != Material.CONCRETE_POWDER) {
        return;
    }
    Location loc = block.getLocation();
    List<Particle> particles = new ArrayList<>(Arrays.asList(Particle.values()));
    particles.remove(Particle.MOB_APPEARANCE);
    Random rnd = new Random();
    int i = rnd.nextInt(particles.size());
    Particle particle = particles.get(i);
    loc.getWorld().spawnParticle(particle, loc, 30, 0.3, 0, 0.3);
    event.setCancelled(true);
}
Also used : Particle(org.bukkit.Particle) Random(java.util.Random) ArrayList(java.util.ArrayList) Block(org.bukkit.block.Block) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Particle (org.bukkit.Particle)4 Location (org.bukkit.Location)3 MCItemStack (com.laytonsmith.abstraction.MCItemStack)2 MCLocation (com.laytonsmith.abstraction.MCLocation)2 BukkitMCItemStack (com.laytonsmith.abstraction.bukkit.BukkitMCItemStack)1 BukkitMCLocation (com.laytonsmith.abstraction.bukkit.BukkitMCLocation)1 MCParticle (com.laytonsmith.abstraction.enums.MCParticle)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 Block (org.bukkit.block.Block)1 EventHandler (org.bukkit.event.EventHandler)1