Class AbstractPipePart

java.lang.Object
io.github.apfelcreme.Pipes.Pipe.AbstractPipePart
Direct Known Subclasses:
ChunkLoader, PipeInput, PipeOutput

public abstract class AbstractPipePart extends Object
  • Field Details

    • TYPE_KEY

      public static final org.bukkit.NamespacedKey TYPE_KEY
    • OPTIONS_KEY

      public static final org.bukkit.NamespacedKey OPTIONS_KEY
    • STORED_TYPE_KEY

      public static final org.bukkit.NamespacedKey STORED_TYPE_KEY
  • Constructor Details

    • AbstractPipePart

      protected AbstractPipePart(PipesItem type, org.bukkit.Location location)
  • Method Details

    • getType

      public PipesItem getType()
      Get the type of this pipe part
      Returns:
      The type of this pipe part
    • getLocation

      public SimpleLocation getLocation()
      returns the location of this pipe part
      Returns:
      the location of this pipe part
    • getHolder

      public org.bukkit.block.Container getHolder()
      returns the inventory holder of pipe part
      Returns:
      the inventory holder of pipe part
    • getValue

      public <T> AbstractPipePart.Value<T> getValue(AbstractPipePart.Option<T> option)
      Get a certain option value of this pipe part
      Type Parameters:
      T - The type of the value
      Parameters:
      option - The option to get
      Returns:
      The value of the option or null if it wasn't set and there is no default one
    • getValue

      public <T> AbstractPipePart.Value<T> getValue(AbstractPipePart.Option<T> option, AbstractPipePart.Value<T> defaultValue)
      Get a certain option value of this pipe part
      Type Parameters:
      T - The type of the value
      Parameters:
      option - The option to get
      defaultValue - The default value to return if the value wasn't found
      Returns:
      The value of the option or null if it wasn't set
    • getOption

      public <T> T getOption(AbstractPipePart.Option<T> option)
      Get a certain option of this pipe part
      Type Parameters:
      T - The type of the value
      Parameters:
      option - The option to get
      Returns:
      The value of the option or null if it wasn't set and there is no default one
    • getOption

      public <T> T getOption(AbstractPipePart.Option<T> option, AbstractPipePart.Value<T> defaultValue)
      Get a certain option of this pipe part
      Type Parameters:
      T - The type of the value
      Parameters:
      option - The option to get
      defaultValue - The default value to return if the value wasn't found
      Returns:
      The value of the option or null if it wasn't set
    • setOption

      public <T> void setOption(AbstractPipePart.Option<T> option, AbstractPipePart.Value<T> value) throws IllegalArgumentException
      Set an option of this output. This also saves the options to the block
      Type Parameters:
      T - The type of the value
      Parameters:
      option - The option to set
      value - The value to set the option to
      Throws:
      IllegalArgumentException - When the values type is not compatible with the option
    • setOption

      public <T> void setOption(AbstractPipePart.Option<T> option, AbstractPipePart.Value<T> value, boolean save)
      Set an option of this output.
      Type Parameters:
      T - The type of the value
      Parameters:
      option - The option to set
      value - The value to set the option to
      save - Whether or not to save the option after setting the value
      Throws:
      IllegalArgumentException - When the values type is not compatible with the option
    • getOptionsString

      protected String getOptionsString()
      Generate a mapped string of the options to write to the block's name
      Returns:
      The options as a string, mapped as option=value
    • showGui

      public void showGui(org.bukkit.entity.Player player)
      Show the parts GUI if it has one
      Parameters:
      player - The player to show the GUI to
    • getGuiSetup

      public abstract String[] getGuiSetup()
      Get the setup of the GUI with the character 'i' for the block's inventory, 's' and 'z' for settings, 'c' for the copy book
      Returns:
      The setup for the GUI
    • getOptions

      protected abstract AbstractPipePart.Option<?>[] getOptions()
      Get all possible options
      Returns:
      All possible options of this part
    • getAvailableOption

      protected AbstractPipePart.Option<?> getAvailableOption(String name) throws IllegalArgumentException
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - The name of the option to get
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
    • applyBook

      public void applyBook(org.bukkit.command.CommandSender player, org.bukkit.inventory.ItemStack book) throws IllegalArgumentException
      Apply the settings stored in a book to this pipe part
      Parameters:
      player - the player that applied the book
      book - the book to apply
      Throws:
      IllegalArgumentException - if the item is not a book or the settings stored are invalid
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object