Add configurable announcement for current bypass status

This commit is contained in:
JOO200 2020-09-12 11:05:52 +02:00 committed by wizjany
parent ad000ab051
commit 136ec31f38
3 changed files with 13 additions and 2 deletions

View File

@ -281,6 +281,7 @@ public void loadConfiguration() {
claimOnlyInsideExistingRegions = getBoolean("regions.claim-only-inside-existing-regions", false);
boundedLocationFlags = getBoolean("regions.location-flags-only-inside-regions", false);
disableDefaultBypass = getBoolean("regions.disable-bypass-by-default", false);
announceBypassStatus = getBoolean("regions.announce-bypass-status", false);
maxRegionCountPerPlayer = getInt("regions.max-region-count-per-player.default", 7);
maxRegionCounts = new HashMap<>();

View File

@ -175,6 +175,7 @@ public abstract class WorldConfiguration {
public boolean breakDeniedHoppers;
public boolean useMaxPriorityAssociation;
public boolean disableDefaultBypass;
public boolean announceBypassStatus;
protected Map<String, Integer> maxRegionCounts;
/**

View File

@ -22,8 +22,11 @@
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.config.WorldConfiguration;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.flags.StateFlag.State;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
@ -103,8 +106,14 @@ public void initialize(LocalPlayer player) {
lastValid = location;
lastRegionSet = set.getRegions();
disableBypass = WorldGuard.getInstance().getPlatform().getGlobalStateManager()
.get(player.getWorld()).disableDefaultBypass;
WorldConfiguration cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(player.getWorld());
disableBypass = cfg.disableDefaultBypass;
if (cfg.announceBypassStatus && player.hasPermission("worldguard.region.toggle-bypass")) {
player.printInfo(TextComponent.of(
"You are " + (disableBypass ? "not" : "") + " bypassing region protection. " +
"You can toggle this with /rg bypass", TextColor.DARK_PURPLE));
}
for (Handler handler : handlers.values()) {
handler.initialize(player, location, set);