mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-24 14:16:44 +01:00
Introduce base plot count placeholder (#4328)
* Introduce base plot count placeholder * add world-specific variant
This commit is contained in:
parent
b369683b9c
commit
a2e3274215
@ -20,6 +20,8 @@ package com.plotsquared.bukkit.placeholder;
|
|||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
|
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
||||||
|
import com.plotsquared.core.util.query.PlotQuery;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -83,6 +85,20 @@ public class PAPIPlaceholders extends PlaceholderExpansion {
|
|||||||
return String.valueOf(pl.getPlotCount(identifier));
|
return String.valueOf(pl.getPlotCount(identifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (identifier.startsWith("base_plot_count_")) {
|
||||||
|
identifier = identifier.substring("base_plot_count_".length());
|
||||||
|
if (identifier.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return String.valueOf(PlotQuery.newQuery()
|
||||||
|
.ownedBy(pl)
|
||||||
|
.inWorld(identifier)
|
||||||
|
.whereBasePlot()
|
||||||
|
.thatPasses(plot -> !DoneFlag.isDone(plot))
|
||||||
|
.count());
|
||||||
|
}
|
||||||
|
|
||||||
// PlotSquared placeholders
|
// PlotSquared placeholders
|
||||||
return PlotSquared.platform().placeholderRegistry().getPlaceholderValue(identifier, pl);
|
return PlotSquared.platform().placeholderRegistry().getPlaceholderValue(identifier, pl);
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,11 @@ import com.plotsquared.core.player.PlotPlayer;
|
|||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
|
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
|
||||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||||
|
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
||||||
import com.plotsquared.core.plot.flag.implementations.ServerPlotFlag;
|
import com.plotsquared.core.plot.flag.implementations.ServerPlotFlag;
|
||||||
import com.plotsquared.core.util.EventDispatcher;
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.PlayerManager;
|
import com.plotsquared.core.util.PlayerManager;
|
||||||
|
import com.plotsquared.core.util.query.PlotQuery;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
@ -95,6 +97,12 @@ public final class PlaceholderRegistry {
|
|||||||
}
|
}
|
||||||
return Integer.toString(player.getAllowedPlots());
|
return Integer.toString(player.getAllowedPlots());
|
||||||
});
|
});
|
||||||
|
this.createPlaceholder("base_plot_count", player -> Integer.toString(PlotQuery.newQuery()
|
||||||
|
.ownedBy(player)
|
||||||
|
.whereBasePlot()
|
||||||
|
.thatPasses(plot -> !DoneFlag.isDone(plot))
|
||||||
|
.count())
|
||||||
|
);
|
||||||
this.createPlaceholder("plot_count", player -> Integer.toString(player.getPlotCount()));
|
this.createPlaceholder("plot_count", player -> Integer.toString(player.getPlotCount()));
|
||||||
this.createPlaceholder("currentplot_alias", (player, plot) -> {
|
this.createPlaceholder("currentplot_alias", (player, plot) -> {
|
||||||
if (plot.getAlias().isEmpty()) {
|
if (plot.getAlias().isEmpty()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user