From 1a1e20ccf961eab7fcafc8072d0cf77b3a02bf65 Mon Sep 17 00:00:00 2001 From: Warrior <50800980+Warriorrrr@users.noreply.github.com> Date: Sat, 1 Jul 2023 10:28:45 +0200 Subject: [PATCH] More localization fixes --- .../townymenus/commands/TownyMenuCommand.java | 25 +++++++++---------- .../townymenus/menu/PlotMenu.java | 6 ++--- .../townymenus/menu/TownMenu.java | 2 +- src/main/resources/lang/en_US.yml | 1 + 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/io/github/townyadvanced/townymenus/commands/TownyMenuCommand.java b/src/main/java/io/github/townyadvanced/townymenus/commands/TownyMenuCommand.java index af4bb44..887f85a 100644 --- a/src/main/java/io/github/townyadvanced/townymenus/commands/TownyMenuCommand.java +++ b/src/main/java/io/github/townyadvanced/townymenus/commands/TownyMenuCommand.java @@ -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; @@ -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; @@ -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; } @@ -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()) diff --git a/src/main/java/io/github/townyadvanced/townymenus/menu/PlotMenu.java b/src/main/java/io/github/townyadvanced/townymenus/menu/PlotMenu.java index b5ed4f9..b58c521 100644 --- a/src/main/java/io/github/townyadvanced/townymenus/menu/PlotMenu.java +++ b/src/main/java/io/github/townyadvanced/townymenus/menu/PlotMenu.java @@ -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)) @@ -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) diff --git a/src/main/java/io/github/townyadvanced/townymenus/menu/TownMenu.java b/src/main/java/io/github/townyadvanced/townymenus/menu/TownMenu.java index 32dd280..146988e 100644 --- a/src/main/java/io/github/townyadvanced/townymenus/menu/TownMenu.java +++ b/src/main/java/io/github/townyadvanced/townymenus/menu/TownMenu.java @@ -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) diff --git a/src/main/resources/lang/en_US.yml b/src/main/resources/lang/en_US.yml index 595a071..23374b9 100644 --- a/src/main/resources/lang/en_US.yml +++ b/src/main/resources/lang/en_US.yml @@ -182,6 +182,7 @@ plot-menu-only-owner-clear-plot-name: "Only the owner of the plot can clea plot-menu-set-plot-type-title: "Set plot type" plot-menu-set-plot-type-subtitle: "Changes the type of the current plot." plot-menu-only-owner-can-set-plot-type: "Only the owner of the plot can change it's type." +plot-menu-plot-type-tax: "Tax for this type is %s." plot-menu-change-plot-type: "change the type for this plot." plot-menu-plot-currently-selected: "Currently selected!"