From d6469e2429539177c1aa2f3814eef64f65814fe2 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Sat, 26 Jul 2025 13:09:42 +0100 Subject: [PATCH] feat: add placeholder for multiple owners - closes #4695 --- .../util/placeholders/PlaceholderRegistry.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 6892d6787..b6a3fbd93 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 @@ -49,10 +49,12 @@ import java.util.Collection; import java.util.Collections; import java.util.Locale; import java.util.Map; +import java.util.Set; import java.util.TimeZone; import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.function.BiFunction; +import java.util.stream.Collectors; /** * Registry that contains {@link Placeholder placeholders} @@ -127,6 +129,22 @@ public final class PlaceholderRegistry { } return legacyComponent(TranslatableCaption.of("info.unknown"), player); }); + this.createPlaceholder("currentplot_owners", (player, plot) -> { + if (plot.getFlag(ServerPlotFlag.class)) { + return legacyComponent(TranslatableCaption.of("info.server"), player); + } + final Set plotOwners = plot.getOwners(); + if (plotOwners.isEmpty()) { + return legacyComponent(TranslatableCaption.of("generic.generic_unowned"), player); + } + return plotOwners.stream().map(PlotSquared.platform().playerManager()::getUsernameCaption).map(f -> { + try { + return f.get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS).getComponent(player); + } catch (final Exception ignored) { + return legacyComponent(TranslatableCaption.of("info.unknown"), player); + } + }).collect(Collectors.joining(", ")); + }); this.createPlaceholder("currentplot_members", (player, plot) -> { if (plot.getMembers().isEmpty() && plot.getTrusted().isEmpty()) { return legacyComponent(TranslatableCaption.of("info.none"), player);