diff --git a/src/main/java/me/outspending/biomesapi/BiomeSetter.java b/src/main/java/me/outspending/biomesapi/BiomeSetter.java index 4af88ac..55fd48c 100644 --- a/src/main/java/me/outspending/biomesapi/BiomeSetter.java +++ b/src/main/java/me/outspending/biomesapi/BiomeSetter.java @@ -23,13 +23,7 @@ */ @UtilityClass @AsOf("0.0.1") -public final class BiomeSetter { - - @SuppressWarnings("deprecation") - private static final UnsafeValues UNSAFE = Bukkit.getUnsafe(); - - private static final int MAX_HEIGHT = 320; - private static final int MIN_HEIGHT = -64; +public interface BiomeSetter { /** * Returns the RegionAccessor for the given location. @@ -39,7 +33,7 @@ public final class BiomeSetter { * @version 0.0.1 */ @AsOf("0.0.1") - private static @NotNull RegionAccessor getRegionAccessor(@NotNull Location location) { + default @NotNull RegionAccessor getRegionAccessor(@NotNull Location location) { return location.getWorld(); } @@ -51,9 +45,7 @@ public final class BiomeSetter { * @version 0.0.1 */ @AsOf("0.0.1") - public static void setBlockBiome(@NotNull Block block, @NotNull CustomBiome customBiome) { - setBlockBiome(block, customBiome, false); - } + void setBlockBiome(@NotNull Block block, @NotNull CustomBiome customBiome); /** * Sets the biome of a block to a custom biome. @@ -67,16 +59,7 @@ public static void setBlockBiome(@NotNull Block block, @NotNull CustomBiome cust * @version 0.0.1 */ @AsOf("0.0.1") - public static void setBlockBiome(@NotNull Block block, @NotNull CustomBiome customBiome, boolean updateBiome) { - Location location = block.getLocation(); - RegionAccessor accessor = getRegionAccessor(location); - - UNSAFE.setBiomeKey(accessor, location.getBlockX(), location.getBlockY(), location.getBlockZ(), customBiome.toNamespacedKey()); - - if (updateBiome) { - BiomeUpdater.updateChunk(location.getChunk()); - } - } + void setBlockBiome(@NotNull Block block, @NotNull CustomBiome customBiome, boolean updateBiome); /** * Sets the biome of a chunk to a custom biome. @@ -86,9 +69,7 @@ public static void setBlockBiome(@NotNull Block block, @NotNull CustomBiome cust * @version 0.0.1 */ @AsOf("0.0.1") - public static void setChunkBiome(@NotNull Chunk chunk, @NotNull CustomBiome customBiome) { - setChunkBiome(chunk, MIN_HEIGHT, MAX_HEIGHT, customBiome); - } + void setChunkBiome(@NotNull Chunk chunk, @NotNull CustomBiome customBiome); /** * Sets the biome of a chunk to a custom biome within the default height range. @@ -101,9 +82,7 @@ public static void setChunkBiome(@NotNull Chunk chunk, @NotNull CustomBiome cust * @version 0.0.1 */ @AsOf("0.0.1") - public static void setChunkBiome(@NotNull Chunk chunk, @NotNull CustomBiome customBiome, boolean updateBiome) { - setChunkBiome(chunk, MIN_HEIGHT, MAX_HEIGHT, customBiome, updateBiome); - } + void setChunkBiome(@NotNull Chunk chunk, @NotNull CustomBiome customBiome, boolean updateBiome); /** * Sets the biome of a chunk to a custom biome within a height range. @@ -115,9 +94,7 @@ public static void setChunkBiome(@NotNull Chunk chunk, @NotNull CustomBiome cust * @version 0.0.1 */ @AsOf("0.0.1") - public static void setChunkBiome(@NotNull Chunk chunk, int minHeight, int maxHeight, @NotNull CustomBiome customBiome) { - setChunkBiome(chunk, minHeight, maxHeight, customBiome, false); - } + void setChunkBiome(@NotNull Chunk chunk, int minHeight, int maxHeight, @NotNull CustomBiome customBiome); /** * Sets the biome of a chunk to a custom biome within a specified height range. @@ -133,35 +110,7 @@ public static void setChunkBiome(@NotNull Chunk chunk, int minHeight, int maxHei * @version 0.0.1 */ @AsOf("0.0.1") - public static void setChunkBiome( - @NotNull Chunk chunk, - int minHeight, - int maxHeight, - @NotNull CustomBiome customBiome, - boolean updateBiome - ) { - RegionAccessor accessor = chunk.getWorld(); - NamespacedKey key = customBiome.toNamespacedKey(); - - int minX = chunk.getX() << 4; - int maxX = minX + 16; - - int minZ = chunk.getZ() << 4; - int maxZ = minZ + 16; - - for (int x = minX; x < maxX; x++) { - for (int y = minHeight; y < maxHeight; y++) { - for (int z = minZ; z < maxZ; z++) { - // Set the biome of each block to the custom biome - UNSAFE.setBiomeKey(accessor, x, y, z, key); - } - } - } - - if (updateBiome) { - BiomeUpdater.updateChunk(chunk); - } - } + void setChunkBiome(@NotNull Chunk chunk, int minHeight, int maxHeight, @NotNull CustomBiome customBiome, boolean updateBiome); /** * Sets the biome of a bounding box to a custom biome. @@ -172,9 +121,7 @@ public static void setChunkBiome( * @version 0.0.1 */ @AsOf("0.0.1") - public static void setBoundingBoxBiome(@NotNull World world, @NotNull BoundingBox boundingBox, @NotNull CustomBiome customBiome) { - setRegionBiome(world, boundingBox.getMin(), boundingBox.getMax(), customBiome); - } + void setBoundingBoxBiome(@NotNull World world, @NotNull BoundingBox boundingBox, @NotNull CustomBiome customBiome); /** * Sets the biome of a region to a custom biome. @@ -185,14 +132,7 @@ public static void setBoundingBoxBiome(@NotNull World world, @NotNull BoundingBo * @version 0.0.1 */ @AsOf("0.0.1") - public static void setRegionBiome(@NotNull Location from, @NotNull Location to, @NotNull CustomBiome customBiome) { - if (from.getWorld().equals(to.getWorld())) { - setRegionBiome(from.getWorld(), from, to, customBiome, true); - return; - } - - throw new IllegalArgumentException("Locations must be in the same world!"); - } + void setRegionBiome(@NotNull Location from, @NotNull Location to, @NotNull CustomBiome customBiome); /** * Sets the biome of a region to a custom biome. @@ -205,14 +145,7 @@ public static void setRegionBiome(@NotNull Location from, @NotNull Location to, * @version 0.0.1 */ @AsOf("0.0.1") - public static void setRegionBiome(@NotNull Location from, @NotNull Location to, @NotNull CustomBiome customBiome, boolean updateBiome) { - if (from.getWorld().equals(to.getWorld())) { - setRegionBiome(from.getWorld(), from, to, customBiome, updateBiome); - return; - } - - throw new IllegalArgumentException("Locations must be in the same world!"); - } + void setRegionBiome(@NotNull Location from, @NotNull Location to, @NotNull CustomBiome customBiome, boolean updateBiome); /** * Sets the biome of a region to a custom biome. @@ -224,9 +157,7 @@ public static void setRegionBiome(@NotNull Location from, @NotNull Location to, * @version 0.0.1 */ @AsOf("0.0.1") - public static void setRegionBiome(@NotNull World world, @NotNull Vector from, @NotNull Vector to, @NotNull CustomBiome customBiome) { - setRegionBiome(world, from, to, customBiome, false); - } + void setRegionBiome(@NotNull World world, @NotNull Vector from, @NotNull Vector to, @NotNull CustomBiome customBiome); /** * Sets the biome of a region to a custom biome. @@ -240,15 +171,7 @@ public static void setRegionBiome(@NotNull World world, @NotNull Vector from, @N * @version 0.0.1 */ @AsOf("0.0.2") - public static void setRegionBiome( - @NotNull World world, - @NotNull Vector from, - @NotNull Vector to, - @NotNull CustomBiome customBiome, - boolean updateBiome - ) { - setRegionBiome(world, from.toLocation(world), to.toLocation(world), customBiome, updateBiome); - } + void setRegionBiome(@NotNull World world, @NotNull Vector from, @NotNull Vector to, @NotNull CustomBiome customBiome, boolean updateBiome); /** * Sets the biome of a region to a custom biome. @@ -264,34 +187,6 @@ public static void setRegionBiome( * @version 0.0.2 */ @AsOf("0.0.1") - public static void setRegionBiome( - @NotNull World world, - @NotNull Location from, - @NotNull Location to, - @NotNull CustomBiome customBiome, - boolean updateBiome - ) { - PointRange3D range = PointRange3D.of(from, to); - Optional nms = NMSHandler.getNMS(); - - nms.ifPresent(n -> n.updateBiome(range.getMinLocation(world), range.getMaxLocation(world), customBiome.toNamespacedKey())); - - if (updateBiome) { - BiomeUpdater.updateChunks(from, to); - } -// int minHeight = Math.max(range.minY(), MIN_HEIGHT); -// int maxHeight = Math.min(range.maxY(), MAX_HEIGHT); -// -// // Iterate over the blocks in the region -// for (int x = range.minX(); x <= range.maxX(); x++) { -// for (int y = minHeight; y <= maxHeight; y++) { -// for (int z = range.minZ(); z <= range.maxZ(); z++) { -// // Set the biome of each block to the custom biome -// UNSAFE.setBiomeKey(accessor, x, y, z, key); -// } -// } -// } - - } + void setRegionBiome(@NotNull World world, @NotNull Location from, @NotNull Location to, @NotNull CustomBiome customBiome, boolean updateBiome); } \ No newline at end of file diff --git a/src/main/java/me/outspending/biomesapi/BiomeSetterImpl.java b/src/main/java/me/outspending/biomesapi/BiomeSetterImpl.java new file mode 100644 index 0000000..c12b22e --- /dev/null +++ b/src/main/java/me/outspending/biomesapi/BiomeSetterImpl.java @@ -0,0 +1,128 @@ +package me.outspending.biomesapi; + +import me.outspending.biomesapi.biome.CustomBiome; +import me.outspending.biomesapi.misc.PointRange3D; +import me.outspending.biomesapi.nms.NMS; +import me.outspending.biomesapi.nms.NMSHandler; +import org.bukkit.*; +import org.bukkit.block.Block; +import org.bukkit.util.BoundingBox; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +import java.util.Optional; + +public class BiomeSetterImpl implements BiomeSetter { + + @SuppressWarnings("deprecation") + private static final UnsafeValues UNSAFE = Bukkit.getUnsafe(); + private static final BiomeUpdater BIOME_UPDATER = BiomeUpdater.of(); + + private static final int MAX_HEIGHT = 320; + private static final int MIN_HEIGHT = -64; + + @Override + public void setBlockBiome(@NotNull Block block, @NotNull CustomBiome customBiome) { + setBlockBiome(block, customBiome, false); + } + + @Override + public void setBlockBiome(@NotNull Block block, @NotNull CustomBiome customBiome, boolean updateBiome) { + Location location = block.getLocation(); + RegionAccessor accessor = getRegionAccessor(location); + + UNSAFE.setBiomeKey(accessor, location.getBlockX(), location.getBlockY(), location.getBlockZ(), customBiome.toNamespacedKey()); + + if (updateBiome) { + BIOME_UPDATER.updateChunk(location.getChunk()); + } + } + + @Override + public void setChunkBiome(@NotNull Chunk chunk, @NotNull CustomBiome customBiome) { + setChunkBiome(chunk, MIN_HEIGHT, MAX_HEIGHT, customBiome); + } + + @Override + public void setChunkBiome(@NotNull Chunk chunk, @NotNull CustomBiome customBiome, boolean updateBiome) { + setChunkBiome(chunk, MIN_HEIGHT, MAX_HEIGHT, customBiome, updateBiome); + } + + @Override + public void setChunkBiome(@NotNull Chunk chunk, int minHeight, int maxHeight, @NotNull CustomBiome customBiome) { + setChunkBiome(chunk, minHeight, maxHeight, customBiome, false); + } + + @Override + public void setChunkBiome(@NotNull Chunk chunk, int minHeight, int maxHeight, @NotNull CustomBiome customBiome, boolean updateBiome) { + RegionAccessor accessor = chunk.getWorld(); + NamespacedKey key = customBiome.toNamespacedKey(); + + int minX = chunk.getX() << 4; + int maxX = minX + 16; + + int minZ = chunk.getZ() << 4; + int maxZ = minZ + 16; + + for (int x = minX; x < maxX; x++) { + for (int y = minHeight; y < maxHeight; y++) { + for (int z = minZ; z < maxZ; z++) { + // Set the biome of each block to the custom biome + UNSAFE.setBiomeKey(accessor, x, y, z, key); + } + } + } + + if (updateBiome) { + BIOME_UPDATER.updateChunk(chunk); + } + } + + @Override + public void setBoundingBoxBiome(@NotNull World world, @NotNull BoundingBox boundingBox, @NotNull CustomBiome customBiome) { + setRegionBiome(world, boundingBox.getMin(), boundingBox.getMax(), customBiome); + } + + @Override + public void setRegionBiome(@NotNull Location from, @NotNull Location to, @NotNull CustomBiome customBiome) { + World world = from.getWorld(); + if (!world.equals(to.getWorld())) { + throw new IllegalArgumentException("Locations must be in the same world!"); + } + + setRegionBiome(world, from, to, customBiome, false); + } + + @Override + public void setRegionBiome(@NotNull Location from, @NotNull Location to, @NotNull CustomBiome customBiome, boolean updateBiome) { + World world = from.getWorld(); + if (!world.equals(to.getWorld())) { + throw new IllegalArgumentException("Locations must be in the same world!"); + } + + setRegionBiome(world, from, to, customBiome, updateBiome); + } + + @Override + public void setRegionBiome(@NotNull World world, @NotNull Vector from, @NotNull Vector to, @NotNull CustomBiome customBiome) { + setRegionBiome(world, from, to, customBiome, false); + } + + @Override + public void setRegionBiome(@NotNull World world, @NotNull Vector from, @NotNull Vector to, @NotNull CustomBiome customBiome, boolean updateBiome) { + setRegionBiome(world, from.toLocation(world), to.toLocation(world), customBiome, updateBiome); + } + + @Override + public void setRegionBiome(@NotNull World world, @NotNull Location from, @NotNull Location to, @NotNull CustomBiome customBiome, boolean updateBiome) { + PointRange3D range = PointRange3D.of(from, to); + Optional nms = NMSHandler.getNMS(); + + nms.ifPresent(n -> n.updateBiome(range.getMinLocation(world), range.getMaxLocation(world), customBiome.toNamespacedKey())); + + if (updateBiome) { + BIOME_UPDATER.updateChunks(from, to); + } + } + +} diff --git a/src/main/java/me/outspending/biomesapi/BiomeUpdater.java b/src/main/java/me/outspending/biomesapi/BiomeUpdater.java index 2236169..eb4ecde 100644 --- a/src/main/java/me/outspending/biomesapi/BiomeUpdater.java +++ b/src/main/java/me/outspending/biomesapi/BiomeUpdater.java @@ -8,6 +8,7 @@ import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; +import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -21,9 +22,20 @@ * * @version 0.0.1 */ -@UtilityClass @AsOf("0.0.1") -public final class BiomeUpdater { +public interface BiomeUpdater { + + /** + * Returns an instance of BiomeUpdater. + * This method returns an instance of BiomeUpdaterImpl. + * + * @return an instance of BiomeUpdater. + * @version 0.0.2 + */ + @AsOf("0.0.2") + static @NotNull BiomeUpdater of() { + return new BiomeUpdaterImpl(); + } /** * Returns a list of chunks between two locations. @@ -36,7 +48,7 @@ public final class BiomeUpdater { * @version 0.0.1 */ @AsOf("0.0.1") - private static @NotNull List getChunksBetweenLocations(@NotNull Location from, @NotNull Location to) { + default @NotNull List getChunksBetweenLocations(@NotNull Location from, @NotNull Location to) { if (!from.getWorld().equals(to.getWorld())) { throw new IllegalArgumentException("Locations must be in the same world."); } @@ -62,9 +74,7 @@ public final class BiomeUpdater { * @version 0.0.1 */ @AsOf("0.0.1") - public static void updateChunk(@NotNull Chunk chunk) { - updateChunks(List.of(chunk)); - } + void updateChunk(@NotNull Chunk chunk); /** * Updates the biomes of the chunks between two locations. @@ -75,9 +85,8 @@ public static void updateChunk(@NotNull Chunk chunk) { * @version 0.0.1 */ @AsOf("0.0.1") - public static void updateChunks(@NotNull Location from, @NotNull Location to) { - updateChunks(getChunksBetweenLocations(from, to)); - } + @Contract("null, _ -> fail; _, null -> fail") + void updateChunks(Location from, Location to); /** * Updates the biomes of a list of chunks within a certain distance. @@ -88,10 +97,6 @@ public static void updateChunks(@NotNull Location from, @NotNull Location to) { * @version 0.0.1 */ @AsOf("0.0.1") - public static void updateChunks(@NotNull List chunks) { - Optional nms = NMSHandler.getNMS(); - - nms.ifPresent(nmsInstance -> nmsInstance.updateChunks(chunks)); - } + void updateChunks(@NotNull List chunks); } diff --git a/src/main/java/me/outspending/biomesapi/BiomeUpdaterImpl.java b/src/main/java/me/outspending/biomesapi/BiomeUpdaterImpl.java new file mode 100644 index 0000000..0e4cda8 --- /dev/null +++ b/src/main/java/me/outspending/biomesapi/BiomeUpdaterImpl.java @@ -0,0 +1,30 @@ +package me.outspending.biomesapi; + +import me.outspending.biomesapi.nms.NMSHandler; +import org.bukkit.Chunk; +import org.bukkit.Location; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +public class BiomeUpdaterImpl implements BiomeUpdater { + + @Override + public void updateChunk(Chunk chunk) { + updateChunks(List.of(chunk)); + } + + @Override + public void updateChunks(Location from, Location to) { + if (from == null || to == null) + throw new IllegalArgumentException("Locations cannot be null."); + + updateChunks(getChunksBetweenLocations(from, to)); + } + + @Override + public void updateChunks(@NotNull List chunks) { + NMSHandler.executeNMS(nms -> nms.updateChunks(chunks)); + } + +} diff --git a/src/main/java/me/outspending/biomesapi/BiomeHandler.java b/src/main/java/me/outspending/biomesapi/biome/BiomeHandler.java similarity index 95% rename from src/main/java/me/outspending/biomesapi/BiomeHandler.java rename to src/main/java/me/outspending/biomesapi/biome/BiomeHandler.java index 6d48947..a03564b 100644 --- a/src/main/java/me/outspending/biomesapi/BiomeHandler.java +++ b/src/main/java/me/outspending/biomesapi/biome/BiomeHandler.java @@ -1,11 +1,10 @@ -package me.outspending.biomesapi; +package me.outspending.biomesapi.biome; import lombok.Getter; import lombok.experimental.UtilityClass; +import me.outspending.biomesapi.registry.BiomeResourceKey; import me.outspending.biomesapi.annotations.AsOf; -import me.outspending.biomesapi.biome.CustomBiome; import me.outspending.biomesapi.exceptions.UnknownBiomeException; -import net.minecraft.world.level.biome.Biome; import org.bukkit.Location; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/me/outspending/biomesapi/biome/CustomBiome.java b/src/main/java/me/outspending/biomesapi/biome/CustomBiome.java index 2d6e0ad..aca6bf0 100644 --- a/src/main/java/me/outspending/biomesapi/biome/CustomBiome.java +++ b/src/main/java/me/outspending/biomesapi/biome/CustomBiome.java @@ -1,9 +1,9 @@ package me.outspending.biomesapi.biome; import com.google.common.base.Preconditions; -import me.outspending.biomesapi.BiomeResourceKey; +import me.outspending.biomesapi.registry.BiomeResourceKey; import me.outspending.biomesapi.BiomeSettings; -import me.outspending.biomesapi.ParticleRenderer; +import me.outspending.biomesapi.renderer.ParticleRenderer; import me.outspending.biomesapi.annotations.AsOf; import org.bukkit.Color; import org.bukkit.NamespacedKey; @@ -12,41 +12,113 @@ @AsOf("0.0.2") public interface CustomBiome { + /** + * Returns a new instance of the Builder class. + * + * @return a new Builder instance + * @since 0.0.2 + */ @AsOf("0.0.2") static @NotNull Builder builder() { return new Builder(); } + /** + * Returns the NamespacedKey of the CustomBiome. + * + * @return the NamespacedKey of the CustomBiome + * @since 0.0.2 + */ @AsOf("0.0.2") @NotNull NamespacedKey toNamespacedKey(); + /** + * Returns the BiomeResourceKey of the CustomBiome. + * + * @return the BiomeResourceKey of the CustomBiome + * @since 0.0.2 + */ @AsOf("0.0.2") @NotNull BiomeResourceKey getResourceKey(); + /** + * Returns the BiomeSettings of the CustomBiome. + * + * @return the BiomeSettings of the CustomBiome + * @since 0.0.2 + */ @AsOf("0.0.2") @NotNull BiomeSettings getSettings(); + /** + * Returns the fog color of the CustomBiome. + * + * @return the fog color of the CustomBiome + * @since 0.0.2 + */ @AsOf("0.0.2") int getFogColor(); + /** + * Returns the water color of the CustomBiome. + * + * @return the water color of the CustomBiome + * @since 0.0.2 + */ @AsOf("0.0.2") int getWaterColor(); + /** + * Returns the water fog color of the CustomBiome. + * + * @return the water fog color of the CustomBiome + * @since 0.0.2 + */ @AsOf("0.0.2") int getWaterFogColor(); + /** + * Returns the sky color of the CustomBiome. + * + * @return the sky color of the CustomBiome + * @since 0.0.2 + */ @AsOf("0.0.2") int getSkyColor(); + /** + * Returns the foliage color of the CustomBiome. + * + * @return the foliage color of the CustomBiome + * @since 0.0.2 + */ @AsOf("0.0.2") int getFoliageColor(); + /** + * Returns the grass color of the CustomBiome. + * + * @return the grass color of the CustomBiome + * @since 0.0.2 + */ @AsOf("0.0.2") int getGrassColor(); + /** + * Returns the ParticleRenderer of the CustomBiome. + * + * @return the ParticleRenderer of the CustomBiome + * @since 0.0.2 + */ @AsOf("0.0.2") @NotNull ParticleRenderer getParticleRenderer(); + /** + * This class is used to create a new CustomBiome object. + * It provides methods to set the properties of the CustomBiome. + * + * @version 0.0.2 + */ @AsOf("0.0.2") class Builder { diff --git a/src/main/java/me/outspending/biomesapi/biome/CustomBiomeImpl.java b/src/main/java/me/outspending/biomesapi/biome/CustomBiomeImpl.java index cd8b5e2..871b7fc 100644 --- a/src/main/java/me/outspending/biomesapi/biome/CustomBiomeImpl.java +++ b/src/main/java/me/outspending/biomesapi/biome/CustomBiomeImpl.java @@ -1,8 +1,8 @@ package me.outspending.biomesapi.biome; -import me.outspending.biomesapi.BiomeResourceKey; +import me.outspending.biomesapi.registry.BiomeResourceKey; import me.outspending.biomesapi.BiomeSettings; -import me.outspending.biomesapi.ParticleRenderer; +import me.outspending.biomesapi.renderer.ParticleRenderer; import me.outspending.biomesapi.annotations.AsOf; import net.minecraft.resources.ResourceLocation; import org.bukkit.NamespacedKey; diff --git a/src/main/java/me/outspending/biomesapi/nms/NMSHandler.java b/src/main/java/me/outspending/biomesapi/nms/NMSHandler.java index b813249..8724e81 100644 --- a/src/main/java/me/outspending/biomesapi/nms/NMSHandler.java +++ b/src/main/java/me/outspending/biomesapi/nms/NMSHandler.java @@ -4,8 +4,10 @@ import me.outspending.biomesapi.annotations.AsOf; import me.outspending.biomesapi.exceptions.UnknownNMSVersionException; import org.bukkit.Bukkit; +import org.jetbrains.annotations.NotNull; import java.util.Optional; +import java.util.function.Consumer; /** * Utility class for handling NMS (Net Minecraft Server) related operations. @@ -53,7 +55,6 @@ static void init() { String version = Bukkit.getMinecraftVersion(); switch (version) { - // case "1.19", "1.19.1", "1.19.2" -> NMS_VERSION = new NMS_v1_19_R1(); 1.19_R1 is not supported anymore case "1.19.3" -> NMS_VERSION = new NMS_v1_19_R2(); case "1.19.4" -> NMS_VERSION = new NMS_v1_19_R3(); case "1.20", "1.20.1" -> NMS_VERSION = new NMS_v1_20_R1(); @@ -85,4 +86,15 @@ public static Optional getNMS() { return Optional.ofNullable(NMS_VERSION); } + /** + * Executes the given consumer if the NMS version exists. + * + * @param consumer the consumer to execute + * @version 0.0.2 + */ + @AsOf("0.0.2") + public static void executeNMS(@NotNull Consumer consumer) { + getNMS().ifPresent(consumer); + } + } diff --git a/src/main/java/me/outspending/biomesapi/BiomeRegistry.java b/src/main/java/me/outspending/biomesapi/registry/BiomeRegistry.java similarity index 76% rename from src/main/java/me/outspending/biomesapi/BiomeRegistry.java rename to src/main/java/me/outspending/biomesapi/registry/BiomeRegistry.java index a1b44b6..20d35aa 100644 --- a/src/main/java/me/outspending/biomesapi/BiomeRegistry.java +++ b/src/main/java/me/outspending/biomesapi/registry/BiomeRegistry.java @@ -1,8 +1,8 @@ -package me.outspending.biomesapi; +package me.outspending.biomesapi.registry; import me.outspending.biomesapi.annotations.AsOf; +import me.outspending.biomesapi.annotations.Experimental; import me.outspending.biomesapi.biome.CustomBiome; -import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; /** @@ -37,6 +37,13 @@ static BiomeRegistry newRegistry() { @AsOf("0.0.1") void register(@NotNull CustomBiome biome); + /** + * This method unregisters a custom biome from a Minecraft server. + * It takes a DedicatedServer object and a CustomBiome object as arguments. + * + * @version 0.0.2 + * @param biome The CustomBiome object that should be unregistered from the server. + */ @AsOf("0.0.2") @Experimental void unregister(@NotNull CustomBiome biome); diff --git a/src/main/java/me/outspending/biomesapi/BiomeResourceKey.java b/src/main/java/me/outspending/biomesapi/registry/BiomeResourceKey.java similarity index 98% rename from src/main/java/me/outspending/biomesapi/BiomeResourceKey.java rename to src/main/java/me/outspending/biomesapi/registry/BiomeResourceKey.java index eda7b2a..c36ccc8 100644 --- a/src/main/java/me/outspending/biomesapi/BiomeResourceKey.java +++ b/src/main/java/me/outspending/biomesapi/registry/BiomeResourceKey.java @@ -1,4 +1,4 @@ -package me.outspending.biomesapi; +package me.outspending.biomesapi.registry; import me.outspending.biomesapi.annotations.AsOf; import net.minecraft.resources.ResourceLocation; diff --git a/src/main/java/me/outspending/biomesapi/CustomBiomeRegistry.java b/src/main/java/me/outspending/biomesapi/registry/CustomBiomeRegistry.java similarity index 94% rename from src/main/java/me/outspending/biomesapi/CustomBiomeRegistry.java rename to src/main/java/me/outspending/biomesapi/registry/CustomBiomeRegistry.java index a82d458..9851b30 100644 --- a/src/main/java/me/outspending/biomesapi/CustomBiomeRegistry.java +++ b/src/main/java/me/outspending/biomesapi/registry/CustomBiomeRegistry.java @@ -1,6 +1,10 @@ -package me.outspending.biomesapi; +package me.outspending.biomesapi.registry; +import me.outspending.biomesapi.BiomeLock; +import me.outspending.biomesapi.BiomeSettings; +import me.outspending.biomesapi.renderer.ParticleRenderer; import me.outspending.biomesapi.annotations.AsOf; +import me.outspending.biomesapi.biome.BiomeHandler; import me.outspending.biomesapi.biome.CustomBiome; import me.outspending.biomesapi.exceptions.UnknownNMSVersionException; import me.outspending.biomesapi.nms.NMS; diff --git a/src/main/java/me/outspending/biomesapi/AmbientParticle.java b/src/main/java/me/outspending/biomesapi/renderer/AmbientParticle.java similarity index 99% rename from src/main/java/me/outspending/biomesapi/AmbientParticle.java rename to src/main/java/me/outspending/biomesapi/renderer/AmbientParticle.java index 361167b..8537e7b 100644 --- a/src/main/java/me/outspending/biomesapi/AmbientParticle.java +++ b/src/main/java/me/outspending/biomesapi/renderer/AmbientParticle.java @@ -1,4 +1,4 @@ -package me.outspending.biomesapi; +package me.outspending.biomesapi.renderer; import lombok.Getter; import me.outspending.biomesapi.annotations.AsOf; diff --git a/src/main/java/me/outspending/biomesapi/ParticleRenderer.java b/src/main/java/me/outspending/biomesapi/renderer/ParticleRenderer.java similarity index 97% rename from src/main/java/me/outspending/biomesapi/ParticleRenderer.java rename to src/main/java/me/outspending/biomesapi/renderer/ParticleRenderer.java index e1c9fe6..3592abd 100644 --- a/src/main/java/me/outspending/biomesapi/ParticleRenderer.java +++ b/src/main/java/me/outspending/biomesapi/renderer/ParticleRenderer.java @@ -1,4 +1,4 @@ -package me.outspending.biomesapi; +package me.outspending.biomesapi.renderer; import me.outspending.biomesapi.annotations.AsOf; import org.jetbrains.annotations.NotNull;