Skip to content

Commit

Permalink
capitalise displayname
Browse files Browse the repository at this point in the history
  • Loading branch information
Oribuin committed Dec 18, 2024
1 parent c733923 commit 75d91f1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/xyz/oribuin/fishing/augment/Augment.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import xyz.oribuin.fishing.FishingPlugin;
import xyz.oribuin.fishing.api.config.Configurable;
import xyz.oribuin.fishing.api.event.FishEventHandler;
import xyz.oribuin.fishing.util.FishUtils;
import xyz.oribuin.fishing.util.ItemConstruct;

import java.nio.file.Path;
Expand Down Expand Up @@ -152,7 +153,7 @@ public NamespacedKey loreKey() {
public StringPlaceholders placeholders() {
return StringPlaceholders.builder()
.add("id", this.name)
.add("display_name", StringUtils.capitalize(this.name.replace("_", " ")))
.add("display_name", FishUtils.capitalizeFully(this.name.replace("_", " ")))
.add("max_level", this.maxLevel)
.add("required_level", this.requiredLevel)
.add("description", String.join("\n", this.description))
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/xyz/oribuin/fishing/util/FishUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,21 @@ public static <T extends Enum<T>> String niceify(T enumValue, String def) {
return StringUtils.capitalize(noUnderscores);
}

/**
* Format every word in a string to be capitalized
* @param str The string to format
* @return The formatted string
*/
public static String capitalizeFully(String str) {
String[] split = str.toLowerCase().split(" ");
StringBuilder builder = new StringBuilder();

for (String s : split) {
builder.append(StringUtils.capitalize(s)).append(" ");
}

return builder.toString().trim();
}


/**
Expand Down

0 comments on commit 75d91f1

Please sign in to comment.