diff --git a/API/src/main/java/com/bgsoftware/wildloaders/api/loaders/LoaderData.java b/API/src/main/java/com/bgsoftware/wildloaders/api/loaders/LoaderData.java index c745083..4569755 100644 --- a/API/src/main/java/com/bgsoftware/wildloaders/api/loaders/LoaderData.java +++ b/API/src/main/java/com/bgsoftware/wildloaders/api/loaders/LoaderData.java @@ -14,6 +14,11 @@ public interface LoaderData { */ long getTimeLeft(); + /** + * Whether or not the chunk loader is infinite. + */ + boolean isInfinite(); + /** * Get the drop item of the chunk loader, with default time. */ diff --git a/src/main/java/com/bgsoftware/wildloaders/handlers/SettingsHandler.java b/src/main/java/com/bgsoftware/wildloaders/handlers/SettingsHandler.java index a5a3c68..e3c7237 100644 --- a/src/main/java/com/bgsoftware/wildloaders/handlers/SettingsHandler.java +++ b/src/main/java/com/bgsoftware/wildloaders/handlers/SettingsHandler.java @@ -17,6 +17,7 @@ import java.util.stream.Collectors; public final class SettingsHandler { public List hologramLines; + public List infiniteHologramLines; public SettingsHandler(WildLoadersPlugin plugin){ WildLoadersPlugin.log("Loading configuration started..."); @@ -31,13 +32,15 @@ public final class SettingsHandler { hologramLines = cfg.getStringList("hologram-lines").stream() .map(line -> ChatColor.translateAlternateColorCodes('&', line)).collect(Collectors.toList()); + infiniteHologramLines = cfg.getStringList("infinite-hologram-lines").stream() + .map(line -> ChatColor.translateAlternateColorCodes('&', line)).collect(Collectors.toList()); plugin.getLoaders().removeLoadersData(); for (String name : cfg.getConfigurationSection("chunkloaders").getKeys(false)) { ConfigurationSection loaderSection = cfg.getConfigurationSection("chunkloaders." + name); - long timeLeft = loaderSection.getLong("time", 0); + long timeLeft = loaderSection.getLong("time", Integer.MIN_VALUE); ItemBuilder itemBuilder = null; @@ -72,7 +75,7 @@ public final class SettingsHandler { } } catch(Exception ignored){} - if (timeLeft <= 0 || itemBuilder == null) { + if (itemBuilder == null) { WildLoadersPlugin.log("Something went wrong while loading chunk-loader '" + name + "'."); continue; } diff --git a/src/main/java/com/bgsoftware/wildloaders/loaders/WChunkLoader.java b/src/main/java/com/bgsoftware/wildloaders/loaders/WChunkLoader.java index d1377a9..e7b859c 100644 --- a/src/main/java/com/bgsoftware/wildloaders/loaders/WChunkLoader.java +++ b/src/main/java/com/bgsoftware/wildloaders/loaders/WChunkLoader.java @@ -61,18 +61,27 @@ public final class WChunkLoader implements ChunkLoader { } public void tick(){ - timeLeft--; - if(timeLeft < 0) { - remove(); - } - else if(timeLeft > 0 && timeLeft % 10 == 0){ - Query.UPDATE_CHUNK_LOADER_TIME_LEFT.insertParameters() - .setObject(timeLeft) - .setLocation(location) - .queue(location); + if(!isInfinite()) { + timeLeft--; + if (timeLeft < 0) { + remove(); + } else if (timeLeft > 0 && timeLeft % 10 == 0) { + Query.UPDATE_CHUNK_LOADER_TIME_LEFT.insertParameters() + .setObject(timeLeft) + .setLocation(location) + .queue(location); + } } } + public boolean isInfinite(){ + return timeLeft == Integer.MIN_VALUE; + } + + public List getHologramLines(){ + return isInfinite() ? plugin.getSettings().infiniteHologramLines : plugin.getSettings().hologramLines; + } + @Override public Location getLocation() { return location.clone(); diff --git a/src/main/java/com/bgsoftware/wildloaders/loaders/WLoaderData.java b/src/main/java/com/bgsoftware/wildloaders/loaders/WLoaderData.java index c2d9bf9..36f42a3 100644 --- a/src/main/java/com/bgsoftware/wildloaders/loaders/WLoaderData.java +++ b/src/main/java/com/bgsoftware/wildloaders/loaders/WLoaderData.java @@ -33,6 +33,11 @@ public final class WLoaderData implements LoaderData { return timeLeft; } + @Override + public boolean isInfinite() { + return timeLeft == Integer.MIN_VALUE; + } + @Override public ItemStack getLoaderItem() { return loaderItem.clone(); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 561182e..62c0091 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -5,10 +5,29 @@ ## ## ####################################################### +# Hologram lines for regular chunk loaders. hologram-lines: - '&b{0}''s Loader' - '&bTime Left: &f{1} days, {2} hours, {3} minutes, {4} seconds' +# Hologram lines for chunk loaders with no time limits. +infinite-hologram-lines: +- '&b{0}''s Loader' + +# You can use the following settings when setting up chunk loaders: +# +# time (Integer) - The default amount of time the chunk loader will be alive. +# This field is in seconds. You can remove this field to have no time limit for the loader. +# chunks-radius (Integer) - The radius of chunks that will be loaded by the chunk loader for each direction. +# By default, the radius is 0 (1 chunk will be loaded). +# chunks-spread (Boolean) - Whether or not the chunk loader should load all the connected chunks inside a claim. +# This will give the ability to load all the claims in a faction, for example. +# +# type (String) - The material-type of the item (and the block) of the chunk-loader. +# name (String) - The name of the item of the chunk loader. +# lore: (List) - The lore of the item of the chunk loader. +# +# # List of all the chunk-loaders # Do not name 2 chunk-loaders the same chunkloaders: diff --git a/v1_10_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_10_R1.java b/v1_10_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_10_R1.java index 93581b4..647a5b4 100644 --- a/v1_10_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_10_R1.java +++ b/v1_10_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_10_R1.java @@ -177,37 +177,41 @@ public final class NMSAdapter_v1_10_R1 implements NMSAdapter { private static final Map tileEntityChunkLoaderMap = new HashMap<>(); private final List holograms = new ArrayList<>(); - private final ChunkLoader chunkLoader; + private final WChunkLoader chunkLoader; private short currentTick = 20; - private short daysAmount, hoursAmount, minutesAmount, secondsAmount; + private short daysAmount, hoursAmount = 0, minutesAmount = 0, secondsAmount = 0; private boolean removed = false; TileEntityChunkLoader(ChunkLoader chunkLoader, World world, BlockPosition blockPosition){ - this.chunkLoader = chunkLoader; + this.chunkLoader = (WChunkLoader) chunkLoader; setPosition(blockPosition); a(world); - long timeLeft = chunkLoader.getTimeLeft(); + if(!this.chunkLoader.isInfinite()) { + long timeLeft = chunkLoader.getTimeLeft(); - daysAmount = (short) (timeLeft / 86400); - timeLeft = timeLeft % 86400; + daysAmount = (short) (timeLeft / 86400); + timeLeft = timeLeft % 86400; - hoursAmount = (short) (timeLeft / 3600); - timeLeft = timeLeft % 3600; + hoursAmount = (short) (timeLeft / 3600); + timeLeft = timeLeft % 3600; - minutesAmount = (short) (timeLeft / 60); - timeLeft = timeLeft % 60; + minutesAmount = (short) (timeLeft / 60); + timeLeft = timeLeft % 60; - secondsAmount = (short) timeLeft; + secondsAmount = (short) timeLeft; + } tileEntityChunkLoaderMap.put(LongHash.toLong(blockPosition.getX() >> 4, blockPosition.getZ() >> 4), this); + List hologramLines = this.chunkLoader.getHologramLines(); + double currentY = position.getY() + 1; - for(int i = plugin.getSettings().hologramLines.size(); i > 0; i--){ + for(int i = hologramLines.size(); i > 0; i--){ EntityHolograms_v1_10_R1 hologram = new EntityHolograms_v1_10_R1(world, position.getX() + 0.5, currentY, position.getZ() + 0.5); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); world.addEntity(hologram); currentY += 0.23; holograms.add(hologram); @@ -221,20 +225,25 @@ public final class NMSAdapter_v1_10_R1 implements NMSAdapter { currentTick = 0; - if(((WChunkLoader) chunkLoader).isNotActive()){ + if(chunkLoader.isNotActive()){ chunkLoader.remove(); return; } + if(chunkLoader.isInfinite()) + return; + + List hologramLines = chunkLoader.getHologramLines(); + int hologramsAmount = holograms.size(); for (int i = hologramsAmount; i > 0; i--) { EntityHolograms_v1_10_R1 hologram = holograms.get(hologramsAmount - i); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); } - ((WChunkLoader) chunkLoader).tick(); + chunkLoader.tick(); - if(!removed) { + if(!removed && daysAmount != -1) { secondsAmount--; if (secondsAmount < 0) { secondsAmount = 59; diff --git a/v1_11_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_11_R1.java b/v1_11_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_11_R1.java index 97e6938..77f2094 100644 --- a/v1_11_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_11_R1.java +++ b/v1_11_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_11_R1.java @@ -177,37 +177,41 @@ public final class NMSAdapter_v1_11_R1 implements NMSAdapter { private static final Map tileEntityChunkLoaderMap = new HashMap<>(); private final List holograms = new ArrayList<>(); - private final ChunkLoader chunkLoader; + private final WChunkLoader chunkLoader; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; private boolean removed = false; TileEntityChunkLoader(ChunkLoader chunkLoader, World world, BlockPosition blockPosition){ - this.chunkLoader = chunkLoader; + this.chunkLoader = (WChunkLoader) chunkLoader; setPosition(blockPosition); a(world); - long timeLeft = chunkLoader.getTimeLeft(); + if(!this.chunkLoader.isInfinite()) { + long timeLeft = chunkLoader.getTimeLeft(); - daysAmount = (short) (timeLeft / 86400); - timeLeft = timeLeft % 86400; + daysAmount = (short) (timeLeft / 86400); + timeLeft = timeLeft % 86400; - hoursAmount = (short) (timeLeft / 3600); - timeLeft = timeLeft % 3600; + hoursAmount = (short) (timeLeft / 3600); + timeLeft = timeLeft % 3600; - minutesAmount = (short) (timeLeft / 60); - timeLeft = timeLeft % 60; + minutesAmount = (short) (timeLeft / 60); + timeLeft = timeLeft % 60; - secondsAmount = (short) timeLeft; + secondsAmount = (short) timeLeft; + } tileEntityChunkLoaderMap.put(LongHash.toLong(blockPosition.getX() >> 4, blockPosition.getZ() >> 4), this); + List hologramLines = this.chunkLoader.getHologramLines(); + double currentY = position.getY() + 1; - for(int i = plugin.getSettings().hologramLines.size(); i > 0; i--){ + for(int i = hologramLines.size(); i > 0; i--){ EntityHolograms_v1_11_R1 hologram = new EntityHolograms_v1_11_R1(world, position.getX() + 0.5, currentY, position.getZ() + 0.5); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); world.addEntity(hologram); currentY += 0.23; holograms.add(hologram); @@ -221,18 +225,23 @@ public final class NMSAdapter_v1_11_R1 implements NMSAdapter { currentTick = 0; - if(((WChunkLoader) chunkLoader).isNotActive()){ + if(chunkLoader.isNotActive()){ chunkLoader.remove(); return; } + if(chunkLoader.isInfinite()) + return; + + List hologramLines = chunkLoader.getHologramLines(); + int hologramsAmount = holograms.size(); for (int i = hologramsAmount; i > 0; i--) { EntityHolograms_v1_11_R1 hologram = holograms.get(hologramsAmount - i); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); } - ((WChunkLoader) chunkLoader).tick(); + chunkLoader.tick(); if(!removed) { secondsAmount--; diff --git a/v1_12_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_12_R1.java b/v1_12_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_12_R1.java index 91e59d3..f889327 100644 --- a/v1_12_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_12_R1.java +++ b/v1_12_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_12_R1.java @@ -200,37 +200,41 @@ public final class NMSAdapter_v1_12_R1 implements NMSAdapter { private static final Map tileEntityChunkLoaderMap = new HashMap<>(); private final List holograms = new ArrayList<>(); - private final ChunkLoader chunkLoader; + private final WChunkLoader chunkLoader; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; private boolean removed = false; TileEntityChunkLoader(ChunkLoader chunkLoader, World world, BlockPosition blockPosition){ - this.chunkLoader = chunkLoader; + this.chunkLoader = (WChunkLoader) chunkLoader; setPosition(blockPosition); a(world); - long timeLeft = chunkLoader.getTimeLeft(); + if(!this.chunkLoader.isInfinite()) { + long timeLeft = chunkLoader.getTimeLeft(); - daysAmount = (short) (timeLeft / 86400); - timeLeft = timeLeft % 86400; + daysAmount = (short) (timeLeft / 86400); + timeLeft = timeLeft % 86400; - hoursAmount = (short) (timeLeft / 3600); - timeLeft = timeLeft % 3600; + hoursAmount = (short) (timeLeft / 3600); + timeLeft = timeLeft % 3600; - minutesAmount = (short) (timeLeft / 60); - timeLeft = timeLeft % 60; + minutesAmount = (short) (timeLeft / 60); + timeLeft = timeLeft % 60; - secondsAmount = (short) timeLeft; + secondsAmount = (short) timeLeft; + } tileEntityChunkLoaderMap.put(LongHash.toLong(blockPosition.getX() >> 4, blockPosition.getZ() >> 4), this); + List hologramLines = this.chunkLoader.getHologramLines(); + double currentY = position.getY() + 1; - for(int i = plugin.getSettings().hologramLines.size(); i > 0; i--){ + for(int i = hologramLines.size(); i > 0; i--){ EntityHolograms_v1_12_R1 hologram = new EntityHolograms_v1_12_R1(world, position.getX() + 0.5, currentY, position.getZ() + 0.5); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); world.addEntity(hologram); currentY += 0.23; holograms.add(hologram); @@ -244,18 +248,23 @@ public final class NMSAdapter_v1_12_R1 implements NMSAdapter { currentTick = 0; - if(((WChunkLoader) chunkLoader).isNotActive()){ + if(chunkLoader.isNotActive()){ chunkLoader.remove(); return; } + if(chunkLoader.isInfinite()) + return; + + List hologramLines = chunkLoader.getHologramLines(); + int hologramsAmount = holograms.size(); for (int i = hologramsAmount; i > 0; i--) { EntityHolograms_v1_12_R1 hologram = holograms.get(hologramsAmount - i); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); } - ((WChunkLoader) chunkLoader).tick(); + chunkLoader.tick(); if(!removed) { secondsAmount--; diff --git a/v1_13_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_13_R1.java b/v1_13_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_13_R1.java index 3dade72..1f99ae9 100644 --- a/v1_13_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_13_R1.java +++ b/v1_13_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_13_R1.java @@ -170,7 +170,7 @@ public final class NMSAdapter_v1_13_R1 implements NMSAdapter { private static final Map tileEntityChunkLoaderMap = new HashMap<>(); private final List holograms = new ArrayList<>(); - private final ChunkLoader chunkLoader; + private final WChunkLoader chunkLoader; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; @@ -179,30 +179,34 @@ public final class NMSAdapter_v1_13_R1 implements NMSAdapter { TileEntityChunkLoader(ChunkLoader chunkLoader, World world, BlockPosition blockPosition){ super(TileEntityTypes.w); - this.chunkLoader = chunkLoader; + this.chunkLoader = (WChunkLoader) chunkLoader; setPosition(blockPosition); setWorld(world); - long timeLeft = chunkLoader.getTimeLeft(); + if(!this.chunkLoader.isInfinite()) { + long timeLeft = chunkLoader.getTimeLeft(); - daysAmount = (short) (timeLeft / 86400); - timeLeft = timeLeft % 86400; + daysAmount = (short) (timeLeft / 86400); + timeLeft = timeLeft % 86400; - hoursAmount = (short) (timeLeft / 3600); - timeLeft = timeLeft % 3600; + hoursAmount = (short) (timeLeft / 3600); + timeLeft = timeLeft % 3600; - minutesAmount = (short) (timeLeft / 60); - timeLeft = timeLeft % 60; + minutesAmount = (short) (timeLeft / 60); + timeLeft = timeLeft % 60; - secondsAmount = (short) timeLeft; + secondsAmount = (short) timeLeft; + } tileEntityChunkLoaderMap.put(LongHash.toLong(blockPosition.getX() >> 4, blockPosition.getZ() >> 4), this); + List hologramLines = this.chunkLoader.getHologramLines(); + double currentY = position.getY() + 1; - for(int i = plugin.getSettings().hologramLines.size(); i > 0; i--){ + for(int i = hologramLines.size(); i > 0; i--){ EntityHolograms_v1_13_R1 hologram = new EntityHolograms_v1_13_R1(world, position.getX() + 0.5, currentY, position.getZ() + 0.5); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); world.addEntity(hologram); currentY += 0.23; holograms.add(hologram); @@ -216,18 +220,23 @@ public final class NMSAdapter_v1_13_R1 implements NMSAdapter { currentTick = 0; - if(((WChunkLoader) chunkLoader).isNotActive()){ + if(chunkLoader.isNotActive()){ chunkLoader.remove(); return; } + if(chunkLoader.isInfinite()) + return; + + List hologramLines = chunkLoader.getHologramLines(); + int hologramsAmount = holograms.size(); for (int i = hologramsAmount; i > 0; i--) { EntityHolograms_v1_13_R1 hologram = holograms.get(hologramsAmount - i); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); } - ((WChunkLoader) chunkLoader).tick(); + chunkLoader.tick(); if(!removed) { secondsAmount--; diff --git a/v1_13_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_13_R2.java b/v1_13_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_13_R2.java index 9b3e92d..7ed5929 100644 --- a/v1_13_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_13_R2.java +++ b/v1_13_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_13_R2.java @@ -170,7 +170,7 @@ public final class NMSAdapter_v1_13_R2 implements NMSAdapter { private static final Map tileEntityChunkLoaderMap = new HashMap<>(); private final List holograms = new ArrayList<>(); - private final ChunkLoader chunkLoader; + private final WChunkLoader chunkLoader; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; @@ -179,30 +179,34 @@ public final class NMSAdapter_v1_13_R2 implements NMSAdapter { TileEntityChunkLoader(ChunkLoader chunkLoader, World world, BlockPosition blockPosition){ super(TileEntityTypes.COMMAND_BLOCK); - this.chunkLoader = chunkLoader; + this.chunkLoader = (WChunkLoader) chunkLoader; setPosition(blockPosition); setWorld(world); - long timeLeft = chunkLoader.getTimeLeft(); + if(!this.chunkLoader.isInfinite()) { + long timeLeft = chunkLoader.getTimeLeft(); - daysAmount = (short) (timeLeft / 86400); - timeLeft = timeLeft % 86400; + daysAmount = (short) (timeLeft / 86400); + timeLeft = timeLeft % 86400; - hoursAmount = (short) (timeLeft / 3600); - timeLeft = timeLeft % 3600; + hoursAmount = (short) (timeLeft / 3600); + timeLeft = timeLeft % 3600; - minutesAmount = (short) (timeLeft / 60); - timeLeft = timeLeft % 60; + minutesAmount = (short) (timeLeft / 60); + timeLeft = timeLeft % 60; - secondsAmount = (short) timeLeft; + secondsAmount = (short) timeLeft; + } tileEntityChunkLoaderMap.put(LongHash.toLong(blockPosition.getX() >> 4, blockPosition.getZ() >> 4), this); + List hologramLines = this.chunkLoader.getHologramLines(); + double currentY = position.getY() + 1; - for(int i = plugin.getSettings().hologramLines.size(); i > 0; i--){ + for(int i = hologramLines.size(); i > 0; i--){ EntityHolograms_v1_13_R2 hologram = new EntityHolograms_v1_13_R2(world, position.getX() + 0.5, currentY, position.getZ() + 0.5); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); world.addEntity(hologram); currentY += 0.23; holograms.add(hologram); @@ -216,18 +220,23 @@ public final class NMSAdapter_v1_13_R2 implements NMSAdapter { currentTick = 0; - if(((WChunkLoader) chunkLoader).isNotActive()){ + if(chunkLoader.isNotActive()){ chunkLoader.remove(); return; } + if(chunkLoader.isInfinite()) + return; + + List hologramLines = chunkLoader.getHologramLines(); + int hologramsAmount = holograms.size(); for (int i = hologramsAmount; i > 0; i--) { EntityHolograms_v1_13_R2 hologram = holograms.get(hologramsAmount - i); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); } - ((WChunkLoader) chunkLoader).tick(); + chunkLoader.tick(); if(!removed) { secondsAmount--; diff --git a/v1_14_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_14_R1.java b/v1_14_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_14_R1.java index 522efb6..e4c1556 100644 --- a/v1_14_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_14_R1.java +++ b/v1_14_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_14_R1.java @@ -178,7 +178,7 @@ public final class NMSAdapter_v1_14_R1 implements NMSAdapter { private static final Map tileEntityChunkLoaderMap = new HashMap<>(); private final List holograms = new ArrayList<>(); - private final ChunkLoader chunkLoader; + private final WChunkLoader chunkLoader; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; @@ -187,30 +187,34 @@ public final class NMSAdapter_v1_14_R1 implements NMSAdapter { TileEntityChunkLoader(ChunkLoader chunkLoader, World world, BlockPosition blockPosition){ super(TileEntityTypes.COMMAND_BLOCK); - this.chunkLoader = chunkLoader; + this.chunkLoader = (WChunkLoader) chunkLoader; setPosition(blockPosition); setWorld(world); - long timeLeft = chunkLoader.getTimeLeft(); + if(!this.chunkLoader.isInfinite()) { + long timeLeft = chunkLoader.getTimeLeft(); - daysAmount = (short) (timeLeft / 86400); - timeLeft = timeLeft % 86400; + daysAmount = (short) (timeLeft / 86400); + timeLeft = timeLeft % 86400; - hoursAmount = (short) (timeLeft / 3600); - timeLeft = timeLeft % 3600; + hoursAmount = (short) (timeLeft / 3600); + timeLeft = timeLeft % 3600; - minutesAmount = (short) (timeLeft / 60); - timeLeft = timeLeft % 60; + minutesAmount = (short) (timeLeft / 60); + timeLeft = timeLeft % 60; - secondsAmount = (short) timeLeft; + secondsAmount = (short) timeLeft; + } tileEntityChunkLoaderMap.put(ChunkCoordIntPair.pair(blockPosition.getX() >> 4, blockPosition.getZ() >> 4), this); + List hologramLines = this.chunkLoader.getHologramLines(); + double currentY = position.getY() + 1; - for(int i = plugin.getSettings().hologramLines.size(); i > 0; i--){ + for(int i = hologramLines.size(); i > 0; i--){ EntityHolograms_v1_14_R1 hologram = new EntityHolograms_v1_14_R1(world, position.getX() + 0.5, currentY, position.getZ() + 0.5); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); world.addEntity(hologram); currentY += 0.23; holograms.add(hologram); @@ -229,18 +233,23 @@ public final class NMSAdapter_v1_14_R1 implements NMSAdapter { currentTick = 0; - if(((WChunkLoader) chunkLoader).isNotActive()){ + if(chunkLoader.isNotActive()){ chunkLoader.remove(); return; } + if(chunkLoader.isInfinite()) + return; + + List hologramLines = chunkLoader.getHologramLines(); + int hologramsAmount = holograms.size(); for (int i = hologramsAmount; i > 0; i--) { EntityHolograms_v1_14_R1 hologram = holograms.get(hologramsAmount - i); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); } - ((WChunkLoader) chunkLoader).tick(); + chunkLoader.tick(); if(!removed) { secondsAmount--; diff --git a/v1_15_R1/src/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_15_R1.java b/v1_15_R1/src/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_15_R1.java index f3d25b6..66e1423 100644 --- a/v1_15_R1/src/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_15_R1.java +++ b/v1_15_R1/src/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_15_R1.java @@ -178,7 +178,7 @@ public final class NMSAdapter_v1_15_R1 implements NMSAdapter { private static final Map tileEntityChunkLoaderMap = new HashMap<>(); private final List holograms = new ArrayList<>(); - private final ChunkLoader chunkLoader; + private final WChunkLoader chunkLoader; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; @@ -187,29 +187,33 @@ public final class NMSAdapter_v1_15_R1 implements NMSAdapter { TileEntityChunkLoader(ChunkLoader chunkLoader, World world, BlockPosition blockPosition){ super(TileEntityTypes.COMMAND_BLOCK); - this.chunkLoader = chunkLoader; + this.chunkLoader = (WChunkLoader) chunkLoader; setLocation(world, blockPosition); - long timeLeft = chunkLoader.getTimeLeft(); + if(!this.chunkLoader.isInfinite()) { + long timeLeft = chunkLoader.getTimeLeft(); - daysAmount = (short) (timeLeft / 86400); - timeLeft = timeLeft % 86400; + daysAmount = (short) (timeLeft / 86400); + timeLeft = timeLeft % 86400; - hoursAmount = (short) (timeLeft / 3600); - timeLeft = timeLeft % 3600; + hoursAmount = (short) (timeLeft / 3600); + timeLeft = timeLeft % 3600; - minutesAmount = (short) (timeLeft / 60); - timeLeft = timeLeft % 60; + minutesAmount = (short) (timeLeft / 60); + timeLeft = timeLeft % 60; - secondsAmount = (short) timeLeft; + secondsAmount = (short) timeLeft; + } tileEntityChunkLoaderMap.put(ChunkCoordIntPair.pair(blockPosition.getX() >> 4, blockPosition.getZ() >> 4), this); + List hologramLines = this.chunkLoader.getHologramLines(); + double currentY = position.getY() + 1; - for(int i = plugin.getSettings().hologramLines.size(); i > 0; i--){ + for(int i = hologramLines.size(); i > 0; i--){ EntityHolograms_v1_15_R1 hologram = new EntityHolograms_v1_15_R1(world, position.getX() + 0.5, currentY, position.getZ() + 0.5); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); world.addEntity(hologram); currentY += 0.23; holograms.add(hologram); @@ -228,18 +232,23 @@ public final class NMSAdapter_v1_15_R1 implements NMSAdapter { currentTick = 0; - if(((WChunkLoader) chunkLoader).isNotActive()){ + if(chunkLoader.isNotActive()){ chunkLoader.remove(); return; } + if(chunkLoader.isInfinite()) + return; + + List hologramLines = chunkLoader.getHologramLines(); + int hologramsAmount = holograms.size(); for (int i = hologramsAmount; i > 0; i--) { EntityHolograms_v1_15_R1 hologram = holograms.get(hologramsAmount - i); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); } - ((WChunkLoader) chunkLoader).tick(); + chunkLoader.tick(); if(!removed) { secondsAmount--; diff --git a/v1_16_R1/src/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_16_R1.java b/v1_16_R1/src/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_16_R1.java index 5b4da57..c45ebaf 100644 --- a/v1_16_R1/src/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_16_R1.java +++ b/v1_16_R1/src/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_16_R1.java @@ -180,7 +180,7 @@ public final class NMSAdapter_v1_16_R1 implements NMSAdapter { private static final Map tileEntityChunkLoaderMap = new HashMap<>(); private final List holograms = new ArrayList<>(); - private final ChunkLoader chunkLoader; + private final WChunkLoader chunkLoader; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; @@ -189,29 +189,33 @@ public final class NMSAdapter_v1_16_R1 implements NMSAdapter { TileEntityChunkLoader(ChunkLoader chunkLoader, World world, BlockPosition blockPosition){ super(TileEntityTypes.COMMAND_BLOCK); - this.chunkLoader = chunkLoader; + this.chunkLoader = (WChunkLoader) chunkLoader; setLocation(world, blockPosition); - long timeLeft = chunkLoader.getTimeLeft(); + if(!this.chunkLoader.isInfinite()) { + long timeLeft = chunkLoader.getTimeLeft(); - daysAmount = (short) (timeLeft / 86400); - timeLeft = timeLeft % 86400; + daysAmount = (short) (timeLeft / 86400); + timeLeft = timeLeft % 86400; - hoursAmount = (short) (timeLeft / 3600); - timeLeft = timeLeft % 3600; + hoursAmount = (short) (timeLeft / 3600); + timeLeft = timeLeft % 3600; - minutesAmount = (short) (timeLeft / 60); - timeLeft = timeLeft % 60; + minutesAmount = (short) (timeLeft / 60); + timeLeft = timeLeft % 60; - secondsAmount = (short) timeLeft; + secondsAmount = (short) timeLeft; + } tileEntityChunkLoaderMap.put(ChunkCoordIntPair.pair(blockPosition.getX() >> 4, blockPosition.getZ() >> 4), this); + List hologramLines = this.chunkLoader.getHologramLines(); + double currentY = position.getY() + 1; - for(int i = plugin.getSettings().hologramLines.size(); i > 0; i--){ + for(int i = hologramLines.size(); i > 0; i--){ EntityHolograms_v1_16_R1 hologram = new EntityHolograms_v1_16_R1(world, position.getX() + 0.5, currentY, position.getZ() + 0.5); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); world.addEntity(hologram); currentY += 0.23; holograms.add(hologram); @@ -230,18 +234,23 @@ public final class NMSAdapter_v1_16_R1 implements NMSAdapter { currentTick = 0; - if(((WChunkLoader) chunkLoader).isNotActive()){ + if(chunkLoader.isNotActive()){ chunkLoader.remove(); return; } + if(chunkLoader.isInfinite()) + return; + + List hologramLines = chunkLoader.getHologramLines(); + int hologramsAmount = holograms.size(); for (int i = hologramsAmount; i > 0; i--) { EntityHolograms_v1_16_R1 hologram = holograms.get(hologramsAmount - i); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); } - ((WChunkLoader) chunkLoader).tick(); + chunkLoader.tick(); if(!removed) { secondsAmount--; diff --git a/v1_16_R2/src/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_16_R2.java b/v1_16_R2/src/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_16_R2.java index b965514..8938e9d 100644 --- a/v1_16_R2/src/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_16_R2.java +++ b/v1_16_R2/src/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_16_R2.java @@ -180,7 +180,7 @@ public final class NMSAdapter_v1_16_R2 implements NMSAdapter { private static final Map tileEntityChunkLoaderMap = new HashMap<>(); private final List holograms = new ArrayList<>(); - private final ChunkLoader chunkLoader; + private final WChunkLoader chunkLoader; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; @@ -189,29 +189,33 @@ public final class NMSAdapter_v1_16_R2 implements NMSAdapter { TileEntityChunkLoader(ChunkLoader chunkLoader, World world, BlockPosition blockPosition){ super(TileEntityTypes.COMMAND_BLOCK); - this.chunkLoader = chunkLoader; + this.chunkLoader = (WChunkLoader) chunkLoader; setLocation(world, blockPosition); - long timeLeft = chunkLoader.getTimeLeft(); + if(!this.chunkLoader.isInfinite()) { + long timeLeft = chunkLoader.getTimeLeft(); - daysAmount = (short) (timeLeft / 86400); - timeLeft = timeLeft % 86400; + daysAmount = (short) (timeLeft / 86400); + timeLeft = timeLeft % 86400; - hoursAmount = (short) (timeLeft / 3600); - timeLeft = timeLeft % 3600; + hoursAmount = (short) (timeLeft / 3600); + timeLeft = timeLeft % 3600; - minutesAmount = (short) (timeLeft / 60); - timeLeft = timeLeft % 60; + minutesAmount = (short) (timeLeft / 60); + timeLeft = timeLeft % 60; - secondsAmount = (short) timeLeft; + secondsAmount = (short) timeLeft; + } tileEntityChunkLoaderMap.put(ChunkCoordIntPair.pair(blockPosition.getX() >> 4, blockPosition.getZ() >> 4), this); + List hologramLines = this.chunkLoader.getHologramLines(); + double currentY = position.getY() + 1; - for(int i = plugin.getSettings().hologramLines.size(); i > 0; i--){ + for(int i = hologramLines.size(); i > 0; i--){ EntityHolograms_v1_16_R2 hologram = new EntityHolograms_v1_16_R2(world, position.getX() + 0.5, currentY, position.getZ() + 0.5); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); world.addEntity(hologram); currentY += 0.23; holograms.add(hologram); @@ -230,18 +234,23 @@ public final class NMSAdapter_v1_16_R2 implements NMSAdapter { currentTick = 0; - if(((WChunkLoader) chunkLoader).isNotActive()){ + if(chunkLoader.isNotActive()){ chunkLoader.remove(); return; } + if(chunkLoader.isInfinite()) + return; + + List hologramLines = chunkLoader.getHologramLines(); + int hologramsAmount = holograms.size(); for (int i = hologramsAmount; i > 0; i--) { EntityHolograms_v1_16_R2 hologram = holograms.get(hologramsAmount - i); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); } - ((WChunkLoader) chunkLoader).tick(); + chunkLoader.tick(); if(!removed) { secondsAmount--; diff --git a/v1_8_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R1.java b/v1_8_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R1.java index 2db9ee7..fcf2401 100644 --- a/v1_8_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R1.java +++ b/v1_8_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R1.java @@ -7,7 +7,6 @@ import com.bgsoftware.wildloaders.loaders.WChunkLoader; import net.minecraft.server.v1_8_R1.Block; import net.minecraft.server.v1_8_R1.BlockPosition; import net.minecraft.server.v1_8_R1.Chunk; -import net.minecraft.server.v1_8_R1.Entity; import net.minecraft.server.v1_8_R1.IUpdatePlayerListBox; import net.minecraft.server.v1_8_R1.ItemStack; import net.minecraft.server.v1_8_R1.NBTTagCompound; @@ -181,37 +180,41 @@ public final class NMSAdapter_v1_8_R1 implements NMSAdapter { private static final Map tileEntityChunkLoaderMap = new HashMap<>(); private final List holograms = new ArrayList<>(); - private final ChunkLoader chunkLoader; + private final WChunkLoader chunkLoader; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; private boolean removed = false; TileEntityChunkLoader(ChunkLoader chunkLoader, World world, BlockPosition blockPosition){ - this.chunkLoader = chunkLoader; + this.chunkLoader = (WChunkLoader) chunkLoader; a(blockPosition); a(world); - long timeLeft = chunkLoader.getTimeLeft(); + if(!this.chunkLoader.isInfinite()) { + long timeLeft = chunkLoader.getTimeLeft(); - daysAmount = (short) (timeLeft / 86400); - timeLeft = timeLeft % 86400; + daysAmount = (short) (timeLeft / 86400); + timeLeft = timeLeft % 86400; - hoursAmount = (short) (timeLeft / 3600); - timeLeft = timeLeft % 3600; + hoursAmount = (short) (timeLeft / 3600); + timeLeft = timeLeft % 3600; - minutesAmount = (short) (timeLeft / 60); - timeLeft = timeLeft % 60; + minutesAmount = (short) (timeLeft / 60); + timeLeft = timeLeft % 60; - secondsAmount = (short) timeLeft; + secondsAmount = (short) timeLeft; + } tileEntityChunkLoaderMap.put(LongHash.toLong(blockPosition.getX() >> 4, blockPosition.getZ() >> 4), this); + List hologramLines = this.chunkLoader.getHologramLines(); + double currentY = position.getY() + 1; - for(int i = plugin.getSettings().hologramLines.size(); i > 0; i--){ + for (int i = hologramLines.size(); i > 0; i--) { EntityHolograms_v1_8_R1 hologram = new EntityHolograms_v1_8_R1(world, position.getX() + 0.5, currentY, position.getZ() + 0.5); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); world.addEntity(hologram); currentY += 0.23; holograms.add(hologram); @@ -225,18 +228,23 @@ public final class NMSAdapter_v1_8_R1 implements NMSAdapter { currentTick = 0; - if(((WChunkLoader) chunkLoader).isNotActive()){ + if(chunkLoader.isNotActive()){ chunkLoader.remove(); return; } + if(chunkLoader.isInfinite()) + return; + + List hologramLines = chunkLoader.getHologramLines(); + int hologramsAmount = holograms.size(); for (int i = hologramsAmount; i > 0; i--) { EntityHolograms_v1_8_R1 hologram = holograms.get(hologramsAmount - i); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); } - ((WChunkLoader) chunkLoader).tick(); + chunkLoader.tick(); if(!removed) { secondsAmount--; diff --git a/v1_8_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R2.java b/v1_8_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R2.java index 3138bbb..3b01653 100644 --- a/v1_8_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R2.java +++ b/v1_8_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R2.java @@ -177,37 +177,41 @@ public final class NMSAdapter_v1_8_R2 implements NMSAdapter { private static final Map tileEntityChunkLoaderMap = new HashMap<>(); private final List holograms = new ArrayList<>(); - private final ChunkLoader chunkLoader; + private final WChunkLoader chunkLoader; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; private boolean removed = false; TileEntityChunkLoader(ChunkLoader chunkLoader, World world, BlockPosition blockPosition){ - this.chunkLoader = chunkLoader; + this.chunkLoader = (WChunkLoader) chunkLoader; a(blockPosition); a(world); - long timeLeft = chunkLoader.getTimeLeft(); + if(!this.chunkLoader.isInfinite()) { + long timeLeft = chunkLoader.getTimeLeft(); - daysAmount = (short) (timeLeft / 86400); - timeLeft = timeLeft % 86400; + daysAmount = (short) (timeLeft / 86400); + timeLeft = timeLeft % 86400; - hoursAmount = (short) (timeLeft / 3600); - timeLeft = timeLeft % 3600; + hoursAmount = (short) (timeLeft / 3600); + timeLeft = timeLeft % 3600; - minutesAmount = (short) (timeLeft / 60); - timeLeft = timeLeft % 60; + minutesAmount = (short) (timeLeft / 60); + timeLeft = timeLeft % 60; - secondsAmount = (short) timeLeft; + secondsAmount = (short) timeLeft; + } tileEntityChunkLoaderMap.put(LongHash.toLong(blockPosition.getX() >> 4, blockPosition.getZ() >> 4), this); + List hologramLines = this.chunkLoader.getHologramLines(); + double currentY = position.getY() + 1; - for(int i = plugin.getSettings().hologramLines.size(); i > 0; i--){ + for(int i = hologramLines.size(); i > 0; i--){ EntityHolograms_v1_8_R2 hologram = new EntityHolograms_v1_8_R2(world, position.getX() + 0.5, currentY, position.getZ() + 0.5); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); world.addEntity(hologram); currentY += 0.23; holograms.add(hologram); @@ -221,18 +225,23 @@ public final class NMSAdapter_v1_8_R2 implements NMSAdapter { currentTick = 0; - if(((WChunkLoader) chunkLoader).isNotActive()){ + if(chunkLoader.isNotActive()){ chunkLoader.remove(); return; } + if(chunkLoader.isInfinite()) + return; + + List hologramLines = chunkLoader.getHologramLines(); + int hologramsAmount = holograms.size(); for (int i = hologramsAmount; i > 0; i--) { EntityHolograms_v1_8_R2 hologram = holograms.get(hologramsAmount - i); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); } - ((WChunkLoader) chunkLoader).tick(); + chunkLoader.tick(); if(!removed) { secondsAmount--; diff --git a/v1_8_R3/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R3.java b/v1_8_R3/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R3.java index 9a25339..0c7bd4b 100644 --- a/v1_8_R3/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R3.java +++ b/v1_8_R3/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_8_R3.java @@ -177,37 +177,41 @@ public final class NMSAdapter_v1_8_R3 implements NMSAdapter { private static final Map tileEntityChunkLoaderMap = new HashMap<>(); private final List holograms = new ArrayList<>(); - private final ChunkLoader chunkLoader; + private final WChunkLoader chunkLoader; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; private boolean removed = false; TileEntityChunkLoader(ChunkLoader chunkLoader, World world, BlockPosition blockPosition){ - this.chunkLoader = chunkLoader; + this.chunkLoader = (WChunkLoader) chunkLoader; a(blockPosition); a(world); - long timeLeft = chunkLoader.getTimeLeft(); + if(!this.chunkLoader.isInfinite()) { + long timeLeft = chunkLoader.getTimeLeft(); - daysAmount = (short) (timeLeft / 86400); - timeLeft = timeLeft % 86400; + daysAmount = (short) (timeLeft / 86400); + timeLeft = timeLeft % 86400; - hoursAmount = (short) (timeLeft / 3600); - timeLeft = timeLeft % 3600; + hoursAmount = (short) (timeLeft / 3600); + timeLeft = timeLeft % 3600; - minutesAmount = (short) (timeLeft / 60); - timeLeft = timeLeft % 60; + minutesAmount = (short) (timeLeft / 60); + timeLeft = timeLeft % 60; - secondsAmount = (short) timeLeft; + secondsAmount = (short) timeLeft; + } tileEntityChunkLoaderMap.put(LongHash.toLong(blockPosition.getX() >> 4, blockPosition.getZ() >> 4), this); + List hologramLines = this.chunkLoader.getHologramLines(); + double currentY = position.getY() + 1; - for(int i = plugin.getSettings().hologramLines.size(); i > 0; i--){ + for(int i = hologramLines.size(); i > 0; i--){ EntityHolograms_v1_8_R3 hologram = new EntityHolograms_v1_8_R3(world, position.getX() + 0.5, currentY, position.getZ() + 0.5); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); world.addEntity(hologram); currentY += 0.23; holograms.add(hologram); @@ -221,18 +225,23 @@ public final class NMSAdapter_v1_8_R3 implements NMSAdapter { currentTick = 0; - if(((WChunkLoader) chunkLoader).isNotActive()){ + if(chunkLoader.isNotActive()){ chunkLoader.remove(); return; } + if(chunkLoader.isInfinite()) + return; + + List hologramLines = chunkLoader.getHologramLines(); + int hologramsAmount = holograms.size(); for (int i = hologramsAmount; i > 0; i--) { EntityHolograms_v1_8_R3 hologram = holograms.get(hologramsAmount - i); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); } - ((WChunkLoader) chunkLoader).tick(); + chunkLoader.tick(); if(!removed) { secondsAmount--; diff --git a/v1_9_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_9_R1.java b/v1_9_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_9_R1.java index 394b43e..06c3bb9 100644 --- a/v1_9_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_9_R1.java +++ b/v1_9_R1/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_9_R1.java @@ -177,37 +177,41 @@ public final class NMSAdapter_v1_9_R1 implements NMSAdapter { private static final Map tileEntityChunkLoaderMap = new HashMap<>(); private final List holograms = new ArrayList<>(); - private final ChunkLoader chunkLoader; + private final WChunkLoader chunkLoader; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; private boolean removed = false; TileEntityChunkLoader(ChunkLoader chunkLoader, World world, BlockPosition blockPosition){ - this.chunkLoader = chunkLoader; + this.chunkLoader = (WChunkLoader) chunkLoader; a(blockPosition); a(world); - long timeLeft = chunkLoader.getTimeLeft(); + if(!this.chunkLoader.isInfinite()) { + long timeLeft = chunkLoader.getTimeLeft(); - daysAmount = (short) (timeLeft / 86400); - timeLeft = timeLeft % 86400; + daysAmount = (short) (timeLeft / 86400); + timeLeft = timeLeft % 86400; - hoursAmount = (short) (timeLeft / 3600); - timeLeft = timeLeft % 3600; + hoursAmount = (short) (timeLeft / 3600); + timeLeft = timeLeft % 3600; - minutesAmount = (short) (timeLeft / 60); - timeLeft = timeLeft % 60; + minutesAmount = (short) (timeLeft / 60); + timeLeft = timeLeft % 60; - secondsAmount = (short) timeLeft; + secondsAmount = (short) timeLeft; + } tileEntityChunkLoaderMap.put(LongHash.toLong(blockPosition.getX() >> 4, blockPosition.getZ() >> 4), this); + List hologramLines = this.chunkLoader.getHologramLines(); + double currentY = position.getY() + 1; - for(int i = plugin.getSettings().hologramLines.size(); i > 0; i--){ + for(int i = hologramLines.size(); i > 0; i--){ EntityHolograms_v1_9_R1 hologram = new EntityHolograms_v1_9_R1(world, position.getX() + 0.5, currentY, position.getZ() + 0.5); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); world.addEntity(hologram); currentY += 0.23; holograms.add(hologram); @@ -221,18 +225,23 @@ public final class NMSAdapter_v1_9_R1 implements NMSAdapter { currentTick = 0; - if(((WChunkLoader) chunkLoader).isNotActive()){ + if(chunkLoader.isNotActive()){ chunkLoader.remove(); return; } + if(chunkLoader.isInfinite()) + return; + + List hologramLines = chunkLoader.getHologramLines(); + int hologramsAmount = holograms.size(); for (int i = hologramsAmount; i > 0; i--) { EntityHolograms_v1_9_R1 hologram = holograms.get(hologramsAmount - i); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); } - ((WChunkLoader) chunkLoader).tick(); + chunkLoader.tick(); if(!removed) { secondsAmount--; diff --git a/v1_9_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_9_R2.java b/v1_9_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_9_R2.java index da9647f..3320b94 100644 --- a/v1_9_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_9_R2.java +++ b/v1_9_R2/src/main/java/com/bgsoftware/wildloaders/nms/NMSAdapter_v1_9_R2.java @@ -177,37 +177,41 @@ public final class NMSAdapter_v1_9_R2 implements NMSAdapter { private static final Map tileEntityChunkLoaderMap = new HashMap<>(); private final List holograms = new ArrayList<>(); - private final ChunkLoader chunkLoader; + private final WChunkLoader chunkLoader; private short currentTick = 20; private short daysAmount, hoursAmount, minutesAmount, secondsAmount; private boolean removed = false; TileEntityChunkLoader(ChunkLoader chunkLoader, World world, BlockPosition blockPosition){ - this.chunkLoader = chunkLoader; + this.chunkLoader = (WChunkLoader) chunkLoader; a(blockPosition); a(world); - long timeLeft = chunkLoader.getTimeLeft(); + if(!this.chunkLoader.isInfinite()) { + long timeLeft = chunkLoader.getTimeLeft(); - daysAmount = (short) (timeLeft / 86400); - timeLeft = timeLeft % 86400; + daysAmount = (short) (timeLeft / 86400); + timeLeft = timeLeft % 86400; - hoursAmount = (short) (timeLeft / 3600); - timeLeft = timeLeft % 3600; + hoursAmount = (short) (timeLeft / 3600); + timeLeft = timeLeft % 3600; - minutesAmount = (short) (timeLeft / 60); - timeLeft = timeLeft % 60; + minutesAmount = (short) (timeLeft / 60); + timeLeft = timeLeft % 60; - secondsAmount = (short) timeLeft; + secondsAmount = (short) timeLeft; + } tileEntityChunkLoaderMap.put(LongHash.toLong(blockPosition.getX() >> 4, blockPosition.getZ() >> 4), this); + List hologramLines = this.chunkLoader.getHologramLines(); + double currentY = position.getY() + 1; - for(int i = plugin.getSettings().hologramLines.size(); i > 0; i--){ + for(int i = hologramLines.size(); i > 0; i--){ EntityHolograms_v1_9_R2 hologram = new EntityHolograms_v1_9_R2(world, position.getX() + 0.5, currentY, position.getZ() + 0.5); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); world.addEntity(hologram); currentY += 0.23; holograms.add(hologram); @@ -221,18 +225,23 @@ public final class NMSAdapter_v1_9_R2 implements NMSAdapter { currentTick = 0; - if(((WChunkLoader) chunkLoader).isNotActive()){ + if(chunkLoader.isNotActive()){ chunkLoader.remove(); return; } + if(chunkLoader.isInfinite()) + return; + + List hologramLines = chunkLoader.getHologramLines(); + int hologramsAmount = holograms.size(); for (int i = hologramsAmount; i > 0; i--) { EntityHolograms_v1_9_R2 hologram = holograms.get(hologramsAmount - i); - updateName(hologram, plugin.getSettings().hologramLines.get(i - 1)); + updateName(hologram, hologramLines.get(i - 1)); } - ((WChunkLoader) chunkLoader).tick(); + chunkLoader.tick(); if(!removed) { secondsAmount--;