mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-11 03:38:28 +00:00
cleanup
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1388 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
a314f16f90
commit
e18cd69b5d
1 changed files with 20 additions and 15 deletions
|
@ -1,10 +1,8 @@
|
|||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
|
@ -279,10 +277,12 @@ public class Util
|
|||
|
||||
public static double roundDouble(double d)
|
||||
{
|
||||
return Math.round(d*100.0)/100.0;
|
||||
return Math.round(d * 100.0) / 100.0;
|
||||
}
|
||||
|
||||
private static class ConfigClassLoader extends ClassLoader {
|
||||
|
||||
|
||||
private static class ConfigClassLoader extends ClassLoader
|
||||
{
|
||||
private File dataFolder;
|
||||
private ClassLoader cl;
|
||||
|
||||
|
@ -291,7 +291,7 @@ public class Util
|
|||
this.dataFolder = dataFolder;
|
||||
this.cl = cl;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public URL getResource(String string)
|
||||
{
|
||||
|
@ -364,29 +364,34 @@ public class Util
|
|||
cl.setPackageAssertionStatus(string, bln);
|
||||
}
|
||||
}
|
||||
|
||||
private static final Locale defaultLocale = Locale.getDefault();
|
||||
public static Locale currentLocale = defaultLocale;
|
||||
private static ResourceBundle bundle = ResourceBundle.getBundle("messages", defaultLocale);
|
||||
|
||||
public static String i18n(String string) {
|
||||
|
||||
public static String i18n(String string)
|
||||
{
|
||||
return bundle.getString(string);
|
||||
}
|
||||
|
||||
public static String format(String string, Object... objects) {
|
||||
|
||||
public static String format(String string, Object... objects)
|
||||
{
|
||||
MessageFormat mf = new MessageFormat(i18n(string));
|
||||
return mf.format(objects);
|
||||
}
|
||||
|
||||
public static void updateLocale(String loc, File dataFolder) {
|
||||
if (loc == null || loc.isEmpty()) {
|
||||
public static void updateLocale(String loc, File dataFolder)
|
||||
{
|
||||
if (loc == null || loc.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
String[] parts = loc.split("_");
|
||||
if (parts.length == 1) {
|
||||
if (parts.length == 1)
|
||||
{
|
||||
currentLocale = new Locale(parts[0]);
|
||||
}
|
||||
if (parts.length == 2) {
|
||||
if (parts.length == 2)
|
||||
{
|
||||
currentLocale = new Locale(parts[0], parts[1]);
|
||||
}
|
||||
bundle = ResourceBundle.getBundle("messages", currentLocale, new ConfigClassLoader(dataFolder, Util.class.getClassLoader()));
|
||||
|
|
Loading…
Reference in a new issue