Advertisement
broken-arrow

Untitled

Oct 17th, 2021
961
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.40 KB | None | 0 0
  1.  
  2. import org.broken.cheststorage.ChestStorage;
  3. import org.broken.cheststorage.api.ContainerRegistryAPI;
  4. import org.bukkit.Color;
  5. import org.bukkit.Location;
  6. import org.bukkit.Particle;
  7. import org.bukkit.entity.Player;
  8. import org.bukkit.scheduler.BukkitRunnable;
  9.  
  10. import java.util.List;
  11. import java.util.Set;
  12.  
  13. public class SpawnCustomEffects implements HeavyLoad {
  14.  
  15.     private final Set<Location> location;
  16.     private final Location containerLocation;
  17.     private Player player;
  18.     private final List<String> typeOfeffect;
  19.     private final long time;
  20.     private double y = 0;
  21.     private double angle = 0;
  22.  
  23.     private static final int MAX_MS_PER_TICK = 10;
  24.     private final ContainerRegistryAPI registry = ContainerRegistryAPI.getInstance();
  25.  
  26.     public SpawnCustomEffects(Set<Location> location, Location containerLocation, List<String> typeOfeffect, Player player, Integer runTime) {
  27.         this.location = location;
  28.         this.containerLocation = containerLocation;
  29.         this.player = player;
  30.         this.typeOfeffect = typeOfeffect;
  31.         time = System.currentTimeMillis() + (1000L * (runTime != null ? runTime : 10));
  32.     }
  33.  
  34.     private void spawnEffects() {
  35.         if (typeOfeffect.size() == 1)
  36.             if (typeOfeffect.get(0).equals("Dubble_Helix") || typeOfeffect.get(0).equals("Helix"))
  37.                 new BukkitRunnable() {
  38.                     double maxRadius = 1.8;
  39.                     int maxHeight = 5;
  40.  
  41.                     @Override
  42.                     public void run() {
  43.                         if (y < 1.5) {
  44.                             for (int a = 0; a < 60; a += 3) {
  45.                                 for (int l = 0; l < 2; l++) {
  46.                                     double x = Math.cos(Math.toRadians((angle + a) + 360 / 2 * (typeOfeffect.get(0).equals("Dubble_Helix") ? l : 0)));
  47.                                     double z = Math.sin(Math.toRadians((angle + a) + 360 / 2 * (typeOfeffect.get(0).equals("Dubble_Helix") ? l : 0)));
  48.                                     Particle.DustOptions dustOptions = new Particle.DustOptions(Color.fromRGB(0, 127, 210), 0.9F);
  49.                                     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);
  50.                                 }
  51.                             }
  52.                         } else {
  53.                             angle = 0;
  54.                             y = 0;
  55.                             cancel();
  56.                         }
  57.  
  58.                         angle += 30;
  59.                         y += 0.15;
  60.  
  61.                     }
  62.                 }.runTaskTimer(ChestStorage.getInstance(), 0L, 4L);
  63.             else {
  64.                 double X = this.containerLocation.getBlockX() + Math.random();
  65.                 double Y = this.containerLocation.getBlockY() + Math.random();
  66.                 double Z = this.containerLocation.getBlockZ() + Math.random();
  67.                 if (this.typeOfeffect != null && !this.typeOfeffect.isEmpty())
  68.                     for (String particle : this.typeOfeffect) {
  69.                         this.containerLocation.clone().add(0, 1, 0).getWorld().spawnParticle(Particle.valueOf(particle), X, Y, Z, 0, 0.0, 0.0, 0.0, 1.0);
  70.                     }
  71.                 else {
  72.                     Particle.DustOptions dustOptions = new Particle.DustOptions(Color.fromRGB(0, 127, 210), 0.7F);
  73.                     this.containerLocation.getWorld().spawnParticle(Particle.REDSTONE, this.containerLocation.add(0, 1, 0), 0, 0.0, 0.0, 0.0, 1.0, dustOptions);
  74.                 }
  75.             }
  76.     }
  77.  
  78.  
  79.     @Override
  80.     public void compute() {
  81.         spawnEffects();
  82.     }
  83.  
  84.  
  85.     @Override
  86.     public boolean reschedule() {
  87.         return System.currentTimeMillis() <= rescheduleMaxRunTime();
  88.  
  89.     }
  90.  
  91.     @Override
  92.     public boolean computeWithDelay(int conter) {
  93.         return conter % 5 == 0;
  94.     }
  95.  
  96.     @Override
  97.     public long rescheduleMaxRunTime() {
  98.         return time;
  99.     }
  100. }
  101.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement