Skip to content

Commit

Permalink
Fixed logoutDate field for a player remaining null if the server was …
Browse files Browse the repository at this point in the history
…shut down.
  • Loading branch information
dmccoystephenson committed Oct 6, 2021
1 parent e8ac6a2 commit 25ca95d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dansplugins.activitytracker;

import dansplugins.activitytracker.data.PersistentData;
import dansplugins.activitytracker.managers.ConfigManager;
import dansplugins.activitytracker.managers.StorageManager;
import org.bukkit.command.Command;
Expand Down Expand Up @@ -41,6 +42,7 @@ public void onEnable() {

@Override
public void onDisable() {
PersistentData.getInstance().endCurrentSessions();
StorageManager.getInstance().save();
}

Expand Down
10 changes: 10 additions & 0 deletions src/main/java/dansplugins/activitytracker/data/PersistentData.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import dansplugins.activitytracker.objects.ActivityRecord;
import dansplugins.activitytracker.objects.ISession;
import dansplugins.activitytracker.objects.Session;
import dansplugins.activitytracker.utils.Logger;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

import java.util.ArrayList;
Expand Down Expand Up @@ -61,4 +63,12 @@ public Session getSession(int sessionID) {
}
return null;
}

public void endCurrentSessions() {
Logger.getInstance().log("Ending current sessions.");
for (Player player : Bukkit.getOnlinePlayers()) {
ActivityRecord record = getActivityRecord(player);
record.getMostRecentSession().endSession();
}
}
}

0 comments on commit 25ca95d

Please sign in to comment.