Class Response

  • All Implemented Interfaces:
    JsonObject

    public final class Response
    extends Object
    implements JsonObject
    An outgoing packet to the Crowd Control TCP server carrying the result of executing a requested effect.
    See Also:
    Request
    • Constructor Detail

      • Response

        @CheckReturnValue
        public Response​(@NotNull
                        @NotNull Request request,
                        @NotNull
                        Response.ResultType type,
                        @NotNull
                        @NotNull String message,
                        long timeRemaining)
        Constructs a response to a Request given its ID, the result of executing the effect, and an associated message.
        Parameters:
        request - originating request
        type - result of execution
        message - result message
        timeRemaining - remaining duration for the referenced effect in milliseconds
    • Method Detail

      • getRequest

        public Request getRequest()
        Gets the unique Request that caused this response.
        Returns:
        original request
      • getId

        @CheckReturnValue
        public int getId()
        Gets the ID of the outgoing packet. Corresponds to a unique transaction.
        Returns:
        packet ID
      • getResultType

        @NotNull
        @CheckReturnValue
        public Response.ResultType getResultType()
        Gets the result of executing an effect.
        Returns:
        effect result
      • getMessage

        @NotNull
        @CheckReturnValue
        public @NotNull String getMessage()
        Gets the message that will be delivered along with the result.
        Returns:
        result message
      • getTimeRemaining

        @CheckReturnValue
        public long getTimeRemaining()
        Gets the milliseconds left until the referenced effect ends.
        Returns:
        effect duration in milliseconds
      • toJSON

        @NotNull
        @CheckReturnValue
        public @NotNull String toJSON()
        Outputs this object as a JSON string for use in the server connection.
        Specified by:
        toJSON in interface JsonObject
        Returns:
        JSON string
      • toBuilder

        @NotNull
        @CheckReturnValue
        public @NotNull Response.Builder toBuilder()
        Gets a mutable Response.Builder representing this Response.
        Returns:
        new builder