build: include and relocate inventory lib
This commit is contained in:
parent
816bf72d1c
commit
fa32baf26a
3 changed files with 26 additions and 23 deletions
|
@ -37,6 +37,7 @@
|
||||||
<includes>
|
<includes>
|
||||||
<include>xyz.upperlevel.spigot.book:spigot-book-api</include>
|
<include>xyz.upperlevel.spigot.book:spigot-book-api</include>
|
||||||
<include>net.wesjd:anvilgui</include>
|
<include>net.wesjd:anvilgui</include>
|
||||||
|
<include>de.studiocode.invui:*</include>
|
||||||
</includes>
|
</includes>
|
||||||
</artifactSet>
|
</artifactSet>
|
||||||
<relocations>
|
<relocations>
|
||||||
|
@ -48,6 +49,10 @@
|
||||||
<pattern>net.wesjd.anvilgui</pattern>
|
<pattern>net.wesjd.anvilgui</pattern>
|
||||||
<shadedPattern>net.artelnatif.anvilgui</shadedPattern>
|
<shadedPattern>net.artelnatif.anvilgui</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>de.studiocode.invui</pattern>
|
||||||
|
<shadedPattern>net.artelnatif.invui</shadedPattern>
|
||||||
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
<minimizeJar>false</minimizeJar>
|
<minimizeJar>false</minimizeJar>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -58,8 +63,8 @@
|
||||||
</build>
|
</build>
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>minebench-repo</id>
|
<id>xenondevs</id>
|
||||||
<url>https://repo.minebench.de/</url>
|
<url>https://repo.xenondevs.xyz/releases</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>bungeecord-repo</id>
|
<id>bungeecord-repo</id>
|
||||||
|
@ -87,12 +92,6 @@
|
||||||
<version>1.18-R0.1-SNAPSHOT</version>
|
<version>1.18-R0.1-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>de.themoep</groupId>
|
|
||||||
<artifactId>inventorygui</artifactId>
|
|
||||||
<version>1.6-SNAPSHOT</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
|
|
|
@ -104,6 +104,7 @@
|
||||||
<includes>
|
<includes>
|
||||||
<include>xyz.upperlevel.spigot.book:spigot-book-api</include>
|
<include>xyz.upperlevel.spigot.book:spigot-book-api</include>
|
||||||
<include>net.wesjd:anvilgui</include>
|
<include>net.wesjd:anvilgui</include>
|
||||||
|
<include>de.studiocode.invui:*</include>
|
||||||
</includes>
|
</includes>
|
||||||
</artifactSet>
|
</artifactSet>
|
||||||
<relocations>
|
<relocations>
|
||||||
|
@ -115,6 +116,10 @@
|
||||||
<pattern>net.wesjd.anvilgui</pattern>
|
<pattern>net.wesjd.anvilgui</pattern>
|
||||||
<shadedPattern>net.artelnatif.anvilgui</shadedPattern>
|
<shadedPattern>net.artelnatif.anvilgui</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>de.studiocode.invui</pattern>
|
||||||
|
<shadedPattern>net.artelnatif.invui</shadedPattern>
|
||||||
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
<!-- Prevents breaking AnvilGUI's VersionWrapper. -->
|
<!-- Prevents breaking AnvilGUI's VersionWrapper. -->
|
||||||
<minimizeJar>false</minimizeJar>
|
<minimizeJar>false</minimizeJar>
|
||||||
|
|
|
@ -2,35 +2,34 @@ package net.artelnatif.nicko.i18n;
|
||||||
|
|
||||||
import net.artelnatif.nicko.NickoBukkit;
|
import net.artelnatif.nicko.NickoBukkit;
|
||||||
import org.apache.commons.lang.LocaleUtils;
|
import org.apache.commons.lang.LocaleUtils;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
public class I18N {
|
public class I18N {
|
||||||
private final NickoBukkit instance;
|
private final static MessageFormat formatter = new MessageFormat("");
|
||||||
private final MessageFormat formatter = new MessageFormat("");
|
|
||||||
|
|
||||||
public I18N(NickoBukkit instance) {
|
private static Locale getLocale(Player player) {
|
||||||
this.instance = instance;
|
|
||||||
formatter.setLocale(getLocale());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Locale getLocale() {
|
|
||||||
try {
|
try {
|
||||||
return LocaleUtils.toLocale(instance.getNickoConfig().getLocale());
|
return LocaleUtils.toLocale(player.getLocale().substring(0, 1));
|
||||||
} catch (IllegalArgumentException exception) {
|
} 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();
|
return Locale.getDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResourceBundle getBundle() {
|
private static ResourceBundle getBundle(Player player) {
|
||||||
return ResourceBundle.getBundle("locale", getLocale());
|
return ResourceBundle.getBundle("locale", getLocale(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String get(String key, Object... arguments) {
|
public static String translate(Player player, String key, Object... arguments) {
|
||||||
formatter.applyPattern(getBundle().getString(key));
|
try {
|
||||||
return formatter.format(arguments);
|
formatter.applyPattern(getBundle(player).getString(key));
|
||||||
|
return formatter.format(arguments);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue