Created
September 10, 2012 13:27
-
-
Save pschichtel/3690895 to your computer and use it in GitHub Desktop.
thank you Bukkit...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static boolean languageWorkaroundInitialized; | |
private static Field localeStringField; | |
private static Field handleField; | |
private static Field localeField; | |
static | |
{ | |
try | |
{ | |
localeStringField = Class.forName("net.minecraft.server.LocaleLanguage").getDeclaredField("d"); | |
localeStringField.setAccessible(true); | |
handleField = Class.forName("org.bukkit.craftbukkit.entity.CraftPlayer").getDeclaredField("entity"); | |
handleField.setAccessible(true); | |
localeField = Class.forName("net.minecraft.server.EntityPlayer").getDeclaredField("locale"); | |
localeField.setAccessible(true); | |
languageWorkaroundInitialized = true; | |
} | |
catch (Exception e) | |
{ | |
languageWorkaroundInitialized = false; | |
} | |
} | |
public String getLanguage() | |
{ | |
if (languageWorkaroundInitialized) | |
{ | |
try | |
{ | |
return (String)localeStringField.get(localeField.get(handleField.get(this))); | |
} | |
catch (Exception e) | |
{} | |
} | |
return CubeEngine.getCore().getConfiguration().defaultLanguage; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment