Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: localization for options menu #4189

Merged
merged 2 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading