fix(DiscordRPC): NPE on shutdown
@@ -71,20 +71,22 @@ public void postBegin() {
@Override
public void shutdown() {
- if (delayManager.hasPeriodicAction(player.getClientEntity(), UPDATE_PARTY_SIZE_ID)) {
- delayManager.cancelPeriodicAction(player.getClientEntity(), UPDATE_PARTY_SIZE_ID);
+ if (player != null) {
+ EntityRef client = player.getClientEntity();
+ if (delayManager != null && delayManager.hasPeriodicAction(client, UPDATE_PARTY_SIZE_ID)) {
+ delayManager.cancelPeriodicAction(client, UPDATE_PARTY_SIZE_ID);
+ }
}
-
DiscordRPCSubSystem.reset();
DiscordRPCSubSystem.setState("In Main Menu");
DiscordRPCSubSystem.setStartTimestamp(null);
}
@ReceiveEvent
- public void onPlayerInitialized(LocalPlayerInitializedEvent event, EntityRef player) {
+ public void onPlayerInitialized(LocalPlayerInitializedEvent event, EntityRef localPlayer) {
/* Adds the periodic action when the player is hosting or playing online to update party size */
if (networkSystem.getMode() != NetworkMode.NONE) {
- delayManager.addPeriodicAction(player, UPDATE_PARTY_SIZE_ID, 0, UPDATE_PARTY_SIZE_PERIOD);
+ delayManager.addPeriodicAction(localPlayer, UPDATE_PARTY_SIZE_ID, 0, UPDATE_PARTY_SIZE_PERIOD);
}
}
