Skip to content

Commit

Permalink
Added set & toBuilder methods to CustomBiome
Browse files Browse the repository at this point in the history
  • Loading branch information
Outspending committed Jan 5, 2024
1 parent 1dec147 commit 26d0c06
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
99 changes: 99 additions & 0 deletions src/main/java/me/outspending/biomesapi/biome/CustomBiome.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down
48 changes: 44 additions & 4 deletions src/main/java/me/outspending/biomesapi/biome/CustomBiomeImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 26d0c06

Please sign in to comment.