mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-27 13:07:29 +01:00
Use a region deny message indicating region data load failure.
This commit is contained in:
parent
439826ddc6
commit
b7d8562ece
@ -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<String> denyMessageCollection = ImmutableList.of(denyMessage);
|
||||
|
||||
private FailedLoadRegionSet() {
|
||||
}
|
||||
|
||||
@ -62,6 +67,8 @@ public boolean testBuild(RegionAssociable subject, StateFlag... flags) {
|
||||
public <V> V queryValue(@Nullable RegionAssociable subject, Flag<V> 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> V queryValue(@Nullable RegionAssociable subject, Flag<V> flag) {
|
||||
public <V> Collection<V> queryAllValues(@Nullable RegionAssociable subject, Flag<V> flag) {
|
||||
if (flag == DefaultFlag.BUILD) {
|
||||
return (Collection<V>) ImmutableList.of(State.DENY);
|
||||
} else if (flag == DefaultFlag.DENY_MESSAGE) {
|
||||
return (Collection<V>) denyMessageCollection;
|
||||
}
|
||||
V fallback = flag.getDefault();
|
||||
return fallback != null ? ImmutableList.of(fallback) : (Collection<V>) ImmutableList.of();
|
||||
|
Loading…
Reference in New Issue
Block a user