Package com.minecolonies.core.colony
Class ColonyList<T extends IColony>
java.lang.Object
com.minecolonies.core.colony.ColonyList<T>
- Type Parameters:
T- Type of IColony (Colony or ColonyView)
- All Implemented Interfaces:
Iterable<T>
Data structure for storing colonies, optimized for performance.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a new Colony to the List.voidclear()Empty the list.create(net.minecraft.server.level.ServerLevel world, String name, net.minecraft.core.BlockPos position) Creates a new Colony, adds it to the list, and returns it.get(int index) Get the Colony with the provided colony id.Copy all of the colonies to a List.intgetSize()Return the number of Colonies in the list.intgetTopID()Get the top colony id.booleanisEmpty()Checks if there are Colonies in the list.iterator()Makes an iterator for the list.voidremove(int id) Remove the colony with the provided id from the list.voidRemove the Colony from the list.stream()Create a Stream of Colonies.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ColonyList
public ColonyList()
-
-
Method Details
-
create
public Colony create(net.minecraft.server.level.ServerLevel world, String name, net.minecraft.core.BlockPos position) Creates a new Colony, adds it to the list, and returns it.- Parameters:
world- The world for the Colony.position- The position for the Colony center.- Returns:
- The newly created Colony.
-
add
Add a new Colony to the List.- Parameters:
colony- colony to add to the list.
-
get
Get the Colony with the provided colony id.- Parameters:
index- colony id.- Returns:
- The Colony associated with the provided id.
-
remove
Remove the Colony from the list.- Parameters:
colony- the Colony to remove.
-
remove
public void remove(int id) Remove the colony with the provided id from the list.- Parameters:
id- colony id to remove.
-
clear
public void clear()Empty the list. -
getTopID
public int getTopID()Get the top colony id.- Returns:
- the top id.
-
getSize
public int getSize()Return the number of Colonies in the list.- Returns:
- number of Colonies in the list.
-
isEmpty
public boolean isEmpty()Checks if there are Colonies in the list.- Returns:
- true if there are no Colonies.
-
getCopyAsList
Copy all of the colonies to a List. Because this does a copy, it should only be used when really needed.- Returns:
- List of Colonies.
-
iterator
Makes an iterator for the list. -
stream
Create a Stream of Colonies.- Returns:
- a Colony Stream.
-