forked from SteamWar/SteamWar
86 lines
2.8 KiB
Java
86 lines
2.8 KiB
Java
/*
|
|
* This file is a part of the SteamWar software.
|
|
*
|
|
* Copyright (C) 2025 SteamWar.de-Serverteam
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package de.steamwar.lobby.particle.elements;
|
|
|
|
import de.steamwar.lobby.particle.ParticleElement;
|
|
import de.steamwar.lobby.particle.ParticleTickData;
|
|
import org.bukkit.Location;
|
|
import org.bukkit.Particle;
|
|
|
|
public class SimpleParticle implements ParticleElement {
|
|
|
|
private final Particle particle;
|
|
private boolean customVelocity = false;
|
|
private float vx;
|
|
private float vy;
|
|
private float vz;
|
|
private double time = 1;
|
|
private int count = 5;
|
|
|
|
public SimpleParticle(Particle particle) {
|
|
this.particle = particle;
|
|
}
|
|
|
|
public SimpleParticle(Particle particle, float vx, float vy, float vz) {
|
|
this.particle = particle;
|
|
this.customVelocity = true;
|
|
this.vx = vx;
|
|
this.vy = vy;
|
|
this.vz = vz;
|
|
}
|
|
|
|
public SimpleParticle(Particle particle, float vx, float vy, float vz, double time) {
|
|
this.particle = particle;
|
|
this.customVelocity = true;
|
|
this.vx = vx;
|
|
this.vy = vy;
|
|
this.vz = vz;
|
|
this.time = time;
|
|
}
|
|
|
|
public SimpleParticle(Particle particle, float vx, float vy, float vz, double time, int count) {
|
|
this.particle = particle;
|
|
this.customVelocity = true;
|
|
this.vx = vx;
|
|
this.vy = vy;
|
|
this.vz = vz;
|
|
this.time = time;
|
|
this.count = count;
|
|
}
|
|
|
|
public SimpleParticle(Particle particle, double time, int count) {
|
|
this.particle = particle;
|
|
this.time = time;
|
|
this.count = count;
|
|
}
|
|
|
|
@Override
|
|
public void tick(ParticleTickData particleTickData) {
|
|
Location location = particleTickData.getLocation().add(0.0, 0.2, 0.0);
|
|
display(location, particleTickData.getPlayer(), particleTickData.isOnlySelf(), particleTickData.isOnlyOthers(), player -> {
|
|
if (customVelocity) {
|
|
player.spawnParticle(particle, location, count, vx, vy, vz, time);
|
|
} else {
|
|
player.spawnParticle(particle, location, count);
|
|
}
|
|
});
|
|
}
|
|
}
|