Skip to content

Commit

Permalink
Fix returning after color is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
IanTapply22 committed Jun 19, 2024
1 parent 093f7c1 commit b9b9462
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/net/jeqo/bloons/balloon/single/SingleBalloon.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class SingleBalloon extends BukkitRunnable {
private int ticks = 0;
private float targetYaw = 0.0F;

private static final String leatherMaterialPrefix = "LEATHER_"; // A constant to define a dyeable material

/**
* Constructor for the SingleBalloon class
* @param player The player to attach the balloon to, type org.bukkit.entity.Player
Expand Down Expand Up @@ -173,9 +175,9 @@ public ItemStack getConfiguredBalloonVisual(String balloonID) {
meta.setCustomModelData(singleBalloonType.getCustomModelData());

// If the color of the balloon is not set, log an error and return null
if (singleBalloonType.getColor() == null) {
Logger.logError("The color of the balloon " + balloonID + " is not set!");
return null;
if (singleBalloonType.getColor() != null && singleBalloonType.getMaterial().startsWith(leatherMaterialPrefix)) {
LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) meta;
leatherArmorMeta.setColor(ColorManagement.hexToColor(singleBalloonType.getColor()));
}

// If the color of the balloon is set to potion, log a warning and return null
Expand All @@ -184,9 +186,7 @@ public ItemStack getConfiguredBalloonVisual(String balloonID) {
return null;
}

// Finally, set the color of the item and set the item meta because we can assume it's a leather item
LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) meta;
leatherArmorMeta.setColor(ColorManagement.hexToColor(singleBalloonType.getColor()));
// Finally, set the item meta
item.setItemMeta(meta);

return item;
Expand Down

0 comments on commit b9b9462

Please sign in to comment.