Author SHA1 Message Date
iGabyTM ade2c78bfd feat: rename potion_level placeholder
Last edit, I promise 😬
2023-06-21 20:55:33 +03:00
iGabyTM dcfeec98ed fix: move potion placeholders outside the switch block
Because these placeholders requires an argument they need to be outside the switch block
2023-06-21 20:51:34 +03:00
iGabyTM 84d3df2321 feat: rename placeholder
As @BlitzOffline pointed out, `has_potion_effect` makes more sense than `potion_has`
2023-06-21 20:49:01 +03:00
iGabyTM e9198ef980 feat: add potion_has and potion_level (close #66) 2023-06-19 01:16:24 +03:00
cj89898 99f128fa66 Merge pull request #81 from PlaceholderAPI/feat/1.20
feat: add support for player ping in 1.20
2023-06-16 11:40:13 -05:00
darbyjack b516ac0d4e fix: update version in main class as well 2023-06-10 09:50:00 -05:00
darbyjack 60bc8fabed feat: add support for player ping in 1.20 2023-06-10 08:27:34 -05:00
darbyjack 0ffb15aeb7 Bump to 2.0.4 2023-02-19 12:24:45 -06:00
Glare a2f5da710d Merge pull request #72 from kforbro/master 2023-02-19 12:20:32 -06:00
Glare 86b860e3ff Merge pull request #74 from WildTooth/master 2023-02-19 12:19:34 -06:00
WildTooth bbdb93199b Added %has_health_boost% and %health_boost% placeholders 2023-01-31 20:24:12 +01:00
kforbro b870442d19 fix %player_colored_ping_{name}% 2023-01-24 04:20:20 +03:00
4 changed files with 46 additions and 8 deletions

No files matched your search

+4 -4
View File
@@ -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() { }
/**