Add startup and shutdown methods to DiscordPlugin
Add startup and shutdown methods that will update/reset the current discord rich presence status Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -65,6 +65,19 @@ public class DiscordPlugin extends Plugin
|
|||||||
return configManager.getConfig(DiscordConfig.class);
|
return configManager.getConfig(DiscordConfig.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void startUp() throws Exception
|
||||||
|
{
|
||||||
|
updateGameStatus(client.getGameState(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void shutDown() throws Exception
|
||||||
|
{
|
||||||
|
discordService.clearPresence();
|
||||||
|
discordState.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onGameStateChanged(GameStateChanged event)
|
public void onGameStateChanged(GameStateChanged event)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,6 +41,16 @@ public class DiscordState
|
|||||||
private DiscordPresence lastPresence;
|
private DiscordPresence lastPresence;
|
||||||
private boolean needsFlush;
|
private boolean needsFlush;
|
||||||
|
|
||||||
|
void reset()
|
||||||
|
{
|
||||||
|
lastQueue.clear();
|
||||||
|
lastEvent = null;
|
||||||
|
startOfAction = null;
|
||||||
|
lastAction = null;
|
||||||
|
lastPresence = null;
|
||||||
|
needsFlush = false;
|
||||||
|
}
|
||||||
|
|
||||||
void flushEvent(DiscordService discordService)
|
void flushEvent(DiscordService discordService)
|
||||||
{
|
{
|
||||||
if (lastPresence != null && needsFlush)
|
if (lastPresence != null && needsFlush)
|
||||||
|
|||||||
Reference in New Issue
Block a user