mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-27 21:15:57 +01:00
Remove use of ObjectArrays.concat() in ApplicableRegionSet.
This commit is contained in:
parent
3eb5c65a3d
commit
ae8bf63c86
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldguard.protection;
|
||||
|
||||
import com.google.common.collect.ObjectArrays;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
@ -121,7 +120,7 @@ public boolean canBuild(LocalPlayer player) {
|
||||
*/
|
||||
public boolean testBuild(RegionAssociable subject, StateFlag... flags) {
|
||||
checkNotNull(subject);
|
||||
return test(flagValueCalculator.queryState(subject, ObjectArrays.concat(flags, DefaultFlag.BUILD)));
|
||||
return test(flagValueCalculator.queryState(subject, DefaultFlag.BUILD, flags));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -205,6 +205,53 @@ public State queryState(@Nullable RegionAssociable subject, StateFlag... flags)
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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}.
|
||||
*
|
||||
* <p>This method is the same as
|
||||
* {@link #queryState(RegionAssociable, StateFlag...)}.</p>
|
||||
*
|
||||
* @param subject an optional subject, which would be used to determine the region group to apply
|
||||
* @param flag a flag to check
|
||||
* @return a state
|
||||
*/
|
||||
@Nullable
|
||||
public State queryState(@Nullable RegionAssociable subject, StateFlag flag) {
|
||||
return queryValue(subject, flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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}.
|
||||
*
|
||||
* <p>This method is the same as
|
||||
* {@link #queryState(RegionAssociable, StateFlag...)} except it allows
|
||||
* another flag to be added at the beginning of the flag list without
|
||||
* having to concatenate the vararg array with the first flag.</p>
|
||||
*
|
||||
* @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 firstFlag, StateFlag... flags) {
|
||||
State value = queryValue(subject, firstFlag);
|
||||
|
||||
if (value != State.DENY) {
|
||||
for (StateFlag flag : flags) {
|
||||
value = StateFlag.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, if there are multiple regions with the same priority
|
||||
|
Loading…
Reference in New Issue
Block a user