mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-27 21:15:57 +01:00
Document flag classes and make BUILD slightly less magic.
This commit is contained in:
parent
3bd1c869f1
commit
d883c22d64
@ -270,8 +270,8 @@ private <V> Collection<V> queryAllValues(@Nullable RegionAssociable subject, Fla
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check to see whether we have a subject if this is BUILD
|
// Check to see whether we have a subject if this is BUILD
|
||||||
if (flag == DefaultFlag.BUILD && subject == null) {
|
if (flag.requiresSubject() && subject == null) {
|
||||||
throw new NullPointerException("The BUILD flag is handled in a special fashion and requires a non-null subject parameter");
|
throw new NullPointerException("The " + flag.getName() + " flag is handled in a special fashion and requires a non-null subject parameter");
|
||||||
}
|
}
|
||||||
|
|
||||||
int minimumPriority = Integer.MIN_VALUE;
|
int minimumPriority = Integer.MIN_VALUE;
|
||||||
@ -303,16 +303,15 @@ private <V> Collection<V> queryAllValues(@Nullable RegionAssociable subject, Fla
|
|||||||
|
|
||||||
addParents(ignoredParents, region);
|
addParents(ignoredParents, region);
|
||||||
|
|
||||||
// The BUILD flag (of lower priorities) can be overridden if
|
// The BUILD flag is implicitly set on every region where
|
||||||
// this region has members... this check is here due to legacy
|
// PASSTHROUGH is not set to ALLOW
|
||||||
// reasons
|
if (priority != minimumPriority && flag.implicitlySetWithMembership()
|
||||||
if (priority != minimumPriority && flag == DefaultFlag.BUILD
|
|
||||||
&& getEffectiveFlag(region, DefaultFlag.PASSTHROUGH, subject) != State.ALLOW) {
|
&& getEffectiveFlag(region, DefaultFlag.PASSTHROUGH, subject) != State.ALLOW) {
|
||||||
minimumPriority = getPriority(region);
|
minimumPriority = getPriority(region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag == DefaultFlag.BUILD && consideredValues.isEmpty()) {
|
if (flag.usesMembershipAsDefault() && consideredValues.isEmpty()) {
|
||||||
switch (getMembership(subject)) {
|
switch (getMembership(subject)) {
|
||||||
case FAIL:
|
case FAIL:
|
||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
@ -365,10 +364,10 @@ public <V> V getEffectiveFlag(final ProtectedRegion region, Flag<V> flag, @Nulla
|
|||||||
return (V) State.ALLOW;
|
return (V) State.ALLOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (flag == DefaultFlag.BUILD) {
|
} else if (flag instanceof StateFlag && ((StateFlag) flag).preventsAllowOnGlobal()) {
|
||||||
// Legacy behavior -> we can't let people change BUILD on
|
// Legacy behavior -> we can't let people change BUILD on
|
||||||
// the global region
|
// the global region
|
||||||
State value = region.getFlag(DefaultFlag.BUILD);
|
State value = region.getFlag((StateFlag) flag);
|
||||||
return value != State.ALLOW ? (V) value : null;
|
return value != State.ALLOW ? (V) value : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,7 @@
|
|||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* A boolean flag.
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class BooleanFlag extends Flag<Boolean> {
|
public class BooleanFlag extends Flag<Boolean> {
|
||||||
|
|
||||||
@ -38,8 +37,7 @@ public BooleanFlag(String name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean parseInput(WorldGuardPlugin plugin, CommandSender sender,
|
public Boolean parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat {
|
||||||
String input) throws InvalidFlagFormat {
|
|
||||||
input = input.trim();
|
input = input.trim();
|
||||||
|
|
||||||
if (input.equalsIgnoreCase("true") || input.equalsIgnoreCase("yes")
|
if (input.equalsIgnoreCase("true") || input.equalsIgnoreCase("yes")
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* WorldGuard, a suite of tools for Minecraft
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldGuard team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sk89q.worldguard.protection.flags;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A special implementation of the {@link StateFlag} for
|
||||||
|
* {@link DefaultFlag#BUILD}.
|
||||||
|
*/
|
||||||
|
class BuildFlag extends StateFlag {
|
||||||
|
|
||||||
|
public BuildFlag(String name, boolean def) {
|
||||||
|
super(name, def);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean implicitlySetWithMembership() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean usesMembershipAsDefault() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean preventsAllowOnGlobal() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresSubject() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -24,8 +24,7 @@
|
|||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Stores a command/
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class CommandStringFlag extends Flag<String> {
|
public class CommandStringFlag extends Flag<String> {
|
||||||
|
|
||||||
@ -38,8 +37,7 @@ public CommandStringFlag(String name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String parseInput(WorldGuardPlugin plugin, CommandSender sender,
|
public String parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat {
|
||||||
String input) throws InvalidFlagFormat {
|
|
||||||
input = input.trim();
|
input = input.trim();
|
||||||
if (!input.startsWith("/")) {
|
if (!input.startsWith("/")) {
|
||||||
input = "/" + input;
|
input = "/" + input;
|
||||||
|
@ -39,7 +39,7 @@ public final class DefaultFlag {
|
|||||||
public static final RegionGroupFlag CONSTRUCT = new RegionGroupFlag("construct", RegionGroup.MEMBERS);
|
public static final RegionGroupFlag CONSTRUCT = new RegionGroupFlag("construct", RegionGroup.MEMBERS);
|
||||||
|
|
||||||
// This flag is unlike the others. It forces the checking of region membership
|
// This flag is unlike the others. It forces the checking of region membership
|
||||||
public static final StateFlag BUILD = new StateFlag("build", true);
|
public static final StateFlag BUILD = new BuildFlag("build", true);
|
||||||
|
|
||||||
// These flags are used in tandem with the BUILD flag - if the player can
|
// These flags are used in tandem with the BUILD flag - if the player can
|
||||||
// build, then the following flags do not need to be checked (although they
|
// build, then the following flags do not need to be checked (although they
|
||||||
|
@ -24,8 +24,7 @@
|
|||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Stores doubles.
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class DoubleFlag extends Flag<Double> {
|
public class DoubleFlag extends Flag<Double> {
|
||||||
|
|
||||||
@ -38,8 +37,7 @@ public DoubleFlag(String name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Double parseInput(WorldGuardPlugin plugin, CommandSender sender,
|
public Double parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat {
|
||||||
String input) throws InvalidFlagFormat {
|
|
||||||
input = input.trim();
|
input = input.trim();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -22,9 +22,7 @@
|
|||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an entity type.
|
* Stores an entity type.
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class EntityTypeFlag extends EnumFlag<EntityType> {
|
public class EntityTypeFlag extends EnumFlag<EntityType> {
|
||||||
|
|
||||||
|
@ -24,8 +24,7 @@
|
|||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Stores an enum value.
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class EnumFlag<T extends Enum<T>> extends Flag<T> {
|
public class EnumFlag<T extends Enum<T>> extends Flag<T> {
|
||||||
|
|
||||||
@ -79,8 +78,7 @@ public T detectValue(String input) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T parseInput(WorldGuardPlugin plugin, CommandSender sender,
|
public T parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat {
|
||||||
String input) throws InvalidFlagFormat {
|
|
||||||
try {
|
try {
|
||||||
return findValue(input);
|
return findValue(input);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
@ -20,33 +20,45 @@
|
|||||||
package com.sk89q.worldguard.protection.flags;
|
package com.sk89q.worldguard.protection.flags;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
import com.sk89q.worldguard.protection.FlagValueCalculator;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* A flag carries extra data on a region.
|
||||||
* @author sk89q
|
|
||||||
* @param <T>
|
|
||||||
*/
|
*/
|
||||||
public abstract class Flag<T> {
|
public abstract class Flag<T> {
|
||||||
|
|
||||||
private String name;
|
private final String name;
|
||||||
private RegionGroupFlag regionGroup;
|
private final RegionGroupFlag regionGroup;
|
||||||
|
|
||||||
public Flag(String name, RegionGroup defaultGroup) {
|
/**
|
||||||
|
* Create a new flag.
|
||||||
|
*
|
||||||
|
* @param name The name of the flag
|
||||||
|
* @param defaultGroup The default group
|
||||||
|
*/
|
||||||
|
public Flag(String name, @Nullable RegionGroup defaultGroup) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.regionGroup = defaultGroup != null ? new RegionGroupFlag(name + "-group", defaultGroup) : null;
|
||||||
if (defaultGroup != null) {
|
|
||||||
this.regionGroup = new RegionGroupFlag(name + "-group", defaultGroup);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new flag with {@link RegionGroup#ALL} as the default group.
|
||||||
|
*
|
||||||
|
* @param name The name of the flag
|
||||||
|
*/
|
||||||
public Flag(String name) {
|
public Flag(String name) {
|
||||||
this(name, RegionGroup.ALL);
|
this(name, RegionGroup.ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of the flag.
|
||||||
|
*
|
||||||
|
* @return The name of the flag
|
||||||
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@ -54,26 +66,13 @@ public String getName() {
|
|||||||
/**
|
/**
|
||||||
* Get the default value.
|
* Get the default value.
|
||||||
*
|
*
|
||||||
* @return the default value, if one exists, otherwise {@code null} may be returned
|
* @return The default value, if one exists, otherwise {@code null} may be returned
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public T getDefault() {
|
public T getDefault() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether the flag can take a list of values and choose a "best one."
|
|
||||||
*
|
|
||||||
* <p>This is the case with the {@link StateFlag} where {@code DENY}
|
|
||||||
* overrides {@code ALLOW}, but most flags just return the
|
|
||||||
* first result from a list.</p>
|
|
||||||
*
|
|
||||||
* @return whether a best value can be chosen
|
|
||||||
*/
|
|
||||||
public boolean hasConflictStrategy() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public T chooseValue(Collection<T> values) {
|
public T chooseValue(Collection<T> values) {
|
||||||
if (!values.isEmpty()) {
|
if (!values.isEmpty()) {
|
||||||
@ -83,14 +82,100 @@ public T chooseValue(Collection<T> values) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the flag can take a list of values and choose a "best one."
|
||||||
|
*
|
||||||
|
* <p>This is the case with the {@link StateFlag} where {@code DENY}
|
||||||
|
* overrides {@code ALLOW}, but most flags just return the
|
||||||
|
* first result from a list.</p>
|
||||||
|
*
|
||||||
|
* <p>This flag is primarily used to optimize flag lookup in
|
||||||
|
* {@link FlagValueCalculator}.</p>
|
||||||
|
*
|
||||||
|
* @return Whether a best value can be chosen
|
||||||
|
*/
|
||||||
|
public boolean hasConflictStrategy() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the flag implicitly has a value set as long as
|
||||||
|
* {@link DefaultFlag#PASSTHROUGH} is not set.
|
||||||
|
*
|
||||||
|
* <p>This value is only changed, at least in WorldGuard, for the
|
||||||
|
* {@link DefaultFlag#BUILD} flag.</p>
|
||||||
|
*
|
||||||
|
* @return Whether the flag is ignored
|
||||||
|
*/
|
||||||
|
public boolean implicitlySetWithMembership() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether, if the flag is not set at all, the value should be derived
|
||||||
|
* from membership.
|
||||||
|
*
|
||||||
|
* <p>This value is only changed, at least in WorldGuard, for the
|
||||||
|
* {@link DefaultFlag#BUILD} flag.</p>
|
||||||
|
*
|
||||||
|
* @return Whether membership is used
|
||||||
|
*/
|
||||||
|
public boolean usesMembershipAsDefault() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the flag requires that a subject is specified in
|
||||||
|
* {@link FlagValueCalculator}.
|
||||||
|
*
|
||||||
|
* <p>This value is only changed, at least in WorldGuard, for the
|
||||||
|
* {@link DefaultFlag#BUILD} flag.</p>
|
||||||
|
*
|
||||||
|
* @return Whether a subject is required
|
||||||
|
*/
|
||||||
|
public boolean requiresSubject() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the region group flag.
|
||||||
|
*
|
||||||
|
* <p>Every group has a region group flag except for region group flags
|
||||||
|
* themselves.</p>
|
||||||
|
*
|
||||||
|
* @return The region group flag
|
||||||
|
*/
|
||||||
public RegionGroupFlag getRegionGroupFlag() {
|
public RegionGroupFlag getRegionGroupFlag() {
|
||||||
return regionGroup;
|
return regionGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a given input to coerce it to a type compatible with the flag.
|
||||||
|
*
|
||||||
|
* @param plugin The plugin
|
||||||
|
* @param sender The sender
|
||||||
|
* @param input THe input
|
||||||
|
* @return The coerced type
|
||||||
|
* @throws InvalidFlagFormat Raised if the input is invalid
|
||||||
|
*/
|
||||||
public abstract T parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat;
|
public abstract T parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a raw type that was loaded (from a YAML file, for example)
|
||||||
|
* into the type that this flag uses.
|
||||||
|
*
|
||||||
|
* @param o The object
|
||||||
|
* @return The unmarshalled type
|
||||||
|
*/
|
||||||
public abstract T unmarshal(@Nullable Object o);
|
public abstract T unmarshal(@Nullable Object o);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the value stored for this flag into a type that can be
|
||||||
|
* serialized into YAML.
|
||||||
|
*
|
||||||
|
* @param o The object
|
||||||
|
* @return The marshalled type
|
||||||
|
*/
|
||||||
public abstract Object marshal(T o);
|
public abstract Object marshal(T o);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -24,8 +24,7 @@
|
|||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Stores an integer.
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class IntegerFlag extends Flag<Integer> {
|
public class IntegerFlag extends Flag<Integer> {
|
||||||
|
|
||||||
@ -38,8 +37,7 @@ public IntegerFlag(String name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer parseInput(WorldGuardPlugin plugin, CommandSender sender,
|
public Integer parseInput(WorldGuardPlugin plugin, CommandSender sender,String input) throws InvalidFlagFormat {
|
||||||
String input) throws InvalidFlagFormat {
|
|
||||||
input = input.trim();
|
input = input.trim();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A location that stores the name of the world in case the world is unloaded.
|
||||||
|
*/
|
||||||
class LazyLocation extends Location {
|
class LazyLocation extends Location {
|
||||||
|
|
||||||
private final String worldName;
|
private final String worldName;
|
||||||
@ -66,6 +69,4 @@ public LazyLocation add(double x, double y, double z) {
|
|||||||
return this.setPosition(getPosition().add(x, y, z));
|
return this.setPosition(getPosition().add(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,7 @@
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Stores a region group.
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class RegionGroupFlag extends EnumFlag<RegionGroup> {
|
public class RegionGroupFlag extends EnumFlag<RegionGroup> {
|
||||||
|
|
||||||
|
@ -29,9 +29,7 @@
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a flag that consists of a set.
|
* Stores a set of types.
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class SetFlag<T> extends Flag<Set<T>> {
|
public class SetFlag<T> extends Flag<Set<T>> {
|
||||||
|
|
||||||
@ -57,8 +55,7 @@ public Flag<T> getType() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<T> parseInput(WorldGuardPlugin plugin, CommandSender sender,
|
public Set<T> parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat {
|
||||||
String input) throws InvalidFlagFormat {
|
|
||||||
Set<T> items = new HashSet<T>();
|
Set<T> items = new HashSet<T>();
|
||||||
|
|
||||||
for (String str : input.split(",")) {
|
for (String str : input.split(",")) {
|
||||||
|
@ -26,8 +26,7 @@
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Stores a bi-state value.
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class StateFlag extends Flag<StateFlag.State> {
|
public class StateFlag extends Flag<StateFlag.State> {
|
||||||
|
|
||||||
@ -68,9 +67,21 @@ public State chooseValue(Collection<State> values) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether setting this flag to {@link State#ALLOW} is prevented on
|
||||||
|
* the global region.
|
||||||
|
*
|
||||||
|
* <p>This value is only changed, at least in WorldGuard, for the
|
||||||
|
* {@link DefaultFlag#BUILD} flag.</p>
|
||||||
|
*
|
||||||
|
* @return Whether {@code ALLOW} is prevented
|
||||||
|
*/
|
||||||
|
public boolean preventsAllowOnGlobal() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public State parseInput(WorldGuardPlugin plugin, CommandSender sender,
|
public State parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat {
|
||||||
String input) throws InvalidFlagFormat {
|
|
||||||
input = input.trim();
|
input = input.trim();
|
||||||
|
|
||||||
if (input.equalsIgnoreCase("allow")) {
|
if (input.equalsIgnoreCase("allow")) {
|
||||||
|
@ -26,8 +26,7 @@
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Stores a string.
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class StringFlag extends Flag<String> {
|
public class StringFlag extends Flag<String> {
|
||||||
|
|
||||||
@ -60,8 +59,7 @@ public String getDefault() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String parseInput(WorldGuardPlugin plugin, CommandSender sender,
|
public String parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat {
|
||||||
String input) throws InvalidFlagFormat {
|
|
||||||
return input.replaceAll("(?!\\\\)\\\\n", "\n").replaceAll("\\\\\\\\n", "\\n");
|
return input.replaceAll("(?!\\\\)\\\\n", "\n").replaceAll("\\\\\\\\n", "\\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,19 +19,17 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.protection.flags;
|
package com.sk89q.worldguard.protection.flags;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.CommandException;
|
import com.sk89q.minecraft.util.commands.CommandException;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Stores a vector.
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class VectorFlag extends Flag<Vector> {
|
public class VectorFlag extends Flag<Vector> {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user