Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ade2c78bfd | ||
|
|
dcfeec98ed | ||
|
|
84d3df2321 | ||
|
|
e9198ef980 | ||
|
|
99f128fa66 | ||
|
|
b516ac0d4e | ||
|
|
60bc8fabed | ||
|
|
0ffb15aeb7 | ||
|
|
a2f5da710d | ||
|
|
86b860e3ff | ||
|
|
bbdb93199b | ||
|
|
b870442d19 |
No files matched your search
@@ -3,7 +3,7 @@
|
||||
|
||||
<groupId>com.extendedclip.papi.expansion.player</groupId>
|
||||
<artifactId>player-expansion</artifactId>
|
||||
<version>2.0.3</version>
|
||||
<version>2.0.5</version>
|
||||
|
||||
<name>PAPI-Expansion-Player</name>
|
||||
<description>PlaceholderAPI expansion for player placeholders</description>
|
||||
@@ -30,13 +30,13 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.17-R0.1-SNAPSHOT</version>
|
||||
<version>1.20-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.10.9</version>
|
||||
<version>2.11.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -48,7 +48,7 @@
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<finalName>${name}</finalName>
|
||||
<finalName>${project.name}</finalName>
|
||||
<archive>
|
||||
<manifest>
|
||||
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
|
||||
|
||||
@@ -76,7 +76,7 @@ public final class PlayerExpansion extends PlaceholderExpansion implements Confi
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return "2.0.3";
|
||||
return "2.0.5";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,10 +102,11 @@ public final class PlayerExpansion extends PlaceholderExpansion implements Confi
|
||||
public String onRequest(OfflinePlayer player, String identifier) {
|
||||
|
||||
final boolean targetedPing = identifier.startsWith("ping_");
|
||||
if (targetedPing || identifier.startsWith("colored_ping_")) {
|
||||
final boolean targetedColoredPing = identifier.startsWith("colored_ping_");
|
||||
if (targetedPing || targetedColoredPing) {
|
||||
final Player target = Bukkit.getPlayer(identifier.substring(targetedPing ? 5 : 13)); // yes, I know, magic value
|
||||
|
||||
return target == null ? "0" : retrievePing(target, false);
|
||||
return target == null ? "0" : retrievePing(target, targetedColoredPing);
|
||||
}
|
||||
|
||||
if (player == null) {
|
||||
@@ -337,6 +338,15 @@ public final class PlayerExpansion extends PlaceholderExpansion implements Confi
|
||||
return String.valueOf(Math.round(p.getHealth()));
|
||||
case "health_scale":
|
||||
return String.valueOf(p.getHealthScale());
|
||||
case "has_health_boost":
|
||||
return bool(p.hasPotionEffect(PotionEffectType.HEALTH_BOOST));
|
||||
case "health_boost": {
|
||||
if (p.getHealthScale() > 20) {
|
||||
return Double.toString(p.getHealthScale() - 20);
|
||||
} else {
|
||||
return "0";
|
||||
}
|
||||
}
|
||||
case "item_in_hand":
|
||||
return String.valueOf(itemInHand(p).getType());
|
||||
case "item_in_hand_name":
|
||||
@@ -438,6 +448,23 @@ public final class PlayerExpansion extends PlaceholderExpansion implements Confi
|
||||
case "is_inside_vehicle":
|
||||
return bool(p.isInsideVehicle());
|
||||
}
|
||||
|
||||
if (identifier.startsWith("has_potion_effect_")) {
|
||||
final PotionEffectType potion = PotionEffectType.getByName(identifier.replace("has_potion_effect_", ""));
|
||||
return bool(potion != null && p.hasPotionEffect(potion));
|
||||
}
|
||||
|
||||
if (identifier.startsWith("potion_effect_level_")) {
|
||||
final PotionEffectType potion = PotionEffectType.getByName(identifier.replace("potion_effect_level_", ""));
|
||||
|
||||
if (potion == null || !p.hasPotionEffect(potion)) {
|
||||
return "0";
|
||||
}
|
||||
|
||||
//noinspection DataFlowIssue
|
||||
return String.valueOf(p.getPotionEffect(potion).getAmplifier());
|
||||
}
|
||||
|
||||
// return null for unknown placeholders
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,16 @@ public final class PlayerUtil {
|
||||
|
||||
final Object entityPlayer = getHandle.invoke(player);
|
||||
|
||||
ping = entityPlayer.getClass().getDeclaredField(VersionHelper.IS_1_17_OR_NEWER ? "e" : "ping");
|
||||
String pingFieldName;
|
||||
if (VersionHelper.IS_1_20_OR_NEWER) {
|
||||
pingFieldName = "f";
|
||||
} else if (VersionHelper.IS_1_17_OR_NEWER) {
|
||||
pingFieldName = "e";
|
||||
} else {
|
||||
pingFieldName = "ping";
|
||||
}
|
||||
|
||||
ping = entityPlayer.getClass().getDeclaredField(pingFieldName);
|
||||
ping.setAccessible(true);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,6 +22,8 @@ public final class VersionHelper {
|
||||
|
||||
public static final boolean IS_1_17_OR_NEWER = VERSION >= 1_17_0;
|
||||
|
||||
public static final boolean IS_1_20_OR_NEWER = VERSION >= 1_20_0;
|
||||
|
||||
private VersionHelper() { }
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user