Class PipeManager
java.lang.Object
io.github.apfelcreme.Pipes.Manager.PipeManager
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a block to a pipe while checking settings and caching the locationvoid
addPart
(Pipe pipe, AbstractPipePart pipePart) Add a part to a pipe while checking settings and caching the locationcreatePipePart
(PipesItem item, org.bukkit.block.Block block) Create a new pipe partgetCachedPipePart
(SimpleLocation location) Get the pipes part.static PipeManager
returns the PipeManager instancereturns the cache for blocks that can belong to multiple pipes (outputs and chunk loaders)getPipeByInput
(SimpleLocation location) Get the pipe by an input at a location.com.google.common.cache.Cache<SimpleLocation,
Pipe> returns the pipe cachegetPipePart
(org.bukkit.block.Block block) Get the pipes part.getPipePart
(org.bukkit.block.BlockState state) Get the pipes part.returns the cache for pipe partsgetPipes
(org.bukkit.block.Block block) Get the pipe for a blockgetPipes
(org.bukkit.block.Block block, boolean cacheOnly) Get the pipe for a blockgetPipesSafe
(SimpleLocation location) Get the pipe that is at that location, returns an empty set instead of throwing an exceptiongetPipesSafe
(SimpleLocation location, boolean cacheOnly) Get the pipe that is at that location, returns an empty set instead of throwing an exceptiongetPipesSafe
(org.bukkit.block.Block block) Get the pipe, returns an empty set instead of throwing an exceptiongetPipesSafe
(org.bukkit.block.Block block, boolean cacheOnly) Get the pipe, returns an empty set instead of throwing an exceptionreturns the cache for blocks that can only belong to a single pipe (and aren't inputs)isPipe
(org.bukkit.block.Block startingPoint) checks if the block is part of a pipe.mergePipes
(Set<Pipe> pipes) Merge multiple pipes into onevoid
removePart
(Pipe pipe, AbstractPipePart pipePart) Remove a part from a pipevoid
removePipe
(Pipe pipe)
-
Method Details
-
getPipeCache
returns the pipe cache- Returns:
- the pipe cache
-
getSingleCache
returns the cache for blocks that can only belong to a single pipe (and aren't inputs)- Returns:
- the single cache
-
getMultiCache
returns the cache for blocks that can belong to multiple pipes (outputs and chunk loaders)- Returns:
- the multi cache
-
getPipePartCache
returns the cache for pipe parts- Returns:
- the pipe part cache
-
getInstance
returns the PipeManager instance- Returns:
- the PipeManager instance
-
getPipeByInput
public Pipe getPipeByInput(SimpleLocation location) throws ChunkNotLoadedException, TooManyOutputsException, PipeTooLongException Get the pipe by an input at a location. This will only lookup in the input cache and no other one. If none is found it will try to calculate the pipe that starts at that position- Parameters:
location
- the location the input is at- Returns:
- a Pipe or
null
- Throws:
ChunkNotLoadedException
- When the pipe reaches into a chunk that is not loadedPipeTooLongException
- When the pipe is too longTooManyOutputsException
- when the pipe has too many outputs
-
getPipesSafe
Get the pipe that is at that location, returns an empty set instead of throwing an exception- Parameters:
location
- The location- Returns:
- the pipes; an empty set if none were found or an error occurred
-
getPipesSafe
Get the pipe that is at that location, returns an empty set instead of throwing an exception- Parameters:
location
- The locationcacheOnly
- Only look in the cache, don't search for new ones- Returns:
- the pipes; an empty set if none were found or an error occurred
-
getPipesSafe
Get the pipe, returns an empty set instead of throwing an exception- Parameters:
block
- the block to get the pipe for- Returns:
- the pipes; an empty set if none were found or an error occurred
-
getPipesSafe
Get the pipe, returns an empty set instead of throwing an exception- Parameters:
block
- the block to get the pipe forcacheOnly
- Only look in the cache, don't search for new ones- Returns:
- the pipes; an empty set if none were found or an error occurred
-
getPipes
public Set<Pipe> getPipes(org.bukkit.block.Block block) throws ChunkNotLoadedException, PipeTooLongException, TooManyOutputsException Get the pipe for a block- Parameters:
block
- The block- Returns:
- the pipes; an empty set if none were found
- Throws:
ChunkNotLoadedException
- When the pipe reaches into a chunk that is not loadedPipeTooLongException
- When the pipe is too longTooManyOutputsException
- when the pipe has too many outputs
-
getPipes
public Set<Pipe> getPipes(org.bukkit.block.Block block, boolean cacheOnly) throws ChunkNotLoadedException, PipeTooLongException, TooManyOutputsException Get the pipe for a block- Parameters:
block
- The blockcacheOnly
- Only look in the cache, don't search for new ones- Returns:
- the pipes; an empty set if none were found
- Throws:
ChunkNotLoadedException
- When the pipe reaches into a chunk that is not loadedPipeTooLongException
- When the pipe is too longTooManyOutputsException
- when the pipe has too many outputs
-
removePipe
-
addPart
Add a part to a pipe while checking settings and caching the location- Parameters:
pipe
- the pipe to add topipePart
- the part to add- Throws:
TooManyOutputsException
- when the pipe has too many outputs
-
removePart
Remove a part from a pipe- Parameters:
pipe
- the pipe to remove frompipePart
- the part to remove
-
addBlock
Add a block to a pipe while checking settings and caching the location- Parameters:
pipe
- the pipe to add toblock
- the block to add- Throws:
PipeTooLongException
- When the pipe is too long
-
mergePipes
Merge multiple pipes into one- Parameters:
pipes
- The pipes to merge- Returns:
- the merged Pipe or
null
if they couldn't be merged - Throws:
PipeTooLongException
- When the pipe is too longTooManyOutputsException
- when the pipe has too many outputs
-
isPipe
public Pipe isPipe(org.bukkit.block.Block startingPoint) throws ChunkNotLoadedException, TooManyOutputsException, PipeTooLongException checks if the block is part of a pipe.- Parameters:
startingPoint
- a block- Returns:
- a pipe, if there is one
- Throws:
ChunkNotLoadedException
- When the pipe reaches into a chunk that is not loadedPipeTooLongException
- When the pipe is too longTooManyOutputsException
- when the pipe has too many outputs
-
createPipePart
Create a new pipe part- Parameters:
item
- The PipesItem to create the part fromblock
- The block to create the part at- Returns:
- The pipepart
-
getPipePart
Get the pipes part. Will try to lookup the part in the cache first, if not found it will create a new one.- Parameters:
block
- the block to get the part for- Returns:
- the pipespart or null if the block isn't one
-
getPipePart
Get the pipes part. Will try to lookup the part in the cache first, if not found it will create a new one.- Parameters:
state
- the block's state to get the part for- Returns:
- the pipespart or null if the block isn't one
-
getCachedPipePart
Get the pipes part. Will try to lookup the part in the cache first, if not found it will create a new one.- Parameters:
location
- the block to get the part for- Returns:
- the pipespart or
-