Class StateFlag
java.lang.Object
com.sk89q.worldguard.protection.flags.Flag<StateFlag.State>
com.sk89q.worldguard.protection.flags.StateFlag
Stores a bi-state value.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StateFlag.StateallowOrNone(boolean flag)Turn a boolean into eitherNONE(null) orALLOWif the boolean is false or true, respectively.chooseValue(Collection<StateFlag.State> values)Given a list of values, choose the best one.static StateFlag.Statecombine(StateFlag.State... states)Combine states, lettingDENYoverrideALLOWandALLOWoverrideNONE(or null).static StateFlag.Statecombine(Collection<StateFlag.State> states)Combine states, lettingDENYoverrideALLOWandALLOWoverrideNONE(or null).static StateFlag.StatedenyToNone(StateFlag.State state)TurnDENYintoNONE(null).Get the default value.booleanWhether the flag can take a list of values and choose a "best one."Convert the value stored for this flag into a type that can be serialized into YAML.parseInput(FlagContext context)Parse a given input to coerce it to a type compatible with the flag.booleanWhether setting this flag toStateFlag.State.ALLOWis prevented on the global region.static booleantest(StateFlag.State... states)Test whether at least one of the given states isALLOWbut none are set toDENY.Convert a raw type that was loaded (from a YAML file, for example) into the type that this flag uses.Methods inherited from class com.sk89q.worldguard.protection.flags.Flag
getName, getRegionGroupFlag, implicitlySetWithMembership, isValidName, requiresSubject, toString, usesMembershipAsDefault
-
Constructor Details
-
StateFlag
-
StateFlag
-
-
Method Details
-
getDefault
Description copied from class:FlagGet the default value.- Overrides:
getDefaultin classFlag<StateFlag.State>- Returns:
- The default value, if one exists, otherwise
nullmay be returned
-
hasConflictStrategy
public boolean hasConflictStrategy()Description copied from class:FlagWhether the flag can take a list of values and choose a "best one."This is the case with the
StateFlagwhereDENYoverridesALLOW, but most flags just return the first result from a list.This flag is primarily used to optimize flag lookup in
FlagValueCalculator.- Overrides:
hasConflictStrategyin classFlag<StateFlag.State>- Returns:
- Whether a best value can be chosen
-
chooseValue
Description copied from class:FlagGiven a list of values, choose the best one.If there is no "best value" defined, then the first value should be returned. The default implementation returns the first value. If an implementation does have a strategy defined, then
Flag.hasConflictStrategy()should be overridden too.- Overrides:
chooseValuein classFlag<StateFlag.State>- Parameters:
values- A collection of values- Returns:
- The chosen value
-
preventsAllowOnGlobal
public boolean preventsAllowOnGlobal()Whether setting this flag toStateFlag.State.ALLOWis prevented on the global region.This value is only changed, at least in WorldGuard, for the
Flags.BUILDflag.- Returns:
- Whether
ALLOWis prevented
-
parseInput
Description copied from class:FlagParse a given input to coerce it to a type compatible with the flag.- Specified by:
parseInputin classFlag<StateFlag.State>- Parameters:
context- theFlagContext- Returns:
- The coerced type
- Throws:
InvalidFlagFormat- Raised if the input is invalid
-
unmarshal
Description copied from class:FlagConvert a raw type that was loaded (from a YAML file, for example) into the type that this flag uses.- Specified by:
unmarshalin classFlag<StateFlag.State>- Parameters:
o- The object- Returns:
- The unmarshalled type
-
marshal
Description copied from class:FlagConvert the value stored for this flag into a type that can be serialized into YAML.- Specified by:
marshalin classFlag<StateFlag.State>- Parameters:
o- The object- Returns:
- The marshalled type
-
test
Test whether at least one of the given states isALLOWbut none are set toDENY.- Parameters:
states- zero or more states- Returns:
- true if the condition is matched
-
combine
Combine states, lettingDENYoverrideALLOWandALLOWoverrideNONE(or null).- Parameters:
states- zero or more states- Returns:
- the new state
-
combine
Combine states, lettingDENYoverrideALLOWandALLOWoverrideNONE(or null).- Parameters:
states- zero or more states- Returns:
- the new state
-
allowOrNone
Turn a boolean into eitherNONE(null) orALLOWif the boolean is false or true, respectively.- Parameters:
flag- a boolean value- Returns:
- a state
-
denyToNone
TurnDENYintoNONE(null).- Parameters:
state- a state- Returns:
- a state
-