Interface TestServerContext

All Known Subinterfaces:
TestDedicatedServerContext

@NonExtendable public interface TestServerContext
Context for a client gametest containing various helpful functions while a server (integrated or dedicated) is running.

Functions in this class can only be called on the client gametest thread.

  • Method Summary

    Modifier and Type
    Method
    Description
    <T, E extends Throwable>
    T
    computeOnServer(org.apache.commons.lang3.function.FailableFunction<MinecraftServer,T,E> function)
    Runs the given function on the server thread, and returns the result.
    void
    runCommand(String command)
    Runs a command on the server.
    <E extends Throwable>
    void
    runOnServer(org.apache.commons.lang3.function.FailableConsumer<MinecraftServer,E> action)
    Runs the given action on the server thread, and waits for it to complete.
  • Method Details

    • runCommand

      void runCommand(String command)
      Runs a command on the server.
      Parameters:
      command - The command to run
    • runOnServer

      <E extends Throwable> void runOnServer(org.apache.commons.lang3.function.FailableConsumer<MinecraftServer,E> action) throws E
      Runs the given action on the server thread, and waits for it to complete.
      Type Parameters:
      E - The type of the checked exception that the action throws
      Parameters:
      action - The action to run on the server thread
      Throws:
      E - When the action throws an exception
    • computeOnServer

      <T, E extends Throwable> T computeOnServer(org.apache.commons.lang3.function.FailableFunction<MinecraftServer,T,E> function) throws E
      Runs the given function on the server thread, and returns the result.
      Type Parameters:
      T - The type of the value to return
      E - The type of the checked exception that the function throws
      Parameters:
      function - The function to run on the server thread
      Returns:
      The result of the function
      Throws:
      E - When the function throws an exception