mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI.git
synced 2024-12-29 04:18:02 +01:00
Sort expansions alphabetically without errors Fixes #102
This commit is contained in:
parent
8447395c7b
commit
b2a488c694
@ -23,9 +23,11 @@ package me.clip.placeholderapi.commands;
|
|||||||
import static me.clip.placeholderapi.util.Msg.color;
|
import static me.clip.placeholderapi.util.Msg.color;
|
||||||
import static me.clip.placeholderapi.util.Msg.msg;
|
import static me.clip.placeholderapi.util.Msg.msg;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
@ -319,15 +321,25 @@ public class ExpansionCloudCommands implements CommandExecutor {
|
|||||||
msg(s, "&6Gold = Expansions which need updated");
|
msg(s, "&6Gold = Expansions which need updated");
|
||||||
|
|
||||||
if (!(s instanceof Player)) {
|
if (!(s instanceof Player)) {
|
||||||
|
Map<String, CloudExpansion> expansions = new HashMap<>();
|
||||||
for (Entry<Integer, CloudExpansion> expansion : ex.entrySet().stream().sorted().collect(Collectors.toList())) {
|
for (CloudExpansion exp : ex.values()) {
|
||||||
if (expansion == null || expansion.getValue() == null) {
|
if (exp == null || exp.getName() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
expansions.put(exp.getName(), exp);
|
||||||
|
}
|
||||||
|
List<String> ce = expansions.keySet().stream().sorted().collect(Collectors.toList());
|
||||||
|
int i = 1;
|
||||||
|
for (String name : ce) {
|
||||||
|
if (expansions.get(name) == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
CloudExpansion expansion = expansions.get(name);
|
||||||
msg(s,
|
msg(s,
|
||||||
"&b" + (expansion.getKey() + 1) + "&7: " + (expansion.getValue().shouldUpdate() ? "&6"
|
"&b" + i + "&7: " + (expansion.shouldUpdate() ? "&6"
|
||||||
: (expansion.getValue().hasExpansion() ? "&a" : "&7")) + expansion.getValue()
|
: (expansion.hasExpansion() ? "&a" : "&7")) + expansion
|
||||||
.getName() + " &8&m-- &r" + expansion.getValue().getVersion().getUrl());
|
.getName() + " &8&m-- &r" + expansion.getVersion().getUrl());
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -335,45 +347,52 @@ public class ExpansionCloudCommands implements CommandExecutor {
|
|||||||
|
|
||||||
Player p = (Player) s;
|
Player p = (Player) s;
|
||||||
|
|
||||||
for (Entry<Integer, CloudExpansion> expansion : ex.entrySet()) {
|
Map<String, CloudExpansion> expansions = new HashMap<>();
|
||||||
|
for (CloudExpansion exp : ex.values()) {
|
||||||
if (expansion == null || expansion.getValue() == null) {
|
if (exp == null || exp.getName() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
expansions.put(exp.getName(), exp);
|
||||||
|
}
|
||||||
|
List<String> ce = expansions.keySet().stream().sorted().collect(Collectors.toList());
|
||||||
|
int i = 1;
|
||||||
|
for (String name : ce) {
|
||||||
|
if (expansions.get(name) == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
CloudExpansion expansion = expansions.get(name);
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
if (expansion.getValue().shouldUpdate()) {
|
if (expansion.shouldUpdate()) {
|
||||||
sb.append("&6Click to update to the latest version of this expansion\n\n");
|
sb.append("&6Click to update to the latest version of this expansion\n\n");
|
||||||
} else if (!expansion.getValue().hasExpansion()) {
|
} else if (!expansion.hasExpansion()) {
|
||||||
sb.append("&bClick to download this expansion\n\n");
|
sb.append("&bClick to download this expansion\n\n");
|
||||||
} else {
|
} else {
|
||||||
sb.append("&aYou have the latest version of this expansion\n\n");
|
sb.append("&aYou have the latest version of this expansion\n\n");
|
||||||
}
|
}
|
||||||
sb.append("&bAuthor&7: &f" + expansion.getValue().getAuthor() + "\n");
|
sb.append("&bAuthor&7: &f" + expansion.getAuthor() + "\n");
|
||||||
sb.append("&bVerified&7: &f" + expansion.getValue().isVerified() + "\n");
|
sb.append("&bVerified&7: &f" + expansion.isVerified() + "\n");
|
||||||
sb.append("&bLatest version&7: &f" + expansion.getValue().getVersion().getVersion() + "\n");
|
sb.append("&bLatest version&7: &f" + expansion.getVersion().getVersion() + "\n");
|
||||||
sb.append(
|
sb.append(
|
||||||
"&bLast updated&7: &f" + expansion.getValue().getTimeSinceLastUpdate() + " ago\n");
|
"&bLast updated&7: &f" + expansion.getTimeSinceLastUpdate() + " ago\n");
|
||||||
sb.append("\n" + expansion.getValue().getDescription());
|
sb.append("\n" + expansion.getDescription());
|
||||||
|
|
||||||
String msg = color(
|
String msg = color(
|
||||||
"&b" + (expansion.getKey() + 1) + "&7: " + (expansion.getValue().shouldUpdate() ? "&6"
|
"&b" + (i + 1) + "&7: " + (expansion.shouldUpdate() ? "&6"
|
||||||
: (expansion.getValue().hasExpansion() ? "&a" : "")) + expansion.getValue()
|
: (expansion.hasExpansion() ? "&a" : "")) + expansion.getName());
|
||||||
.getName());
|
|
||||||
|
|
||||||
String hover = color(sb.toString());
|
String hover = color(sb.toString());
|
||||||
|
|
||||||
JSONMessage line = JSONMessage.create(msg);
|
JSONMessage line = JSONMessage.create(msg);
|
||||||
line.tooltip(hover);
|
line.tooltip(hover);
|
||||||
if (expansion.getValue().shouldUpdate()) {
|
if (expansion.shouldUpdate()) {
|
||||||
line.suggestCommand("/papi ecloud download " + expansion.getValue().getName());
|
line.suggestCommand("/papi ecloud download " + expansion.getName());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
line.suggestCommand("/papi ecloud info " + expansion.getValue().getName());
|
line.suggestCommand("/papi ecloud info " + expansion.getName());
|
||||||
}
|
}
|
||||||
line.send(p);
|
line.send(p);
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user