mirror of
https://github.com/BG-Software-LLC/WildLoaders.git
synced 2024-11-13 10:33:58 +01:00
Fixed chunk loaders with chunks-spread enabled not loading chunks at all if they are not placed inside a claim (#36)
This commit is contained in:
parent
0a2fbde412
commit
2fd477d47e
@ -33,7 +33,7 @@ public final class WChunkLoader implements ChunkLoader {
|
|||||||
private boolean active = true;
|
private boolean active = true;
|
||||||
private long timeLeft;
|
private long timeLeft;
|
||||||
|
|
||||||
public WChunkLoader(LoaderData loaderData, UUID whoPlaced, Location location, long timeLeft){
|
public WChunkLoader(LoaderData loaderData, UUID whoPlaced, Location location, long timeLeft) {
|
||||||
this.loaderName = loaderData.getName();
|
this.loaderName = loaderData.getName();
|
||||||
this.whoPlaced = whoPlaced;
|
this.whoPlaced = whoPlaced;
|
||||||
this.location = location.clone();
|
this.location = location.clone();
|
||||||
@ -52,8 +52,8 @@ public final class WChunkLoader implements ChunkLoader {
|
|||||||
return Bukkit.getOfflinePlayer(whoPlaced);
|
return Bukkit.getOfflinePlayer(whoPlaced);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNotActive(){
|
public boolean isNotActive() {
|
||||||
if(active)
|
if (active)
|
||||||
active = plugin.getLoaders().getChunkLoader(getLocation()).orElse(null) == this;
|
active = plugin.getLoaders().getChunkLoader(getLocation()).orElse(null) == this;
|
||||||
return !active;
|
return !active;
|
||||||
}
|
}
|
||||||
@ -63,10 +63,10 @@ public final class WChunkLoader implements ChunkLoader {
|
|||||||
return timeLeft;
|
return timeLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tick(){
|
public void tick() {
|
||||||
plugin.getProviders().tick(loadedChunks);
|
plugin.getProviders().tick(loadedChunks);
|
||||||
|
|
||||||
if(!isInfinite()) {
|
if (!isInfinite()) {
|
||||||
timeLeft--;
|
timeLeft--;
|
||||||
if (timeLeft < 0) {
|
if (timeLeft < 0) {
|
||||||
remove();
|
remove();
|
||||||
@ -79,7 +79,7 @@ public final class WChunkLoader implements ChunkLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInfinite(){
|
public boolean isInfinite() {
|
||||||
return timeLeft == Integer.MIN_VALUE;
|
return timeLeft == Integer.MIN_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ public final class WChunkLoader implements ChunkLoader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
if(!Bukkit.isPrimaryThread()){
|
if (!Bukkit.isPrimaryThread()) {
|
||||||
Executor.sync(this::remove);
|
Executor.sync(this::remove);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -121,17 +121,18 @@ public final class WChunkLoader implements ChunkLoader {
|
|||||||
return tileEntityChunkLoader.getHolograms();
|
return tileEntityChunkLoader.getHolograms();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getHologramLines(){
|
public List<String> getHologramLines() {
|
||||||
return isInfinite() ? plugin.getSettings().infiniteHologramLines : plugin.getSettings().hologramLines;
|
return isInfinite() ? plugin.getSettings().infiniteHologramLines : plugin.getSettings().hologramLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Chunk[] calculateChunks(LoaderData loaderData, UUID whoPlaced, Location original){
|
private static Chunk[] calculateChunks(LoaderData loaderData, UUID whoPlaced, Location original) {
|
||||||
List<Chunk> chunkList = new ArrayList<>();
|
List<Chunk> chunkList = new ArrayList<>();
|
||||||
|
|
||||||
if(loaderData.isChunksSpread()){
|
if (loaderData.isChunksSpread()) {
|
||||||
calculateClaimChunks(original.getChunk(), whoPlaced, chunkList);
|
calculateClaimChunks(original.getChunk(), whoPlaced, chunkList);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
if (chunkList.isEmpty()) {
|
||||||
int chunkX = original.getBlockX() >> 4, chunkZ = original.getBlockZ() >> 4;
|
int chunkX = original.getBlockX() >> 4, chunkZ = original.getBlockZ() >> 4;
|
||||||
|
|
||||||
for (int x = -loaderData.getChunksRadius(); x <= loaderData.getChunksRadius(); x++)
|
for (int x = -loaderData.getChunksRadius(); x <= loaderData.getChunksRadius(); x++)
|
||||||
@ -142,8 +143,8 @@ public final class WChunkLoader implements ChunkLoader {
|
|||||||
return chunkList.toArray(new Chunk[0]);
|
return chunkList.toArray(new Chunk[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void calculateClaimChunks(Chunk originalChunk, UUID whoPlaced, List<Chunk> chunkList){
|
private static void calculateClaimChunks(Chunk originalChunk, UUID whoPlaced, List<Chunk> chunkList) {
|
||||||
if(!plugin.getProviders().hasChunkAccess(whoPlaced, originalChunk))
|
if (!plugin.getProviders().hasChunkAccess(whoPlaced, originalChunk))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
chunkList.add(originalChunk);
|
chunkList.add(originalChunk);
|
||||||
@ -152,7 +153,7 @@ public final class WChunkLoader implements ChunkLoader {
|
|||||||
|
|
||||||
for (int x = -1; x <= 1; x++) {
|
for (int x = -1; x <= 1; x++) {
|
||||||
for (int z = -1; z <= 1; z++) {
|
for (int z = -1; z <= 1; z++) {
|
||||||
if(x != 0 || z != 0) // We don't want to add the originalChunk again.
|
if (x != 0 || z != 0) // We don't want to add the originalChunk again.
|
||||||
calculateClaimChunks(originalChunk.getWorld().getChunkAt(chunkX + x, chunkZ + z), whoPlaced, chunkList);
|
calculateClaimChunks(originalChunk.getWorld().getChunkAt(chunkX + x, chunkZ + z), whoPlaced, chunkList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user