|
|
|
@@ -25,7 +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;
|
|
|
|
@@ -42,7 +42,8 @@ import java.text.NumberFormat;
|
|
|
|
|
import java.time.Instant;
|
|
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.IntStream;
|
|
|
|
|
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
import java.util.stream.StreamSupport;
|
|
|
|
|
|
|
|
|
|
public class EssentialsExpansion extends PlaceholderExpansion {
|
|
|
|
@@ -169,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";
|
|
|
|
@@ -178,7 +186,17 @@ 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")) {
|
|
|
|
@@ -197,6 +215,19 @@ public class EssentialsExpansion extends PlaceholderExpansion {
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
@@ -298,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));
|
|
|
|
|