From b560db16e37b4abb2d4538f4cda0e535bbbb866a Mon Sep 17 00:00:00 2001 From: ybw0014 Date: Sun, 22 Sep 2024 06:28:08 -0700 Subject: [PATCH] chore: localization for options menu (#4189) --- .../core/guide/options/FireworksOption.java | 9 +++++++- .../core/guide/options/GuideModeOption.java | 11 +++++----- src/main/resources/languages/en/messages.yml | 21 +++++++++++++++++++ 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java index 07b757018a..64f48a0656 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java @@ -1,5 +1,6 @@ package io.github.thebusybiscuit.slimefun4.core.guide.options; +import java.util.List; import java.util.Optional; import org.bukkit.Material; @@ -31,7 +32,13 @@ public Optional getDisplayItem(Player p, ItemStack guide) { if (registry.isResearchingEnabled() && registry.isResearchFireworkEnabled()) { boolean enabled = getSelectedOption(p, guide).orElse(true); - ItemStack item = new CustomItemStack(Material.FIREWORK_ROCKET, "&bFireworks: &" + (enabled ? "aYes" : "4No"), "", "&7You can now toggle whether you", "&7will be presented with a big firework", "&7upon researching an item.", "", "&7\u21E8 &eClick to " + (enabled ? "disable" : "enable") + " your fireworks"); + + String optionState = enabled ? "enabled" : "disabled"; + List lore = Slimefun.getLocalization().getMessages(p, "guide.options.fireworks." + optionState + ".text"); + lore.add(""); + lore.add("&7\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.options.fireworks." + optionState + ".click")); + + ItemStack item = new CustomItemStack(Material.FIREWORK_ROCKET, lore); return Optional.of(item); } else { return Optional.empty(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java index f86694211d..92ede97bc9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java @@ -56,14 +56,15 @@ public Optional getDisplayItem(Player p, ItemStack guide) { } ItemMeta meta = item.getItemMeta(); - meta.setDisplayName(ChatColor.GRAY + "Slimefun Guide Type: " + ChatColor.YELLOW + ChatUtils.humanize(selectedMode.name())); + meta.setDisplayName(ChatColor.GRAY + Slimefun.getLocalization().getMessage(p, "guide.modes.selected") + + ChatColor.YELLOW + Slimefun.getLocalization().getMessage(p, "guide.modes." + selectedMode.name())); List lore = new ArrayList<>(); lore.add(""); - lore.add((selectedMode == SlimefunGuideMode.SURVIVAL_MODE ? ChatColor.GREEN : ChatColor.GRAY) + "Survival Mode"); - lore.add((selectedMode == SlimefunGuideMode.CHEAT_MODE ? ChatColor.GREEN : ChatColor.GRAY) + "Cheat Sheet"); + lore.add((selectedMode == SlimefunGuideMode.SURVIVAL_MODE ? ChatColor.GREEN : ChatColor.GRAY) + Slimefun.getLocalization().getMessage(p, "guide.modes.SURVIVAL_MODE")); + lore.add((selectedMode == SlimefunGuideMode.CHEAT_MODE ? ChatColor.GREEN : ChatColor.GRAY) + Slimefun.getLocalization().getMessage(p, "guide.modes.CHEAT_MODE")); lore.add(""); - lore.add(ChatColor.GRAY + "\u21E8 " + ChatColor.YELLOW + "Click to change the type"); + lore.add(ChatColor.GRAY + "\u21E8 " + ChatColor.YELLOW + Slimefun.getLocalization().getMessage(p, "guide.modes.change")); meta.setLore(lore); item.setItemMeta(meta); @@ -114,4 +115,4 @@ public void setSelectedOption(Player p, ItemStack guide, SlimefunGuideMode value guide.setItemMeta(SlimefunGuide.getItem(value).getItemMeta()); } -} \ No newline at end of file +} diff --git a/src/main/resources/languages/en/messages.yml b/src/main/resources/languages/en/messages.yml index 81d5115c30..77bd80895a 100644 --- a/src/main/resources/languages/en/messages.yml +++ b/src/main/resources/languages/en/messages.yml @@ -98,7 +98,28 @@ guide: name: '&aIs something missing?' lore: 'Click to add your own translation' + modes: + selected: 'Slimefun Guide Type: ' + change: 'Click to change the type' + SURVIVAL_MODE: 'Survival Mode' + CHEAT_MODE: 'Cheat Sheet' + options: + fireworks: + enabled: + text: + - '&bFireworks: &aYes' + - '' + - '&7You can now toggle whether you' + - '&7will see fireworks upon researching an item.' + click: '&eClick to disable your fireworks' + disabled: + text: + - '&bFireworks: &4No' + - '' + - '&7You can now toggle whether you' + - '&7will see fireworks upon researching an item.' + click: '&eClick to enable your fireworks' learning-animation: enabled: text: