From 26d0c062801a837d51bc1b181cdcd96851acbfe6 Mon Sep 17 00:00:00 2001 From: Outspending Date: Fri, 5 Jan 2024 09:31:10 -0700 Subject: [PATCH] Added `set` & `toBuilder` methods to `CustomBiome` --- .../biomesapi/biome/BiomeHandler.java | 1 - .../biomesapi/biome/CustomBiome.java | 99 +++++++++++++++++++ .../biomesapi/biome/CustomBiomeImpl.java | 48 ++++++++- 3 files changed, 143 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/outspending/biomesapi/biome/BiomeHandler.java b/src/main/java/me/outspending/biomesapi/biome/BiomeHandler.java index ed802e4..5614b90 100644 --- a/src/main/java/me/outspending/biomesapi/biome/BiomeHandler.java +++ b/src/main/java/me/outspending/biomesapi/biome/BiomeHandler.java @@ -3,7 +3,6 @@ import me.outspending.biomesapi.annotations.AsOf; import me.outspending.biomesapi.exceptions.UnknownBiomeException; import me.outspending.biomesapi.registry.BiomeResourceKey; -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 7f3896e..4dcdc22 100644 --- a/src/main/java/me/outspending/biomesapi/biome/CustomBiome.java +++ b/src/main/java/me/outspending/biomesapi/biome/CustomBiome.java @@ -113,6 +113,78 @@ public interface CustomBiome { @AsOf("0.0.1") @NotNull ParticleRenderer getParticleRenderer(); + /** + * Sets the fog color of the CustomBiome. + * + * @param fogColor the fog color of the CustomBiome + * @since 0.0.5 + */ + @AsOf("0.0.5") + void setFogColor(int fogColor); + + /** + * Sets the water color of the CustomBiome. + * + * @param waterColor the water color of the CustomBiome + * @since 0.0.5 + */ + @AsOf("0.0.5") + void setWaterColor(int waterColor); + + /** + * Sets the water fog color of the CustomBiome. + * + * @param waterFogColor the water fog color of the CustomBiome + * @since 0.0.5 + */ + @AsOf("0.0.5") + void setWaterFogColor(int waterFogColor); + + /** + * Sets the sky color of the CustomBiome. + * + * @param skyColor the sky color of the CustomBiome + * @since 0.0.5 + */ + @AsOf("0.0.5") + void setSkyColor(int skyColor); + + /** + * Sets the foliage color of the CustomBiome. + * + * @param foliageColor the foliage color of the CustomBiome + * @since 0.0.5 + */ + @AsOf("0.0.5") + void setFoliageColor(int foliageColor); + + /** + * Sets the grass color of the CustomBiome. + * + * @param grassColor the grass color of the CustomBiome + * @since 0.0.5 + */ + @AsOf("0.0.5") + void setGrassColor(int grassColor); + + /** + * Sets the ParticleRenderer of the CustomBiome. + * + * @param particleRenderer the ParticleRenderer of the CustomBiome + * @since 0.0.5 + */ + @AsOf("0.0.5") + void setParticleRenderer(@NotNull ParticleRenderer particleRenderer); + + /** + * Returns a new Builder instance with the properties of the CustomBiome. + * + * @return a new Builder instance with the properties of the CustomBiome + * @since 0.0.5 + */ + @AsOf("0.0.5") + Builder toBuilder(); + /** * Registers the CustomBiome to the biome registry. * @@ -157,6 +229,33 @@ private String formatHex(@NotNull String color) { return color; } + /** + * This method creates a new Builder object. + * + * @version 0.0.1 + */ + @AsOf("0.0.1") + public Builder() {} + + /** + * This method creates a new Builder object with the properties of the provided CustomBiome. + * + * @param biome The CustomBiome object to copy the properties from. + * @version 0.0.5 + */ + @AsOf("0.0.5") + public Builder(@NotNull CustomBiome biome) { + this.resourceKey = biome.getResourceKey(); + this.settings = biome.getSettings(); + this.fogColor = biome.getFogColor(); + this.waterColor = biome.getWaterColor(); + this.waterFogColor = biome.getWaterFogColor(); + this.skyColor = biome.getSkyColor(); + this.foliageColor = biome.getFoliageColor(); + this.grassColor = biome.getGrassColor(); + this.particleRenderer = biome.getParticleRenderer(); + } + /** * This method sets the BiomeResourceKey property of the CustomBiome. * diff --git a/src/main/java/me/outspending/biomesapi/biome/CustomBiomeImpl.java b/src/main/java/me/outspending/biomesapi/biome/CustomBiomeImpl.java index cdde474..7ab5583 100644 --- a/src/main/java/me/outspending/biomesapi/biome/CustomBiomeImpl.java +++ b/src/main/java/me/outspending/biomesapi/biome/CustomBiomeImpl.java @@ -17,10 +17,10 @@ public final class CustomBiomeImpl implements CustomBiome { private final BiomeSettings settings; // Required Colors - private final int fogColor; - private final int waterColor; - private final int waterFogColor; - private final int skyColor; + private int fogColor; + private int waterColor; + private int waterFogColor; + private int skyColor; // Optional Colors private int foliageColor = 0; @@ -121,6 +121,46 @@ public int getGrassColor() { return particleRenderer; } + @Override + public void setFogColor(int fogColor) { + this.fogColor = fogColor; + } + + @Override + public void setWaterColor(int waterColor) { + this.waterColor = waterColor; + } + + @Override + public void setWaterFogColor(int waterFogColor) { + this.waterFogColor = waterFogColor; + } + + @Override + public void setSkyColor(int skyColor) { + this.skyColor = skyColor; + } + + @Override + public void setFoliageColor(int foliageColor) { + this.foliageColor = foliageColor; + } + + @Override + public void setGrassColor(int grassColor) { + this.grassColor = grassColor; + } + + @Override + public void setParticleRenderer(@NotNull ParticleRenderer particleRenderer) { + this.particleRenderer = particleRenderer; + } + + @Override + public Builder toBuilder() { + return new Builder(this); + } + @Override public void register() { BiomeRegistry.newRegistry().register(this);