Class ArenaManager<T,A extends Arena & ManagedArena<T>>

java.lang.Object
me.hsgamer.minigamecore.base.FeatureUnit
me.hsgamer.minigamecore.manager.ArenaManager<T,A>
Type Parameters:
T - the type of the identifier of the arena
A - the type of the arena
All Implemented Interfaces:
Initializer
Direct Known Subclasses:
LoadedArenaManager

public abstract class ArenaManager<T,A extends Arena & ManagedArena<T>> extends FeatureUnit
The manager that handles all arenas
  • Constructor Details

    • ArenaManager

      public ArenaManager(List<FeatureUnit> parentList)
      Create a new arena manager
      Parameters:
      parentList - the parent FeatureUnit list
    • ArenaManager

      public ArenaManager(FeatureUnit... parent)
      Create a new arena manager
      Parameters:
      parent - the parent FeatureUnit
  • Method Details

    • postInit

      public void postInit()
      Description copied from interface: Initializer
      Called on special event when all the objects are initialized
      Specified by:
      postInit in interface Initializer
      Overrides:
      postInit in class FeatureUnit
    • clear

      public void clear()
      Description copied from interface: Initializer
      Clear the object
      Specified by:
      clear in interface Initializer
      Overrides:
      clear in class FeatureUnit
    • containsArena

      public boolean containsArena(T identifier)
      Check if the arena manager contains the arena
      Parameters:
      identifier - the identifier
      Returns:
      true if it does
    • getArena

      public Optional<A> getArena(T identifier)
      Get the arena by its identifier
      Parameters:
      identifier - the identifier
      Returns:
      the arena
    • getArenaMap

      public Map<T,A> getArenaMap()
      Get the arena map
      Returns:
      the arena map
    • getAllArenas

      public Collection<A> getAllArenas()
      Get all arenas
      Returns:
      the collection of arenas
    • addArena

      public boolean addArena(A arena)
      Add an arena
      Parameters:
      arena - the arena
    • removeArena

      public void removeArena(T identifier)
      Remove an arena
      Parameters:
      identifier - the identifier
    • clearAllArenas

      public void clearAllArenas()
      Clear all arenas
    • createArena

      public Optional<A> createArena(T identifier, Function<T,A> arenaCreator, Consumer<A> onCreateConsumer)
      Create an arena
      Parameters:
      identifier - the identifier
      arenaCreator - the arena creator
      onCreateConsumer - the consumer that will be called when the arena is created
      Returns:
      the created arena