Move comments to ChunkCoordinator, remove Range annotations

This commit is contained in:
dordsor21 2020-07-28 08:44:16 +01:00
parent 3288721259
commit 97b1a60ae8
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
4 changed files with 20 additions and 22 deletions

View File

@ -38,7 +38,6 @@ import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
import org.jetbrains.annotations.Range;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.Random; import java.util.Random;
@ -72,8 +71,7 @@ final class DelegatePlotGenerator extends IndependentPlotGenerator {
Random random = new Random(MathMan.pair((short) chunkX, (short) chunkZ)); Random random = new Random(MathMan.pair((short) chunkX, (short) chunkZ));
try { try {
ChunkGenerator.BiomeGrid grid = new ChunkGenerator.BiomeGrid() { ChunkGenerator.BiomeGrid grid = new ChunkGenerator.BiomeGrid() {
@Override public void setBiome(@Range(from = 0, to = 15) int x, @Override public void setBiome(int x, int z, @Nonnull Biome biome) {
@Range(from = 0, to = 15) int z, @Nonnull Biome biome) {
result.setBiome(x, z, BukkitAdapter.adapt(biome)); result.setBiome(x, z, BukkitAdapter.adapt(biome));
} }

View File

@ -97,9 +97,6 @@ public final class BukkitChunkCoordinator extends ChunkCoordinator {
this.bukkitWorld = Bukkit.getWorld(world.getName()); this.bukkitWorld = Bukkit.getWorld(world.getName());
} }
/**
* Start the coordinator instance
*/
@Override public void start() { @Override public void start() {
// Request initial batch // Request initial batch
this.requestBatch(); this.requestBatch();
@ -195,20 +192,10 @@ public final class BukkitChunkCoordinator extends ChunkCoordinator {
chunk.removePluginChunkTicket(this.plugin); chunk.removePluginChunkTicket(this.plugin);
} }
/**
* Get the amount of remaining chunks (at the time of the method call)
*
* @return Snapshot view of remaining chunk count
*/
@Override public int getRemainingChunks() { @Override public int getRemainingChunks() {
return this.expectedSize.get(); return this.expectedSize.get();
} }
/**
* Get the amount of requested chunks
*
* @return Requested chunk count
*/
@Override public int getTotalChunks() { @Override public int getTotalChunks() {
return this.totalSize; return this.totalSize;
} }

View File

@ -39,9 +39,24 @@ public abstract class ChunkCoordinator implements PlotSquaredTask {
// Do nothing // Do nothing
} }
/**
* Starts the chunk coordinator. This will usually (implementation-specific-permitting) mark chunks to be loaded in batches,
* then add them to a queue and apply tickets once loaded to prevent unloading. A repeating task will then iterate over loaded
* chunks, access them with a Consumer(BlockVector2) and remove the ticket once work has been completed on it.
*/
public abstract void start(); public abstract void start();
/**
* Get the amount of remaining chunks (at the time of the method call)
*
* @return Snapshot view of remaining chunk count
*/
public abstract int getRemainingChunks(); public abstract int getRemainingChunks();
/**
* Get the amount of requested chunks
*
* @return Requested chunk count
*/
public abstract int getTotalChunks(); public abstract int getTotalChunks();
} }

View File

@ -28,7 +28,6 @@ package com.plotsquared.core.util;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
import org.jetbrains.annotations.Range;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@ -84,8 +83,7 @@ public class ChunkUtil {
* @param z Relative z coordinate * @param z Relative z coordinate
* @return J value for xyz position in Array[4096]. * @return J value for xyz position in Array[4096].
*/ */
public static int getJ(@Range(from = 0, to = 15) int x, @Range(from = 0, to = 255) int y, public static int getJ(int x, int y, int z) {
@Range(from = 0, to = 15) int z) {
return CACHE_J[y][x][z]; return CACHE_J[y][x][z];
} }
@ -95,7 +93,7 @@ public class ChunkUtil {
* @param j Position in the xyz Array[4096]. * @param j Position in the xyz Array[4096].
* @return x coordinate within the chunk * @return x coordinate within the chunk
*/ */
public static int getX(@Range(from = 0, to = 4095) int j) { public static int getX(int j) {
return x_loc[j]; return x_loc[j];
} }
@ -106,7 +104,7 @@ public class ChunkUtil {
* @param j Position in the xyz Array[4096]. * @param j Position in the xyz Array[4096].
* @return x coordinate within the chunk * @return x coordinate within the chunk
*/ */
public static int getY(@Range(from = 0, to = 15) int i, @Range(from = 0, to = 4095) int j) { public static int getY(int i, int j) {
return y_loc[i][j]; return y_loc[i][j];
} }
@ -116,7 +114,7 @@ public class ChunkUtil {
* @param j Position in the xyz Array[4096]. * @param j Position in the xyz Array[4096].
* @return z coordinate within the chunk * @return z coordinate within the chunk
*/ */
public static int getZ(@Range(from = 0, to = 4095) int j) { public static int getZ(int j) {
return z_loc[j]; return z_loc[j];
} }