diff --git a/Core/src/main/java/com/plotsquared/core/command/ListCmd.java b/Core/src/main/java/com/plotsquared/core/command/ListCmd.java index 17e211331..f78bcfdcb 100644 --- a/Core/src/main/java/com/plotsquared/core/command/ListCmd.java +++ b/Core/src/main/java/com/plotsquared/core/command/ListCmd.java @@ -353,9 +353,9 @@ public class ListCmd extends SubCommand { color = TranslatableCaption.of("info.plot_list_default"); } Component trusted = MINI_MESSAGE.parse(TranslatableCaption.of("info.plot_info_trusted").getComponent(player), - Template.of("trusted", PlayerManager.getPlayerList(plot.getTrusted()))); + Template.of("trusted", PlayerManager.getPlayerList(plot.getTrusted(), player))); Component members = MINI_MESSAGE.parse(TranslatableCaption.of("info.plot_info_members").getComponent(player), - Template.of("members", PlayerManager.getPlayerList(plot.getMembers()))); + Template.of("members", PlayerManager.getPlayerList(plot.getMembers(), player))); Template command_tp = Template.of("command_tp", "/plot visit " + plot.getArea() + ";" + plot.getId()); Template command_info = Template.of("command_info", "/plot info " + plot.getArea() + ";" + plot.getId()); Template hover_info = diff --git a/Core/src/main/java/com/plotsquared/core/plot/Plot.java b/Core/src/main/java/com/plotsquared/core/plot/Plot.java index 40efa215f..6c28ef756 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/Plot.java +++ b/Core/src/main/java/com/plotsquared/core/plot/Plot.java @@ -1514,7 +1514,7 @@ public class Plot { /** * Gets the average rating of the plot. This is the value displayed in /plot info * - * @return average rating as double + * @return average rating as double, {@link Double#NaN} of no ratings exist */ public double getAverageRating() { Collection ratings = this.getRatings().values(); @@ -2669,9 +2669,9 @@ public class Plot { String alias = !this.getAlias().isEmpty() ? this.getAlias() : TranslatableCaption.of("info.none").getComponent(player); Location bot = this.getCorners()[0]; PlotSquared.platform().worldUtil().getBiome(Objects.requireNonNull(this.getWorldName()), bot.getX(), bot.getZ(), biome -> { - Component trusted = PlayerManager.getPlayerList(this.getTrusted()); - Component members = PlayerManager.getPlayerList(this.getMembers()); - Component denied = PlayerManager.getPlayerList(this.getDenied()); + Component trusted = PlayerManager.getPlayerList(this.getTrusted(), player); + Component members = PlayerManager.getPlayerList(this.getMembers(), player); + Component denied = PlayerManager.getPlayerList(this.getDenied(), player); String seen; if (Settings.Enabled_Components.PLOT_EXPIRY && ExpireManager.IMP != null) { if (this.isOnline()) { @@ -2723,7 +2723,7 @@ public class Plot { } else if (this.getOwner().equals(DBFunc.SERVER)) { owner = Component.text(MINI_MESSAGE.stripTokens(TranslatableCaption.of("info.server").getComponent(player))); } else { - owner = PlayerManager.getPlayerList(this.getOwners()); + owner = PlayerManager.getPlayerList(this.getOwners(), player); } Template headerTemplate = Template.of("header", TranslatableCaption.of("info.plot_info_header").getComponent(player)); Template footerTemplate = Template.of("footer", TranslatableCaption.of("info.plot_info_footer").getComponent(player)); @@ -2775,7 +2775,13 @@ public class Plot { } ratingTemplate = Template.of("rating", rating.toString()); } else { - ratingTemplate = Template.of("rating", String.format("%.1f", this.getAverageRating()) + '/' + max); + double rating = this.getAverageRating(); + if (Double.isFinite(rating)) { + ratingTemplate = Template.of("rating", String.format("%.1f", rating) + '/' + max); + } else { + ratingTemplate = Template.of("rating", + TranslatableCaption.of("info.none").getComponent(player)); + } } } future.complete(StaticCaption.of(MINI_MESSAGE.serialize(MINI_MESSAGE diff --git a/Core/src/main/java/com/plotsquared/core/util/PlayerManager.java b/Core/src/main/java/com/plotsquared/core/util/PlayerManager.java index bc8375cf4..a7bd57fe1 100644 --- a/Core/src/main/java/com/plotsquared/core/util/PlayerManager.java +++ b/Core/src/main/java/com/plotsquared/core/util/PlayerManager.java @@ -27,7 +27,7 @@ package com.plotsquared.core.util; import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.Settings; -import com.plotsquared.core.configuration.caption.Caption; +import com.plotsquared.core.configuration.caption.LocaleHolder; import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.player.ConsolePlayer; @@ -112,22 +112,23 @@ public abstract class PlayerManager

, T> { * - Uses the format {@link TranslatableCaption#of(String)} of "info.plot_user_list" for the returned string * * @param uuids UUIDs + * @param localeHolder the localeHolder to localize the component for * @return Component of name list */ - @Nonnull public static Component getPlayerList(@Nonnull final Collection uuids) { - if (uuids.size() < 1) { - TranslatableCaption.of("info.none"); + @Nonnull public static Component getPlayerList(@Nonnull final Collection uuids, LocaleHolder localeHolder) { + if (uuids.isEmpty()) { + return MINI_MESSAGE.parse(TranslatableCaption.of("info.none").getComponent(localeHolder)); } final List players = new LinkedList<>(); final List users = new LinkedList<>(); for (final UUID uuid : uuids) { if (uuid == null) { - users.add(MINI_MESSAGE.stripTokens(TranslatableCaption.of("info.none").getComponent(ConsolePlayer.getConsole()))); + users.add(MINI_MESSAGE.stripTokens(TranslatableCaption.of("info.none").getComponent(localeHolder))); } else if (DBFunc.EVERYONE.equals(uuid)) { - users.add(MINI_MESSAGE.stripTokens(TranslatableCaption.of("info.everyone").getComponent(ConsolePlayer.getConsole()))); + users.add(MINI_MESSAGE.stripTokens(TranslatableCaption.of("info.everyone").getComponent(localeHolder))); } else if (DBFunc.SERVER.equals(uuid)) { - users.add(MINI_MESSAGE.stripTokens(TranslatableCaption.of("info.console").getComponent(ConsolePlayer.getConsole()))); + users.add(MINI_MESSAGE.stripTokens(TranslatableCaption.of("info.console").getComponent(localeHolder))); } else { players.add(uuid); } diff --git a/Core/src/main/java/com/plotsquared/core/util/placeholders/PlaceholderRegistry.java b/Core/src/main/java/com/plotsquared/core/util/placeholders/PlaceholderRegistry.java index e362b7e3f..563e0cdc2 100644 --- a/Core/src/main/java/com/plotsquared/core/util/placeholders/PlaceholderRegistry.java +++ b/Core/src/main/java/com/plotsquared/core/util/placeholders/PlaceholderRegistry.java @@ -120,19 +120,19 @@ public final class PlaceholderRegistry { if (plot.getTrusted() == null) { return "0"; } - return String.valueOf(PlayerManager.getPlayerList(plot.getTrusted())); + return String.valueOf(PlayerManager.getPlayerList(plot.getTrusted(), player)); }); this.createPlaceholder("currentplot_members_added_list", (player, plot) -> { if (plot.getMembers() == null) { return "0"; } - return String.valueOf(PlayerManager.getPlayerList(plot.getMembers())); + return String.valueOf(PlayerManager.getPlayerList(plot.getMembers(), player)); }); this.createPlaceholder("currentplot_members_denied_list", (player, plot) -> { if (plot.getDenied() == null) { return "0"; } - return String.valueOf(PlayerManager.getPlayerList(plot.getDenied())); + return String.valueOf(PlayerManager.getPlayerList(plot.getDenied(), player)); }); this.createPlaceholder("currentplot_creationdate", (player, plot) -> { if (plot.getTimestamp() == 0) {