Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.broken.cheststorage.ChestStorage;
- import org.broken.cheststorage.api.ContainerRegistryAPI;
- import org.bukkit.Color;
- import org.bukkit.Location;
- import org.bukkit.Particle;
- import org.bukkit.entity.Player;
- import org.bukkit.scheduler.BukkitRunnable;
- import java.util.List;
- import java.util.Set;
- public class SpawnCustomEffects implements HeavyLoad {
- private final Set<Location> location;
- private final Location containerLocation;
- private Player player;
- private final List<String> typeOfeffect;
- private final long time;
- private double y = 0;
- private double angle = 0;
- private static final int MAX_MS_PER_TICK = 10;
- private final ContainerRegistryAPI registry = ContainerRegistryAPI.getInstance();
- public SpawnCustomEffects(Set<Location> location, Location containerLocation, List<String> typeOfeffect, Player player, Integer runTime) {
- this.location = location;
- this.containerLocation = containerLocation;
- this.player = player;
- this.typeOfeffect = typeOfeffect;
- time = System.currentTimeMillis() + (1000L * (runTime != null ? runTime : 10));
- }
- private void spawnEffects() {
- if (typeOfeffect.size() == 1)
- if (typeOfeffect.get(0).equals("Dubble_Helix") || typeOfeffect.get(0).equals("Helix"))
- new BukkitRunnable() {
- double maxRadius = 1.8;
- int maxHeight = 5;
- @Override
- public void run() {
- if (y < 1.5) {
- for (int a = 0; a < 60; a += 3) {
- for (int l = 0; l < 2; l++) {
- double x = Math.cos(Math.toRadians((angle + a) + 360 / 2 * (typeOfeffect.get(0).equals("Dubble_Helix") ? l : 0)));
- double z = Math.sin(Math.toRadians((angle + a) + 360 / 2 * (typeOfeffect.get(0).equals("Dubble_Helix") ? l : 0)));
- Particle.DustOptions dustOptions = new Particle.DustOptions(Color.fromRGB(0, 127, 210), 0.9F);
- containerLocation.getWorld().spawnParticle(Particle.REDSTONE, new Location(containerLocation.getWorld(), ((containerLocation.getX() + 0.5) + (x / maxRadius)), ((containerLocation.getY() + y) + a * (.25 / 60)), ((containerLocation.getZ() + 0.5) + (z / maxRadius))), 0, 0.0, 0.0, 0.0, 0.0, dustOptions);
- }
- }
- } else {
- angle = 0;
- y = 0;
- cancel();
- }
- angle += 30;
- y += 0.15;
- }
- }.runTaskTimer(ChestStorage.getInstance(), 0L, 4L);
- else {
- double X = this.containerLocation.getBlockX() + Math.random();
- double Y = this.containerLocation.getBlockY() + Math.random();
- double Z = this.containerLocation.getBlockZ() + Math.random();
- if (this.typeOfeffect != null && !this.typeOfeffect.isEmpty())
- for (String particle : this.typeOfeffect) {
- this.containerLocation.clone().add(0, 1, 0).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);
- this.containerLocation.getWorld().spawnParticle(Particle.REDSTONE, this.containerLocation.add(0, 1, 0), 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 % 5 == 0;
- }
- @Override
- public long rescheduleMaxRunTime() {
- return time;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement