Class Request

    • 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
      • getQuantity

        @AvailableSince("3.6.0")
        @CheckReturnValue
        @Nullable
        public @Nullable Integer getQuantity()
        Gets the quantity of the item to be added or removed. May be null for non-effect requests or for effects that do not involve items.
        Returns:
        the quantity of the item to be added or removed
        Since:
        3.6.0
      • getQuantityOrDefault

        @AvailableSince("3.6.0")
        @CheckReturnValue
        public int getQuantityOrDefault()
        Gets the quantity of the item to be added or removed. If null or below 1, returns 1.
        Returns:
        the quantity of the item to be added or removed
        Since:
        3.6.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
      • getOriginatingSocket

        @AvailableSince("3.6.0")
        @Internal
        @Nullable
        public @Nullable SocketManager getOriginatingSocket()
        Gets the Socket that this Request originated from.
        Returns:
        originating socket
        Since:
        3.6.0
      • getSource

        @AvailableSince("3.6.0")
        @Nullable
        public @Nullable Request.Source getSource()
        Gets the streamer that this Request originated from.
        Returns:
        originating streamer
        Since:
        3.6.0
      • setSource

        @Internal
        public void setSource​(@Nullable
                              @Nullable Request.Source source)
        Sets the streamer that this Request originated from.

        This method is for internal use only, see Request.Builder.source(Source) if you need to set this value.

        Parameters:
        source - originating streamer
        Since:
        3.6.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