Package wtf.choco.arrows.registry
Class ArrowStateManager
java.lang.Object
wtf.choco.arrows.registry.ArrowStateManager
public final class ArrowStateManager extends Object
Handles the in-world entities for
AlchemicalArrow
types. All alchemical arrows in the
world have an associated AlchemicalArrowEntity
registered in this state manager so long
as they are still valid according to Entity.isValid()
.- Author:
- Parker Hawke - Choco
-
Constructor Summary
Constructors Constructor Description ArrowStateManager()
-
Method Summary
Modifier and Type Method Description void
add(@NotNull AlchemicalArrowEntity arrow)
Add anAlchemicalArrowEntity
to the state manager.void
clear()
Clears the state manager.@Nullable AlchemicalArrowEntity
get(@Nullable UUID uuid)
Get theAlchemicalArrowEntity
associated with the providedUUID
.@Nullable AlchemicalArrowEntity
get(@Nullable org.bukkit.entity.Arrow arrow)
Get theAlchemicalArrowEntity
associated with the providedArrow
.@NotNull Collection<AlchemicalArrowEntity>
getArrows()
Get a copied collection of allAlchemicalArrowEntity
states in the manager.<T extends AlchemicalArrowEntity>
@NotNull Collection<T>getArrows(@NotNull Class<T> type)
Get an unmodifiable collection of allAlchemicalArrowEntity
states of the specified arrow entity type.@NotNull Collection<AlchemicalArrowEntity>
getArrows(@NotNull org.bukkit.World world)
Get an unmodifiable collection of allAlchemicalArrowEntity
states in the specified world.@NotNull Collection<AlchemicalArrowEntity>
getArrowsOfType(@NotNull Class<? extends AlchemicalArrow> type)
Get an unmodifiable collection of allAlchemicalArrowEntity
states of the specifiedAlchemicalArrow
type.void
remove(@NotNull org.bukkit.entity.Arrow arrow)
Remove anArrow
(and therefore its associatedAlchemicalArrowEntity
, if one exists) from the state manager.void
remove(@NotNull AlchemicalArrowEntity arrow)
Remove anAlchemicalArrowEntity
from the state manager.
-
Constructor Details
-
ArrowStateManager
public ArrowStateManager()
-
-
Method Details
-
add
Add anAlchemicalArrowEntity
to the state manager.- Parameters:
arrow
- the arrow to add
-
remove
Remove anAlchemicalArrowEntity
from the state manager.- Parameters:
arrow
- the arrow to remove
-
remove
public void remove(@NotNull @NotNull org.bukkit.entity.Arrow arrow)Remove anArrow
(and therefore its associatedAlchemicalArrowEntity
, if one exists) from the state manager.- Parameters:
arrow
- the arrow to remove
-
get
@Nullable public @Nullable AlchemicalArrowEntity get(@Nullable @Nullable org.bukkit.entity.Arrow arrow)Get theAlchemicalArrowEntity
associated with the providedArrow
.- Parameters:
arrow
- the Bukkit arrow from which to get an alchemical arrow- Returns:
- an instance of the alchemical arrow entity. null if not stated
-
get
Get theAlchemicalArrowEntity
associated with the providedUUID
.- Parameters:
uuid
- the UUID of the arrow from which to get an alchemical arrow- Returns:
- an instance of the alchemical arrow entity. null if none
-
getArrows
Get a copied collection of allAlchemicalArrowEntity
states in the manager. Changes made to the returned collection will not affect the state manager.- Returns:
- all actively stated arrows
-
getArrows
@NotNull public @NotNull Collection<AlchemicalArrowEntity> getArrows(@NotNull @NotNull org.bukkit.World world)Get an unmodifiable collection of allAlchemicalArrowEntity
states in the specified world.- Parameters:
world
- the world from which to query arrows- Returns:
- all actively stated arrows in the specified world
-
getArrows
@NotNull public <T extends AlchemicalArrowEntity> @NotNull Collection<T> getArrows(@NotNull @NotNull Class<T> type)Get an unmodifiable collection of allAlchemicalArrowEntity
states of the specified arrow entity type.- Type Parameters:
T
- the arrow entity type- Parameters:
type
- the type of arrows to get- Returns:
- all actively stated arrows of the specified type
- See Also:
getArrowsOfType(Class)
-
getArrowsOfType
@NotNull public @NotNull Collection<AlchemicalArrowEntity> getArrowsOfType(@NotNull @NotNull Class<? extends AlchemicalArrow> type)Get an unmodifiable collection of allAlchemicalArrowEntity
states of the specifiedAlchemicalArrow
type.- Parameters:
type
- the type of arrows to get- Returns:
- all actively stated arrows of the specified type
- See Also:
getArrows(Class)
-
clear
public void clear()Clears the state manager.
-