5 Commits
Author SHA1 Message Date
Star 08012e057e Merge pull request #47 from PlaceholderAPI/baltop-up
fix(baltop): Moved baltop above player null check
2022-04-07 17:32:19 -06:00
Starmism 33878de93c Replace Blitz' crunchy code with a spicier version 2022-04-07 17:30:02 -06:00
Starmism 048314c31f fix(baltop): Moved baltop above player null check
This moves the baltop placeholders above the player null check so that
one may use `/papi parse --null %essentials_baltop_rank_1%` for
instance.
2022-04-07 16:21:44 -06:00
Glare 704e07d042 Merge pull request #44 from PlaceholderAPI/fix/43-malformed-home-xz-coordinates 2022-04-07 17:15:17 -05:00
Andre_601 2518f64fe1 Remove .5 appending from Home location 2022-01-16 09:55:54 +01:00
@@ -25,6 +25,7 @@ import com.earth2me.essentials.Kit;
import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.DescParseTickFormat;
import com.google.common.collect.Streams;
import com.google.common.primitives.Ints;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
@@ -40,10 +41,8 @@ import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.*;
import java.util.stream.IntStream;
import java.util.stream.StreamSupport;
public class EssentialsExpansion extends PlaceholderExpansion {
@@ -102,8 +101,8 @@ public class EssentialsExpansion extends PlaceholderExpansion {
final String papiTrue = PlaceholderAPIPlugin.booleanTrue();
final String papiFalse = PlaceholderAPIPlugin.booleanFalse();
// Put this before the null check as most of it is not required
if (identifier.startsWith("baltop_")) {
BalanceTop baltop = essentials.getBalanceTop();
Map<UUID, BalanceTop.Entry> baltopCache = baltop.getBalanceTopCache();
identifier = identifier.substring(7);
@@ -182,11 +181,20 @@ public class EssentialsExpansion extends PlaceholderExpansion {
return entries[id].getDisplayName();
}
if (identifier.equals("rank")) {
// Another null check because it is above the normal one
if (player == null) return "";
if (!baltopCache.containsKey(player.getUniqueId())) {
return "";
}
return String.valueOf(new ArrayList<>(baltopCache.keySet()).indexOf(player.getUniqueId()) + 1);
}
return null;
}
if (player == null) return "";
if (identifier.startsWith("kit_last_use_")) {
@@ -301,13 +309,13 @@ public class EssentialsExpansion extends PlaceholderExpansion {
switch (identifier.charAt(identifier.length() - 1)) {
case 'x':
stringBuilder.append(home.getX()).append(".5");
stringBuilder.append(home.getX());
break;
case 'y':
stringBuilder.append((int) home.getY());
break;
case 'z':
stringBuilder.append(home.getZ()).append(".5");
stringBuilder.append(home.getZ());
break;
}