feat(i18n): translate unavailable item
This commit is contained in:
parent
6633ac94a8
commit
292e9a4a6b
7 changed files with 37 additions and 6 deletions
|
@ -9,7 +9,6 @@ import xyz.atnrch.nicko.config.Configuration;
|
||||||
import xyz.atnrch.nicko.config.ConfigurationManager;
|
import xyz.atnrch.nicko.config.ConfigurationManager;
|
||||||
import xyz.atnrch.nicko.event.PlayerJoinListener;
|
import xyz.atnrch.nicko.event.PlayerJoinListener;
|
||||||
import xyz.atnrch.nicko.event.PlayerQuitListener;
|
import xyz.atnrch.nicko.event.PlayerQuitListener;
|
||||||
import xyz.atnrch.nicko.gui.items.common.UnavailableItem;
|
|
||||||
import xyz.atnrch.nicko.i18n.Locale;
|
import xyz.atnrch.nicko.i18n.Locale;
|
||||||
import xyz.atnrch.nicko.i18n.LocaleFileManager;
|
import xyz.atnrch.nicko.i18n.LocaleFileManager;
|
||||||
import xyz.atnrch.nicko.mojang.MojangAPI;
|
import xyz.atnrch.nicko.mojang.MojangAPI;
|
||||||
|
@ -92,7 +91,6 @@ public class NickoBukkit extends JavaPlugin {
|
||||||
|
|
||||||
Structure.addGlobalIngredient('#', new SimpleItem(new ItemBuilder(Material.AIR)));
|
Structure.addGlobalIngredient('#', new SimpleItem(new ItemBuilder(Material.AIR)));
|
||||||
Structure.addGlobalIngredient('%', new SimpleItem(new ItemBuilder(Material.BLACK_STAINED_GLASS_PANE).setDisplayName(" ")));
|
Structure.addGlobalIngredient('%', new SimpleItem(new ItemBuilder(Material.BLACK_STAINED_GLASS_PANE).setDisplayName(" ")));
|
||||||
Structure.addGlobalIngredient('U', new UnavailableItem());
|
|
||||||
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||||
getLogger().info("Enabling PlaceHolderAPI support...");
|
getLogger().info("Enabling PlaceHolderAPI support...");
|
||||||
|
|
|
@ -4,17 +4,24 @@ import xyz.atnrch.nicko.gui.items.admin.ManageCacheItem;
|
||||||
import xyz.atnrch.nicko.gui.items.admin.ManagePlayerItem;
|
import xyz.atnrch.nicko.gui.items.admin.ManagePlayerItem;
|
||||||
import xyz.atnrch.nicko.gui.items.common.GoBackItem;
|
import xyz.atnrch.nicko.gui.items.common.GoBackItem;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import xyz.atnrch.nicko.gui.items.common.UnavailableItem;
|
||||||
|
import xyz.atnrch.nicko.i18n.I18N;
|
||||||
|
import xyz.atnrch.nicko.i18n.I18NDict;
|
||||||
import xyz.xenondevs.invui.gui.Gui;
|
import xyz.xenondevs.invui.gui.Gui;
|
||||||
import xyz.xenondevs.invui.window.Window;
|
import xyz.xenondevs.invui.window.Window;
|
||||||
|
|
||||||
public class AdminGUI {
|
public class AdminGUI {
|
||||||
private final String title = "Nicko > Administration";
|
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final Gui gui;
|
private final Gui gui;
|
||||||
|
private final String title;
|
||||||
|
|
||||||
public AdminGUI(Player player) {
|
public AdminGUI(Player player) {
|
||||||
|
final I18N i18n = new I18N(player);
|
||||||
|
this.title = i18n.translatePrefixless(I18NDict.GUI.Admin.TITLE);
|
||||||
|
|
||||||
final HomeGUI parent = new HomeGUI(player);
|
final HomeGUI parent = new HomeGUI(player);
|
||||||
final GoBackItem backItem = new GoBackItem(player);
|
final GoBackItem backItem = new GoBackItem(player);
|
||||||
|
final UnavailableItem unavailableItem = new UnavailableItem(player);
|
||||||
|
|
||||||
this.gui = Gui.normal()
|
this.gui = Gui.normal()
|
||||||
.setStructure(
|
.setStructure(
|
||||||
|
@ -23,6 +30,7 @@ public class AdminGUI {
|
||||||
"B # # # # # # # #"
|
"B # # # # # # # #"
|
||||||
)
|
)
|
||||||
.addIngredient('S', new ManageCacheItem())
|
.addIngredient('S', new ManageCacheItem())
|
||||||
|
.addIngredient('U', unavailableItem.get())
|
||||||
.addIngredient('C', new ManagePlayerItem())
|
.addIngredient('C', new ManagePlayerItem())
|
||||||
.addIngredient('B', backItem.get(parent.getGUI(), parent.getTitle()))
|
.addIngredient('B', backItem.get(parent.getGUI(), parent.getTitle()))
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package xyz.atnrch.nicko.gui;
|
package xyz.atnrch.nicko.gui;
|
||||||
|
|
||||||
import xyz.atnrch.nicko.gui.items.common.GoBackItem;
|
import xyz.atnrch.nicko.gui.items.common.GoBackItem;
|
||||||
|
import xyz.atnrch.nicko.gui.items.common.UnavailableItem;
|
||||||
import xyz.atnrch.nicko.gui.items.settings.BungeeCordCyclingItem;
|
import xyz.atnrch.nicko.gui.items.settings.BungeeCordCyclingItem;
|
||||||
import xyz.atnrch.nicko.gui.items.settings.LanguageCyclingItem;
|
import xyz.atnrch.nicko.gui.items.settings.LanguageCyclingItem;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -28,6 +29,7 @@ public class SettingsGUI {
|
||||||
this.title = i18n.translatePrefixless(I18NDict.GUI.Settings.TITLE);
|
this.title = i18n.translatePrefixless(I18NDict.GUI.Settings.TITLE);
|
||||||
|
|
||||||
final HomeGUI parent = new HomeGUI(player);
|
final HomeGUI parent = new HomeGUI(player);
|
||||||
|
final UnavailableItem unavailableItem = new UnavailableItem(player);
|
||||||
final LanguageCyclingItem languageItem = new LanguageCyclingItem(player);
|
final LanguageCyclingItem languageItem = new LanguageCyclingItem(player);
|
||||||
final BungeeCordCyclingItem bungeeCordItem = new BungeeCordCyclingItem(player);
|
final BungeeCordCyclingItem bungeeCordItem = new BungeeCordCyclingItem(player);
|
||||||
final GoBackItem backItem = new GoBackItem(player);
|
final GoBackItem backItem = new GoBackItem(player);
|
||||||
|
@ -36,6 +38,7 @@ public class SettingsGUI {
|
||||||
.setStructure(dynamicStructure)
|
.setStructure(dynamicStructure)
|
||||||
.addIngredient('B', backItem.get(parent.getGUI(), parent.getTitle()))
|
.addIngredient('B', backItem.get(parent.getGUI(), parent.getTitle()))
|
||||||
.addIngredient('L', languageItem.get())
|
.addIngredient('L', languageItem.get())
|
||||||
|
.addIngredient('U', unavailableItem.get())
|
||||||
.addIngredient('T', bungeeCordItem.get())
|
.addIngredient('T', bungeeCordItem.get())
|
||||||
.build();
|
.build();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
|
@ -1,13 +1,26 @@
|
||||||
package xyz.atnrch.nicko.gui.items.common;
|
package xyz.atnrch.nicko.gui.items.common;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import xyz.atnrch.nicko.i18n.I18N;
|
||||||
|
import xyz.atnrch.nicko.i18n.I18NDict;
|
||||||
|
import xyz.atnrch.nicko.i18n.ItemTranslation;
|
||||||
import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
||||||
import xyz.xenondevs.invui.item.impl.SuppliedItem;
|
import xyz.xenondevs.invui.item.impl.SuppliedItem;
|
||||||
|
|
||||||
public class UnavailableItem extends SuppliedItem {
|
public class UnavailableItem {
|
||||||
public UnavailableItem() {
|
private final I18N i18n;
|
||||||
super(() -> {
|
|
||||||
|
public UnavailableItem(Player player) {
|
||||||
|
this.i18n = new I18N(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuppliedItem get() {
|
||||||
|
return new SuppliedItem(() -> {
|
||||||
final ItemBuilder builder = new ItemBuilder(Material.RED_TERRACOTTA);
|
final ItemBuilder builder = new ItemBuilder(Material.RED_TERRACOTTA);
|
||||||
|
final ItemTranslation translation = i18n.translateItem(I18NDict.GUI.UNAVAILABLE);
|
||||||
|
builder.setDisplayName(translation.getName());
|
||||||
|
translation.getLore().forEach(builder::addLoreLines);
|
||||||
builder.setDisplayName("Unavailable");
|
builder.setDisplayName("Unavailable");
|
||||||
builder.addLoreLines("§7§oThis button is disabled.");
|
builder.addLoreLines("§7§oThis button is disabled.");
|
||||||
return builder;
|
return builder;
|
||||||
|
|
|
@ -67,6 +67,7 @@ public class I18NDict {
|
||||||
private static final String GUI_KEY = "gui.";
|
private static final String GUI_KEY = "gui.";
|
||||||
|
|
||||||
public static final String EXIT = GUI_KEY + "exit";
|
public static final String EXIT = GUI_KEY + "exit";
|
||||||
|
public static final String UNAVAILABLE = GUI_KEY + "unavailable";
|
||||||
public static final String GO_BACK = GUI_KEY + "go_back";
|
public static final String GO_BACK = GUI_KEY + "go_back";
|
||||||
|
|
||||||
public static class Home {
|
public static class Home {
|
||||||
|
|
|
@ -32,6 +32,10 @@ gui:
|
||||||
name: "Exit"
|
name: "Exit"
|
||||||
go_back:
|
go_back:
|
||||||
name: "Back"
|
name: "Back"
|
||||||
|
unavailable:
|
||||||
|
name: "Unavailable"
|
||||||
|
lore:
|
||||||
|
- "§7§oThis button is disabled."
|
||||||
home:
|
home:
|
||||||
title: "Nicko - Home"
|
title: "Nicko - Home"
|
||||||
admin:
|
admin:
|
||||||
|
|
|
@ -32,6 +32,10 @@ gui:
|
||||||
name: "Quitter"
|
name: "Quitter"
|
||||||
go_back:
|
go_back:
|
||||||
name: "Retour"
|
name: "Retour"
|
||||||
|
unavailable:
|
||||||
|
name: "Indisponible"
|
||||||
|
lore:
|
||||||
|
- "§7§oCe boutton est désactivé."
|
||||||
home:
|
home:
|
||||||
title: "Nicko - Accueil"
|
title: "Nicko - Accueil"
|
||||||
admin:
|
admin:
|
||||||
|
|
Loading…
Reference in a new issue