From ff83868cbc20f082362bfcb487b62c865a2926e9 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Sat, 30 Mar 2024 18:30:40 +0100 Subject: [PATCH] Add a placeholder for grants (#4380) * Add a placeholder for grants Signed-off-by: Alexander Brandes * Address feedback Signed-off-by: Alexander Brandes --------- Signed-off-by: Alexander Brandes --- .../core/util/placeholders/PlaceholderRegistry.java | 7 +++++++ 1 file changed, 7 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 d68e425aa..6892d6787 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 @@ -27,6 +27,8 @@ import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.caption.LocaleHolder; import com.plotsquared.core.configuration.caption.TranslatableCaption; +import com.plotsquared.core.player.MetaDataAccess; +import com.plotsquared.core.player.PlayerMetaDataKeys; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.flag.GlobalFlagContainer; @@ -197,6 +199,11 @@ public final class PlaceholderRegistry { }); this.createPlaceholder("currentplot_biome", (player, plot) -> plot.getBiomeSynchronous().toString()); this.createPlaceholder("currentplot_size", (player, plot) -> String.valueOf(plot.getConnectedPlots().size())); + this.createPlaceholder("total_grants", player -> { + try (final MetaDataAccess metaDataAccess = player.accessPersistentMetaData(PlayerMetaDataKeys.PERSISTENT_GRANTED_PLOTS)) { + return Integer.toString(metaDataAccess.get().orElse(0)); + } + }); } /**