Package io.github.apfelcreme.Pipes.Pipe
Class AbstractPipePart
java.lang.Object
io.github.apfelcreme.Pipes.Pipe.AbstractPipePart
- Direct Known Subclasses:
ChunkLoader
,PipeInput
,PipeOutput
public abstract class AbstractPipePart extends Object
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractPipePart.Option<T>
static class
AbstractPipePart.OptionsList
static class
AbstractPipePart.Value<T>
-
Field Summary
Fields Modifier and Type Field Description static org.bukkit.NamespacedKey
OPTIONS_KEY
static org.bukkit.NamespacedKey
STORED_TYPE_KEY
static org.bukkit.NamespacedKey
TYPE_KEY
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractPipePart(PipesItem type, org.bukkit.Location location)
-
Method Summary
Modifier and Type Method Description void
applyBook(org.bukkit.inventory.ItemStack book)
Apply the settings stored in a book to this pipe partboolean
equals(Object o)
protected AbstractPipePart.Option<?>
getAvailableOption(String name)
Returns the enum constant of this type with the specified name.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 bookorg.bukkit.block.Container
getHolder()
returns the inventory holder of pipe partSimpleLocation
getLocation()
returns the location of this pipe part<T> T
getOption(AbstractPipePart.Option<T> option)
Get a certain option of this pipe part<T> T
getOption(AbstractPipePart.Option<T> option, AbstractPipePart.Value<T> defaultValue)
Get a certain option of this pipe partprotected abstract AbstractPipePart.Option<?>[]
getOptions()
Get all possible optionsprotected String
getOptionsString()
Generate a mapped string of the options to write to the block's namePipesItem
getType()
Get the type of this pipe part<T> AbstractPipePart.Value<T>
getValue(AbstractPipePart.Option<T> option)
Get a certain option value of this pipe part<T> AbstractPipePart.Value<T>
getValue(AbstractPipePart.Option<T> option, AbstractPipePart.Value<T> defaultValue)
Get a certain option value of this pipe partint
hashCode()
<T> void
setOption(AbstractPipePart.Option<T> option, AbstractPipePart.Value<T> value)
Set an option of this output.<T> void
setOption(AbstractPipePart.Option<T> option, AbstractPipePart.Value<T> value, boolean save)
Set an option of this output.void
showGui(org.bukkit.entity.Player player)
Show the parts GUI if it has oneString
toString()
-
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
-
-
Method Details
-
getType
Get the type of this pipe part- Returns:
- The type of this pipe part
-
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
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 getdefaultValue
- 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
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
Get a certain option of this pipe part- Type Parameters:
T
- The type of the value- Parameters:
option
- The option to getdefaultValue
- 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 IllegalArgumentExceptionSet 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 setvalue
- 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 setvalue
- The value to set the option tosave
- Whether or not to save the option after setting the value- Throws:
IllegalArgumentException
- When the values type is not compatible with the option
-
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
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
Get all possible options- Returns:
- All possible options of this part
-
getAvailableOption
protected AbstractPipePart.Option<?> getAvailableOption(String name) throws IllegalArgumentExceptionReturns 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
Apply the settings stored in a book to this pipe part- Parameters:
book
- the book to apply- Throws:
IllegalArgumentException
- if the item is not a book or the settings stored are invalid
-
equals
-
toString
-
hashCode
public int hashCode()
-