Skip to content

Commit 3496331

Browse files
committed
track runs of each tasks
1 parent 4a1d7f0 commit 3496331

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

src/main/java/lol/hyper/customlauncher/fieldofficetracker/FieldOfficeTask.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
package lol.hyper.customlauncher.fieldofficetracker;
1919

20+
import dorkbox.notify.Notify;
21+
import dorkbox.notify.Pos;
22+
import lol.hyper.customlauncher.Main;
2023
import lol.hyper.customlauncher.accounts.JSONManager;
2124
import org.apache.logging.log4j.LogManager;
2225
import org.apache.logging.log4j.Logger;
@@ -92,7 +95,7 @@ public void actionPerformed(ActionEvent e) {
9295
it.remove();
9396
}
9497
}
95-
98+
fieldOfficeTracker.runs++;
9699
fieldOfficeTracker.lastFetched = System.currentTimeMillis();
97100
}
98101
}

src/main/java/lol/hyper/customlauncher/fieldofficetracker/FieldOfficeTracker.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public class FieldOfficeTracker {
4343
public JLabel lastFetchedLabel;
4444
public final SimpleDateFormat lastFetchedFormat = new SimpleDateFormat("hh:mm:ss a");
4545
public long lastFetched = 0;
46+
public int runs = 0;
4647
public static final HashMap<Integer, String> zonesToStreets = new HashMap<>();
4748
public boolean isDown = false;
4849
public Timer fieldOfficeTaskTimer;
@@ -163,6 +164,10 @@ private void startFieldOfficeRefresh() {
163164
}
164165

165166
public void showNotification(FieldOffice fieldOffice, boolean newFieldOffice) {
167+
// do not spam the user with all notifications at once
168+
if (runs == 0) {
169+
return;
170+
}
166171
// do we show notifications?
167172
if (!configHandler.showFieldOfficeNotifications()) {
168173
return;

src/main/java/lol/hyper/customlauncher/invasiontracker/InvasionTask.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,16 @@ public void actionPerformed(ActionEvent e) {
9999
Iterator<Map.Entry<String, Invasion>> it = invasionTracker.invasions.entrySet().iterator();
100100
while (it.hasNext()) {
101101
Map.Entry<String, Invasion> pair = it.next();
102-
String key = pair.getKey() + "/" + pair.getValue().getCogType(); // this is the district
102+
// this is the district
103+
// <district>/<cog name>
104+
String key = pair.getKey() + "/" + pair.getValue().getCogType();
103105
if (!invasionsJSON.has(key)) {
104106
invasionTracker.showNotification(pair.getValue(), false);
105107
it.remove();
106108
logger.info("Remove invasion: " + key);
107109
}
108110
}
111+
invasionTracker.runs++;
109112
invasionTracker.lastFetched = System.currentTimeMillis();
110113
}
111114
}

src/main/java/lol/hyper/customlauncher/invasiontracker/InvasionTracker.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public class InvasionTracker {
4444
public JLabel lastFetchedLabel;
4545
public final SimpleDateFormat lastFetchedFormat = new SimpleDateFormat("hh:mm:ss a");
4646
public long lastFetched = 0;
47+
public int runs = 0;
4748
public boolean isDown = false;
4849
public Timer invasionTaskTimer;
4950
final ConfigHandler configHandler;
@@ -170,6 +171,11 @@ private String convertTime(long totalSecs) {
170171
}
171172

172173
public void showNotification(Invasion invasion, boolean newInvasion) {
174+
// do not spam the user with all notifications at once
175+
if (runs == 0) {
176+
return;
177+
}
178+
173179
// do we show notifications?
174180
if (!configHandler.showCogInvasionNotifications()) {
175181
return;

0 commit comments

Comments
 (0)