Class WallStatesPluginLoader

java.lang.Object
net.regsirius06.engine.plugins.loaders.DefaultPluginLoader<WallState>
net.regsirius06.engine.plugins.loaders.WallStatesPluginLoader
All Implemented Interfaces:
PluginLoader<WallState>

public final class WallStatesPluginLoader extends DefaultPluginLoader<WallState>
A PluginLoader implementation for loading WallState plugins. This class extends DefaultPluginLoader to load plugins of type WallState and categorizes them into different types based on their generability, emptiness, and light status.

The loader provides methods to retrieve generable wall states, lights, and empty states separately, and also allows for selecting a random wall state or creating a new random instance of a WallState plugin.

  • Constructor Details

    • WallStatesPluginLoader

      public WallStatesPluginLoader(@NotNull @NotNull Class<? extends Core> type)
      Constructs a new WallStatesPluginLoader for the given core type.

      This constructor initializes the loader and automatically loads the wall state plugins using the DefaultPluginLoader.loadPlugins() method.

      Parameters:
      type - the core type to associate with the loader
  • Method Details

    • loadPlugins

      public void loadPlugins()
      Loads all available WallState plugins and categorizes them into three groups: generable walls, generable lights, and generable empties.

      Generable walls are walls that are not empty and are not of type End. Generable lights are walls that have a light state, and generable empties are walls that are empty.

      Specified by:
      loadPlugins in interface PluginLoader<WallState>
      Overrides:
      loadPlugins in class DefaultPluginLoader<WallState>
    • getGenerableWalls

      public List<? extends WallState> getGenerableWalls()
      Returns the list of generable wall states.

      Generable walls are walls that are not empty and are not of type End.

      Returns:
      a list of generable wall states
    • getGenerableLights

      public List<? extends WallState> getGenerableLights()
      Returns the list of generable light wall states.
      Returns:
      a list of generable light wall states
    • getGenerableEmpties

      public List<? extends WallState> getGenerableEmpties()
      Returns the list of generable empty wall states.
      Returns:
      a list of generable empty wall states
    • getRandomWallStateInstance

      public WallState getRandomWallStateInstance(@NotNull @NotNull List<? extends WallState> list)
      Returns a random WallState from the provided list.
      Parameters:
      list - the list from which a random wall state will be selected
      Returns:
      a randomly selected wall state
    • getNewRandomWallState

      @NotNull public @NotNull WallState getNewRandomWallState(@NotNull @NotNull List<? extends WallState> list) throws RuntimeException
      Creates and returns a new instance of a random WallState from the provided list.

      This method uses reflection to instantiate a new object of the selected WallState type from the list.

      Parameters:
      list - the list from which a new random wall state will be instantiated
      Returns:
      a new instance of a randomly selected wall state
      Throws:
      RuntimeException - if there is an error instantiating the wall state