Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SpawnContainerEffects implements HeavyLoad {
- private final Set<Location> location;
- private final Set<Location> containerLocations;
- private final List<String> effectType;
- private final long time;
- private final ContainerRegistryAPI registry = ContainerRegistryAPI.getInstance();
- PreferenceSettingsRegistery preferenceRegistery = PreferenceSettingsRegistery.getInstance();
- public SpawnContainerEffects(Set<Location> location, Set<Location> containerLocations, List<String> effectType, Integer runTime) {
- this.location = location;
- this.containerLocations = containerLocations;
- this.effectType = effectType;
- time = System.currentTimeMillis() + (1000L * (runTime != null ? runTime : 2));
- }
- private void spawnEffects() {
- for (Location containerLocation : containerLocations) {
- if (!containerLocation.getWorld().isChunkLoaded(containerLocation.getBlockX() >> 4, containerLocation.getBlockZ() >> 4))
- continue;
- double X = containerLocation.getBlockX() + Math.random();
- double Y = containerLocation.getBlockY() + Math.random();
- double Z = containerLocation.getBlockZ() + Math.random();
- if (preferenceRegistery.isEffectsOnContainer(registry.getPlayerUUID(containerLocation))) {
- List<String> effectType = YamlSettingsContainers.getEffectTypeOnContainer(registry.getContainerFileName(containerLocation), registry.getCurrentUpdate(containerLocation));
- //for (Location location : this.location) {
- if (this.effectType != null && !this.effectType.isEmpty())
- for (String particle : this.effectType) {
- containerLocation.getWorld().spawnParticle(Particle.valueOf(particle), X, Y, Z, 0, 0.0, 0.0, 0.0, 1.0);
- }
- if (effectType != null && !effectType.isEmpty()) {
- //System.out.println("testkjbhkug " + containerLocation);
- for (String particle : effectType) {
- containerLocation.getWorld().spawnParticle(Particle.valueOf(particle), X, Y, Z, 0, 0.0, 0.0, 0.0, 1.0);
- }
- } else {
- Particle.DustOptions dustOptions = new Particle.DustOptions(Color.fromRGB(0, 127, 210), 0.7F);
- containerLocation.getWorld().spawnParticle(Particle.REDSTONE, X, Y, Z, 0, 0.0, 0.0, 0.0, 1.0, dustOptions);
- }
- //}
- }
- }
- }
- @Override
- public void compute() {
- spawnEffects();
- }
- @Override
- public boolean reschedule() {
- return System.currentTimeMillis() <= rescheduleMaxRunTime();
- }
- @Override
- public long getMilliPerTick() {
- return 2;
- }
- @Override
- public boolean computeWithDelay(int conter) {
- return !(conter % 4 == 0);
- }
- @Override
- public long rescheduleMaxRunTime() {
- return time;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement