Skip to content

Instantly share code, notes, and snippets.

@pschichtel
Created September 10, 2012 13:27
Show Gist options
  • Save pschichtel/3690895 to your computer and use it in GitHub Desktop.
Save pschichtel/3690895 to your computer and use it in GitHub Desktop.
thank you Bukkit...
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