public class RegionQuery
extends java.lang.Object
Results may be cached for brief amounts of time. If you want to get data for the purposes of changing it, use of this class is not recommended. Some of the return values of the methods may be simulated to reduce boilerplate code related to implementing protection, meaning that false data is returned.
| Constructor and Description |
|---|
RegionQuery(QueryCache cache)
Create a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
ApplicableRegionSet |
getApplicableRegions(com.sk89q.worldedit.util.Location location)
Query for regions containing the given location.
|
<V> java.util.Collection<V> |
queryAllValues(com.sk89q.worldedit.util.Location location,
LocalPlayer player,
Flag<V> flag)
Get the effective values for a flag, returning a collection of all
values.
|
<V> java.util.Collection<V> |
queryAllValues(com.sk89q.worldedit.util.Location location,
RegionAssociable associable,
Flag<V> flag)
Get the effective values for a flag, returning a collection of all
values.
|
StateFlag.State |
queryState(com.sk89q.worldedit.util.Location location,
LocalPlayer player,
StateFlag... flags)
Get the (effective) value for a list of state flags.
|
StateFlag.State |
queryState(com.sk89q.worldedit.util.Location location,
RegionAssociable associable,
StateFlag... flags)
Get the (effective) value for a list of state flags.
|
<V> V |
queryValue(com.sk89q.worldedit.util.Location location,
LocalPlayer player,
Flag<V> flag)
Get the effective value for a flag.
|
<V> V |
queryValue(com.sk89q.worldedit.util.Location location,
RegionAssociable associable,
Flag<V> flag)
Get the effective value for a flag.
|
boolean |
testBuild(com.sk89q.worldedit.util.Location location,
LocalPlayer player,
StateFlag... flag)
Returns true if the BUILD flag allows the action in the location, but it
can be overridden by a list of other flags.
|
boolean |
testBuild(com.sk89q.worldedit.util.Location location,
RegionAssociable associable,
StateFlag... flag)
Returns true if the BUILD flag allows the action in the location, but it
can be overridden by a list of other flags.
|
boolean |
testState(com.sk89q.worldedit.util.Location location,
LocalPlayer player,
StateFlag... flag)
Test whether the (effective) value for a list of state flags equals
ALLOW. |
boolean |
testState(com.sk89q.worldedit.util.Location location,
RegionAssociable associable,
StateFlag... flag)
Test whether the (effective) value for a list of state flags equals
ALLOW. |
public RegionQuery(QueryCache cache)
cache - the query cachepublic ApplicableRegionSet getApplicableRegions(com.sk89q.worldedit.util.Location location)
An instance of RegionResultSet will always be returned,
even if regions are disabled or region data failed to load. An
appropriate "virtual" set will be returned in such a case
(for example, if regions are disabled, the returned set
would permit all activities).
location - the locationpublic boolean testBuild(com.sk89q.worldedit.util.Location location,
LocalPlayer player,
StateFlag... flag)
Use this method when checking flags that are related to build protection. For example, lighting fire in a region should not be permitted unless the player is a member of the region or the LIGHTER flag allows it. However, the LIGHTER flag should be able to allow lighting fires even if BUILD is set to DENY.
How this method works (BUILD can be overridden by other flags but not the other way around) is inconsistent, but it's required for legacy reasons.
This method does not check the region bypass permission. That must be done by the calling code.
location - the locationplayer - an optional player, which would be used to determine the region group to applyflag - the flagALLOWRegionResultSet.queryValue(RegionAssociable, Flag)public boolean testBuild(com.sk89q.worldedit.util.Location location,
RegionAssociable associable,
StateFlag... flag)
Use this method when checking flags that are related to build protection. For example, lighting fire in a region should not be permitted unless the player is a member of the region or the LIGHTER flag allows it. However, the LIGHTER flag should be able to allow lighting fires even if BUILD is set to DENY.
How this method works (BUILD can be overridden by other flags but not the other way around) is inconsistent, but it's required for legacy reasons.
This method does not check the region bypass permission. That must be done by the calling code.
location - the locationassociable - an optional associableflag - the flagALLOWRegionResultSet.queryValue(RegionAssociable, Flag)public boolean testState(com.sk89q.worldedit.util.Location location,
@Nullable
LocalPlayer player,
StateFlag... flag)
ALLOW.
player can be non-null to satisfy region group requirements,
otherwise it will be assumed that the caller that is not a member of any
regions. (FlagUtil on a region can be changed so that they only apply
to certain users.) The player argument is required if the
Flags.BUILD flag is in the list of flags.
This method does not check the region bypass permission. That must be done by the calling code.
location - the locationplayer - an optional player, which would be used to determine the region group to applyflag - the flagALLOWRegionResultSet.queryValue(RegionAssociable, Flag)public boolean testState(com.sk89q.worldedit.util.Location location,
@Nullable
RegionAssociable associable,
StateFlag... flag)
ALLOW.
player can be non-null to satisfy region group requirements,
otherwise it will be assumed that the caller that is not a member of any
regions. (FlagUtil on a region can be changed so that they only apply
to certain users.) The player argument is required if the
Flags.BUILD flag is in the list of flags.
This method does not check the region bypass permission. That must be done by the calling code.
location - the locationassociable - an optional associableflag - the flagALLOWRegionResultSet.queryValue(RegionAssociable, Flag)@Nullable public StateFlag.State queryState(com.sk89q.worldedit.util.Location location, @Nullable LocalPlayer player, StateFlag... flags)
DENY overrides ALLOW,
and ALLOW overrides NONE. One flag may override another.
player can be non-null to satisfy region group requirements,
otherwise it will be assumed that the caller that is not a member of any
regions. (FlagUtil on a region can be changed so that they only apply
to certain users.) The player argument is required if the
Flags.BUILD flag is in the list of flags.
location - the locationplayer - an optional player, which would be used to determine the region groups that applyflags - a list of flags to checkRegionResultSet.queryState(RegionAssociable, StateFlag...)@Nullable public StateFlag.State queryState(com.sk89q.worldedit.util.Location location, @Nullable RegionAssociable associable, StateFlag... flags)
DENY overrides ALLOW,
and ALLOW overrides NONE. One flag may override another.
player can be non-null to satisfy region group requirements,
otherwise it will be assumed that the caller that is not a member of any
regions. (FlagUtil on a region can be changed so that they only apply
to certain users.) The player argument is required if the
Flags.BUILD flag is in the list of flags.
location - the locationassociable - an optional associableflags - a list of flags to checkRegionResultSet.queryState(RegionAssociable, StateFlag...)@Nullable
public <V> V queryValue(com.sk89q.worldedit.util.Location location,
@Nullable
LocalPlayer player,
Flag<V> flag)
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.
player can be non-null to satisfy region group requirements,
otherwise it will be assumed that the caller that is not a member of any
regions. (FlagUtil on a region can be changed so that they only apply
to certain users.) The player argument is required if the
Flags.BUILD flag is the flag being queried.
location - the locationplayer - an optional player, which would be used to determine the region group to applyflag - the flagnullRegionResultSet.queryValue(RegionAssociable, Flag)@Nullable
public <V> V queryValue(com.sk89q.worldedit.util.Location location,
@Nullable
RegionAssociable associable,
Flag<V> flag)
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.
player can be non-null to satisfy region group requirements,
otherwise it will be assumed that the caller that is not a member of any
regions. (FlagUtil on a region can be changed so that they only apply
to certain users.) The player argument is required if the
Flags.BUILD flag is the flag being queried.
location - the locationassociable - an optional associableflag - the flagnullRegionResultSet.queryValue(RegionAssociable, Flag)public <V> java.util.Collection<V> queryAllValues(com.sk89q.worldedit.util.Location location,
@Nullable
LocalPlayer player,
Flag<V> flag)
player can be non-null to satisfy region group requirements,
otherwise it will be assumed that the caller that is not a member of any
regions. (FlagUtil on a region can be changed so that they only apply
to certain users.) The player argument is required if the
Flags.BUILD flag is the flag being queried.
location - the locationplayer - an optional player, which would be used to determine the region group to applyflag - the flagRegionResultSet.queryAllValues(RegionAssociable, Flag)public <V> java.util.Collection<V> queryAllValues(com.sk89q.worldedit.util.Location location,
@Nullable
RegionAssociable associable,
Flag<V> flag)
player can be non-null to satisfy region group requirements,
otherwise it will be assumed that the caller that is not a member of any
regions. (FlagUtil on a region can be changed so that they only apply
to certain users.) The player argument is required if the
Flags.BUILD flag is the flag being queried.
location - the locationassociable - an optional associableflag - the flagRegionResultSet.queryAllValues(RegionAssociable, Flag)