ShardManager
public 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, wait
getApplicationInfo, 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, setStatus
public static final org.slf4j.Logger LOG
public static final java.util.concurrent.ThreadFactory DEFAULT_THREAD_FACTORY
public void addEventListener(java.lang.Object... listeners)
ShardManager
Note: when using the InterfacedEventListener
(default),
given listener must be instance of EventListener
!
addEventListener
in interface ShardManager
listeners
- The listener(s) which will react to events.public void removeEventListener(java.lang.Object... listeners)
ShardManager
removeEventListener
in interface ShardManager
listeners
- The listener(s) to be removed.public void addEventListeners(java.util.function.IntFunction<java.lang.Object> eventListenerProvider)
ShardManager
Note: when using the InterfacedEventListener
(default),
given listener must be instance of EventListener
!
addEventListeners
in interface ShardManager
eventListenerProvider
- The provider of listener(s) which will react to events.public void removeEventListenerProvider(java.util.function.IntFunction<java.lang.Object> eventListenerProvider)
ShardManager
removeEventListenerProvider(IntFunction)
for actual coderemoveEventListenerProvider
in interface ShardManager
eventListenerProvider
- The provider of listeners that shall be removed.public int getShardsQueued()
ShardManager
getShardsQueued
in interface ShardManager
public int getShardsTotal()
ShardManager
ShardManager
.
This includes shards currently queued for a restart.getShardsTotal
in interface ShardManager
public Guild getGuildById(long id)
ShardManager
Guild
which has the same id as the one provided.
null
.getGuildById
in interface ShardManager
id
- The id of the Guild
.Guild
with matching id.public ShardCacheView getShardCache()
ShardManager
ShardCacheView
of
all cached JDA
bound to this ShardManager instance.getShardCache
in interface ShardManager
ShardCacheView
public void login() throws javax.security.auth.login.LoginException
javax.security.auth.login.LoginException
public void restart(int shardId)
ShardManager
ShardManager.start(int)
.restart
in interface ShardManager
shardId
- The id of the target shardpublic void restart()
ShardManager
restart
in interface ShardManager
public void shutdown()
ShardManager
shutdown
in interface ShardManager
public void shutdown(int shardId)
ShardManager
shutdown
in interface ShardManager
shardId
- The id of the shard that should be stoppedpublic void start(int shardId)
ShardManager
start
in interface ShardManager
shardId
- The id of the shard that should be startedpublic void setGameProvider(java.util.function.IntFunction<? extends Game> gameProvider)
ShardManager
Game
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 ShardManager
gameProvider
- A Game
instance or null to resetGame.playing(String)
,
Game.streaming(String, String)
public void setIdleProvider(java.util.function.IntFunction<java.lang.Boolean> idleProvider)
ShardManager
This will also change the provider for shards that are created in the future.
setIdleProvider
in interface ShardManager
idleProvider
- booleanpublic void setStatusProvider(java.util.function.IntFunction<OnlineStatus> statusProvider)
ShardManager
OnlineStatus
for all shards.
This will also change the provider for shards that are created in the future.
setStatusProvider
in interface ShardManager
statusProvider
- the OnlineStatus
to be used (OFFLINE/null -> INVISIBLE)