feat: custom language file reload
This commit is contained in:
parent
84e558afb2
commit
dbc1da0c2c
6 changed files with 54 additions and 4 deletions
|
@ -5,6 +5,7 @@ import de.studiocode.invui.gui.builder.GUIBuilder;
|
||||||
import de.studiocode.invui.gui.builder.guitype.GUIType;
|
import de.studiocode.invui.gui.builder.guitype.GUIType;
|
||||||
import de.studiocode.invui.gui.structure.Structure;
|
import de.studiocode.invui.gui.structure.Structure;
|
||||||
import de.studiocode.invui.window.impl.single.SimpleWindow;
|
import de.studiocode.invui.window.impl.single.SimpleWindow;
|
||||||
|
import net.artelnatif.nicko.gui.items.admin.ReloadLanguageFileItem;
|
||||||
import net.artelnatif.nicko.gui.items.common.BackItem;
|
import net.artelnatif.nicko.gui.items.common.BackItem;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -14,13 +15,13 @@ public class AdminPanelGUI {
|
||||||
|
|
||||||
public AdminPanelGUI(Player player) {
|
public AdminPanelGUI(Player player) {
|
||||||
final Structure structure = new Structure("# # # # # # # # #",
|
final Structure structure = new Structure("# # # # # # # # #",
|
||||||
"# % % M C R % % #",
|
"# % % P U L % % #",
|
||||||
"B # # # # # # # #");
|
"B # # # # # # # #");
|
||||||
structure.addIngredient('B', new BackItem(new MainGUI(player).getGUI()));
|
structure.addIngredient('B', new BackItem(new MainGUI(player).getGUI()));
|
||||||
this.gui = new GUIBuilder<>(GUIType.NORMAL)
|
this.gui = new GUIBuilder<>(GUIType.NORMAL)
|
||||||
.setStructure(structure)
|
.setStructure(structure)
|
||||||
|
.addIngredient('L', new ReloadLanguageFileItem())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package net.artelnatif.nicko.gui.items.admin;
|
||||||
|
|
||||||
|
import de.studiocode.invui.item.ItemProvider;
|
||||||
|
import de.studiocode.invui.item.builder.ItemBuilder;
|
||||||
|
import de.studiocode.invui.item.impl.BaseItem;
|
||||||
|
import net.artelnatif.nicko.NickoBukkit;
|
||||||
|
import net.artelnatif.nicko.i18n.I18N;
|
||||||
|
import net.artelnatif.nicko.i18n.I18NDict;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
public class ReloadLanguageFileItem extends BaseItem {
|
||||||
|
@Override
|
||||||
|
public ItemProvider getItemProvider() {
|
||||||
|
return new ItemBuilder(Material.OAK_DOOR).setDisplayName("§fExit");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {
|
||||||
|
if (clickType.isLeftClick() || clickType.isRightClick()) {
|
||||||
|
event.getView().close();
|
||||||
|
final Properties properties = NickoBukkit.getInstance().getLocaleManager().reloadCustomLanguageFile();
|
||||||
|
if (properties != null) {
|
||||||
|
player.sendMessage(I18N.translate(player, I18NDict.Plugin.CUSTOM_LANGUAGE_RELOAD_SUCCESS));
|
||||||
|
} else {
|
||||||
|
player.sendMessage(I18N.translate(player, I18NDict.Plugin.CUSTOM_LANGUAGE_RELOAD_FAIL));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,11 @@ public record I18NDict(String key) {
|
||||||
public static final I18NDict PREVIOUS_SKIN_APPLY_FAIL = new I18NDict("event.previous_skin_applied.fail");
|
public static final I18NDict PREVIOUS_SKIN_APPLY_FAIL = new I18NDict("event.previous_skin_applied.fail");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class Plugin {
|
||||||
|
public static final I18NDict CUSTOM_LANGUAGE_RELOAD_SUCCESS = new I18NDict("admin.custom_language_reload_success");
|
||||||
|
public static final I18NDict CUSTOM_LANGUAGE_RELOAD_FAIL = new I18NDict("admin.custom_language_reload_fail");
|
||||||
|
}
|
||||||
|
|
||||||
public static class Error {
|
public static class Error {
|
||||||
public static final I18NDict PLAYER_OFFLINE = new I18NDict("error.player_offline");
|
public static final I18NDict PLAYER_OFFLINE = new I18NDict("error.player_offline");
|
||||||
public static final I18NDict SKIN_FAIL_MOJANG = new I18NDict("error.couldnt_get_skin_from_mojang");
|
public static final I18NDict SKIN_FAIL_MOJANG = new I18NDict("error.couldnt_get_skin_from_mojang");
|
||||||
|
|
|
@ -63,6 +63,11 @@ public class LocaleManager {
|
||||||
return customLanguageFile;
|
return customLanguageFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Properties reloadCustomLanguageFile() {
|
||||||
|
customLanguageFile = null;
|
||||||
|
return getCustomLanguageFile();
|
||||||
|
}
|
||||||
|
|
||||||
public void findFallbackLocale() {
|
public void findFallbackLocale() {
|
||||||
final String locale = instance.getNickoConfig().getFallbackLocale();
|
final String locale = instance.getNickoConfig().getFallbackLocale();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -11,3 +11,5 @@ error.couldnt_get_name_from_mojang=Failed to get username from Mojang
|
||||||
error.couldnt_get_skin_from_mojang=Failed to get skin from Mojang
|
error.couldnt_get_skin_from_mojang=Failed to get skin from Mojang
|
||||||
error.couldnt_get_skin_from_cache=Failed to get skin from cache
|
error.couldnt_get_skin_from_cache=Failed to get skin from cache
|
||||||
error.invalid_username=§cThe specified username is not a valid Minecraft username.
|
error.invalid_username=§cThe specified username is not a valid Minecraft username.
|
||||||
|
admin.custom_language_reload_success=§aReloaded custom language file.
|
||||||
|
admin.custom_language_reload_fail=§cFailed to reload the custom language file!
|
|
@ -11,3 +11,5 @@ error.couldnt_get_name_from_mojang=Impossible de récupérer le nom d'utilisateu
|
||||||
error.couldnt_get_skin_from_mojang=Impossible de récupérer le skin depuis Mojang
|
error.couldnt_get_skin_from_mojang=Impossible de récupérer le skin depuis Mojang
|
||||||
error.couldnt_get_skin_from_cache=Impossible de récupérer le skin depuis le cache
|
error.couldnt_get_skin_from_cache=Impossible de récupérer le skin depuis le cache
|
||||||
error.invalid_username=§cLe pseudo spécifié n'est pas un pseudo Minecraft valide.
|
error.invalid_username=§cLe pseudo spécifié n'est pas un pseudo Minecraft valide.
|
||||||
|
admin.custom_language_reload_success=§aFichier de langue rechargé.
|
||||||
|
admin.custom_language_reload_fail=§cImpossible de recharger le fichier de langue !
|
Loading…
Reference in a new issue