Skip to content

Commit

Permalink
More localization fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Warriorrrr committed Jul 1, 2023
1 parent 59d8da3 commit 1a1e20c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package io.github.townyadvanced.townymenus.commands;

import com.palmergames.adventure.text.Component;
import com.palmergames.adventure.text.format.NamedTextColor;
import com.palmergames.bukkit.towny.Towny;
import com.palmergames.bukkit.towny.TownyMessaging;
import com.palmergames.bukkit.towny.object.Translatable;
import io.github.townyadvanced.townymenus.TownyMenus;
import io.github.townyadvanced.townymenus.gui.MenuHistory;
import io.github.townyadvanced.townymenus.gui.MenuInventory;
Expand All @@ -29,6 +26,8 @@
import java.util.List;
import java.util.Locale;

import static com.palmergames.bukkit.towny.object.Translatable.of;

public class TownyMenuCommand implements CommandExecutor, TabCompleter {
private final TownyMenus plugin;

Expand All @@ -54,7 +53,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
}

if (!player.hasPermission("townymenus.command.townymenu")) {
TownyMessaging.sendErrorMsg(player, Translatable.of("msg_err_command_disable"));
TownyMessaging.sendErrorMsg(player, of("msg_err_command_disable"));
return true;
}

Expand All @@ -69,29 +68,29 @@ public static MenuInventory createRootMenu(Player player) {

return MenuInventory.builder()
.rows(3)
.title(Translatable.of("main-menu-title").component(locale))
.title(of("main-menu-title").component(locale))
.addItem(MenuItem.builder(Material.EMERALD)
.name(Translatable.of("main-menu-town").component(locale))
.lore(Translatable.of("main-menu-town-subtitle").component(locale))
.name(of("main-menu-town").component(locale))
.lore(of("main-menu-town-subtitle").component(locale))
.slot(10)
.action(ClickAction.openInventory(() -> TownMenu.createTownMenu(player)))
.build())
.addItem(MenuItem.builder(Material.DIAMOND)
.name(Component.text("Nation Settings", NamedTextColor.AQUA))
.lore(Component.text("Click to view the nation menu!", NamedTextColor.GRAY))
.name(of("main-menu-nation").component(locale))
.lore(of("main-menu-nation-subtitle").component(locale))
.slot(12)
.action(ClickAction.openInventory(() -> NationMenu.createNationMenu(player)))
.build())
.addItem(MenuItem.builder(Material.GRASS_BLOCK)
.name(Component.text("Plot Settings", NamedTextColor.DARK_GREEN))
.lore(Component.text("Click to view the plot menu!", NamedTextColor.GRAY))
.name(of("main-menu-plot").component(locale))
.lore(of("main-menu-plot-subtitle").component(locale))
.slot(14)
.action(ClickAction.openInventory(() -> PlotMenu.createPlotMenu(player)))
.build())
.addItem(MenuItem.builder(Material.PLAYER_HEAD)
.skullOwner(player.getUniqueId())
.name(Component.text("Resident Settings", NamedTextColor.YELLOW))
.lore(Component.text("Click to view the resident menu!", NamedTextColor.GRAY))
.name(of("main-menu-resident").component(locale))
.lore(of("main-menu-resident-subtitle").component(locale))
.slot(16)
.action(ClickAction.openInventory(() -> ResidentMenu.createResidentMenu(player)))
.build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,9 @@ private static MenuInventory formatPlotSetType(Player player, WorldCoord worldCo

plotTypeItems.add(MenuItem.builder(Material.GRASS_BLOCK)
.name(text(type.getFormattedName(), GREEN))
.lore(alreadySelected ? of("plot-menu-plot-currently-selected").component(locale) : of("msg-clicl-to").append("plot-menu-change-plot-type-to").append(type.getFormattedName() + ".").component(locale).color(GRAY))
.lore(alreadySelected ? of("plot-menu-plot-currently-selected").component(locale) : of("msg-click-to").append(of("plot-menu-change-plot-type-to")).append(type.getFormattedName() + ".").component(locale).color(GRAY))
.lore(!alreadySelected && changeCost > 0 && TownyEconomyHandler.isActive() ? of("plot-menu-setting-type-cost").append(TownyEconomyHandler.getFormattedBalance(changeCost) + ".").component(locale).color(GRAY) : Component.empty())
.lore(!alreadySelected && TownyEconomyHandler.isActive() && townBlock.getTownOrNull() != null && type.getTax(townBlock.getTownOrNull()) > 0 ? text("Tax for this type is " + TownyEconomyHandler.getFormattedBalance(type.getTax(townBlock.getTownOrNull())) + ".", GRAY) : Component.empty())
.lore(!alreadySelected && TownyEconomyHandler.isActive() && townBlock.getTownOrNull() != null && type.getTax(townBlock.getTownOrNull()) > 0 ? of("plot-menu-plot-type-tax", TownyEconomyHandler.getFormattedBalance(type.getTax(townBlock.getTownOrNull()))).component(locale) : Component.empty())
.withGlint(alreadySelected)
.action(alreadySelected ? ClickAction.NONE : changeCost > 0 && TownyEconomyHandler.isActive() // Add confirmation if cost > 0 and economy is active
? ClickAction.confirmation(() -> of("plot-menu-change-type-cost").append(TownyEconomyHandler.getFormattedBalance(changeCost)).append("plot-menu-change-type-confirm").component(locale).color(RED), ClickAction.run(onClick))
Expand Down Expand Up @@ -741,7 +741,7 @@ private static NamedTextColor colorFromType(final SetPermissionType type) {

private static MenuInventory openPermissionOverrideEditor(final Player player, final WorldCoord worldCoord, final Resident resident, final PermissionData data) {
final MenuInventory.Builder builder = MenuInventory.builder()
.title(of("plot-menu-permission-gui-header").locale(resident).component())
.title(of("permission_gui_header").locale(resident).component())
.rows(5)
.addItem(MenuHelper.backButton().build())
.addItem(MenuItem.builder(Material.PLAYER_HEAD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ else if (!player.hasPermission(PermissionNodes.TOWNY_COMMAND_TOWN_ONLINE.getNode
online.add(ResidentMenu.formatResidentInfo(onlinePlayer.getUniqueId(), player).build());
}

return MenuInventory.paginator().addItems(online).title(of("Online in Town").component(locale)).build();
return MenuInventory.paginator().addItems(online).title(of("town-menu-online").component(locale)).build();
}))
.build())
.addItem(MenuItem.builder(Material.PLAYER_HEAD)
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/lang/en_US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ plot-menu-only-owner-clear-plot-name: "<gray>Only the owner of the plot can clea
plot-menu-set-plot-type-title: "<green>Set plot type"
plot-menu-set-plot-type-subtitle: "<gray>Changes the type of the current plot."
plot-menu-only-owner-can-set-plot-type: "<gray>Only the owner of the plot can change it's type."
plot-menu-plot-type-tax: "<gray>Tax for this type is %s."

plot-menu-change-plot-type: "change the type for this plot."
plot-menu-plot-currently-selected: "<gray>Currently selected!"
Expand Down

0 comments on commit 1a1e20c

Please sign in to comment.