Class Request

    • Constructor Detail

      • Request

        @AvailableSince("3.5.0")
        @Experimental
        public Request​(int id,
                       @NotNull
                       @NotNull Request.Type type,
                       @Nullable
                       @Nullable String effect,
                       @Nullable
                       @Nullable String viewer,
                       @Nullable
                       @Nullable String message,
                       @Nullable
                       @Nullable Integer cost,
                       @Nullable
                       @Nullable Duration duration,
                       Request.Target @Nullable [] targets,
                       Object @Nullable [] parameters)
                throws IllegalArgumentException
        Instantiates a Request with the given parameters.

        This constructor is marked as experimental because it is frequently deprecated and eventually removed in new releases. Please use Request.Builder where possible instead.

        Parameters:
        id - the ID of the request
        effect - the effect to be played
        message - the message to be displayed
        viewer - the viewer who requested the effect
        cost - the cost of the effect
        duration - the duration of the effect
        type - the packet type to send
        targets - the targets of the effect
        parameters - the miscellaneous parameters of the effect
        Throws:
        IllegalArgumentException - If a provided argument is invalid. Specifically:
        • if the given ID is negative
        • if the given packet type is null
        • if the given packet type is an effect type and the effect or viewer is null
        • if the given packet type is not an Request.Type.isEffectType() effect type} and the effect, viewer, cost, or targets is non-null
        • if the given packet type is Request.Type.LOGIN and the message is null
        Since:
        3.5.0
      • Request

        @AvailableSince("3.3.0")
        public Request​(int id,
                       @NotNull
                       @NotNull Request.Type type,
                       @Nullable
                       @Nullable String message)
                throws IllegalArgumentException
        Instantiates a non-effect type Request with the given parameters.
        Parameters:
        id - the ID of the request
        type - the packet type to send
        message - the message to be displayed
        Throws:
        IllegalArgumentException - If a provided argument is invalid. Specifically:
        • if the given ID is negative
        • if the given packet type is null
        • if the given packet type is an effect type
        • if the given packet type is Request.Type.LOGIN and the message is null
        Since:
        3.3.0
    • Method Detail

      • fromJSON

        @NotNull
        @CheckReturnValue
        @Internal
        @AvailableSince("1.0.0")
        public static @NotNull Request fromJSON​(@NotNull
                                                @NotNull String json)
                                         throws com.google.gson.JsonSyntaxException
        Creates a Request object from JSON.
        Parameters:
        json - input json data from the Crowd Control TCP server
        Returns:
        a new Request object
        Throws:
        com.google.gson.JsonSyntaxException - the JSON failed to be parsed
        Since:
        1.0.0
      • getId

        @AvailableSince("1.0.0")
        @CheckReturnValue
        public int getId()
        Gets the ID of the incoming packet. Corresponds to a unique transaction.
        Returns:
        packet ID
        Since:
        1.0.0
      • getMessage

        @AvailableSince("3.0.0")
        @Nullable
        @CheckReturnValue
        public @Nullable String getMessage()
        Gets the message from the incoming packet.
        Returns:
        message
        Since:
        3.0.0
      • getEffect

        @AvailableSince("1.0.0")
        @Nullable
        @CheckReturnValue
        public @Nullable String getEffect()
        Gets the name of the effect to play. May be null if getType() is not an effect type.
        Returns:
        effect name
        Since:
        1.0.0
      • getViewer

        @AvailableSince("1.0.0")
        @NotNull
        @CheckReturnValue
        public @NotNull String getViewer()
        Gets the name of the viewer who triggered the effect.
        Returns:
        viewer name
        Since:
        1.0.0
      • getCost

        @AvailableSince("2.0.0")
        @Nullable
        @CheckReturnValue
        public @Nullable Integer getCost()
        Gets the cost of the effect specified in this Request.
        Returns:
        effect cost
        Since:
        2.0.0
      • getType

        @AvailableSince("1.0.0")
        @NotNull
        @CheckReturnValue
        public @NotNull Request.Type getType()
        Gets the Type of the request.
        Returns:
        request type
        Since:
        1.0.0
      • getTargets

        @AvailableSince("3.0.0")
        @CheckReturnValue
        public Request.Target @NotNull [] getTargets()
        Gets the streamers being targeted by this effect. An empty array suggests that all players may be targeted.
        Returns:
        possibly empty array of Request.Target
        Since:
        3.0.0
      • getDuration

        @AvailableSince("3.5.0")
        @Nullable
        @CheckReturnValue
        public @Nullable Duration getDuration()
        Gets the streamer-specified duration of this effect. A null value suggests that the effect is not timed.
        Returns:
        duration if applicable, null otherwise
        Since:
        3.5.0
      • getParameters

        @AvailableSince("3.5.0")
        @CheckReturnValue
        public Object @Nullable [] getParameters()
        Gets the miscellaneous parameters for this effect. This may be used by, for example, sliders defined in your CS file.
        Returns:
        array of objects if applicable, null otherwise
        Since:
        3.5.0
      • isGlobal

        @AvailableSince("3.0.0")
        @CheckReturnValue
        public boolean isGlobal()
        Determines if this Request is triggering an effect for all users.
        Returns:
        if the triggered effect is global
        Since:
        3.0.0
      • toJSON

        @AvailableSince("3.3.0")
        @Internal
        @NotNull
        @CheckReturnValue
        public @NotNull String toJSON()
        Outputs this object as a JSON string.
        Specified by:
        toJSON in interface JsonObject
        Returns:
        JSON string
        Since:
        3.3.0
      • equals

        public boolean equals​(@Nullable
                              @Nullable Object o)
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object