From b7d8562eceb3653011c57eff63c881219273b285 Mon Sep 17 00:00:00 2001 From: sk89q Date: Fri, 22 Aug 2014 20:43:03 -0700 Subject: [PATCH] Use a region deny message indicating region data load failure. --- .../sk89q/worldguard/protection/FailedLoadRegionSet.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/sk89q/worldguard/protection/FailedLoadRegionSet.java b/src/main/java/com/sk89q/worldguard/protection/FailedLoadRegionSet.java index 1437b203..402377e7 100644 --- a/src/main/java/com/sk89q/worldguard/protection/FailedLoadRegionSet.java +++ b/src/main/java/com/sk89q/worldguard/protection/FailedLoadRegionSet.java @@ -28,6 +28,7 @@ import com.sk89q.worldguard.protection.flags.StateFlag; import com.sk89q.worldguard.protection.flags.StateFlag.State; import com.sk89q.worldguard.protection.regions.ProtectedRegion; +import org.bukkit.ChatColor; import javax.annotation.Nullable; import java.util.Collection; @@ -43,6 +44,10 @@ public class FailedLoadRegionSet extends AbstractRegionSet { private static final FailedLoadRegionSet INSTANCE = new FailedLoadRegionSet(); + private final String denyMessage = ChatColor.RED + "Region data for WorldGuard failed to load for this world, so " + + "everything has been protected as a precaution. Please inform a server administrator."; + private final Collection denyMessageCollection = ImmutableList.of(denyMessage); + private FailedLoadRegionSet() { } @@ -62,6 +67,8 @@ public boolean testBuild(RegionAssociable subject, StateFlag... flags) { public V queryValue(@Nullable RegionAssociable subject, Flag flag) { if (flag == DefaultFlag.BUILD) { return (V) State.DENY; + } else if (flag == DefaultFlag.DENY_MESSAGE) { + return (V) denyMessage; } return flag.getDefault(); } @@ -71,6 +78,8 @@ public V queryValue(@Nullable RegionAssociable subject, Flag flag) { public Collection queryAllValues(@Nullable RegionAssociable subject, Flag flag) { if (flag == DefaultFlag.BUILD) { return (Collection) ImmutableList.of(State.DENY); + } else if (flag == DefaultFlag.DENY_MESSAGE) { + return (Collection) denyMessageCollection; } V fallback = flag.getDefault(); return fallback != null ? ImmutableList.of(fallback) : (Collection) ImmutableList.of();