Fix: add missing placeholders for plot info

Fixes #3339
This commit is contained in:
dordsor21 2021-12-30 14:41:31 +00:00
parent a77a51b6f2
commit eb334b3aac
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
2 changed files with 15 additions and 2 deletions

View File

@ -57,7 +57,8 @@ public class Info extends SubCommand {
if (args.length > 0) {
arg = args[0];
switch (arg) {
case "trusted", "alias", "inv", "biome", "denied", "flags", "id", "size", "members", "creationdate", "seen", "owner", "rating", "likes" -> plot = Plot
// TODO: (re?)implement /plot info inv. (it was never properly implemented)
case "trusted", "alias", "biome", "denied", "flags", "id", "size", "members", "creationdate", "seen", "owner", "rating", "likes" -> plot = Plot
.getPlotFromString(player, null, false);
default -> {
plot = Plot.getPlotFromString(player, arg, false);

View File

@ -2928,14 +2928,21 @@ public class Plot {
Template flagsTemplate = Template.of("flags", flags);
Template creationTemplate = Template.of("creationdate", newDate);
Template buildTemplate = Template.of("build", String.valueOf(build));
if (iInfo.getComponent(player).contains("<rating>")) {
Template sizeTemplate = Template.of("size", String.valueOf(getConnectedPlots().size()));
String component = iInfo.getComponent(player);
if (component.contains("<rating>") || component.contains("<likes>")) {
TaskManager.runTaskAsync(() -> {
Template ratingTemplate;
Template likesTemplate;
if (Settings.Ratings.USE_LIKES) {
ratingTemplate = Template.of(
"rating",
String.format("%.0f%%", Like.getLikesPercentage(this) * 100D)
);
likesTemplate = Template.of(
"likes",
String.format("%.0f%%", Like.getLikesPercentage(this) * 100D)
);
} else {
int max = 10;
if (Settings.Ratings.CATEGORIES != null && !Settings.Ratings.CATEGORIES.isEmpty()) {
@ -2962,6 +2969,7 @@ public class Plot {
);
}
}
likesTemplate = Template.of("likes", "N/A");
}
future.complete(StaticCaption.of(MINI_MESSAGE.serialize(MINI_MESSAGE
.parse(
@ -2984,6 +2992,8 @@ public class Plot {
buildTemplate,
ratingTemplate,
creationTemplate,
sizeTemplate,
likesTemplate,
footerTemplate
))));
});
@ -3008,6 +3018,8 @@ public class Plot {
seenTemplate,
flagsTemplate,
buildTemplate,
creationTemplate,
sizeTemplate,
footerTemplate
))));
}