Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SpawnContainerEffects implements heavyLoad {
- private final Set<Location> location;
- private final Location containerLocation;
- private final List<String> effectType;
- private final long time;
- private final ContainerRegistryAPI registry = ContainerRegistryAPI.getInstance();
- public SpawnContainerEffects(Set<Location> location, Location containerLocation, List<String> effectType, Integer runTime) {
- this.location = location;
- this.containerLocation = containerLocation;
- this.effectType = effectType;
- time = System.currentTimeMillis() + (1000L * (runTime != null ? runTime : 5));
- }
- private void spawnEffects() {
- double X = this.containerLocation.getBlockX() + Math.random();
- double Y = this.containerLocation.getBlockY() + Math.random();
- double Z = this.containerLocation.getBlockZ() + Math.random();
- for (Location location : this.location) {
- if (this.effectType != null && !this.effectType.isEmpty())
- for (String particle : this.effectType) {
- location.getWorld().spawnParticle(Particle.valueOf(particle), X, Y, Z, 0, 0.0, 0.0, 0.0, 1.0);
- }
- else {
- Particle.DustOptions dustOptions = new Particle.DustOptions(Color.fromRGB(0, 127, 210), 0.7F);
- location.getWorld().spawnParticle(Particle.REDSTONE, location, 0, 0.0, 0.0, 0.0, 1.0, dustOptions);
- }
- }
- }
- @Override
- public void compute() {
- spawnEffects();
- }
- @Override
- public boolean reschedule() {
- return System.currentTimeMillis() <= rescheduleMaxRunTime();
- }
- @Override
- public boolean computeWithDelay(int conter) {
- return conter % 13 == 0;
- }
- @Override
- public long rescheduleMaxRunTime() {
- return time;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement