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.State
allowOrNone
(boolean flag) Turn a boolean into eitherNONE
(null) orALLOW
if the boolean is false or true, respectively.chooseValue
(Collection<StateFlag.State> values) Given a list of values, choose the best one.static StateFlag.State
combine
(StateFlag.State... states) Combine states, lettingDENY
overrideALLOW
andALLOW
overrideNONE
(or null).static StateFlag.State
combine
(Collection<StateFlag.State> states) Combine states, lettingDENY
overrideALLOW
andALLOW
overrideNONE
(or null).static StateFlag.State
denyToNone
(StateFlag.State state) TurnDENY
intoNONE
(null).Get the default value.boolean
Whether 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.boolean
Whether setting this flag toStateFlag.State.ALLOW
is prevented on the global region.static boolean
test
(StateFlag.State... states) Test whether at least one of the given states isALLOW
but 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:Flag
Get the default value.- Overrides:
getDefault
in classFlag<StateFlag.State>
- Returns:
- The default value, if one exists, otherwise
null
may be returned
-
hasConflictStrategy
public boolean hasConflictStrategy()Description copied from class:Flag
Whether the flag can take a list of values and choose a "best one."This is the case with the
StateFlag
whereDENY
overridesALLOW
, but most flags just return the first result from a list.This flag is primarily used to optimize flag lookup in
FlagValueCalculator
.- Overrides:
hasConflictStrategy
in classFlag<StateFlag.State>
- Returns:
- Whether a best value can be chosen
-
chooseValue
Description copied from class:Flag
Given 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:
chooseValue
in classFlag<StateFlag.State>
- Parameters:
values
- A collection of values- Returns:
- The chosen value
-
preventsAllowOnGlobal
public boolean preventsAllowOnGlobal()Whether setting this flag toStateFlag.State.ALLOW
is prevented on the global region.This value is only changed, at least in WorldGuard, for the
Flags.BUILD
flag.- Returns:
- Whether
ALLOW
is prevented
-
parseInput
Description copied from class:Flag
Parse a given input to coerce it to a type compatible with the flag.- Specified by:
parseInput
in classFlag<StateFlag.State>
- Parameters:
context
- theFlagContext
- Returns:
- The coerced type
- Throws:
InvalidFlagFormat
- Raised if the input is invalid
-
unmarshal
Description copied from class:Flag
Convert a raw type that was loaded (from a YAML file, for example) into the type that this flag uses.- Specified by:
unmarshal
in classFlag<StateFlag.State>
- Parameters:
o
- The object- Returns:
- The unmarshalled type
-
marshal
Description copied from class:Flag
Convert the value stored for this flag into a type that can be serialized into YAML.- Specified by:
marshal
in classFlag<StateFlag.State>
- Parameters:
o
- The object- Returns:
- The marshalled type
-
test
Test whether at least one of the given states isALLOW
but none are set toDENY
.- Parameters:
states
- zero or more states- Returns:
- true if the condition is matched
-
combine
Combine states, lettingDENY
overrideALLOW
andALLOW
overrideNONE
(or null).- Parameters:
states
- zero or more states- Returns:
- the new state
-
combine
Combine states, lettingDENY
overrideALLOW
andALLOW
overrideNONE
(or null).- Parameters:
states
- zero or more states- Returns:
- the new state
-
allowOrNone
Turn a boolean into eitherNONE
(null) orALLOW
if the boolean is false or true, respectively.- Parameters:
flag
- a boolean value- Returns:
- a state
-
denyToNone
TurnDENY
intoNONE
(null).- Parameters:
state
- a state- Returns:
- a state
-