Package dev.qixils.crowdcontrol.socket
Class Request
- java.lang.Object
-
- dev.qixils.crowdcontrol.socket.Request
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Request.Target
A recipient of an effect.static class
Request.Type
The type of incoming packet.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Response.Builder
buildResponse()
Creates aResponse.Builder
for aResponse
to this request.static @NotNull Request
fromJSON(@NotNull String json)
Creates aRequest
object from JSON.@Nullable Integer
getCost()
Gets the cost of the effect specified in this Request.@NotNull String
getEffect()
Gets the name of the effect to play.int
getId()
Gets the ID of the incoming packet.String
getMessage()
Gets the message from the incoming packet.@NotNull Object[]
getParameters()
Gets the arguments supplied by the C# Crowd Control packRequest.Target @NotNull []
getTargets()
Gets the streamers being targeted by this effect.@NotNull Request.Type
getType()
Gets theType
of the request.@NotNull String
getViewer()
Gets the name of the viewer who triggered the effect.boolean
isGlobal()
Determines if this Request is triggering an effect for all users.
-
-
-
Method Detail
-
fromJSON
@NotNull @CheckReturnValue public static @NotNull Request fromJSON(@NotNull @NotNull String json) throws com.google.gson.JsonSyntaxException
Creates aRequest
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
-
getId
@CheckReturnValue public int getId()
Gets the ID of the incoming packet. Corresponds to a unique transaction.- Returns:
- packet ID
-
getMessage
public String getMessage()
Gets the message from the incoming packet.- Returns:
- message
-
getEffect
@NotNull @CheckReturnValue public @NotNull String getEffect()
Gets the name of the effect to play.- Returns:
- effect name
-
getParameters
@NotNull @CheckReturnValue public @NotNull Object[] getParameters()
Gets the arguments supplied by the C# Crowd Control pack- Returns:
- effect parameters
-
getViewer
@NotNull @CheckReturnValue public @NotNull String getViewer()
Gets the name of the viewer who triggered the effect.- Returns:
- viewer name
-
getCost
@Nullable @CheckReturnValue public @Nullable Integer getCost()
Gets the cost of the effect specified in this Request.- Returns:
- effect cost
-
getType
@NotNull @CheckReturnValue public @NotNull Request.Type getType()
Gets theType
of the request.- Returns:
- request type
-
getTargets
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
-
isGlobal
public boolean isGlobal()
Determines if this Request is triggering an effect for all users.- Returns:
- if the triggered effect is global
-
buildResponse
public Response.Builder buildResponse()
Creates aResponse.Builder
for aResponse
to this request.- Returns:
- new response builder
-
-