Class Renderer

java.lang.Object
ke.ric.renderer.api.Renderer
All Implemented Interfaces:
AutoCloseable

public final class Renderer extends Object implements AutoCloseable
Plugin-owned entry point for immutable snapshots and live camera streams. Create one facade on the server thread, normally in onEnable(), and retain it for your plugin's lifetime. Closing it cancels owned work and removes its temporary stream outputs; owner disable also closes it automatically. Saved photographs remain in provider-owned storage.

Use snapshot(Entity) for a one-off camera and stream(Entity) for a tracked feed. Living entities use their eye position; the source entity is excluded from its own capture. The advanced session() and client() routes remain available for scene composition, assets, attachments and custom jobs.


 Renderer renderer = Renderer.forPlugin(plugin);
 renderer.snapshot(player).fov(75).capture(frame -> {
     // Bukkit operations are safe here: consumer callbacks run on the server thread.
     plugin.getLogger().info("Captured " + frame.image().getWidth() + " pixels across");
 });
 

Consumer overloads dispatch to the server thread and recheck lifecycle before delivery. Ordinary CompletableFuture continuations keep Java's normal threading semantics. Never block the server thread waiting for a capture, render, conversion or save. The fluent and creative controls require a matching development provider; older providers reject unsupported optional capabilities rather than silently ignoring them.

  • Method Summary

    Modifier and Type
    Method
    Description
    Discovers the current low-level client on the server thread.
    void
    Stops owned work and streams and releases listeners, the client and conversion workers.
    static Renderer
    forPlugin(org.bukkit.plugin.Plugin owner)
    Creates a facade for an enabled plugin.
    Returns the advanced session owned by this facade.
    snapshot(org.bukkit.entity.Entity source)
    Starts a snapshot whose pose is read on the server thread when capture begins.
    snapshot(org.bukkit.Location camera)
    Starts a snapshot from a defensive copy of a Bukkit location, including yaw and pitch.
    stream(Supplier<org.bukkit.Location> source)
    Starts a feed that samples a location supplier on the server thread when useful work can begin.
    stream(org.bukkit.entity.Entity source)
    Starts a feed that follows a live entity.
    stream(org.bukkit.Location camera)
    Starts a live feed from a defensive copy of a fixed camera pose.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • forPlugin

      public static Renderer forPlugin(org.bukkit.plugin.Plugin owner)
      Creates a facade for an enabled plugin. Service discovery happens when work first needs it.
      Parameters:
      owner - consuming plugin, not the renderer provider
      Returns:
      a new facade whose lifecycle belongs to the owner
      Throws:
      IllegalStateException - if called outside the server thread
      RendererException - if the owner is disabled
      NullPointerException - if owner is null
    • session

      public RendererSession session()
      Returns the advanced session owned by this facade. Do not close it while continuing to use the facade.
      Returns:
      the session for explicit capture/render workflows
      Throws:
      RendererException - if this facade is closed
    • client

      public RendererClient client()
      Discovers the current low-level client on the server thread. Do not retain the returned client across provider replacement; call this method again when starting new work.
      Returns:
      an active client for scene composition, assets, attachments and custom jobs
      Throws:
      IllegalStateException - if called outside the server thread
      RendererException - if the owner or provider is unavailable
    • snapshot

      public SnapshotBuilder snapshot(org.bukkit.Location camera)
      Starts a snapshot from a defensive copy of a Bukkit location, including yaw and pitch.
      Parameters:
      camera - pose in a loaded world; later changes to this Location are ignored
      Returns:
      immutable settings with Classic 128×128, 70° vertical FOV, zero roll and radius 16
      Throws:
      NullPointerException - if camera is null
    • snapshot

      public SnapshotBuilder snapshot(org.bukkit.entity.Entity source)
      Starts a snapshot whose pose is read on the server thread when capture begins. A living entity uses its eye pose; another entity uses its location. The source UUID is excluded automatically.
      Parameters:
      source - live camera entity; a dead, invalid or offline source makes capture fail
      Returns:
      immutable default snapshot settings
      Throws:
      NullPointerException - if source is null
    • stream

      public StreamBuilder stream(org.bukkit.Location camera)
      Starts a live feed from a defensive copy of a fixed camera pose.
      Parameters:
      camera - pose in a loaded world; later Location mutations are ignored
      Returns:
      immutable stream settings, targeting 20 FPS with bounded world-evidence reuse
    • stream

      public StreamBuilder stream(org.bukkit.entity.Entity source)
      Starts a feed that follows a live entity. Living entities use their eye pose; the camera entity is excluded. Death, invalidation or player logout ends the feed.
      Parameters:
      source - entity whose pose is sampled on the server thread
      Returns:
      immutable stream settings, targeting 20 FPS with bounded world-evidence reuse
    • stream

      public StreamBuilder stream(Supplier<org.bukkit.Location> source)
      Starts a feed that samples a location supplier on the server thread when useful work can begin. Returning null ends the feed normally; throwing an exception fails it. Keep the supplier quick.
      Parameters:
      source - supplier of the next camera pose in a loaded world
      Returns:
      immutable stream settings, targeting 20 FPS with bounded world-evidence reuse
    • close

      public void close()
      Stops owned work and streams and releases listeners, the client and conversion workers. This method is idempotent. It removes only owned temporary output; durable photos remain saved.
      Specified by:
      close in interface AutoCloseable
      Throws:
      IllegalStateException - if called outside the server thread