Skip to content

Commit

Permalink
Fix the compatibility issue with Cauldron.
Browse files Browse the repository at this point in the history
  • Loading branch information
Krasjet committed Jul 22, 2015
1 parent 5008a46 commit 3a219fc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ apply plugin: 'maven-publish'

group = 'com.meowj'
archivesBaseName = 'LangUtils'
version = '1.2.0-1.7.10'
version = '1.2.0.1-1.7.10'

final def EULA_ACCEPT = true

Expand Down
11 changes: 9 additions & 2 deletions src/main/java/com/meowj/langutils/LangUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
public class LangUtils extends JavaPlugin {

public static LangUtils plugin;
private static boolean isCauldron = false;

@Override
public void onEnable() {
plugin = this;
if (getServer().getName().contains("Cauldron") || getServer().getName().contains("MCPC"))
warn("Unsupported environment! Currently, Language Utils does NOT support Cauldron/KCauldron environment!");
if (getServer().getName().contains("Cauldron") || getServer().getName().contains("MCPC")) {
isCauldron = true;
warn("This API is not designed for Cauldron/KCauldron server, but it should work without problems for VANILLA items/entities. Again, you cannot use this API with items/entities in mods.");
}
try {
final long startTime = System.currentTimeMillis();
EnumLang.init();
Expand Down Expand Up @@ -61,4 +64,8 @@ public void info(String msg) {
public void warn(String msg) {
getLogger().log(Level.WARNING, msg);
}

public boolean isCauldron() {
return isCauldron;
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/meowj/langutils/locale/LocaleHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class LocaleHelper {
public static String getPlayerLanguage(Player player) {
try {
Object handle = player.getClass().getDeclaredMethod("getHandle").invoke(player, (Object[]) null);
Field f = handle.getClass().getDeclaredField("locale");
Field f = LangUtils.plugin.isCauldron() ? handle.getClass().getDeclaredField("field_71148_cg") : handle.getClass().getDeclaredField("locale");
f.setAccessible(true);
return (String) f.get(handle);
} catch (Exception e) {
Expand Down

0 comments on commit 3a219fc

Please sign in to comment.