Register a Custom Flag
Register a custom rule that Dominion can save and display, then implement its actual behavior in an addon.
Register an environment flag
public final class WeatherAddon extends JavaPlugin implements Listener {
private static final EnvFlag NO_RAIN = new EnvFlag(
"weather_addon_no_rain",
"No Rain",
"Whether rain is blocked in this dominion.",
false,
true,
Material.SUNFLOWER
);
@Override
public void onEnable() {
if (!Flags.registerEnvFlag(this, NO_RAIN)) {
getLogger().warning("Dominion rejected the custom flag.");
return;
}
EnvFlagGroup weather = new EnvFlagGroup(
"weather-addon",
"Weather Addon",
"Weather rules provided by this addon.",
Material.SUNFLOWER
);
weather.addFlag(NO_RAIN);
FlagGroups.registerEnvFlagGroup(this, weather);
Flags.applyChanges().thenRun(() ->
getLogger().info("NO_RAIN is ready."));
getServer().getPluginManager().registerEvents(this, this);
}
}
Implement flag behavior
Registering a flag only adds it to Dominion’s flag data, configuration, and UI systems. The addon still needs to read it in its own event listener and implement the behavior:
@EventHandler
public void onWeatherChange(WeatherChangeEvent event) {
if (!event.toWeather()) return;
for (Player player : event.getWorld().getPlayers()) {
DominionDTO dominion = DominionAPI.getInstance()
.getDominion(player.getLocation());
if (dominion == null) continue;
if (dominion.getEnvFlagValue(NO_RAIN)) {
event.setCancelled(true);
return;
}
}
}
This example only demonstrates how to read the data. Weather is a world-level event; a real project must define the priority when multiple claims are present instead of treating the first player’s result as the conclusion for the entire world.
Use a permission flag
The implementation of PriFlag is similar, but the check needs a player and a location:
if (!DominionAPI.getInstance().checkPrivilegeFlagSilence(
location,
USE_SPECIAL_TOOL,
player
)) {
return;
}
The addon must listen for and cancel the relevant Bukkit event for the actual action of a custom permission flag. Do not use only the MemberDTO flag Map as a substitute for the final permission check.