Skip to content

Commit

Permalink
chore: localization for options menu (#4189)
Browse files Browse the repository at this point in the history
  • Loading branch information
ybw0014 authored Sep 22, 2024
1 parent e02a0f6 commit b560db1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.guide.options;

import java.util.List;
import java.util.Optional;

import org.bukkit.Material;
Expand Down Expand Up @@ -31,7 +32,13 @@ public Optional<ItemStack> 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<String> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,15 @@ public Optional<ItemStack> 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<String> 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);

Expand Down Expand Up @@ -114,4 +115,4 @@ public void setSelectedOption(Player p, ItemStack guide, SlimefunGuideMode value
guide.setItemMeta(SlimefunGuide.getItem(value).getItemMeta());
}

}
}
21 changes: 21 additions & 0 deletions src/main/resources/languages/en/messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b560db1

Please sign in to comment.