ShardManagerpublic class DefaultShardManager extends java.lang.Object implements ShardManager
ShardManager implementation.
To create new instances use the DefaultShardManagerBuilder.| Modifier and Type | Field | Description |
|---|---|---|
static java.util.concurrent.ThreadFactory |
DEFAULT_THREAD_FACTORY |
|
static org.slf4j.Logger |
LOG |
| Modifier and Type | Method | Description |
|---|---|---|
void |
addEventListener(java.lang.Object... listeners) |
Adds all provided listeners to the event-listeners that will be used to handle events.
|
void |
addEventListeners(java.util.function.IntFunction<java.lang.Object> eventListenerProvider) |
Adds listeners provided by the listener provider to each shard to the event-listeners that will be used to handle events.
|
Guild |
getGuildById(long id) |
This returns the
Guild which has the same id as the one provided. |
ShardCacheView |
getShardCache() |
Unified
ShardCacheView of
all cached JDA bound to this ShardManager instance. |
int |
getShardsQueued() |
Returns the amount of shards queued for (re)connecting.
|
int |
getShardsTotal() |
Returns the amount of shards managed by this
ShardManager. |
void |
login() |
|
void |
removeEventListener(java.lang.Object... listeners) |
Removes all provided listeners from the event-listeners and no longer uses them to handle events.
|
void |
removeEventListenerProvider(java.util.function.IntFunction<java.lang.Object> eventListenerProvider) |
Remove a listener provider.
|
void |
restart() |
Restarts all shards, shutting old ones down first.
|
void |
restart(int shardId) |
Restarts the shards with the given id only.
|
void |
setGameProvider(java.util.function.IntFunction<? extends Game> gameProvider) |
Sets provider that provider the
Game for all shards. |
void |
setIdleProvider(java.util.function.IntFunction<java.lang.Boolean> idleProvider) |
Sets the provider that decides for all shards whether they should be marked as afk or not.
|
void |
setStatusProvider(java.util.function.IntFunction<OnlineStatus> statusProvider) |
Sets the provider that provides the
OnlineStatus for all shards. |
void |
shutdown() |
Shuts down all JDA shards, closing all their connections.
|
void |
shutdown(int shardId) |
Shuts down the shard with the given id only.
|
void |
start(int shardId) |
Adds a new shard with the given id to this ShardManager and starts it.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetApplicationInfo, getAveragePing, getCategories, getCategoriesByName, getCategoryById, getCategoryById, getCategoryCache, getEmoteById, getEmoteById, getEmoteCache, getEmotes, getEmotesByName, getGuildById, getGuildCache, getGuilds, getGuildsByName, getMutualGuilds, getMutualGuilds, getPrivateChannelById, getPrivateChannelById, getPrivateChannelCache, getPrivateChannels, getRoleById, getRoleById, getRoleCache, getRoles, getRolesByName, getShardById, getShardById, getShards, getShardsRunning, getStatus, getStatuses, getTextChannelById, getTextChannelById, getTextChannelCache, getTextChannels, getUserById, getUserById, getUserCache, getUsers, getVoiceChannelById, getVoiceChannelById, getVoiceChannelCache, getVoiceChannels, removeEventListeners, retrieveUserById, retrieveUserById, setGame, setIdle, setStatuspublic static final org.slf4j.Logger LOG
public static final java.util.concurrent.ThreadFactory DEFAULT_THREAD_FACTORY
public void addEventListener(java.lang.Object... listeners)
ShardManagerNote: when using the InterfacedEventListener (default),
given listener must be instance of EventListener!
addEventListener in interface ShardManagerlisteners - The listener(s) which will react to events.public void removeEventListener(java.lang.Object... listeners)
ShardManagerremoveEventListener in interface ShardManagerlisteners - The listener(s) to be removed.public void addEventListeners(java.util.function.IntFunction<java.lang.Object> eventListenerProvider)
ShardManagerNote: when using the InterfacedEventListener (default),
given listener must be instance of EventListener!
addEventListeners in interface ShardManagereventListenerProvider - The provider of listener(s) which will react to events.public void removeEventListenerProvider(java.util.function.IntFunction<java.lang.Object> eventListenerProvider)
ShardManagerremoveEventListenerProvider(IntFunction) for actual coderemoveEventListenerProvider in interface ShardManagereventListenerProvider - The provider of listeners that shall be removed.public int getShardsQueued()
ShardManagergetShardsQueued in interface ShardManagerpublic int getShardsTotal()
ShardManagerShardManager.
This includes shards currently queued for a restart.getShardsTotal in interface ShardManagerpublic Guild getGuildById(long id)
ShardManagerGuild which has the same id as the one provided.
null.getGuildById in interface ShardManagerid - The id of the Guild.Guild with matching id.public ShardCacheView getShardCache()
ShardManagerShardCacheView of
all cached JDA bound to this ShardManager instance.getShardCache in interface ShardManagerShardCacheViewpublic void login()
throws javax.security.auth.login.LoginException
javax.security.auth.login.LoginExceptionpublic void restart(int shardId)
ShardManagerShardManager.start(int).restart in interface ShardManagershardId - The id of the target shardpublic void restart()
ShardManagerrestart in interface ShardManagerpublic void shutdown()
ShardManagershutdown in interface ShardManagerpublic void shutdown(int shardId)
ShardManagershutdown in interface ShardManagershardId - The id of the shard that should be stoppedpublic void start(int shardId)
ShardManagerstart in interface ShardManagershardId - The id of the shard that should be startedpublic void setGameProvider(java.util.function.IntFunction<? extends Game> gameProvider)
ShardManagerGame for all shards.
Game.playing(String).
For streams you provide a valid streaming url as second parameter.
This will also change the provider for shards that are created in the future.
setGameProvider in interface ShardManagergameProvider - A Game instance or null to resetGame.playing(String),
Game.streaming(String, String)public void setIdleProvider(java.util.function.IntFunction<java.lang.Boolean> idleProvider)
ShardManagerThis will also change the provider for shards that are created in the future.
setIdleProvider in interface ShardManageridleProvider - booleanpublic void setStatusProvider(java.util.function.IntFunction<OnlineStatus> statusProvider)
ShardManagerOnlineStatus for all shards.
This will also change the provider for shards that are created in the future.
setStatusProvider in interface ShardManagerstatusProvider - the OnlineStatus
to be used (OFFLINE/null -> INVISIBLE)