Advertisement
broken-arrow

Untitled

Oct 17th, 2021
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. public class SpawnContainerEffects implements HeavyLoad {
  2.  
  3. private final Set<Location> location;
  4. private final Set<Location> containerLocations;
  5. private final List<String> effectType;
  6. private final long time;
  7.  
  8. private final ContainerRegistryAPI registry = ContainerRegistryAPI.getInstance();
  9. PreferenceSettingsRegistery preferenceRegistery = PreferenceSettingsRegistery.getInstance();
  10.  
  11. public SpawnContainerEffects(Set<Location> location, Set<Location> containerLocations, List<String> effectType, Integer runTime) {
  12. this.location = location;
  13. this.containerLocations = containerLocations;
  14. this.effectType = effectType;
  15. time = System.currentTimeMillis() + (1000L * (runTime != null ? runTime : 2));
  16. }
  17.  
  18. private void spawnEffects() {
  19.  
  20. for (Location containerLocation : containerLocations) {
  21.  
  22. if (!containerLocation.getWorld().isChunkLoaded(containerLocation.getBlockX() >> 4, containerLocation.getBlockZ() >> 4))
  23. continue;
  24.  
  25. double X = containerLocation.getBlockX() + Math.random();
  26. double Y = containerLocation.getBlockY() + Math.random();
  27. double Z = containerLocation.getBlockZ() + Math.random();
  28.  
  29. if (preferenceRegistery.isEffectsOnContainer(registry.getPlayerUUID(containerLocation))) {
  30.  
  31. List<String> effectType = YamlSettingsContainers.getEffectTypeOnContainer(registry.getContainerFileName(containerLocation), registry.getCurrentUpdate(containerLocation));
  32. //for (Location location : this.location) {
  33. if (this.effectType != null && !this.effectType.isEmpty())
  34. for (String particle : this.effectType) {
  35. containerLocation.getWorld().spawnParticle(Particle.valueOf(particle), X, Y, Z, 0, 0.0, 0.0, 0.0, 1.0);
  36. }
  37. if (effectType != null && !effectType.isEmpty()) {
  38. //System.out.println("testkjbhkug " + containerLocation);
  39. for (String particle : effectType) {
  40. containerLocation.getWorld().spawnParticle(Particle.valueOf(particle), X, Y, Z, 0, 0.0, 0.0, 0.0, 1.0);
  41. }
  42. } else {
  43. Particle.DustOptions dustOptions = new Particle.DustOptions(Color.fromRGB(0, 127, 210), 0.7F);
  44. containerLocation.getWorld().spawnParticle(Particle.REDSTONE, X, Y, Z, 0, 0.0, 0.0, 0.0, 1.0, dustOptions);
  45. }
  46. //}
  47. }
  48. }
  49.  
  50. }
  51.  
  52. @Override
  53. public void compute() {
  54. spawnEffects();
  55. }
  56.  
  57. @Override
  58. public boolean reschedule() {
  59. return System.currentTimeMillis() <= rescheduleMaxRunTime();
  60. }
  61.  
  62. @Override
  63. public long getMilliPerTick() {
  64. return 2;
  65. }
  66.  
  67. @Override
  68. public boolean computeWithDelay(int conter) {
  69. return !(conter % 4 == 0);
  70. }
  71.  
  72. @Override
  73. public long rescheduleMaxRunTime() {
  74. return time;
  75. }
  76. }
  77.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement