Package live.crowdcontrol.cc4j
Class CrowdControl
java.lang.Object
live.crowdcontrol.cc4j.CrowdControl
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final @NotNull Stringprotected final @NotNull Stringprotected final @NotNull Pathprotected final @NotNull ExecutorServiceprotected final @NotNull ExecutorServiceprotected final @NotNull Stringprotected @Nullable GamePackprotected final @NotNull Stringprotected final @NotNull HttpUtilprotected final @NotNull Map<UUID, ConnectedPlayer> static final intAmount of time in seconds that effects are allowed to execute for.protected final @NotNull ScheduledExecutorService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanRegisters an effect which is instantiated upon triggering.booleanRegisters an effect which maintains one object across its lifetime.@NotNull CCPlayerRegisters a player by the provided unique ID.voidvoidcancelByRequestId(@NotNull UUID requestId) Cancels a request given its ID.voidclose()voidexecuteEffect(@NotNull PublicEffectPayload payload, @NotNull ConnectedPlayer source) Executes the provided effect.@NotNull StringgetAppID()Gets the ID of this game's Crowd Control third-party application.@NotNull StringGets the API secret of this game's Crowd Control third-party application.@NotNull PathGets the folder in which players' Crowd Control tokens are stored.@NotNull ExecutorServiceGets the executor service on which effects are to be run.@NotNull ExecutorServiceGets the executor service on which events are to be run.@NotNull StringGets the ID of this game's Crowd Control metadata.@Nullable GamePackGets the data about this game pack.@NotNull StringGets the ID of this game's Crowd Control pack.@NotNull HttpUtilGets the utility for making requests to Crowd Control's HTTP servers.@Nullable CCPlayerGets a registered player by the provided unique ID.getPlayerIds(@NotNull String ccUID) Gets the list of players logged in as the specified user ID.Gets all the currently registered players.@NotNull ScheduledExecutorServiceGets the executor service on which timed effect updates are to be run.protected voidhandleEffectResponse(@NotNull CCEffectResponse response, @NotNull ConnectedPlayer source) booleanisPlayerEffectActive(@NotNull String effectId, @NotNull UUID playerId) Returns whether a request by the given timed effect ID is active.@NotNull CompletableFuture<@Nullable GamePack> Re-fetches thegame pack.@NotNull CompletableFuture<@Nullable GamePack> loadGamePack(@Nullable String token) Re-fetches thegame pack.voidpauseAll()Pauses all requests, and cancels all pending requests.voidpauseByRequestId(@NotNull UUID requestId) Pauses a request given its ID.booleanremovePlayer(@NotNull UUID playerId) Removes a registered player by the provided unique ID.voidResumes all requests.voidresumeByRequestId(@NotNull UUID requestId) Resumes a request given its ID.
-
Field Details
-
QUEUE_DURATION
public static final int QUEUE_DURATIONAmount of time in seconds that effects are allowed to execute for.- See Also:
-
effects
-
players
-
effectPool
-
timedEffectPool
-
eventPool
-
httpUtil
-
gameID
-
gamePackID
-
appID
-
appSecret
-
dataFolder
-
gamePack
-
-
Constructor Details
-
CrowdControl
-
-
Method Details
-
getGameID
Gets the ID of this game's Crowd Control metadata.- Returns:
- gameID
-
getGamePackID
Gets the ID of this game's Crowd Control pack.- Returns:
- gamePackID
-
getAppID
Gets the ID of this game's Crowd Control third-party application.- Returns:
- appID
-
getAppSecret
Gets the API secret of this game's Crowd Control third-party application.- Returns:
- appSecret
-
getDataFolder
Gets the folder in which players' Crowd Control tokens are stored.- Returns:
- data folder
-
getEffectPool
Gets the executor service on which effects are to be run.- Returns:
- executor service
-
getTimedEffectPool
Gets the executor service on which timed effect updates are to be run.- Returns:
- scheduled executor service
-
getEventPool
Gets the executor service on which events are to be run.- Returns:
- executor service
-
getHttpUtil
Gets the utility for making requests to Crowd Control's HTTP servers.- Returns:
- http util
-
getGamePack
Gets the data about this game pack. May be missing if the game IDs are invalid, or it hasn't finished loading yet.- Returns:
- game pack
-
loadGamePack
Re-fetches thegame pack.- Returns:
- future representing the loaded game pack
-
loadGamePack
@NotNull public @NotNull CompletableFuture<@Nullable GamePack> loadGamePack(@Nullable @Nullable String token) Re-fetches thegame pack.- Returns:
- future representing the loaded game pack
-
getPlayer
Gets a registered player by the provided unique ID.- Parameters:
playerId- unique player id- Returns:
- registered player or null
-
addPlayer
Registers a player by the provided unique ID.- Parameters:
playerId- unique player id- Returns:
- crowd control player
-
removePlayer
Removes a registered player by the provided unique ID.- Parameters:
playerId- unique player id- Returns:
- whether a player was removed
-
getPlayers
Gets all the currently registered players. The returned collection is not a view; changes to it will not be reflected.- Returns:
- players
-
getPlayerIds
Gets the list of players logged in as the specified user ID.- Parameters:
ccUID- Crowd Control user IDs- Returns:
- game player ids
-
addEffect
Registers an effect which maintains one object across its lifetime.- Parameters:
effectID- ID of the effecteffect- executor object- Returns:
- whether the effect was added successfully
-
addEffect
public boolean addEffect(@NotNull @NotNull String effectID, @NotNull @NotNull Supplier<@NotNull CCEffect> supplier) Registers an effect which is instantiated upon triggering.- Parameters:
effectID- ID of the effectsupplier- executor supplier- Returns:
- whether the effect was added successfully
-
executeEffect
public void executeEffect(@NotNull @NotNull PublicEffectPayload payload, @NotNull @NotNull ConnectedPlayer source) Executes the provided effect.- Parameters:
payload- info about the effectsource- player who spawned the effect
-
handleEffectResponse
protected void handleEffectResponse(@NotNull @NotNull CCEffectResponse response, @NotNull @NotNull ConnectedPlayer source) -
cancelByRequestId
Cancels a request given its ID.- Parameters:
requestId- request id
-
cancelAll
public void cancelAll() -
pauseByRequestId
Pauses a request given its ID.- Parameters:
requestId- request id
-
pauseAll
public void pauseAll()Pauses all requests, and cancels all pending requests. -
resumeByRequestId
Resumes a request given its ID.- Parameters:
requestId- request id
-
resumeAll
public void resumeAll()Resumes all requests. -
isPlayerEffectActive
public boolean isPlayerEffectActive(@NotNull @NotNull String effectId, @NotNull @NotNull UUID playerId) Returns whether a request by the given timed effect ID is active. Paused effects are considered active.- Parameters:
effectId- effect idplayerId- player id- Returns:
- is effect active
-
close
public void close()
-