Package io.github.apfelcreme.Pipes.Pipe
Class AbstractPipePart
java.lang.Object
io.github.apfelcreme.Pipes.Pipe.AbstractPipePart
- Direct Known Subclasses:
ChunkLoader
,PipeInput
,PipeOutput
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
static class
-
Field Summary
Modifier and TypeFieldDescriptionstatic final org.bukkit.NamespacedKey
static final org.bukkit.NamespacedKey
static final org.bukkit.NamespacedKey
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractPipePart
(PipesItem type, org.bukkit.Location location) -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyBook
(org.bukkit.command.CommandSender player, org.bukkit.inventory.ItemStack book) Apply the settings stored in a book to this pipe partboolean
protected AbstractPipePart.Option<?>
getAvailableOption
(String name) Returns the enum constant of this type with the specified name.abstract String[]
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
returns the inventory holder of pipe partreturns 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<?>[]
Get all possible optionsprotected String
Generate a mapped string of the options to write to the block's namegetType()
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 onetoString()
-
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 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 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 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 bookbook
- 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()
-