feat(gui): translate left item

This commit is contained in:
ineanto 2024-05-16 21:23:10 +02:00
parent 81b1c8275f
commit a64577ac97
Signed by: ineanto
GPG key ID: E511F9CAA2F9CE84
5 changed files with 24 additions and 6 deletions

View file

@ -26,9 +26,11 @@ public class AnvilManager {
private final AppearanceManager appearanceManager; private final AppearanceManager appearanceManager;
private final PlayerDataStore dataStore = NickoBukkit.getInstance().getDataStore(); private final PlayerDataStore dataStore = NickoBukkit.getInstance().getDataStore();
private final NickoProfile profile; private final NickoProfile profile;
private final I18N i18n;
public AnvilManager(Player player) { public AnvilManager(Player player) {
this.player = player; this.player = player;
this.i18n = new I18N(player);
final Optional<NickoProfile> optionalProfile = dataStore.getData(player.getUniqueId()); final Optional<NickoProfile> optionalProfile = dataStore.getData(player.getUniqueId());
this.profile = optionalProfile.orElse(NickoProfile.EMPTY_PROFILE.clone()); this.profile = optionalProfile.orElse(NickoProfile.EMPTY_PROFILE.clone());
@ -112,7 +114,6 @@ public class AnvilManager {
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { return Collections.singletonList(AnvilGUI.ResponseAction.close()); } if (event.isCancelled()) { return Collections.singletonList(AnvilGUI.ResponseAction.close()); }
final I18N i18n = new I18N(player);
final ActionResult actionResult = appearanceManager.updatePlayer(skinChange, false); final ActionResult actionResult = appearanceManager.updatePlayer(skinChange, false);
if (!actionResult.isError()) { if (!actionResult.isError()) {
player.sendMessage(i18n.translate(I18NDict.Event.Appearance.Set.OK, true)); player.sendMessage(i18n.translate(I18NDict.Event.Appearance.Set.OK, true));
@ -130,8 +131,15 @@ public class AnvilManager {
private ItemStack getLeftItem(boolean skin) { private ItemStack getLeftItem(boolean skin) {
final ItemStack item = new ItemStack(Material.PAPER); final ItemStack item = new ItemStack(Material.PAPER);
final ItemMeta meta = item.getItemMeta(); final ItemMeta meta = item.getItemMeta();
// TODO (Ineanto, 12/28/23): Translate this
if (meta != null) meta.displayName(Component.text("New " + (skin ? "skin" : "name") + "...")); if (meta != null) {
if (skin) {
meta.displayName(Component.text(i18n.translate(I18NDict.GUI.NEW_SKIN, false)));
} else {
meta.displayName(Component.text(i18n.translate(I18NDict.GUI.NEW_NAME, false)));
}
}
item.setItemMeta(meta); item.setItemMeta(meta);
return item; return item;
} }

View file

@ -76,6 +76,8 @@ public class I18NDict {
public static final String LOADING = GUI_KEY + "loading"; public static final String LOADING = GUI_KEY + "loading";
public static final String SCROLL_UP = GUI_KEY + "scroll_up"; public static final String SCROLL_UP = GUI_KEY + "scroll_up";
public static final String SCROLL_DOWN = GUI_KEY + "scroll_down"; public static final String SCROLL_DOWN = GUI_KEY + "scroll_down";
public static final String NEW_SKIN = GUI_KEY + "new_skin";
public static final String NEW_NAME = GUI_KEY + "new_name";
public static class Titles { public static class Titles {
public static final String TITLE_KEY = GUI_KEY + "title."; public static final String TITLE_KEY = GUI_KEY + "title.";

View file

@ -9,7 +9,7 @@ public enum Locale implements Serializable {
FRENCH("fr", "Français"), FRENCH("fr", "Français"),
CUSTOM("cm", "Server Custom"); CUSTOM("cm", "Server Custom");
public static final Version VERSION = new Version(1, 1, 2); public static final Version VERSION = new Version(1, 1, 3);
private final String code; private final String code;
private transient final String name; private transient final String name;

View file

@ -1,7 +1,7 @@
# Nicko ${version} - Language File: # Nicko ${version} - Language File:
# Specifies the configuration version, don't change. # Specifies the configuration version, don't change.
version: "1.1.2" version: "1.1.3"
error: error:
generic: "An unknown error occurred." generic: "An unknown error occurred."
@ -73,6 +73,10 @@ gui:
name: "Scroll down" name: "Scroll down"
lore: lore:
- "<dark_gray><i>(You can't scroll any further down.)</i></dark_gray>" - "<dark_gray><i>(You can't scroll any further down.)</i></dark_gray>"
new_skin:
name: "New skin..."
new_name:
name: "New name..."
home: home:
admin: admin:
name: "Administration panel" name: "Administration panel"

View file

@ -1,7 +1,7 @@
# Nicko ${version} - Fichier de langue: # Nicko ${version} - Fichier de langue:
# Précise la version de la configuration, ne pas changer. # Précise la version de la configuration, ne pas changer.
version: "1.1.2" version: "1.1.3"
error: error:
generic: "Une erreur inconnue c'est produite." generic: "Une erreur inconnue c'est produite."
@ -74,6 +74,10 @@ gui:
name: "Défiler vers le bas" name: "Défiler vers le bas"
lore: lore:
- "<dark_gray><i>(Impossible de défiler plus bas.)</i></dark_gray>" - "<dark_gray><i>(Impossible de défiler plus bas.)</i></dark_gray>"
new_skin:
name: "Nouveau skin..."
new_name:
name: "Nouveau nom..."
home: home:
admin: admin:
name: "Panel d'administration" name: "Panel d'administration"