Package org.kingdoms.utils.chunks
Class ChunkConnections
java.lang.Object
org.kingdoms.utils.chunks.ChunkConnections
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleandisconnectsClaimsAfterUnclaim(String world, Kingdom kingdom, int radius, Predicate<SimpleChunkLocation> isGoingToBeUnclaimed) static org.bukkit.LocationgetCentroid(Set<SimpleChunkLocation> chunks) Centroid Finds the most natural looking "center" location for a group of chunks.static Set<SimpleChunkLocation>getConnectedChunks(int radius, SimpleChunkLocation chunk, Predicate<SimpleChunkLocation> consider) Gets all the connected chunks that have a specific property to the specified chunk parameter.static Collection<Set<SimpleChunkLocation>>getConnectedClusters(int radius, Set<SimpleChunkLocation> chunks) Groups all the lands that are next to each other.static intstatic @Nullable LandvalidateDistance(@NonNull SimpleChunkLocation chunk, @NonNull UUID kingdom)
-
Constructor Details
-
ChunkConnections
public ChunkConnections()
-
-
Method Details
-
getConnectionRadius
public static int getConnectionRadius() -
getCentroid
Centroid Finds the most natural looking "center" location for a group of chunks. The given chunks should practically belong to the same group (claimed) but it doesn't matter for this method.- Returns:
- null if chunks is empty.
-
validateDistance
public static @Nullable Land validateDistance(@NonNull SimpleChunkLocation chunk, @NonNull UUID kingdom) - Parameters:
chunk- The chunk to check its distance from other claims.kingdom- The kingdom that is going to own the chunk.- Returns:
- the land that conflicts with the given chunk based on the distance or null if none.
-
disconnectsClaimsAfterUnclaim
public static boolean disconnectsClaimsAfterUnclaim(String world, Kingdom kingdom, int radius, Predicate<SimpleChunkLocation> isGoingToBeUnclaimed) -
getConnectedChunks
public static Set<SimpleChunkLocation> getConnectedChunks(int radius, SimpleChunkLocation chunk, Predicate<SimpleChunkLocation> consider) Gets all the connected chunks that have a specific property to the specified chunk parameter.- Parameters:
radius- The amount of chunks that a chunk can be far away from the last connected chunk to be considered connected. Starts from 1chunk- The chunk to find the connected chunks around.consider- The filter to consider a chunk to be the same type as the original given chunk. In many context this basically means a filter to determine whether a chunk is claimed by the same kingdom as the provided argument.- Returns:
- A group of all the connected chunks to the given chunk.
-
getConnectedClusters
public static Collection<Set<SimpleChunkLocation>> getConnectedClusters(int radius, Set<SimpleChunkLocation> chunks) Groups all the lands that are next to each other. Each set of chunks that are considered to be connected will be put in a single group, therefore no single chunk can occur in two different groups.- Parameters:
radius- the amount of chunks that a chunk can be far away from the cluster to be considered to be in the same group. Starts from 1chunks- the chunks to check. They all must be in the same world.- Returns:
- a list of unconnected groups of chunks.
-