build: include and relocate inventory lib

This commit is contained in:
aroooo 2022-10-27 18:38:07 +02:00
parent 816bf72d1c
commit fa32baf26a
3 changed files with 26 additions and 23 deletions

View file

@ -37,6 +37,7 @@
<includes>
<include>xyz.upperlevel.spigot.book:spigot-book-api</include>
<include>net.wesjd:anvilgui</include>
<include>de.studiocode.invui:*</include>
</includes>
</artifactSet>
<relocations>
@ -48,6 +49,10 @@
<pattern>net.wesjd.anvilgui</pattern>
<shadedPattern>net.artelnatif.anvilgui</shadedPattern>
</relocation>
<relocation>
<pattern>de.studiocode.invui</pattern>
<shadedPattern>net.artelnatif.invui</shadedPattern>
</relocation>
</relocations>
<minimizeJar>false</minimizeJar>
</configuration>
@ -58,8 +63,8 @@
</build>
<repositories>
<repository>
<id>minebench-repo</id>
<url>https://repo.minebench.de/</url>
<id>xenondevs</id>
<url>https://repo.xenondevs.xyz/releases</url>
</repository>
<repository>
<id>bungeecord-repo</id>
@ -87,12 +92,6 @@
<version>1.18-R0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>de.themoep</groupId>
<artifactId>inventorygui</artifactId>
<version>1.6-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>

View file

@ -104,6 +104,7 @@
<includes>
<include>xyz.upperlevel.spigot.book:spigot-book-api</include>
<include>net.wesjd:anvilgui</include>
<include>de.studiocode.invui:*</include>
</includes>
</artifactSet>
<relocations>
@ -115,6 +116,10 @@
<pattern>net.wesjd.anvilgui</pattern>
<shadedPattern>net.artelnatif.anvilgui</shadedPattern>
</relocation>
<relocation>
<pattern>de.studiocode.invui</pattern>
<shadedPattern>net.artelnatif.invui</shadedPattern>
</relocation>
</relocations>
<!-- Prevents breaking AnvilGUI's VersionWrapper. -->
<minimizeJar>false</minimizeJar>

View file

@ -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;
}
}
}