Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a66a3ca452 | ||
|
|
0906079887 | ||
|
|
635c17cbbe |
@@ -102,6 +102,91 @@ public class EssentialsExpansion extends PlaceholderExpansion {
|
||||
final String papiTrue = PlaceholderAPIPlugin.booleanTrue();
|
||||
final String papiFalse = PlaceholderAPIPlugin.booleanFalse();
|
||||
|
||||
if (identifier.startsWith("baltop_")) {
|
||||
BalanceTop baltop = essentials.getBalanceTop();
|
||||
Map<UUID, BalanceTop.Entry> baltopCache = baltop.getBalanceTopCache();
|
||||
identifier = identifier.substring(7);
|
||||
|
||||
if (identifier.startsWith("balance_")) {
|
||||
identifier = identifier.substring(8);
|
||||
|
||||
if (identifier.startsWith("fixed_")) {
|
||||
identifier = identifier.substring(6);
|
||||
|
||||
Integer id = Ints.tryParse(identifier);
|
||||
if (id == null) {
|
||||
return "Invalid ID";
|
||||
}
|
||||
|
||||
BalanceTop.Entry[] entries = baltopCache.values().toArray(new BalanceTop.Entry[0]);
|
||||
if (id >= entries.length) {
|
||||
return "0";
|
||||
}
|
||||
return String.valueOf(entries[id].getBalance().longValue());
|
||||
}
|
||||
|
||||
if (identifier.startsWith("formatted_")) {
|
||||
identifier = identifier.substring(10);
|
||||
|
||||
Integer id = Ints.tryParse(identifier);
|
||||
if (id == null) {
|
||||
return "Invalid ID";
|
||||
}
|
||||
|
||||
BalanceTop.Entry[] entries = baltopCache.values().toArray(new BalanceTop.Entry[0]);
|
||||
if (id >= entries.length) {
|
||||
return "0";
|
||||
}
|
||||
return fixMoney(entries[id].getBalance().doubleValue());
|
||||
}
|
||||
|
||||
if (identifier.startsWith("commas_")) {
|
||||
identifier = identifier.substring(7);
|
||||
|
||||
Integer id = Ints.tryParse(identifier);
|
||||
if (id == null) {
|
||||
return "Invalid ID";
|
||||
}
|
||||
|
||||
BalanceTop.Entry[] entries = baltopCache.values().toArray(new BalanceTop.Entry[0]);
|
||||
if (id >= entries.length) {
|
||||
return "0";
|
||||
}
|
||||
return format.format(entries[id].getBalance().doubleValue());
|
||||
}
|
||||
|
||||
Integer id = Ints.tryParse(identifier);
|
||||
if (id == null) {
|
||||
return "Invalid ID";
|
||||
}
|
||||
|
||||
BalanceTop.Entry[] entries = baltopCache.values().toArray(new BalanceTop.Entry[0]);
|
||||
if (id >= entries.length) {
|
||||
return "0";
|
||||
}
|
||||
return String.valueOf(entries[id].getBalance().doubleValue());
|
||||
}
|
||||
|
||||
if (identifier.startsWith("player_")) {
|
||||
identifier = identifier.substring(7);
|
||||
|
||||
Integer id = Ints.tryParse(identifier);
|
||||
if (id == null) {
|
||||
return "Invalid ID";
|
||||
}
|
||||
|
||||
BalanceTop.Entry[] entries = baltopCache.values().toArray(new BalanceTop.Entry[0]);
|
||||
if (id >= entries.length) {
|
||||
return "0";
|
||||
}
|
||||
return entries[id].getDisplayName();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (player == null) return "";
|
||||
|
||||
if (identifier.startsWith("kit_last_use_")) {
|
||||
@@ -190,103 +275,6 @@ public class EssentialsExpansion extends PlaceholderExpansion {
|
||||
return oPlayer.hasPermission("essentials.kits." + kit) ? papiTrue : papiFalse;
|
||||
}
|
||||
|
||||
if (identifier.startsWith("baltop_")) {
|
||||
Map<UUID, BalanceTop.Entry> baltopCache = baltop.getBalanceTopCache();
|
||||
identifier = identifier.substring(7);
|
||||
|
||||
if (identifier.startsWith("balance_")) {
|
||||
identifier = identifier.substring(8);
|
||||
|
||||
if (identifier.startsWith("fixed_")) {
|
||||
identifier = identifier.substring(6);
|
||||
|
||||
Integer id = Ints.tryParse(identifier);
|
||||
if (id == null) {
|
||||
return "Invalid ID";
|
||||
}
|
||||
|
||||
BalanceTop.Entry[] entries = baltopCache.values().toArray(new BalanceTop.Entry[0]);
|
||||
if (id >= entries.length) {
|
||||
return "0";
|
||||
}
|
||||
return String.valueOf(entries[id].getBalance().longValue());
|
||||
}
|
||||
|
||||
if (identifier.startsWith("formatted_")) {
|
||||
identifier = identifier.substring(10);
|
||||
|
||||
Integer id = Ints.tryParse(identifier);
|
||||
if (id == null) {
|
||||
return "Invalid ID";
|
||||
}
|
||||
|
||||
BalanceTop.Entry[] entries = baltopCache.values().toArray(new BalanceTop.Entry[0]);
|
||||
if (id >= entries.length) {
|
||||
return "0";
|
||||
}
|
||||
return fixMoney(entries[id].getBalance().doubleValue());
|
||||
}
|
||||
|
||||
if (identifier.startsWith("commas_")) {
|
||||
identifier = identifier.substring(7);
|
||||
|
||||
Integer id = Ints.tryParse(identifier);
|
||||
if (id == null) {
|
||||
return "Invalid ID";
|
||||
}
|
||||
|
||||
BalanceTop.Entry[] entries = baltopCache.values().toArray(new BalanceTop.Entry[0]);
|
||||
if (id >= entries.length) {
|
||||
return "0";
|
||||
}
|
||||
return format.format(entries[id].getBalance().doubleValue());
|
||||
}
|
||||
|
||||
Integer id = Ints.tryParse(identifier);
|
||||
if (id == null) {
|
||||
return "Invalid ID";
|
||||
}
|
||||
|
||||
BalanceTop.Entry[] entries = baltopCache.values().toArray(new BalanceTop.Entry[0]);
|
||||
if (id >= entries.length) {
|
||||
return "0";
|
||||
}
|
||||
return String.valueOf(entries[id].getBalance().doubleValue());
|
||||
}
|
||||
|
||||
if (identifier.startsWith("player_")) {
|
||||
identifier = identifier.substring(7);
|
||||
|
||||
Integer id = Ints.tryParse(identifier);
|
||||
if (id == null) {
|
||||
return "Invalid ID";
|
||||
}
|
||||
|
||||
BalanceTop.Entry[] entries = baltopCache.values().toArray(new BalanceTop.Entry[0]);
|
||||
if (id >= entries.length) {
|
||||
return "0";
|
||||
}
|
||||
return entries[id].getDisplayName();
|
||||
}
|
||||
|
||||
if (identifier.equals("rank")) {
|
||||
if (!baltopCache.containsKey(player.getUniqueId())) {
|
||||
return "";
|
||||
}
|
||||
|
||||
int index = 1;
|
||||
for (Map.Entry<UUID, BalanceTop.Entry> entry : baltopCache.entrySet()) {
|
||||
if (entry.getKey() == player.getUniqueId()) {
|
||||
return String.valueOf(index);
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (identifier.startsWith("home_")) {
|
||||
Integer homeNumber;
|
||||
final User user = essentials.getUser(player.getUniqueId());
|
||||
@@ -313,7 +301,7 @@ public class EssentialsExpansion extends PlaceholderExpansion {
|
||||
|
||||
switch (identifier.charAt(identifier.length() - 1)) {
|
||||
case 'x':
|
||||
stringBuilder.append(home.getX()).append(".5";
|
||||
stringBuilder.append(home.getX()).append(".5");
|
||||
break;
|
||||
case 'y':
|
||||
stringBuilder.append((int) home.getY());
|
||||
|
||||
Reference in new issue
Block a user