From fa32baf26a42042f7375130d6005bf989e57e7cf Mon Sep 17 00:00:00 2001 From: aroooo Date: Thu, 27 Oct 2022 18:38:07 +0200 Subject: [PATCH] build: include and relocate inventory lib --- nicko-core/dependency-reduced-pom.xml | 15 +++++----- nicko-core/pom.xml | 5 ++++ .../java/net/artelnatif/nicko/i18n/I18N.java | 29 +++++++++---------- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/nicko-core/dependency-reduced-pom.xml b/nicko-core/dependency-reduced-pom.xml index f160f25..eb01f8a 100644 --- a/nicko-core/dependency-reduced-pom.xml +++ b/nicko-core/dependency-reduced-pom.xml @@ -37,6 +37,7 @@ xyz.upperlevel.spigot.book:spigot-book-api net.wesjd:anvilgui + de.studiocode.invui:* @@ -48,6 +49,10 @@ net.wesjd.anvilgui net.artelnatif.anvilgui + + de.studiocode.invui + net.artelnatif.invui + false @@ -58,8 +63,8 @@ - minebench-repo - https://repo.minebench.de/ + xenondevs + https://repo.xenondevs.xyz/releases bungeecord-repo @@ -87,12 +92,6 @@ 1.18-R0.1-SNAPSHOT compile - - de.themoep - inventorygui - 1.6-SNAPSHOT - compile - com.google.guava guava diff --git a/nicko-core/pom.xml b/nicko-core/pom.xml index 8e67e08..32fc4ab 100644 --- a/nicko-core/pom.xml +++ b/nicko-core/pom.xml @@ -104,6 +104,7 @@ xyz.upperlevel.spigot.book:spigot-book-api net.wesjd:anvilgui + de.studiocode.invui:* @@ -115,6 +116,10 @@ net.wesjd.anvilgui net.artelnatif.anvilgui + + de.studiocode.invui + net.artelnatif.invui + false diff --git a/nicko-core/src/main/java/net/artelnatif/nicko/i18n/I18N.java b/nicko-core/src/main/java/net/artelnatif/nicko/i18n/I18N.java index 9c4b521..29557ca 100644 --- a/nicko-core/src/main/java/net/artelnatif/nicko/i18n/I18N.java +++ b/nicko-core/src/main/java/net/artelnatif/nicko/i18n/I18N.java @@ -2,35 +2,34 @@ package net.artelnatif.nicko.i18n; import net.artelnatif.nicko.NickoBukkit; import org.apache.commons.lang.LocaleUtils; +import org.bukkit.entity.Player; import java.text.MessageFormat; import java.util.Locale; import java.util.ResourceBundle; public class I18N { - private final NickoBukkit instance; - private final MessageFormat formatter = new MessageFormat(""); + private final static MessageFormat formatter = new MessageFormat(""); - public I18N(NickoBukkit instance) { - this.instance = instance; - formatter.setLocale(getLocale()); - } - - private Locale getLocale() { + private static Locale getLocale(Player player) { try { - return LocaleUtils.toLocale(instance.getNickoConfig().getLocale()); + return LocaleUtils.toLocale(player.getLocale().substring(0, 1)); } catch (IllegalArgumentException exception) { - instance.getLogger().severe("Invalid locale provided, defaulting to " + Locale.getDefault().getDisplayName() + "."); + NickoBukkit.getInstance().getLogger().severe("Invalid locale provided, defaulting to " + Locale.getDefault().getDisplayName() + "."); return Locale.getDefault(); } } - private ResourceBundle getBundle() { - return ResourceBundle.getBundle("locale", getLocale()); + private static ResourceBundle getBundle(Player player) { + return ResourceBundle.getBundle("locale", getLocale(player)); } - public String get(String key, Object... arguments) { - formatter.applyPattern(getBundle().getString(key)); - return formatter.format(arguments); + public static String translate(Player player, String key, Object... arguments) { + try { + formatter.applyPattern(getBundle(player).getString(key)); + return formatter.format(arguments); + } catch (Exception e) { + return key; + } } }