Search in sources :

Example 1 with Particle

use of com.gmail.stefvanschiedev.buildinggame.utils.particle.Particle in project buildinggame by stefvanschie.

the class ParticlesMenu method particleClick.

/**
 * Called whenever a user clicks on a particle item
 *
 * @param event the event called when clicking
 * @since 5.6.0
 */
public void particleClick(InventoryClickEvent event, org.bukkit.Particle particleType) {
    var player = (Player) event.getWhoClicked();
    var arena = ArenaManager.getInstance().getArena(player);
    if (arena == null)
        return;
    Location location = player.getLocation();
    Plot plot = arena.getPlot(player);
    if (particleType == org.bukkit.Particle.FALLING_DUST) {
        Particle particle;
        if (event.getCursor() == null) {
            particle = new FallingDustParticle(location, Bukkit.createBlockData(Material.SAND));
        } else {
            particle = new FallingDustParticle(location, Bukkit.createBlockData(event.getCursor().getType()));
        }
        plot.addParticle(particle, player);
    } else if (particleType == org.bukkit.Particle.REDSTONE) {
        plot.addParticle(new RedstoneParticle(location), player);
    } else {
        plot.addParticle(new Particle(location, particleType), player);
    }
    event.setCancelled(true);
}
Also used : FallingDustParticle(com.gmail.stefvanschiedev.buildinggame.utils.particle.FallingDustParticle) Particle(com.gmail.stefvanschiedev.buildinggame.utils.particle.Particle) RedstoneParticle(com.gmail.stefvanschiedev.buildinggame.utils.particle.RedstoneParticle) Player(org.bukkit.entity.Player) Plot(com.gmail.stefvanschiedev.buildinggame.utils.plot.Plot) RedstoneParticle(com.gmail.stefvanschiedev.buildinggame.utils.particle.RedstoneParticle) Location(org.bukkit.Location) FallingDustParticle(com.gmail.stefvanschiedev.buildinggame.utils.particle.FallingDustParticle)

Aggregations

FallingDustParticle (com.gmail.stefvanschiedev.buildinggame.utils.particle.FallingDustParticle)1 Particle (com.gmail.stefvanschiedev.buildinggame.utils.particle.Particle)1 RedstoneParticle (com.gmail.stefvanschiedev.buildinggame.utils.particle.RedstoneParticle)1 Plot (com.gmail.stefvanschiedev.buildinggame.utils.plot.Plot)1 Location (org.bukkit.Location)1 Player (org.bukkit.entity.Player)1