Interface SectionManager


public interface SectionManager
Prodrivers Commons Section Manager

Contains methods to manage and interact with Prodrivers Commons Sections. Use this class to gather information, about sections, players, move players between sections and register new sections.

Before actually moving a player, a PlayerChangeSectionEvent will be triggered and can be cancelled.

Used implementation can be changed in configuration.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Constant that contains the root node's name.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Build the section tree.
    boolean
    enter(org.bukkit.entity.Player player)
    Make a player enter his current section's parent section.
    boolean
    enter(org.bukkit.entity.Player player, String sectionName)
    Make a player enter a section by section name.
    getCurrentSection(org.bukkit.OfflinePlayer player)
    Get a player's current section instance
    Get the root section instance.
    Get a section instance by its name.
    Get all registered sections.
    void
    register(Section section)
    Register a new section instance against the Prodrivers Commons infrastructure
    void
    register(Section section, boolean silent)
    Register a new section instance against the Prodrivers Commons infrastructure
    boolean
    register(org.bukkit.entity.Player player)
    Registers a player against the Prodrivers Commons infrastructure.
    void
    ui(String sectionName, org.bukkit.entity.Player player)
    Opens a selection UI for a specific section.
    void
    unregister(org.bukkit.OfflinePlayer player)
    Unregisters a player from the Prodrivers Commons infrastructure.
  • Field Details

  • Method Details

    • enter

      Make a player enter his current section's parent section.
      Parameters:
      player - Player to be moved
      Returns:
      true if player was correctly moved to parent section
      Throws:
      NoCurrentSectionException - The player does not have a current section
      NoParentSectionException - The player's current section does not have a parent section
      IllegalSectionLeavingException - The current section forbids the player to go to the parent section
      IllegalSectionEnteringException - The player should not enter the parent section
    • enter

      boolean enter(org.bukkit.entity.Player player, String sectionName) throws InvalidSectionException, IllegalSectionLeavingException, IllegalSectionEnteringException
      Make a player enter a section by section name. If the current section force a specific target section, this method will fail gracefully.
      Parameters:
      player - Player to be moved
      sectionName - Section name to go to
      Returns:
      true if player was correctly moved to specified section
      Throws:
      InvalidSectionException - Invalid section name provided
      IllegalSectionLeavingException - A section along the path the player has to walk forbids the player to leave it
      IllegalSectionEnteringException - A section along the path the player has to walk forbids the player from entering it
    • register

      void register(Section section) throws NullPointerException
      Register a new section instance against the Prodrivers Commons infrastructure
      Parameters:
      section - Prodrivers Commons-compatible section to register
      Throws:
      NullPointerException - Provided section is null
    • register

      void register(Section section, boolean silent) throws NullPointerException
      Register a new section instance against the Prodrivers Commons infrastructure
      Parameters:
      section - Prodrivers Commons-compatible section to register
      silent - if true, do not log a message on successful registration
      Throws:
      NullPointerException - Provided section is null
    • register

      boolean register(org.bukkit.entity.Player player)
      Registers a player against the Prodrivers Commons infrastructure.

      Required before any interaction with Prodrivers Commons and dependent plugins. This action is automatically performed by the default section manager on player login, if it is used.

      Parameters:
      player - Player to register
      Returns:
      true if player was correctly registered
    • unregister

      void unregister(org.bukkit.OfflinePlayer player)
      Unregisters a player from the Prodrivers Commons infrastructure.

      Once a player is unregistered, no further interaction with Prodrivers Commons and dependent plugins should happen. This action is automatically performed by the default section manager on player logout, if it is used.

      Parameters:
      player - Player to unregister
    • getCurrentSection

      Section getCurrentSection(org.bukkit.OfflinePlayer player)
      Get a player's current section instance
      Parameters:
      player - Player to consider
      Returns:
      Player's section instance if possible or null
    • getSections

      Iterable<Section> getSections()
      Get all registered sections.
      Returns:
      Iterator going through to all sections
    • getSection

      Section getSection(String name)
      Get a section instance by its name.
      Parameters:
      name - Name of the section instance to return
      Returns:
      Section instance if possible or null
    • getRootSection

      Section getRootSection()
      Get the root section instance. Should never be null.
      Returns:
      Root section instance
    • buildSectionTree

      void buildSectionTree()
      Build the section tree. Fills, for each node, its parent and children. Creates intermediary nodes whenever needed.

      This method is automatically called by Prodrivers Commons on server activation.

    • ui

      void ui(String sectionName, org.bukkit.entity.Player player) throws InvalidSectionException, InvalidUIException
      Opens a selection UI for a specific section.
      Parameters:
      sectionName - Section's full name to open UI for
      player - Player that opened the selection UI
      Throws:
      InvalidSectionException - No corresponding section exists to provided name
      InvalidUIException - Section reports to have custom UI, but does not implement it