Class DiscordEventHandler
DiscordEventAdapter
that forwards all events to other adapters.
All events are unconditionally forwarded to other DiscordEventAdapter
s
that can be registered and unregistered dynamically.
A CopyOnWriteArrayList
is used for increased thread-safety.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(DiscordEventAdapter listener) Registers a new event adapter to forward Discord events to.void
onActivityJoin
(String secret) Fires when the user attempts to join a game by accepting an invite.void
Fires when a user asked to join the user by using "Ask to join" button.void
onActivitySpectate
(String secret) Fires when the user attempts to spectate a game by accepting an invite or using the "spectate"-button.void
Fires when the current user changes their user information (avatar, username, etc.).void
onOverlayToggle
(boolean locked) Fires when the overlay is toggled (locked / unlocked).void
Fires when there is a new cached version of the user's relationships.void
onRelationshipUpdate
(Relationship relationship) Fires when information about a relationship (also user, presence, etc.) in the filtered list changes.void
Removes all registered event adapters.boolean
removeListener
(DiscordEventAdapter listener) Unregisters a event adapter that has been registered before.
-
Constructor Details
-
DiscordEventHandler
public DiscordEventHandler()
-
-
Method Details
-
addListener
Registers a new event adapter to forward Discord events to.- Parameters:
listener
- Any kind ofDiscordEventAdapter
- See Also:
-
removeListener
Unregisters a event adapter that has been registered before.- Parameters:
listener
- Any kind ofDiscordEventAdapter
that has been added before- Returns:
true
if the adapter was registered and is now unregisters- See Also:
-
removeAllListeners
public void removeAllListeners()Removes all registered event adapters.Until new event adapters are registered, all events are effectively ignored.
- See Also:
-
onActivityJoin
Description copied from class:DiscordEventAdapter
Fires when the user attempts to join a game by accepting an invite.- Overrides:
onActivityJoin
in classDiscordEventAdapter
- Parameters:
secret
- The join or the match secret of the activity- See Also:
-
onActivitySpectate
Description copied from class:DiscordEventAdapter
Fires when the user attempts to spectate a game by accepting an invite or using the "spectate"-button.- Overrides:
onActivitySpectate
in classDiscordEventAdapter
- Parameters:
secret
- The spectate secret of the activity- See Also:
-
onActivityJoinRequest
Description copied from class:DiscordEventAdapter
Fires when a user asked to join the user by using "Ask to join" button.- Overrides:
onActivityJoinRequest
in classDiscordEventAdapter
- Parameters:
user
- User that requested to join- See Also:
-
onCurrentUserUpdate
public void onCurrentUserUpdate()Description copied from class:DiscordEventAdapter
Fires when the current user changes their user information (avatar, username, etc.).
Also fires after initialization of the
UserManager
and therefore indicates thatUserManager.getCurrentUser()
is ready to be called.- Overrides:
onCurrentUserUpdate
in classDiscordEventAdapter
- See Also:
-
onOverlayToggle
public void onOverlayToggle(boolean locked) Description copied from class:DiscordEventAdapter
Fires when the overlay is toggled (locked / unlocked).
Apparently also fires after initialization of the
OverlayManager
and therefore tells you the initial overlay state.- Overrides:
onOverlayToggle
in classDiscordEventAdapter
- Parameters:
locked
- Current state of the overlay- See Also:
-
onRelationshipRefresh
public void onRelationshipRefresh()Description copied from class:DiscordEventAdapter
Fires when there is a new cached version of the user's relationships.
Also fires after initialization of the
RelationshipManager
and therefore indicates that its methods can be used to fetch relationship information.- Overrides:
onRelationshipRefresh
in classDiscordEventAdapter
- See Also:
-
onRelationshipUpdate
Description copied from class:DiscordEventAdapter
Fires when information about a relationship (also user, presence, etc.) in the filtered list changes.- Overrides:
onRelationshipUpdate
in classDiscordEventAdapter
- Parameters:
relationship
- New relationship information- See Also:
-