Advertisement
broken-arrow

Untitled

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