diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/protection/AbstractRegionSet.java b/worldguard-core/src/main/java/com/sk89q/worldguard/protection/AbstractRegionSet.java index ea78e6854..98c7341f5 100644 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/protection/AbstractRegionSet.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/protection/AbstractRegionSet.java @@ -19,34 +19,6 @@ package com.sk89q.worldguard.protection; -import static com.sk89q.worldguard.protection.flags.StateFlag.test; - -import com.sk89q.worldguard.protection.association.RegionAssociable; -import com.sk89q.worldguard.protection.flags.StateFlag; -import com.sk89q.worldguard.protection.flags.StateFlag.State; - -import javax.annotation.Nullable; - public abstract class AbstractRegionSet implements ApplicableRegionSet { - @Override - public boolean testState(@Nullable RegionAssociable subject, StateFlag... flags) { - return test(queryState(subject, flags)); - } - - @Nullable - @Override - public State queryState(@Nullable RegionAssociable subject, StateFlag... flags) { - State value = null; - - for (StateFlag flag : flags) { - value = StateFlag.combine(value, queryValue(subject, flag)); - if (value == State.DENY) { - break; - } - } - - return value; - } - } diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/protection/ApplicableRegionSet.java b/worldguard-core/src/main/java/com/sk89q/worldguard/protection/ApplicableRegionSet.java index 845931d08..c4dcbd28a 100644 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/protection/ApplicableRegionSet.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/protection/ApplicableRegionSet.java @@ -20,18 +20,9 @@ package com.sk89q.worldguard.protection; import com.sk89q.worldguard.LocalPlayer; -import com.sk89q.worldguard.protection.association.RegionAssociable; -import com.sk89q.worldguard.protection.flags.Flags; -import com.sk89q.worldguard.protection.flags.Flag; -import com.sk89q.worldguard.protection.flags.MapFlag; -import com.sk89q.worldguard.protection.flags.RegionGroup; -import com.sk89q.worldguard.protection.flags.StateFlag; -import com.sk89q.worldguard.protection.flags.StateFlag.State; import com.sk89q.worldguard.protection.managers.RegionManager; import com.sk89q.worldguard.protection.regions.ProtectedRegion; -import javax.annotation.Nullable; -import java.util.Collection; import java.util.Set; /** @@ -41,7 +32,7 @@ *
An instance of this can be created using the spatial query methods * available on {@link RegionManager}.
*/ -public interface ApplicableRegionSet extends Iterable{@code subject} 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. (Flags on a region can be changed so that they only apply - * to certain users.) The subject argument is required if the - * {@link Flags#BUILD} flag is in the list of flags.
- * - * @param subject an optional subject, which would be used to determine the region groups that apply - * @param flags a list of flags to check - * @return true if the result was {@code ALLOW} - * @see #queryState(RegionAssociable, StateFlag...) - */ - boolean testState(@Nullable RegionAssociable subject, StateFlag... flags); - - /** - * Get the (effective) value for a list of state flags. The rules of - * states is observed here; that is, {@code DENY} overrides {@code ALLOW}, - * and {@code ALLOW} overrides {@code NONE}. One flag may override another. - * - *{@code subject} 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. (Flags on a region can be changed so that they only apply - * to certain users.) The subject argument is required if the - * {@link Flags#BUILD} flag is in the list of flags.
- * - * @param subject an optional subject, which would be used to determine the region groups that apply - * @param flags a list of flags to check - * @return a state - */ - @Nullable - State queryState(@Nullable RegionAssociable subject, StateFlag... flags); - - /** - * Get 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 - * {@link StateFlag}.
- * - *{@code subject} 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. (Flags on a region can be changed so that they only apply - * to certain users.) The subject argument is required if the - * {@link Flags#BUILD} flag is the flag being queried.
- * - * @param subject an optional subject, which would be used to determine the region group to apply - * @param flag the flag - * @return a value, which could be {@code null} - */ - @Nullable -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 {@link RegionGroup#MEMBERS} and the given - * subject is not a member, then the region would be skipped when - * querying that flag. If {@code null} is provided for the subject, then - * only flags that use {@link RegionGroup#ALL}, - * {@link RegionGroup#NON_MEMBERS}, etc. will apply.
- * - * @param subject an optional subject, which would be used to determine the region group to apply - * @param flag the flag of type {@link MapFlag} - * @param key the key for the map flag - * @return a value, which could be {@code null} - */ - @Nullable -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 {@link RegionGroup#MEMBERS} and the given - * subject is not a member, then the region would be skipped when - * querying that flag. If {@code null} is provided for the subject, then - * only flags that use {@link RegionGroup#ALL}, - * {@link RegionGroup#NON_MEMBERS}, etc. will apply.
- * - * @param subject an optional subject, which would be used to determine the region group to apply - * @param flag the flag of type {@link MapFlag} - * @param key the key for the map flag - * @return a value, which could be {@code null} - */ - @Nullable -{@code subject} 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. (Flags on a region can be changed so that they only apply - * to certain users.) The subject argument is required if the - * {@link Flags#BUILD} flag is the flag being queried.
- * - * @param subject an optional subject, which would be used to determine the region group to apply - * @param flag the flag - * @return a collection of values - */ -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.
+ * + * @param subject the subject + * @param flags the flags + * @return true if the result was {@code ALLOW} + */ + default boolean testBuild(RegionAssociable subject, StateFlag... flags) { + if (flags.length == 0) { + return testState(subject, Flags.BUILD); + } + + return test( + denyToNone(queryState(subject, Flags.BUILD)), + queryState(subject, flags)); + } + + /** + * Returns true if the BUILD flag allows the action, but it + * can be overridden by a list of other flags. The BUILD flag will not + * override the other flags, but the other flags can override BUILD. If + * neither BUILD or any of the flags permit the action, then false will + * be returned. + * + *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.
+ * + *This method does include parameters for a {@link MapFlag}.
+ * + *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.
+ * + * @param subject the subject + * @param flag the MapFlag + * @param key the key for the MapFlag + * @param fallback the fallback flag for MapFlag + * @param flags the flags + * @return true if the result was {@code ALLOW} + */ + default{@code subject} 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. (Flags on a region can be changed so that they only apply + * to certain users.) The subject argument is required if the + * {@link Flags#BUILD} flag is in the list of flags.
+ * + * @param subject an optional subject, which would be used to determine the region groups that apply + * @param flags a list of flags to check + * @return true if the result was {@code ALLOW} + */ + default boolean testState(@Nullable RegionAssociable subject, StateFlag... flags) { + return test(queryState(subject, flags)); + } + + /** + * Get the (effective) value for a list of state flags. The rules of + * states is observed here; that is, {@code DENY} overrides {@code ALLOW}, + * and {@code ALLOW} overrides {@code NONE}. One flag may override another. + * + *{@code subject} 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. (Flags on a region can be changed so that they only apply + * to certain users.) The subject argument is required if the + * {@link Flags#BUILD} flag is in the list of flags.
+ * + * @param subject an optional subject, which would be used to determine the region groups that apply + * @param flags a list of flags to check + * @return a state + */ + @Nullable + default State queryState(@Nullable RegionAssociable subject, StateFlag... flags) { + State value = null; + + for (StateFlag flag : flags) { + value = combine(value, queryValue(subject, flag)); + if (value == State.DENY) { + break; + } + } + + return value; + } + + /** + * Get 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 + * {@link StateFlag}.
+ * + *{@code subject} 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. (Flags on a region can be changed so that they only apply + * to certain users.) The subject argument is required if the + * {@link Flags#BUILD} flag is the flag being queried.
+ * + * @param subject an optional subject, which would be used to determine the region group to apply + * @param flag the flag + * @return a value, which could be {@code null} + */ + @Nullable + defaultA 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 {@link RegionGroup#MEMBERS} and the given + * subject is not a member, then the region would be skipped when + * querying that flag. If {@code null} is provided for the subject, then + * only flags that use {@link RegionGroup#ALL}, + * {@link RegionGroup#NON_MEMBERS}, etc. will apply.
+ * + * @param subject an optional subject, which would be used to determine the region group to apply + * @param flag the flag of type {@link MapFlag} + * @param key the key for the map flag + * @return a value, which could be {@code null} + */ + @Nullable + defaultA 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 {@link RegionGroup#MEMBERS} and the given + * subject is not a member, then the region would be skipped when + * querying that flag. If {@code null} is provided for the subject, then + * only flags that use {@link RegionGroup#ALL}, + * {@link RegionGroup#NON_MEMBERS}, etc. will apply.
+ * + * @param subject an optional subject, which would be used to determine the region group to apply + * @param flag the flag of type {@link MapFlag} + * @param key the key for the map flag + * @return a value, which could be {@code null} + */ + @Nullable +{@code subject} 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. (Flags on a region can be changed so that they only apply + * to certain users.) The subject argument is required if the + * {@link Flags#BUILD} flag is the flag being queried.
+ * + * @param subject an optional subject, which would be used to determine the region group to apply + * @param flag the flag + * @return a collection of values + */ + default{@code subject} 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. (Flags on a region can be changed so that they only apply + * to certain users.) The subject argument is required if the + * {@link Flags#BUILD} flag is the flag being queried.
+ * + * @param subject an optional subject, which would be used to determine the region group to apply + * @param flag the flag + * @param acceptOne if possible, return only one value if it doesn't matter + * @return a collection of values + */ +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 {@link RegionGroup#MEMBERS} and the given - * subject is not a member, then the region would be skipped when - * querying that flag. If {@code null} is provided for the subject, then - * only flags that use {@link RegionGroup#ALL}, - * {@link RegionGroup#NON_MEMBERS}, etc. will apply.
- * - * @param subject an optional subject, which would be used to determine the region group to apply - * @param flags a list of flags to check - * @return a state - */ - @Nullable - public State queryState(@Nullable RegionAssociable subject, StateFlag... flags) { - State value = null; - - for (StateFlag flag : flags) { - value = StateFlag.combine(value, queryValue(subject, flag)); - if (value == State.DENY) { - break; - } - } - - return value; - } - - /** - * Get the effective value for a list of state flags. The rules of + * Get the (effective) value for a state flag. The rules of * states is observed here; that is, {@code DENY} overrides {@code ALLOW}, * and {@code ALLOW} overrides {@code NONE}. * *This method is the same as * {@link #queryState(RegionAssociable, StateFlag...)}.
* - * @param subject an optional subject, which would be used to determine the region group to apply + * @param subject an optional subject, which would be used to determine the region groups that apply * @param flag a flag to check * @return a state + * @deprecated use {@link #queryState(RegionAssociable, StateFlag...)} instead, will be removed in WorldGuard 8 */ + @Deprecated(forRemoval = true) @Nullable public State queryState(@Nullable RegionAssociable subject, StateFlag flag) { return queryValue(subject, flag); } - /** - * Get the effective value for a flag. 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 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 can consistently return the same 'best' value is - * {@link StateFlag}.
- * - *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 {@link RegionGroup#MEMBERS} and the given - * subject is not a member, then the region would be skipped when - * querying that flag. If {@code null} is provided for the subject, then - * only flags that use {@link RegionGroup#ALL}, - * {@link RegionGroup#NON_MEMBERS}, etc. will apply.
- * - * @param subject an optional subject, which would be used to determine the region group to apply - * @param flag the flag - * @return a value, which could be {@code null} - */ - @Nullable - publicA 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 {@link RegionGroup#MEMBERS} and the given - * subject is not a member, then the region would be skipped when - * querying that flag. If {@code null} is provided for the subject, then - * only flags that use {@link RegionGroup#ALL}, - * {@link RegionGroup#NON_MEMBERS}, etc. will apply.
- * - * @param subject an optional subject, which would be used to determine the region group to apply - * @param flag the flag of type {@link MapFlag} - * @param key the key for the map flag - * @return a value, which could be {@code null} - */ + @Override @Nullable - publicA 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 {@link RegionGroup#MEMBERS} and the given - * subject is not a member, then the region would be skipped when - * querying that flag. If {@code null} is provided for the subject, then - * only flags that use {@link RegionGroup#ALL}, - * {@link RegionGroup#NON_MEMBERS}, etc. will apply.
- * - * @param subject an optional subject, which would be used to determine the region group to apply - * @param flag the flag - * @param acceptOne if possible, return only one value if it doesn't matter - * @return a collection of values - */ @SuppressWarnings("unchecked") - privateUse 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.
- * - * @param location the location - * @param player an optional player, which would be used to determine the region group to apply - * @param flag the flag - * @return true if the result was {@code ALLOW} - * @see RegionResultSet#queryValue(RegionAssociable, Flag) + * @deprecated use {@link #testBuild(Location, RegionAssociable, StateFlag...)} instead, will be removed in WorldGuard 8 */ - public boolean testBuild(Location location, LocalPlayer player, StateFlag... flag) { - if (flag.length == 0) { - return testState(location, player, Flags.BUILD); - } - - return StateFlag.test(StateFlag.combine( - StateFlag.denyToNone(queryState(location, player, Flags.BUILD)), - queryState(location, player, flag))); + @Deprecated(forRemoval = true) + public boolean testBuild(Location location, LocalPlayer subject, StateFlag... flags) { + return getApplicableRegions(location).testBuild(subject, flags); } /** - * Returns true if the BUILD flag allows the action in the location, but it - * can be overridden by a list of other flags. The BUILD flag will not - * override the other flags, but the other flags can override BUILD. If - * neither BUILD or any of the flags permit the action, then false will - * be returned. - * - *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.
- * - * @param location the location - * @param associable an optional associable - * @param flag the flag - * @return true if the result was {@code ALLOW} - * @see RegionResultSet#queryValue(RegionAssociable, Flag) + * Convenience method for + * {@link #getApplicableRegions(Location)}{@link ApplicableRegionSet#testBuild(RegionAssociable, StateFlag...) + * .testBuild(RegionAssociable, StateFlag...)} */ - public boolean testBuild(Location location, RegionAssociable associable, StateFlag... flag) { - if (flag.length == 0) { - return testState(location, associable, Flags.BUILD); - } - - return StateFlag.test(StateFlag.combine( - StateFlag.denyToNone(queryState(location, associable, Flags.BUILD)), - queryState(location, associable, flag))); + public boolean testBuild(Location location, RegionAssociable subject, StateFlag... flags) { + return getApplicableRegions(location).testBuild(subject, flags); } /** - * Returns true if the BUILD flag allows the action in the location, but it - * can be overridden by a list of other flags. The BUILD flag will not - * override the other flags, but the other flags can override BUILD. If - * neither BUILD or any of the flags permit the action, then false will - * be returned. - * - *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.
- * - *This method does include parameters for a {@link MapFlag}.
- * - *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.
- * - * @param location the location - * @param associable an optional associable - * @param mapFlag the MapFlag - * @param key the key for the MapFlag - * @param fallback the fallback flag for MapFlag - * @param flag the flags - * @return true if the result was {@code ALLOW} - * @see RegionResultSet#queryValue(RegionAssociable, Flag) + * Convenience method for + * {@link #getApplicableRegions(Location)}{@link ApplicableRegionSet#testBuild(RegionAssociable, MapFlag, Object, StateFlag, StateFlag...) + * .testBuild(RegionAssociable, MapFlag, Object, StateFlag, StateFlag...)} */ - public{@code 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. (Flags on a region can be changed so that they only apply - * to certain users.) The player argument is required if the - * {@link 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.
- * - * @param location the location - * @param player an optional player, which would be used to determine the region group to apply - * @param flag the flag - * @return true if the result was {@code ALLOW} - * @see RegionResultSet#queryValue(RegionAssociable, Flag) + * @deprecated use {@link #testState(Location, RegionAssociable, StateFlag...)} instead, will be removed in WorldGuard 8 */ - public boolean testState(Location location, @Nullable LocalPlayer player, StateFlag... flag) { - return StateFlag.test(queryState(location, player, flag)); + @Deprecated(forRemoval = true) + public boolean testState(Location location, @Nullable LocalPlayer subject, StateFlag... flags) { + return getApplicableRegions(location).testState(subject, flags); } /** - * Test whether the (effective) value for a list of state flags equals - * {@code ALLOW}. - * - *{@code 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. (Flags on a region can be changed so that they only apply - * to certain users.) The player argument is required if the - * {@link 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.
- * - * @param location the location - * @param associable an optional associable - * @param flag the flag - * @return true if the result was {@code ALLOW} - * @see RegionResultSet#queryValue(RegionAssociable, Flag) + * Convenience method for + * {@link #getApplicableRegions(Location)}{@link ApplicableRegionSet#testState(RegionAssociable, StateFlag...) + * .testState(RegionAssociable, StateFlag...)} */ - public boolean testState(Location location, @Nullable RegionAssociable associable, StateFlag... flag) { - return StateFlag.test(queryState(location, associable, flag)); + public boolean testState(Location location, @Nullable RegionAssociable subject, StateFlag... flags) { + return getApplicableRegions(location).testState(subject, flags); } /** - * Get the (effective) value for a list of state flags. The rules of - * states is observed here; that is, {@code DENY} overrides {@code ALLOW}, - * and {@code ALLOW} overrides {@code NONE}. One flag may override another. - * - *{@code 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. (Flags on a region can be changed so that they only apply - * to certain users.) The player argument is required if the - * {@link Flags#BUILD} flag is in the list of flags.
+ * Convenience method for + * {@link #getApplicableRegions(Location)}{@link ApplicableRegionSet#queryState(RegionAssociable, StateFlag...) + * .queryState(RegionAssociable, StateFlag...)} * - * @param location the location - * @param player an optional player, which would be used to determine the region groups that apply - * @param flags a list of flags to check - * @return a state - * @see RegionResultSet#queryState(RegionAssociable, StateFlag...) + * @deprecated use {@link #queryState(Location, RegionAssociable, StateFlag...)} instead, will be removed in WorldGuard 8 */ + @Deprecated(forRemoval = true) @Nullable - public State queryState(Location location, @Nullable LocalPlayer player, StateFlag... flags) { - return getApplicableRegions(location).queryState(player, flags); + public State queryState(Location location, @Nullable LocalPlayer subject, StateFlag... flags) { + return getApplicableRegions(location).queryState(subject, flags); } /** - * Get the (effective) value for a list of state flags. The rules of - * states is observed here; that is, {@code DENY} overrides {@code ALLOW}, - * and {@code ALLOW} overrides {@code NONE}. One flag may override another. - * - *{@code 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. (Flags on a region can be changed so that they only apply - * to certain users.) The player argument is required if the - * {@link Flags#BUILD} flag is in the list of flags.
- * - * @param location the location - * @param associable an optional associable - * @param flags a list of flags to check - * @return a state - * @see RegionResultSet#queryState(RegionAssociable, StateFlag...) + * Convenience method for + * {@link #getApplicableRegions(Location)}{@link ApplicableRegionSet#queryState(RegionAssociable, StateFlag...) + * .queryState(RegionAssociable, StateFlag...)} */ @Nullable - public State queryState(Location location, @Nullable RegionAssociable associable, StateFlag... flags) { - return getApplicableRegions(location).queryState(associable, flags); + public State queryState(Location location, @Nullable RegionAssociable subject, StateFlag... flags) { + return getApplicableRegions(location).queryState(subject, flags); } /** - * Get 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 - * {@link StateFlag}.
+ * Convenience method for + * {@link #getApplicableRegions(Location)}{@link ApplicableRegionSet#queryValue(RegionAssociable, Flag) + * .queryValue(RegionAssociable, Flag)} * - *{@code 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. (Flags on a region can be changed so that they only apply - * to certain users.) The player argument is required if the - * {@link Flags#BUILD} flag is the flag being queried.
- * - * @param location the location - * @param player an optional player, which would be used to determine the region group to apply - * @param flag the flag - * @return a value, which could be {@code null} - * @see RegionResultSet#queryValue(RegionAssociable, Flag) + * @deprecated use {@link #queryValue(Location, RegionAssociable, Flag)} instead, will be removed in WorldGuard 8 */ + @Deprecated(forRemoval = true) @Nullable - publicOnly 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 - * {@link StateFlag}.
- * - *{@code 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. (Flags on a region can be changed so that they only apply - * to certain users.) The player argument is required if the - * {@link Flags#BUILD} flag is the flag being queried.
- * - * @param location the location - * @param associable an optional associable - * @param flag the flag - * @return a value, which could be {@code null} - * @see RegionResultSet#queryValue(RegionAssociable, Flag) + * Convenience method for + * {@link #getApplicableRegions(Location)}{@link ApplicableRegionSet#queryValue(RegionAssociable, Flag) + * .queryValue(RegionAssociable, Flag)} */ @Nullable - publicA 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 {@link RegionGroup#MEMBERS} and the given - * subject is not a member, then the region would be skipped when - * querying that flag. If {@code null} is provided for the subject, then - * only flags that use {@link RegionGroup#ALL}, - * {@link RegionGroup#NON_MEMBERS}, etc. will apply.
- * - * @param subject an optional subject, which would be used to determine the region group to apply - * @param flag the flag of type {@link MapFlag} - * @param key the key for the map flag - * @return a value, which could be {@code null} + * Convenience method for + * {@link #getApplicableRegions(Location)}{@link ApplicableRegionSet#queryMapValue(RegionAssociable, MapFlag, Object) + * .queryMapValue(RegionAssociable, MapFlag, Object)} */ @Nullable publicA 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 {@link RegionGroup#MEMBERS} and the given - * subject is not a member, then the region would be skipped when - * querying that flag. If {@code null} is provided for the subject, then - * only flags that use {@link RegionGroup#ALL}, - * {@link RegionGroup#NON_MEMBERS}, etc. will apply.
- * - *It's possible to provide a fallback flag for the case when the key doesn't - * exist in the {@link MapFlag}.
- * - * @param subject an optional subject, which would be used to determine the region group to apply - * @param flag the flag of type {@link MapFlag} - * @param key the key for the map flag - * @param fallback the fallback flag - * @return a value, which could be {@code null} + * Convenience method for + * {@link #getApplicableRegions(Location)}{@link ApplicableRegionSet#queryMapValue(RegionAssociable, MapFlag, Object, Flag) + * .queryMapValue(RegionAssociable, MapFlag, Object, Flag)} */ @Nullable - public{@code 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. (Flags on a region can be changed so that they only apply - * to certain users.) The player argument is required if the - * {@link Flags#BUILD} flag is the flag being queried.
- * - * @param location the location - * @param player an optional player, which would be used to determine the region group to apply - * @param flag the flag - * @return a collection of values - * @see RegionResultSet#queryAllValues(RegionAssociable, Flag) + * @deprecated use {@link #queryAllValues(Location, RegionAssociable, Flag)} instead, will be removed in WorldGuard 8 */ - public{@code 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. (Flags on a region can be changed so that they only apply - * to certain users.) The player argument is required if the - * {@link Flags#BUILD} flag is the flag being queried.
- * - * @param location the location - * @param associable an optional associable - * @param flag the flag - * @return a collection of values - * @see RegionResultSet#queryAllValues(RegionAssociable, Flag) + * Convenience method for + * {@link #getApplicableRegions(Location)}{@link ApplicableRegionSet#queryAllValues(RegionAssociable, Flag) + * .queryAllValues(RegionAssociable, Flag)} + */ + public