Moved baltop calculation before the player null check as it is unnecessary
This commit is contained in:
1 parent
3944cf9552
commit
635c17cbbe
1 file changed
+85
-83
@@ -99,6 +99,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_")) {
|
||||
@@ -187,89 +272,6 @@ public class EssentialsExpansion extends PlaceholderExpansion {
|
||||
return oPlayer.hasPermission("essentials.kits." + kit) ? papiTrue : papiFalse;
|
||||
}
|
||||
|
||||
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 (identifier.startsWith("home_")) {
|
||||
Integer homeNumber;
|
||||
final User user = essentials.getUser(player.getUniqueId());
|
||||
|
||||
Reference in new issue
Block a user