broken-arrow

Untitled

Oct 17th, 2021
822
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. public class SpawnBorderEffects implements HeavyLoad {
  3.  
  4.     private final Set<Location> location;
  5.     private final Location containerLocation;
  6.     private Player player;
  7.     private final long time;
  8.     private final long milliPerTick;
  9.     private final ContainerRegistryAPI registry = ContainerRegistryAPI.getInstance();
  10.  
  11.     public SpawnBorderEffects(Set<Location> location, Player player, Location containerLocation, long showTime, long milliPerTick) {
  12.         this.location = location;
  13.         this.player = player;
  14.         this.containerLocation = containerLocation;
  15.         this.milliPerTick = milliPerTick;
  16.         System.out.println("showTime " + showTime);
  17.         time = System.currentTimeMillis() + (1000L * (showTime > 1 ? showTime : YamlSettingsContainers.getEffectBorderShowTime(this.registry.getContainerFileName(this.containerLocation), this.registry.getCurrentUpdate(this.containerLocation))));
  18.         System.out.println("time " + time + " curent time " + System.currentTimeMillis());
  19.     }
  20.  
  21.     private void spawnEffects() {
  22.         for (Location location : this.location) {
  23.             if (this.player == null && containerLocation != null)
  24.                 this.player = registry.getPlayer(containerLocation);
  25.  
  26.             if (this.player != null) {
  27.                 String particle = YamlSettingsContainers.getEffectSuctionBorder(registry.getContainerFileName(this.containerLocation), registry.getCurrentUpdate(this.containerLocation));
  28.                 this.player.spawnParticle(particle != null ? Particle.valueOf(particle) : Particle.BARRIER, location, 0, 0.0, 0.0, 0.0, 1.0);
  29.             }
  30.         }
  31.     }
  32.  
  33.     @Override
  34.     public void compute() {
  35.         spawnEffects();
  36.     }
  37.  
  38.     @Override
  39.     public boolean reschedule() {
  40.         System.out.println("time " + (TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()) + "  " + TimeUnit.MILLISECONDS.toSeconds(rescheduleMaxRunTime())));
  41.         return System.currentTimeMillis() <= rescheduleMaxRunTime();
  42.     }
  43.  
  44.     @Override
  45.     public long getMilliPerTick() {
  46.         return milliPerTick;
  47.     }
  48.  
  49.     @Override
  50.     public boolean computeWithDelay(int conter) {
  51.         return true;
  52.     }
  53.  
  54.     @Override
  55.     public long rescheduleMaxRunTime() {
  56.         return time;
  57.     }
RAW Paste Data