Advertisement
broken-arrow

Untitled

Oct 15th, 2021
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. public class SpawnContainerEffects implements heavyLoad {
  2.  
  3. private final Set<Location> location;
  4. private final Location containerLocation;
  5. private final List<String> effectType;
  6. private final long time;
  7.  
  8. private final ContainerRegistryAPI registry = ContainerRegistryAPI.getInstance();
  9.  
  10.  
  11. public SpawnContainerEffects(Set<Location> location, Location containerLocation, List<String> effectType, Integer runTime) {
  12. this.location = location;
  13. this.containerLocation = containerLocation;
  14. this.effectType = effectType;
  15. time = System.currentTimeMillis() + (1000L * (runTime != null ? runTime : 5));
  16. }
  17.  
  18. private void spawnEffects() {
  19.  
  20. double X = this.containerLocation.getBlockX() + Math.random();
  21. double Y = this.containerLocation.getBlockY() + Math.random();
  22. double Z = this.containerLocation.getBlockZ() + Math.random();
  23. for (Location location : this.location) {
  24. if (this.effectType != null && !this.effectType.isEmpty())
  25. for (String particle : this.effectType) {
  26. location.getWorld().spawnParticle(Particle.valueOf(particle), X, Y, Z, 0, 0.0, 0.0, 0.0, 1.0);
  27. }
  28. else {
  29. Particle.DustOptions dustOptions = new Particle.DustOptions(Color.fromRGB(0, 127, 210), 0.7F);
  30. location.getWorld().spawnParticle(Particle.REDSTONE, location, 0, 0.0, 0.0, 0.0, 1.0, dustOptions);
  31. }
  32. }
  33. }
  34.  
  35. @Override
  36. public void compute() {
  37. spawnEffects();
  38. }
  39.  
  40. @Override
  41. public boolean reschedule() {
  42. return System.currentTimeMillis() <= rescheduleMaxRunTime();
  43. }
  44.  
  45. @Override
  46. public boolean computeWithDelay(int conter) {
  47. return conter % 13 == 0;
  48. }
  49.  
  50. @Override
  51. public long rescheduleMaxRunTime() {
  52. return time;
  53. }
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement