diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/ExportScheduler.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/ExportScheduler.java index 61f996706..569b48b26 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/ExportScheduler.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/ExportScheduler.java @@ -84,10 +84,11 @@ public class ExportScheduler extends PluginRunnable { } private void schedulePlayersPageExport() { - long period = TimeAmount.toTicks(config.get(ExportSettings.EXPORT_PERIOD), TimeUnit.MILLISECONDS); + long period = TimeAmount.toTicks(config.get(ExportSettings.EXPORT_PERIOD), TimeUnit.MILLISECONDS) + / 4; runnableFactory.create( new ExportTask(exporter, Exporter::exportPlayersPage, errorLogger) - ).runTaskTimerAsynchronously(0L, period); + ).runTaskTimerAsynchronously(TimeAmount.toTicks(2, TimeUnit.MINUTES), period); } private void scheduleServerPageExport() { @@ -102,17 +103,17 @@ public class ExportScheduler extends PluginRunnable { Optional proxy = servers.stream().filter(Server::isProxy).findFirst(); proxy.ifPresent(mainServer -> runnableFactory.create( - new ExportTask(exporter, same -> same.exportServerPage(mainServer), errorLogger)) - .runTaskTimerAsynchronously(0L, period) + new ExportTask(exporter, same -> same.exportServerPage(mainServer), errorLogger)) + .runTaskTimerAsynchronously(TimeAmount.toTicks(1, TimeUnit.MINUTES), period) ); int offsetMultiplier = proxy.isPresent() ? 1 : 0; // Delay first server export if on a network. for (Server server : servers) { runnableFactory.create( - new ExportTask(exporter, same -> { - same.exportServerPage(server); - same.exportServerJSON(server); - }, errorLogger)) + new ExportTask(exporter, same -> { + same.exportServerPage(server); + same.exportServerJSON(server); + }, errorLogger)) .runTaskTimerAsynchronously(offset * offsetMultiplier, period); offsetMultiplier++; } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/utilities/logging/ErrorLogger.java b/Plan/common/src/main/java/com/djrapitops/plan/utilities/logging/ErrorLogger.java index b7069aa06..9aef38c3e 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/utilities/logging/ErrorLogger.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/utilities/logging/ErrorLogger.java @@ -20,20 +20,24 @@ import com.djrapitops.plan.exceptions.ExceptionWithContext; public interface ErrorLogger { default void critical(T throwable) { - critical((Throwable) throwable, throwable.getContext().orElse(ErrorContext.builder().related("Missing Context").build())); + critical((Throwable) throwable, throwable.getContext().orElseGet(this::createMissingContext)); } void critical(Throwable throwable, ErrorContext context); default void error(T throwable) { - error((Throwable) throwable, throwable.getContext().orElse(ErrorContext.builder().related("Missing Context").build())); + error((Throwable) throwable, throwable.getContext().orElseGet(this::createMissingContext)); } void error(Throwable throwable, ErrorContext context); default void warn(T throwable) { - warn((Throwable) throwable, throwable.getContext().orElse(ErrorContext.builder().related("Missing Context").build())); + warn((Throwable) throwable, throwable.getContext().orElseGet(this::createMissingContext)); } void warn(Throwable throwable, ErrorContext context); + + default ErrorContext createMissingContext() { + return ErrorContext.builder().related("Missing Context").build(); + } }