Class Region
- All Implemented Interfaces:
Comparable<Region>,RegionQuery.Flag.Queryable,RegistryResolvable<String>
- Direct Known Subclasses:
GlobalRegion
Regions hold an Area to define the locations affected by the region.
They also hold a set of MutableRegionFlags.
Regions may have region parents defined, where they will inherit the flags of those parents if it does not have an overriding flag set.
There is also a set of Members.
Members may be influenced differently by a GroupedMutableRegionFlag.
By default, flags affect all members in a region.
Multiple regions spanning the same area will be prioritised based off the priority() parameter.
When querying a location for a flag, the region with the highest priority that has that flag should return the flag value.
Regions that have the same priority and conflicting flags have undefined behaviour. In these cases, admins should be warned about possible issues.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<Region> protected final Map<net.kyori.adventure.key.Key, MutableRegionFlag<?>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> MutableRegionFlag<T> addFlag(RegistryRegionFlag<T> flag) Adds a flag to this region.<T> GroupedMutableRegionFlag<T> addGroupedFlag(RegistryRegionFlag<T> flag, Set<FlagMemberGroup> groups) Adds a grouped flag to this region with the initial set of groups.voidvoidAdds a parent to this region.area()Gets the area of this region.intboolean<T> Optional<MutableRegionFlag<T>> getFlag(RegistryRegionFlag<T> flag) RegionType<?> getType()booleanhasFlag(RegistryRegionFlag<?> flag) inthashCode()booleanisGlobal()Gets whether this region is a "global region".key()Gets the registry key used for this object.members()Gets the members of this region.name()Gets the name of this region.parents()Gets the parents of this region.intpriority()Gets the priority of this region.voidpriority(int priority) <FR> RegionQuery.Result<Optional<FR>, RegionQuery.Flag<FR>> query(RegionQuery.Flag<FR> flag) booleanremoveFlag(RegistryRegionFlag<?> flag) Removes a flag from this region.voidremoveMember(Member member) voidremoveParent(Region region) Removes a parent from this region.<T> voidsetFlag(RegistryRegionFlag<T> flag, T value) Sets the value of a flag.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.empirewar.orbis.query.RegionQuery.Flag.Queryable
query
-
Field Details
-
CODEC
-
flags
-
-
Constructor Details
-
Region
-
-
Method Details
-
name
Gets the name of this region.A region name should never include spaces and is considered an identifier.
- Returns:
- the name
-
parents
Gets the parents of this region.- Returns:
- the parents
-
addParent
Adds a parent to this region.- Parameters:
region- the parent to add
-
removeParent
Removes a parent from this region.- Parameters:
region- the parent to remove
-
members
Gets the members of this region.- Returns:
- the members
-
addMember
-
removeMember
-
area
Gets the area of this region.- Returns:
- the area
-
priority
public int priority()Gets the priority of this region.A priority is always positive (including zero) and a higher priority gives precedence over other regions when checking flags.
- Returns:
- the priority
-
priority
public void priority(int priority) - Parameters:
priority- the priority- See Also:
-
addFlag
Adds a flag to this region. The flag is transformed into a mutable flag.- Parameters:
flag- the flag to add- Returns:
- the transformed flag instance
- See Also:
-
addGroupedFlag
public <T> GroupedMutableRegionFlag<T> addGroupedFlag(RegistryRegionFlag<T> flag, Set<FlagMemberGroup> groups) Adds a grouped flag to this region with the initial set of groups.- Parameters:
flag- the flag to addgroups- the groups to add to the flag- Returns:
- the transformed flag instance
-
removeFlag
Removes a flag from this region.- Parameters:
flag- the flag to remove- Returns:
- true if flag existed and was removed
-
hasFlag
-
getFlag
-
setFlag
Sets the value of a flag.- Type Parameters:
T- value type- Parameters:
flag- the flagvalue- the value- Throws:
IllegalArgumentException- if the flag is not present
-
query
- Specified by:
queryin interfaceRegionQuery.Flag.Queryable
-
isGlobal
public boolean isGlobal()Gets whether this region is a "global region".A global region is a region that encompasses a world.
- Returns:
- true if global
-
getType
-
toString
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareToin interfaceComparable<Region>
-
key
Description copied from interface:RegistryResolvableGets the registry key used for this object.- Specified by:
keyin interfaceRegistryResolvable<String>- Returns:
- the registry key
-