Class PipeManager

java.lang.Object
io.github.apfelcreme.Pipes.Manager.PipeManager

public class PipeManager extends Object
  • Method Details

    • getPipeCache

      public com.google.common.cache.Cache<SimpleLocation,Pipe> getPipeCache()
      returns the pipe cache
      Returns:
      the pipe cache
    • getSingleCache

      public Map<SimpleLocation,Pipe> getSingleCache()
      returns the cache for blocks that can only belong to a single pipe (and aren't inputs)
      Returns:
      the single cache
    • getMultiCache

      public Map<SimpleLocation,Set<Pipe>> getMultiCache()
      returns the cache for blocks that can belong to multiple pipes (outputs and chunk loaders)
      Returns:
      the multi cache
    • getPipePartCache

      public Map<SimpleLocation,AbstractPipePart> getPipePartCache()
      returns the cache for pipe parts
      Returns:
      the pipe part cache
    • getInstance

      public static PipeManager getInstance()
      returns the PipeManager instance
      Returns:
      the PipeManager instance
    • getPipeByInput

      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 loaded
      PipeTooLongException - When the pipe is too long
      TooManyOutputsException - when the pipe has too many outputs
    • getPipesSafe

      public Set<Pipe> getPipesSafe(SimpleLocation location)
      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

      public Set<Pipe> getPipesSafe(SimpleLocation location, boolean cacheOnly)
      Get the pipe that is at that location, returns an empty set instead of throwing an exception
      Parameters:
      location - The location
      cacheOnly - 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

      public Set<Pipe> getPipesSafe(org.bukkit.block.Block block)
      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

      public Set<Pipe> getPipesSafe(org.bukkit.block.Block block, boolean cacheOnly)
      Get the pipe, returns an empty set instead of throwing an exception
      Parameters:
      block - the block to get the pipe for
      cacheOnly - 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 loaded
      PipeTooLongException - When the pipe is too long
      TooManyOutputsException - 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 block
      cacheOnly - 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 loaded
      PipeTooLongException - When the pipe is too long
      TooManyOutputsException - when the pipe has too many outputs
    • removePipe

      public void removePipe(Pipe pipe)
    • addPart

      public void addPart(Pipe pipe, AbstractPipePart pipePart) throws TooManyOutputsException
      Add a part to a pipe while checking settings and caching the location
      Parameters:
      pipe - the pipe to add to
      pipePart - the part to add
      Throws:
      TooManyOutputsException - when the pipe has too many outputs
    • removePart

      public void removePart(Pipe pipe, AbstractPipePart pipePart)
      Remove a part from a pipe
      Parameters:
      pipe - the pipe to remove from
      pipePart - the part to remove
    • addBlock

      public void addBlock(Pipe pipe, org.bukkit.block.Block block) throws PipeTooLongException
      Add a block to a pipe while checking settings and caching the location
      Parameters:
      pipe - the pipe to add to
      block - the block to add
      Throws:
      PipeTooLongException - When the pipe is too long
    • mergePipes

      public Pipe mergePipes(Set<Pipe> pipes) throws TooManyOutputsException, PipeTooLongException
      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 long
      TooManyOutputsException - 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 loaded
      PipeTooLongException - When the pipe is too long
      TooManyOutputsException - when the pipe has too many outputs
    • createPipePart

      public AbstractPipePart createPipePart(PipesItem item, org.bukkit.block.Block block)
      Create a new pipe part
      Parameters:
      item - The PipesItem to create the part from
      block - The block to create the part at
      Returns:
      The pipepart
    • getPipePart

      public AbstractPipePart getPipePart(org.bukkit.block.Block block)
      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

      public AbstractPipePart getPipePart(org.bukkit.block.BlockState state)
      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

      public AbstractPipePart getCachedPipePart(SimpleLocation location)
      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