mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-24 10:11:53 +01:00
Processing locale stuff
This commit is contained in:
parent
09796cdbec
commit
3417b6ca9f
@ -13,6 +13,7 @@ import com.djrapitops.plan.system.file.FileSystem;
|
||||
import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.listeners.ListenerSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.LocaleSystem;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.config.ConfigSystem;
|
||||
@ -23,6 +24,8 @@ import com.djrapitops.plugin.api.Check;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* PlanSystem contains everything Plan needs to run.
|
||||
* <p>
|
||||
@ -57,8 +60,10 @@ public abstract class PlanSystem implements SubSystem {
|
||||
protected PlanAPI planAPI;
|
||||
|
||||
public PlanSystem() {
|
||||
processing = new Processing();
|
||||
webServerSystem = new WebServerSystem(() -> getLocaleSystem().getLocale());
|
||||
Supplier<Locale> localeSupplier = () -> getLocaleSystem().getLocale();
|
||||
|
||||
processing = new Processing(localeSupplier);
|
||||
webServerSystem = new WebServerSystem(localeSupplier);
|
||||
localeSystem = new LocaleSystem();
|
||||
cacheSystem = new CacheSystem(this);
|
||||
}
|
||||
|
@ -31,6 +31,8 @@ public enum PluginLang implements Lang {
|
||||
|
||||
DISABLED("Disable", "Player Analytics Disabled."),
|
||||
DISABLED_WEB_SERVER("Disable - WebServer", "Webserver has been disabled."),
|
||||
DISABLED_PROCESSING("Disable - Processing", "Processing critical unprocessed tasks. (${0})"),
|
||||
DISABLED_PROCESSING_COMPLETE("Disable - Processing Complete", "Processing complete."),
|
||||
|
||||
VERSION_NEWEST("Version - Latest", "You're using the latest version."),
|
||||
VERSION_AVAILABLE("Version - New", "New Release (${0}) is available ${1}"),
|
||||
|
@ -4,19 +4,25 @@ import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.SubSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class Processing implements SubSystem {
|
||||
|
||||
private final Supplier<Locale> locale;
|
||||
|
||||
private final ExecutorService nonCriticalExecutor;
|
||||
private final ExecutorService criticalExecutor;
|
||||
|
||||
public Processing() {
|
||||
public Processing(Supplier<Locale> locale) {
|
||||
this.locale = locale;
|
||||
nonCriticalExecutor = Executors.newFixedThreadPool(6);
|
||||
criticalExecutor = Executors.newFixedThreadPool(2);
|
||||
saveInstance(nonCriticalExecutor);
|
||||
@ -129,7 +135,7 @@ public class Processing implements SubSystem {
|
||||
public void disable() {
|
||||
nonCriticalExecutor.shutdown();
|
||||
List<Runnable> criticalTasks = criticalExecutor.shutdownNow();
|
||||
Log.info("Processing critical unprocessed tasks. (" + criticalTasks.size() + ")");
|
||||
Log.info(locale.get().getString(PluginLang.DISABLED_PROCESSING, criticalTasks.size()));
|
||||
for (Runnable runnable : criticalTasks) {
|
||||
try {
|
||||
runnable.run();
|
||||
@ -137,6 +143,6 @@ public class Processing implements SubSystem {
|
||||
Log.toLog(this.getClass(), e);
|
||||
}
|
||||
}
|
||||
Log.info("Processing complete.");
|
||||
Log.info(locale.get().getString(PluginLang.DISABLED_PROCESSING_COMPLETE));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user