16 Commits
Author SHA1 Message Date
darbyjack 51eb4f6890 Update to 1.5.1 2022-04-19 16:10:21 -05:00
Glare 4cd6514724 Merge pull request #48 from Zoiter7/master 2022-04-19 16:09:07 -05:00
Glare 3fe272a3f9 Merge pull request #49 from PlaceholderAPI/baltop-up 2022-04-19 16:08:50 -05:00
Starmism e15055744a Move to Essentials.getPlayer, not Bukkit.getPlayer 2022-04-09 16:00:16 -06:00
Starmism 176d883d69 Avoid NPE 2022-04-09 15:56:10 -06:00
Glare 6cf35e8771 Merge pull request #50 from PlaceholderAPI/fix-homes-above-9 2022-04-09 16:40:59 -05:00
darbyjack f80ab04cda Fixed homes not showing above 9 2022-04-09 16:39:36 -05:00
Starmism 370ef8f8df Add %essentials_baltop_player_stripped_<num>% for raw username, might be moderately expensive 2022-04-09 15:15:41 -06:00
Zoiter7 218e1cd5ee Changed startsWith to equals
Because is final placeholder.
2022-04-09 14:53:19 +02:00
Zoiter7 676c19d394 Update EssentialsExpansion.java 2022-04-09 14:34:13 +02:00
Zoiter7 3dc5c88765 Added new placeholder %essentials_tp_cooldown%
See cooldown for teleport
2022-04-09 14:25:56 +02:00
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
2 changed files with 52 additions and 13 deletions

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.extendedclip.papi.expansion.essentials</groupId>
<artifactId>essentials-expansion</artifactId>
<version>1.5.0</version>
<version>1.5.1</version>
<name>PAPI-Expansion-Essentials</name>
<description>PlaceholderAPI expansion for Essentials placeholders</description>
@@ -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.primitives.Ints;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
@@ -40,10 +41,9 @@ 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.concurrent.TimeUnit;
import java.util.stream.StreamSupport;
public class EssentialsExpansion extends PlaceholderExpansion {
@@ -102,8 +102,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);
@@ -170,6 +170,13 @@ public class EssentialsExpansion extends PlaceholderExpansion {
if (identifier.startsWith("player_")) {
identifier = identifier.substring(7);
boolean stripped = false;
if (identifier.startsWith("stripped_")) {
identifier = identifier.substring(9);
stripped = true;
}
Integer id = Ints.tryParse(identifier);
if (id == null) {
return "Invalid ID";
@@ -179,16 +186,48 @@ public class EssentialsExpansion extends PlaceholderExpansion {
if (id >= entries.length) {
return "0";
}
return entries[id].getDisplayName();
if (stripped) {
User user = essentials.getUser(entries[id].getUuid());
if (user != null) {
return user.getName();
} else {
return null;
}
} else {
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.equals("tp_cooldown")) {
final double cooldown = essentials.getSettings().getTeleportCooldown();
final long d1 = System.currentTimeMillis();
final long d2 = essentials.getUser(player.getUniqueId()).getLastTeleportTimestamp();
long diff = TimeUnit.MILLISECONDS.toSeconds(d1 - d2);
if(diff < cooldown) return String.valueOf((int) (cooldown - diff));
return "0";
}
if (identifier.startsWith("kit_last_use_")) {
String kitName = identifier.split("kit_last_use_")[1].toLowerCase();
Kit kit;
@@ -290,10 +329,10 @@ public class EssentialsExpansion extends PlaceholderExpansion {
if (homeNumber >= user.getHomes().size() || homeNumber < 0) return "";
// checks if the identifier matches the pattern home_%d
if (identifier.matches("(\\w+_)(\\d)")) return user.getHomes().get(homeNumber);
if (identifier.matches("(\\w+_)(\\d+)")) return user.getHomes().get(homeNumber);
//checks if the identifier matches the pattern home_%d_(x/y/z)
if (identifier.matches("(\\w+_)(\\d)(_\\w)")) {
if (identifier.matches("(\\w+_)(\\d+)(_\\w)")) {
try {
final Location home = user.getHome(user.getHomes().get(homeNumber));
@@ -301,13 +340,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;
}