Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>com.extendedclip.papi.expansion.player</groupId>
<artifactId>player-expansion</artifactId>
<version>2.0.8</version>
<version>2.0.9</version>

<name>PAPI-Expansion-Player</name>
<description>PlaceholderAPI expansion for player placeholders</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public String getAuthor() {

@Override
public String getVersion() {
return "2.0.8";
return "2.0.9";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,16 @@ private void cacheReflection(final Player player) throws NoSuchFieldException, N

final Object entityPlayer = getHandle.invoke(player);

if (VersionHelper.IS_1_20_4_OR_NEWER) {
locale = entityPlayer.getClass().getField("cO");
if (VersionHelper.IS_MOJMAP) {
locale = entityPlayer.getClass().getField("language");
} else if (VersionHelper.IS_1_20_6_OR_NEWER) {
locale = entityPlayer.getClass().getField("dd");
} else if (VersionHelper.IS_1_20_4_OR_NEWER) {
locale = entityPlayer.getClass().getField("cO");
} else if (VersionHelper.IS_1_20_2_OR_NEWER) {
locale = entityPlayer.getClass().getField("cM");
locale = entityPlayer.getClass().getField("cM");
} else {
locale = entityPlayer.getClass().getField("locale");
locale = entityPlayer.getClass().getField("locale");
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ public final class VersionHelper {
*/
public static final boolean IS_1_20_4_OR_NEWER = VERSION >= 1_20_4;

/**
* @see Player#getLocale()
*/
public static final boolean IS_1_20_6_OR_NEWER = VERSION >= 1_20_6;

/**
* @see Player#getLocale()
*/
public static final boolean IS_MOJMAP = IS_1_20_6_OR_NEWER && doesClassExist("org.bukkit.craftbukkit.CraftServer");

private VersionHelper() { }

/**
Expand Down Expand Up @@ -65,4 +75,19 @@ private static int getCurrentVersion() {
return version;
}

/**
* Detect specific class exists
*
* @param className
* @return true if the class exists, otherwise false
*/
private static boolean doesClassExist(String className) {
try {
Class.forName(className);
return true;
} catch (ClassNotFoundException e) {
return false;
}
}

}