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) { if (args.length > 0) {
arg = args[0]; arg = args[0];
switch (arg) { 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); .getPlotFromString(player, null, false);
default -> { default -> {
plot = Plot.getPlotFromString(player, arg, false); plot = Plot.getPlotFromString(player, arg, false);

View File

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