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 classRequest.TargetA recipient of an effect.static classRequest.TypeThe type of incoming packet.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Response.BuilderbuildResponse()Creates aResponse.Builderfor aResponseto this request.static @NotNull RequestfromJSON(@NotNull String json)Creates aRequestobject from JSON.@Nullable IntegergetCost()Gets the cost of the effect specified in this Request.@NotNull StringgetEffect()Gets the name of the effect to play.intgetId()Gets the ID of the incoming packet.StringgetMessage()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.TypegetType()Gets theTypeof the request.@NotNull StringgetViewer()Gets the name of the viewer who triggered the effect.booleanisGlobal()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 aRequestobject 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 theTypeof 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.Builderfor aResponseto this request.- Returns:
- new response builder
-
-