From 8cddf30b9e4416b0f878f7d3909bc0e92701a037 Mon Sep 17 00:00:00 2001 From: themode Date: Mon, 14 Dec 2020 01:41:08 +0100 Subject: [PATCH] Annotation for ChunkGenerator --- .../net/minestom/demo/largeframebuffers/MainDemo.java | 5 +++-- .../net/minestom/server/instance/ChunkGenerator.java | 9 ++++++--- src/test/java/demo/MainDemo.java | 5 +++-- src/test/java/demo/generator/ChunkGeneratorDemo.java | 5 +++-- src/test/java/demo/generator/NoiseTestGenerator.java | 5 +++-- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/lwjgl/java/net/minestom/demo/largeframebuffers/MainDemo.java b/src/lwjgl/java/net/minestom/demo/largeframebuffers/MainDemo.java index 4f3faefad..a90bc106e 100644 --- a/src/lwjgl/java/net/minestom/demo/largeframebuffers/MainDemo.java +++ b/src/lwjgl/java/net/minestom/demo/largeframebuffers/MainDemo.java @@ -10,6 +10,7 @@ import net.minestom.server.instance.block.Block; import net.minestom.server.network.ConnectionManager; import net.minestom.server.utils.Position; import net.minestom.server.world.biomes.Biome; +import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.List; @@ -51,7 +52,7 @@ public class MainDemo { private static class GeneratorDemo implements ChunkGenerator { @Override - public void generateChunkData(ChunkBatch batch, int chunkX, int chunkZ) { + public void generateChunkData(@NotNull ChunkBatch batch, int chunkX, int chunkZ) { // Set chunk blocks for (byte x = 0; x < Chunk.CHUNK_SIZE_X; x++) for (byte z = 0; z < Chunk.CHUNK_SIZE_Z; z++) { @@ -62,7 +63,7 @@ public class MainDemo { } @Override - public void fillBiomes(Biome[] biomes, int chunkX, int chunkZ) { + public void fillBiomes(Biome @NotNull [] biomes, int chunkX, int chunkZ) { Arrays.fill(biomes, MinecraftServer.getBiomeManager().getById(0)); } diff --git a/src/main/java/net/minestom/server/instance/ChunkGenerator.java b/src/main/java/net/minestom/server/instance/ChunkGenerator.java index 1b7306145..cd9757c66 100644 --- a/src/main/java/net/minestom/server/instance/ChunkGenerator.java +++ b/src/main/java/net/minestom/server/instance/ChunkGenerator.java @@ -3,6 +3,8 @@ package net.minestom.server.instance; import net.minestom.server.instance.batch.ChunkBatch; import net.minestom.server.instance.block.Block; import net.minestom.server.world.biomes.Biome; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -23,7 +25,7 @@ public interface ChunkGenerator { * @param chunkX the chunk X * @param chunkZ the chunk Z */ - void generateChunkData(ChunkBatch batch, int chunkX, int chunkZ); + void generateChunkData(@NotNull ChunkBatch batch, int chunkX, int chunkZ); /** * Defines all the {@link Biome} in the {@link Chunk}. @@ -32,13 +34,14 @@ public interface ChunkGenerator { * @param chunkX the chunk X * @param chunkZ the chunk Z */ - void fillBiomes(Biome[] biomes, int chunkX, int chunkZ); + void fillBiomes(@NotNull Biome[] biomes, int chunkX, int chunkZ); /** * Gets all the {@link ChunkPopulator} of this generator. * - * @return a {@link List} of {@link ChunkPopulator} + * @return a {@link List} of {@link ChunkPopulator}, can be null or empty */ + @Nullable List getPopulators(); } diff --git a/src/test/java/demo/MainDemo.java b/src/test/java/demo/MainDemo.java index d8327a12a..c53fd3d4c 100644 --- a/src/test/java/demo/MainDemo.java +++ b/src/test/java/demo/MainDemo.java @@ -9,6 +9,7 @@ import net.minestom.server.instance.batch.ChunkBatch; import net.minestom.server.instance.block.Block; import net.minestom.server.utils.Position; import net.minestom.server.world.biomes.Biome; +import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.List; @@ -42,7 +43,7 @@ public class MainDemo { private static class GeneratorDemo implements ChunkGenerator { @Override - public void generateChunkData(ChunkBatch batch, int chunkX, int chunkZ) { + public void generateChunkData(@NotNull ChunkBatch batch, int chunkX, int chunkZ) { // Set chunk blocks for (byte x = 0; x < Chunk.CHUNK_SIZE_X; x++) for (byte z = 0; z < Chunk.CHUNK_SIZE_Z; z++) { @@ -53,7 +54,7 @@ public class MainDemo { } @Override - public void fillBiomes(Biome[] biomes, int chunkX, int chunkZ) { + public void fillBiomes(Biome @NotNull [] biomes, int chunkX, int chunkZ) { Arrays.fill(biomes, Biome.PLAINS); } diff --git a/src/test/java/demo/generator/ChunkGeneratorDemo.java b/src/test/java/demo/generator/ChunkGeneratorDemo.java index 8d58d0386..c86763fd6 100644 --- a/src/test/java/demo/generator/ChunkGeneratorDemo.java +++ b/src/test/java/demo/generator/ChunkGeneratorDemo.java @@ -7,6 +7,7 @@ import net.minestom.server.instance.ChunkPopulator; import net.minestom.server.instance.batch.ChunkBatch; import net.minestom.server.instance.block.Block; import net.minestom.server.world.biomes.Biome; +import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.List; @@ -14,7 +15,7 @@ import java.util.List; public class ChunkGeneratorDemo implements ChunkGenerator { @Override - public void generateChunkData(ChunkBatch batch, int chunkX, int chunkZ) { + public void generateChunkData(@NotNull ChunkBatch batch, int chunkX, int chunkZ) { for (byte x = 0; x < Chunk.CHUNK_SIZE_X; x++) for (byte z = 0; z < Chunk.CHUNK_SIZE_Z; z++) { for (byte y = 0; y < 40; y++) { @@ -24,7 +25,7 @@ public class ChunkGeneratorDemo implements ChunkGenerator { } @Override - public void fillBiomes(Biome[] biomes, int chunkX, int chunkZ) { + public void fillBiomes(Biome @NotNull [] biomes, int chunkX, int chunkZ) { Arrays.fill(biomes, MinecraftServer.getBiomeManager().getById(0)); } diff --git a/src/test/java/demo/generator/NoiseTestGenerator.java b/src/test/java/demo/generator/NoiseTestGenerator.java index f43ccb998..973d09725 100644 --- a/src/test/java/demo/generator/NoiseTestGenerator.java +++ b/src/test/java/demo/generator/NoiseTestGenerator.java @@ -10,6 +10,7 @@ import net.minestom.server.instance.batch.ChunkBatch; import net.minestom.server.instance.block.Block; import net.minestom.server.utils.BlockPosition; import net.minestom.server.world.biomes.Biome; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.Arrays; @@ -29,7 +30,7 @@ public class NoiseTestGenerator implements ChunkGenerator { } @Override - public void generateChunkData(ChunkBatch batch, int chunkX, int chunkZ) { + public void generateChunkData(@NotNull ChunkBatch batch, int chunkX, int chunkZ) { for (int x = 0; x < Chunk.CHUNK_SIZE_X; x++) { for (int z = 0; z < Chunk.CHUNK_SIZE_Z; z++) { final int height = getHeight(x + chunkX * 16, z + chunkZ * 16); @@ -63,7 +64,7 @@ public class NoiseTestGenerator implements ChunkGenerator { } @Override - public void fillBiomes(Biome[] biomes, int chunkX, int chunkZ) { + public void fillBiomes(Biome @NotNull [] biomes, int chunkX, int chunkZ) { Arrays.fill(biomes, MinecraftServer.getBiomeManager().getById(0)); }