From ae80e89446153882e7b5c14c6fe29af6cb85b0c6 Mon Sep 17 00:00:00 2001 From: Ryder Belserion Date: Fri, 27 Sep 2024 21:06:10 -0400 Subject: [PATCH] update locale message --- .../crazycrates/api/enums/Messages.java | 2 ++ .../api/objects/gui/buttons/CrateButton.java | 8 ++++++-- .../config/impl/messages/CrateKeys.java | 14 ++++++++++++-- paper/src/main/resources/messages.yml | 17 ++++++++++++----- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/paper/src/main/java/com/badbones69/crazycrates/api/enums/Messages.java b/paper/src/main/java/com/badbones69/crazycrates/api/enums/Messages.java index e2789c740..dbacb4a55 100644 --- a/paper/src/main/java/com/badbones69/crazycrates/api/enums/Messages.java +++ b/paper/src/main/java/com/badbones69/crazycrates/api/enums/Messages.java @@ -75,6 +75,8 @@ public enum Messages { crate_cannot_teleport(CrateKeys.crate_cannot_teleport), crate_prize_max_pulls(CrateKeys.crate_prize_max_pulls), crate_prize_max_respins(CrateKeys.crate_prize_max_respins), + crate_prize_max_respins_left(CrateKeys.crate_prize_max_respins_left), + crate_prize_max_respins_none(CrateKeys.crate_prize_max_respins_none), gave_a_player_keys(CommandKeys.gave_a_player_keys), cannot_give_player_keys(CommandKeys.cannot_give_player_keys), diff --git a/paper/src/main/java/com/badbones69/crazycrates/api/objects/gui/buttons/CrateButton.java b/paper/src/main/java/com/badbones69/crazycrates/api/objects/gui/buttons/CrateButton.java index 34dac74df..536236bee 100644 --- a/paper/src/main/java/com/badbones69/crazycrates/api/objects/gui/buttons/CrateButton.java +++ b/paper/src/main/java/com/badbones69/crazycrates/api/objects/gui/buttons/CrateButton.java @@ -59,9 +59,13 @@ public CrateButton(final Crate crate, final Prize prize, final ConfigurationSect this.userManager.removeRespinPrize(uuid, this.crate.getFileName()); // remove just in case + final int cap = PrizeManager.getCap(crate, player); + Messages.crate_prize_max_respins.sendMessage(player, new HashMap<>() {{ - put("{respins_left}", "0"); - put("{respins_total}", String.valueOf(PrizeManager.getCap(crate, player))); + put("{status}", cap >= 1 ? Messages.crate_prize_max_respins_left.getMessage(player, new HashMap<>() {{ + put("{respins_total}", String.valueOf(cap)); + put("{respins_left}", "0"); + }}) : Messages.crate_prize_max_respins_none.getMessage(player)); }}); return; diff --git a/paper/src/main/java/com/badbones69/crazycrates/managers/config/impl/messages/CrateKeys.java b/paper/src/main/java/com/badbones69/crazycrates/managers/config/impl/messages/CrateKeys.java index 6c5e05ff7..f4a9415ff 100644 --- a/paper/src/main/java/com/badbones69/crazycrates/managers/config/impl/messages/CrateKeys.java +++ b/paper/src/main/java/com/badbones69/crazycrates/managers/config/impl/messages/CrateKeys.java @@ -107,7 +107,17 @@ public void registerComments(CommentsConfiguration conf) { }) public static final Property crate_prize_max_pulls = newProperty("crates.pulls.max", "{prefix}This prize can no longer be obtained, {pulls}/{maxpulls}"); - @Comment("A list of available placeholders: {respins_left}, {respins_total}") - public static final Property crate_prize_max_respins = newProperty("crates.respins.max", "{prefix}You can no longer respin, {respins_left}/{respins_total}"); + @Comment("A list of available placeholders: {status}") + public static final Property crate_prize_max_respins = newProperty("crates.respins.max", "{prefix}You can no longer respin, Status: {status}"); + + @Comment({ + "If the player has any permission for respins, this format will show above in place of {status}", + "", + "A list of available placeholders: {respins_left}/{respins_total}" + }) + public static final Property crate_prize_max_respins_left = newProperty("crates.respins.format", "{respins_left}/{respins_total}"); + + @Comment("A blank string to configure for {status}") + public static final Property crate_prize_max_respins_none = newProperty("crates.respins.none", "N/A"); } \ No newline at end of file diff --git a/paper/src/main/resources/messages.yml b/paper/src/main/resources/messages.yml index da758775a..3963be4e0 100644 --- a/paper/src/main/resources/messages.yml +++ b/paper/src/main/resources/messages.yml @@ -107,18 +107,25 @@ crates: per-crate: "[{id}]: {crate_name}, {world}, {x}, {y}, {z}" teleport: # A list of available placeholders: {name} - success: '{prefix}You have been teleported to the location with the name: {name}.' + success: "{prefix}You have been teleported to the location with the name: {name}." # A list of available placeholders: {id} - failed: '{prefix}There is no location with the name: {id}.' + failed: "{prefix}There is no location with the name: {id}." pulls: # This will add a notice to a prize, if the prize has reached max pulls. # If this message is empty, it will not add the lore to prizes. # # A list of available placeholders: {maxpulls}, {pulls} - max: '{prefix}This prize can no longer be obtained, {pulls}/{maxpulls}' + max: "{prefix}This prize can no longer be obtained, {pulls}/{maxpulls}" respins: # A list of available placeholders: {respins_left}, {respins_total} - max: '{prefix}You can no longer respin, {respins_left}/{respins_total}' + max: "{prefix}You can no longer respin, {respins_left}/{respins_total}" + # If the player has any permission for respins, this format will show above in place of {status} + # + # A list of available placeholders: {respins_left}/{respins_total} + format: "{respins_left}/{respins_total}" + # A blank string to configure for {status} + none: "N/A" + # All messages related to commands. command: open: @@ -198,7 +205,7 @@ command: no-virtual-keys: "{prefix}(!) The player {player} does not have any keys." # A list of available placeholders: {player}, {crates_opened} virtual-keys-header: - - "(!) List of {player}''s current number of keys." + - "(!) List of {player}""s current number of keys." - " -> Total Crates Opened: {crates_opened}" - "" # A list of available placeholders: {crate}, {keys}, {crate_opened}