Skip to content

Commit 1063e26

Browse files
committed
fix(biome): blank color hexes
1 parent dfd5db3 commit 1063e26

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ plugins {
88
}
99

1010
val isSnapshot: Boolean = project.hasProperty("snapshot") || System.getProperty("snapshot")?.toBoolean() == true
11-
val stable = "1.0.1"
11+
val stable = "1.0.2"
1212

1313
allprojects {
1414
apply(plugin = "java")

main/src/main/java/me/outspending/biomesapi/biome/CustomBiome.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,19 @@ private String formatHex(@NotNull String color) {
312312
return color;
313313
}
314314

315+
/**
316+
* Parses a hexadecimal color string into an integer.
317+
*
318+
* @param color the color string to parse
319+
* @return the integer representation of the color
320+
* @since 0.0.1
321+
*/
322+
@AsOf("1.0.2")
323+
private int parseHex(@NotNull String color) {
324+
if (color.isEmpty()) return 0;
325+
return Integer.parseInt(formatHex(color), 16);
326+
}
327+
315328
/**
316329
* This method creates a new Builder object.
317330
*
@@ -376,7 +389,7 @@ public Builder(@NotNull CustomBiome biome) {
376389
*/
377390
@AsOf("0.0.1")
378391
public @NotNull Builder fogColor(@NotNull String fogColor) {
379-
this.fogColor = Integer.parseInt(formatHex(fogColor), 16);
392+
this.fogColor = parseHex(fogColor);
380393
return this;
381394
}
382395

@@ -402,7 +415,7 @@ public Builder(@NotNull CustomBiome biome) {
402415
*/
403416
@AsOf("0.0.1")
404417
public @NotNull Builder waterColor(@NotNull String waterColor) {
405-
this.waterColor = Integer.parseInt(formatHex(waterColor), 16);
418+
this.waterColor = parseHex(waterColor);
406419
return this;
407420
}
408421

@@ -428,7 +441,7 @@ public Builder(@NotNull CustomBiome biome) {
428441
*/
429442
@AsOf("0.0.1")
430443
public @NotNull Builder waterFogColor(@NotNull String waterFogColor) {
431-
this.waterFogColor = Integer.parseInt(formatHex(waterFogColor), 16);
444+
this.waterFogColor = parseHex(waterFogColor);
432445
return this;
433446
}
434447

@@ -454,7 +467,7 @@ public Builder(@NotNull CustomBiome biome) {
454467
*/
455468
@AsOf("0.0.1")
456469
public @NotNull Builder skyColor(@NotNull String skyColor) {
457-
this.skyColor = Integer.parseInt(formatHex(skyColor), 16);
470+
this.skyColor = parseHex(skyColor);
458471
return this;
459472
}
460473

@@ -480,7 +493,7 @@ public Builder(@NotNull CustomBiome biome) {
480493
*/
481494
@AsOf("0.0.1")
482495
public @NotNull Builder foliageColor(@NotNull String foliageColor) {
483-
this.foliageColor = Integer.parseInt(formatHex(foliageColor), 16);
496+
this.foliageColor = parseHex(foliageColor);
484497
return this;
485498
}
486499

@@ -506,7 +519,7 @@ public Builder(@NotNull CustomBiome biome) {
506519
*/
507520
@AsOf("0.0.1")
508521
public @NotNull Builder grassColor(@NotNull String grassColor) {
509-
this.grassColor = Integer.parseInt(formatHex(grassColor), 16);
522+
this.grassColor = parseHex(grassColor);
510523
return this;
511524
}
512525

0 commit comments

Comments
 (0)