|
49 | 49 | import java.util.Collections; |
50 | 50 | import java.util.Locale; |
51 | 51 | import java.util.Map; |
| 52 | +import java.util.Set; |
52 | 53 | import java.util.TimeZone; |
53 | 54 | import java.util.UUID; |
54 | 55 | import java.util.concurrent.TimeUnit; |
55 | 56 | import java.util.function.BiFunction; |
| 57 | +import java.util.stream.Collectors; |
56 | 58 |
|
57 | 59 | /** |
58 | 60 | * Registry that contains {@link Placeholder placeholders} |
@@ -127,6 +129,22 @@ private void registerDefault() { |
127 | 129 | } |
128 | 130 | return legacyComponent(TranslatableCaption.of("info.unknown"), player); |
129 | 131 | }); |
| 132 | + this.createPlaceholder("currentplot_owners", (player, plot) -> { |
| 133 | + if (plot.getFlag(ServerPlotFlag.class)) { |
| 134 | + return legacyComponent(TranslatableCaption.of("info.server"), player); |
| 135 | + } |
| 136 | + final Set<UUID> plotOwners = plot.getOwners(); |
| 137 | + if (plotOwners.isEmpty()) { |
| 138 | + return legacyComponent(TranslatableCaption.of("generic.generic_unowned"), player); |
| 139 | + } |
| 140 | + return plotOwners.stream().map(PlotSquared.platform().playerManager()::getUsernameCaption).map(f -> { |
| 141 | + try { |
| 142 | + return f.get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS).getComponent(player); |
| 143 | + } catch (final Exception ignored) { |
| 144 | + return legacyComponent(TranslatableCaption.of("info.unknown"), player); |
| 145 | + } |
| 146 | + }).collect(Collectors.joining(", ")); |
| 147 | + }); |
130 | 148 | this.createPlaceholder("currentplot_members", (player, plot) -> { |
131 | 149 | if (plot.getMembers().isEmpty() && plot.getTrusted().isEmpty()) { |
132 | 150 | return legacyComponent(TranslatableCaption.of("info.none"), player); |
|
0 commit comments