Interface ChunkManager


@DoNotStore public interface ChunkManager
Manages chunks for a ServerWorld.
  • Method Details

    • world

      ServerWorld world()
      Gets the ServerWorld this manager operates upon.
      Returns:
      The ServerWorld
    • valid

      boolean valid(Ticket ticket)
      Checks if the provided Ticket is valid for the world this manager represents.
      Parameters:
      ticket - The ticket to check.
      Returns:
      true if so
    • timeLeft

      Ticks timeLeft(Ticket ticket)
      Gets the Ticks remaining on the supplied ticket.
      Returns:
      The Ticks
    • requestTicket

      Ticket requestTicket(TicketType type, Vector3i chunkOrigin, int radius)
      Request a Ticket for the given TicketType.
      Parameters:
      type - The type of ticket to request.
      chunkOrigin - The chunk co-ordinates of the central WorldChunk affected by this Ticket
      radius - The radius of the area, in chunks, that this Ticket affects.
      Returns:
      The ticket, if granted.
    • renewTicket

      boolean renewTicket(Ticket ticket)
      Attempts to renew this ticket, resetting the lifetime to the default.

      If this ticket is no longer valid, it cannot be renewed. Instead, you should requestTicket(TicketType, Vector3i, int) a new one.

      Parameters:
      ticket - The ticket to attempt to renew
      Returns:
      true if successful
    • releaseTicket

      boolean releaseTicket(Ticket ticket)
      Releases the provided Ticket, allowing the chunk position represented by the given ticket to be unloaded (if it is not being kept loaded by other means).
      Parameters:
      ticket - The ticket to release.
    • findTickets

      Collection<Ticket> findTickets(Vector3i chunkOrigin)
      Gets all currently active tickets that have the given chunk origin.
      Parameters:
      chunkOrigin - The chunk co-ordinates of the origin.
      Returns:
      A Collection of tickets
    • findTickets

      Collection<Ticket> findTickets(TicketType type)
      Gets all currently active tickets that are of the provided TicketType.
      Parameters:
      type - The TicketType to retrieve tickets for
      Returns:
      A Collection of tickets
    • findTickets

      Collection<Ticket> findTickets()
      Gets all currently active tickets.
      Returns:
      A Collection of tickets
    • regenerateChunk

      default CompletableFuture<Boolean> regenerateChunk(Vector3i chunkPosition)
      Regenerates a chunk at the given chunk coordinate position.

      Care should be taken to check the result of the future, as an exception may be provided if the regeneration was not successful.

      Users must not use get or join on this future. Doing so may end up causing a deadlock on the server.

      Parameters:
      chunkPosition - The chunk position to regenerate
      Returns:
      The regenerated chunk, if available
    • regenerateChunk

      default CompletableFuture<Boolean> regenerateChunk(int cx, int cy, int cz)
      Regenerates a chunk at the given chunk coordinates.

      Care should be taken to check the result of the future, as an exception may be provided if the regeneration was not successful.

      Users must not use get or join on this future. Doing so may end up causing a deadlock on the server.

      Parameters:
      cx - The chunk x coordinate
      cy - The chunk y coordinate
      cz - The chunk z coordinate
      Returns:
      The regenerated chunk, if available
    • regenerateChunk

      default CompletableFuture<Boolean> regenerateChunk(Vector3i chunkPosition, ChunkRegenerateFlag flag)
      Regenerates a chunk at the given chunk coordinate position.

      Care should be taken to check the result of the future, as an exception may be provided if the regeneration was not successful.

      Users must not use get or join on this future. Doing so may end up causing a deadlock on the server.

      Parameters:
      chunkPosition - The chunk position to regenerate
      flag - The chunk regenerate flag to use
      Returns:
      The regenerated chunk, if available
    • regenerateChunk

      CompletableFuture<Boolean> regenerateChunk(int cx, int cy, int cz, ChunkRegenerateFlag flag)
      Regenerates a chunk at the given chunk coordinates.

      Care should be taken to check the result of the future, as an exception may be provided if the regeneration was not successful.

      Users must not use get or join on this future. Doing so may end up causing a deadlock on the server.

      Parameters:
      cx - The chunk x coordinate
      cy - The chunk y coordinate
      cz - The chunk z coordinate
      flag - The chunk regenerate flag to use
      Returns:
      The regenerated chunk, if available