Class RegionResultSet
- All Implemented Interfaces:
ApplicableRegionSet,Iterable<ProtectedRegion>
-
Constructor Summary
ConstructorsConstructorDescriptionRegionResultSet(List<ProtectedRegion> applicable, ProtectedRegion globalRegion)Create a new region result set.RegionResultSet(List<ProtectedRegion> applicable, ProtectedRegion globalRegion, boolean sorted)Create a new region result set.RegionResultSet(Set<ProtectedRegion> applicable, ProtectedRegion globalRegion)Create a new region result set. -
Method Summary
Modifier and TypeMethodDescriptionstatic RegionResultSetfromSortedList(List<ProtectedRegion> regions, ProtectedRegion globalRegion)Create a new instance using a list of regions that is known to already be sorted by priority descending.Get an immutable set of regions that are included in this set.booleanisMemberOfAll(LocalPlayer player)Test whether a player is an owner or member of all regions in this set.booleanisOwnerOfAll(LocalPlayer player)Test whether a player is an owner of all regions in this set.booleanReturn whether this region set is a virtual set.iterator()<V> Collection<V>queryAllValues(RegionAssociable subject, Flag<V> flag)Get the effective values for a flag, returning a collection of all values.<V, K> VqueryMapValue(RegionAssociable subject, MapFlag<K,V> flag, K key)Get the effective value for a key in aMapFlag.<V, K> VqueryMapValue(RegionAssociable subject, MapFlag<K,V> flag, K key, Flag<V> fallback)Get the effective value for a key in aMapFlag.queryState(RegionAssociable subject, StateFlag... flags)Get the (effective) value for a list of state flags.<V> VqueryValue(RegionAssociable subject, Flag<V> flag)Get the effective value for a flag.intsize()Get the number of regions that are included.Methods inherited from class com.sk89q.worldguard.protection.AbstractRegionSet
testStateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
RegionResultSet
Create a new region result set.The given list must not contain duplicates or the behavior of this instance will be undefined.
- Parameters:
applicable- the regions contained in this setglobalRegion- the global region, set aside for special handling.
-
RegionResultSet
Create a new region result set.- Parameters:
applicable- the regions contained in this setglobalRegion- the global region, set aside for special handling.
-
RegionResultSet
public RegionResultSet(List<ProtectedRegion> applicable, @Nullable ProtectedRegion globalRegion, boolean sorted)Create a new region result set.The list of regions may be first sorted with
NormativeOrders. If that is the case,sortedshould betrue. Otherwise, the list will be sorted in-place.- Parameters:
applicable- the regions contained in this setglobalRegion- the global region, set aside for special handling.sorted- true if the list is already sorted withNormativeOrders
-
-
Method Details
-
isVirtual
public boolean isVirtual()Description copied from interface:ApplicableRegionSetReturn whether this region set is a virtual set. A virtual set does not contain real results.A virtual result may be returned if region data failed to load or there was some special exception (i.e. the region bypass permission).
Be sure to check the value of this flag if an instance of this interface is being retrieved from RegionQuery as it may return an instance of
PermissiveRegionSetorFailedLoadRegionSet, among other possibilities.- Returns:
- true if loaded
- See Also:
FailedLoadRegionSet
-
queryState
@Nullable public StateFlag.State queryState(@Nullable RegionAssociable subject, StateFlag... flags)Description copied from interface:ApplicableRegionSetGet the (effective) value for a list of state flags. The rules of states is observed here; that is,DENYoverridesALLOW, andALLOWoverridesNONE. One flag may override another.subjectcan be non-null to satisfy region group requirements, otherwise it will be assumed that the caller that is not a member of any regions. (Flags on a region can be changed so that they only apply to certain users.) The subject argument is required if theFlags.BUILDflag is in the list of flags.- Specified by:
queryStatein interfaceApplicableRegionSet- Overrides:
queryStatein classAbstractRegionSet- Parameters:
subject- an optional subject, which would be used to determine the region groups that applyflags- a list of flags to check- Returns:
- a state
-
queryValue
Description copied from interface:ApplicableRegionSetGet the effective value for a flag. If there are multiple values (for example, multiple overlapping regions with the same priority may have the same flag set), then the selected (or "winning") value will depend on the flag type.Only some flag types actually have a strategy for picking the "best value." For most types, the actual value that is chosen to be returned is undefined (it could be any value). As of writing, the only type of flag that actually has a strategy for picking a value is the
StateFlag.subjectcan be non-null to satisfy region group requirements, otherwise it will be assumed that the caller that is not a member of any regions. (Flags on a region can be changed so that they only apply to certain users.) The subject argument is required if theFlags.BUILDflag is the flag being queried.- Parameters:
subject- an optional subject, which would be used to determine the region group to applyflag- the flag- Returns:
- a value, which could be
null
-
queryAllValues
Description copied from interface:ApplicableRegionSetGet the effective values for a flag, returning a collection of all values. It is up to the caller to determine which value, if any, from the collection will be used.subjectcan be non-null to satisfy region group requirements, otherwise it will be assumed that the caller that is not a member of any regions. (Flags on a region can be changed so that they only apply to certain users.) The subject argument is required if theFlags.BUILDflag is the flag being queried.- Parameters:
subject- an optional subject, which would be used to determine the region group to applyflag- the flag- Returns:
- a collection of values
-
queryMapValue
@Nullable public <V, K> V queryMapValue(@Nullable RegionAssociable subject, MapFlag<K,V> flag, K key)Description copied from interface:ApplicableRegionSetGet the effective value for a key in aMapFlag. If there are multiple values (for example, if there are multiple regions with the same priority but with different farewell messages set, there would be multiple completing values), then the selected (or "winning") value will be undefined.A subject can be provided that is used to determine whether the value of a flag on a particular region should be used. For example, if a flag's region group is set to
RegionGroup.MEMBERSand the given subject is not a member, then the region would be skipped when querying that flag. Ifnullis provided for the subject, then only flags that useRegionGroup.ALL,RegionGroup.NON_MEMBERS, etc. will apply.- Parameters:
subject- an optional subject, which would be used to determine the region group to applyflag- the flag of typeMapFlagkey- the key for the map flag- Returns:
- a value, which could be
null
-
queryMapValue
@Nullable public <V, K> V queryMapValue(@Nullable RegionAssociable subject, MapFlag<K,V> flag, K key, Flag<V> fallback)Description copied from interface:ApplicableRegionSetGet the effective value for a key in aMapFlag. If there are multiple values (for example, if there are multiple regions with the same priority but with different farewell messages set, there would be multiple completing values), then the selected (or "winning") value will be undefined.A subject can be provided that is used to determine whether the value of a flag on a particular region should be used. For example, if a flag's region group is set to
RegionGroup.MEMBERSand the given subject is not a member, then the region would be skipped when querying that flag. Ifnullis provided for the subject, then only flags that useRegionGroup.ALL,RegionGroup.NON_MEMBERS, etc. will apply.- Parameters:
subject- an optional subject, which would be used to determine the region group to applyflag- the flag of typeMapFlagkey- the key for the map flag- Returns:
- a value, which could be
null
-
isOwnerOfAll
Description copied from interface:ApplicableRegionSetTest whether a player is an owner of all regions in this set.- Parameters:
player- the player- Returns:
- whether the player is an owner of all regions
-
isMemberOfAll
Description copied from interface:ApplicableRegionSetTest whether a player is an owner or member of all regions in this set.- Parameters:
player- the player- Returns:
- whether the player is a member of all regions
-
size
public int size()Description copied from interface:ApplicableRegionSetGet the number of regions that are included.- Returns:
- the number of contained regions
-
getRegions
Description copied from interface:ApplicableRegionSetGet an immutable set of regions that are included in this set.- Returns:
- a set of regions
-
iterator
-
fromSortedList
public static RegionResultSet fromSortedList(List<ProtectedRegion> regions, @Nullable ProtectedRegion globalRegion)Create a new instance using a list of regions that is known to already be sorted by priority descending.- Parameters:
regions- a list of regionsglobalRegion- a global region- Returns:
- an instance
-