mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2024-11-26 03:26:48 +01:00
fixed ordering of methods
This commit is contained in:
parent
50cee40531
commit
89061e6437
@ -40,91 +40,6 @@ public final class CommandECloudExpansionList extends PlaceholderCommand
|
||||
super("list");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<CloudExpansion> getPage(@NotNull final List<CloudExpansion> expansions, final int page, final int pageSize)
|
||||
{
|
||||
if (expansions.isEmpty())
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
final int head = (page * pageSize);
|
||||
final int tail = Math.min(expansions.size(), head + pageSize);
|
||||
|
||||
if (expansions.size() < head)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return IntStream.range(head, tail).mapToObj(expansions::get).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Collection<CloudExpansion> getExpansions(@NotNull final String target, @NotNull final PlaceholderAPIPlugin plugin)
|
||||
{
|
||||
switch (target.toLowerCase())
|
||||
{
|
||||
case "all":
|
||||
return plugin.getCloudExpansionManager().getCloudExpansions().values();
|
||||
case "installed":
|
||||
return plugin.getCloudExpansionManager().getCloudExpansionsInstalled().values();
|
||||
default:
|
||||
return plugin.getCloudExpansionManager().getCloudExpansionsByAuthor(target).values();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static JSONMessage getMessage(@NotNull final List<CloudExpansion> expansions, final int page)
|
||||
{
|
||||
final SimpleDateFormat format = PlaceholderAPIPlugin.getDateFormat();
|
||||
|
||||
final StringBuilder tooltip = new StringBuilder();
|
||||
final JSONMessage message = JSONMessage.create();
|
||||
|
||||
int index = ((page - 1) * PAGE_SIZE) + 1;
|
||||
for (int i = 0; i < expansions.size(); i++)
|
||||
{
|
||||
final CloudExpansion expansion = expansions.get(i);
|
||||
tooltip.append("&bClick to download this expansion!")
|
||||
.append('\n')
|
||||
.append('\n')
|
||||
.append("&bAuthor: &f")
|
||||
.append(expansion.getAuthor())
|
||||
.append('\n')
|
||||
.append("&bVerified: ")
|
||||
.append(expansion.isVerified() ? "&a&l✔&r" : "&c&l❌&r")
|
||||
.append('\n')
|
||||
.append("&bLatest Version: &f")
|
||||
.append(expansion.getLatestVersion())
|
||||
.append('\n')
|
||||
.append("&bReleased: &f")
|
||||
.append(format.format(expansion.getLastUpdate()));
|
||||
|
||||
final String description = expansion.getDescription();
|
||||
if (description != null && !description.isEmpty())
|
||||
{
|
||||
tooltip.append('\n')
|
||||
.append('\n')
|
||||
.append("&f")
|
||||
.append(description.replace("\r", "").trim());
|
||||
}
|
||||
|
||||
message.then(Msg.color("&8" + (index++) + ".&r " + (expansion.shouldUpdate() ? "&6" : expansion.hasExpansion() ? "&a" : "&7") + expansion.getName()));
|
||||
|
||||
message.tooltip(Msg.color(tooltip.toString()));
|
||||
message.suggestCommand("/papi ecloud download " + expansion.getName());
|
||||
|
||||
if (i < expansions.size() - 1)
|
||||
{
|
||||
message.newline();
|
||||
}
|
||||
|
||||
tooltip.setLength(0);
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
||||
{
|
||||
@ -266,4 +181,90 @@ public final class CommandECloudExpansionList extends PlaceholderCommand
|
||||
suggestByParameter(IntStream.rangeClosed(1, (int) Math.ceil((double) getExpansions(params.get(0), plugin).size() / PAGE_SIZE)).mapToObj(Objects::toString), suggestions, params.get(1));
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
private static Collection<CloudExpansion> getExpansions(@NotNull final String target, @NotNull final PlaceholderAPIPlugin plugin)
|
||||
{
|
||||
switch (target.toLowerCase())
|
||||
{
|
||||
case "all":
|
||||
return plugin.getCloudExpansionManager().getCloudExpansions().values();
|
||||
case "installed":
|
||||
return plugin.getCloudExpansionManager().getCloudExpansionsInstalled().values();
|
||||
default:
|
||||
return plugin.getCloudExpansionManager().getCloudExpansionsByAuthor(target).values();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<CloudExpansion> getPage(@NotNull final List<CloudExpansion> expansions, final int page, final int pageSize)
|
||||
{
|
||||
if (expansions.isEmpty())
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
final int head = (page * pageSize);
|
||||
final int tail = Math.min(expansions.size(), head + pageSize);
|
||||
|
||||
if (expansions.size() < head)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return IntStream.range(head, tail).mapToObj(expansions::get).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static JSONMessage getMessage(@NotNull final List<CloudExpansion> expansions, final int page)
|
||||
{
|
||||
final SimpleDateFormat format = PlaceholderAPIPlugin.getDateFormat();
|
||||
|
||||
final StringBuilder tooltip = new StringBuilder();
|
||||
final JSONMessage message = JSONMessage.create();
|
||||
|
||||
int index = ((page - 1) * PAGE_SIZE) + 1;
|
||||
for (int i = 0; i < expansions.size(); i++)
|
||||
{
|
||||
final CloudExpansion expansion = expansions.get(i);
|
||||
tooltip.append("&bClick to download this expansion!")
|
||||
.append('\n')
|
||||
.append('\n')
|
||||
.append("&bAuthor: &f")
|
||||
.append(expansion.getAuthor())
|
||||
.append('\n')
|
||||
.append("&bVerified: ")
|
||||
.append(expansion.isVerified() ? "&a&l✔&r" : "&c&l❌&r")
|
||||
.append('\n')
|
||||
.append("&bLatest Version: &f")
|
||||
.append(expansion.getLatestVersion())
|
||||
.append('\n')
|
||||
.append("&bReleased: &f")
|
||||
.append(format.format(expansion.getLastUpdate()));
|
||||
|
||||
final String description = expansion.getDescription();
|
||||
if (description != null && !description.isEmpty())
|
||||
{
|
||||
tooltip.append('\n')
|
||||
.append('\n')
|
||||
.append("&f")
|
||||
.append(description.replace("\r", "").trim());
|
||||
}
|
||||
|
||||
message.then(Msg.color("&8" + (index++) + ".&r " + (expansion.shouldUpdate() ? "&6" : expansion.hasExpansion() ? "&a" : "&7") + expansion.getName()));
|
||||
|
||||
message.tooltip(Msg.color(tooltip.toString()));
|
||||
message.suggestCommand("/papi ecloud download " + expansion.getName());
|
||||
|
||||
if (i < expansions.size() - 1)
|
||||
{
|
||||
message.newline();
|
||||
}
|
||||
|
||||
tooltip.setLength(0);
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user