Class CaptureChannel<T>

java.lang.Object
org.geysermc.conduit.CaptureChannel<T>
Type Parameters:
T - the type of item emitted

public class CaptureChannel<T> extends Object
Hands results from an Intercept handler to whoever is listening.

Declare one as a static field marked Intercept.Capture and it is created when the handler is registered. Listen through VirtualMachine.capture(CaptureChannel, Consumer), which scopes the listener to a single run.

  • Method Details

    • emit

      public void emit(T item)
      Sends an item to every listener. A listener that throws doesn't stop the others.
      Parameters:
      item - the item
    • listen

      public void listen(Consumer<T> listener)
      Adds a listener until it is silenced.
      Parameters:
      listener - the listener
    • silence

      public boolean silence(Consumer<T> listener)
      Removes a listener.
      Parameters:
      listener - the listener
      Returns:
      whether it was registered
    • create

      public static <T> CaptureChannel<T> create()
      Creates an empty channel.
      Type Parameters:
      T - the type of item emitted
      Returns:
      a new channel with no listeners