Processing locale stuff

This commit is contained in:
Rsl1122 2018-07-29 09:39:08 +03:00
parent 09796cdbec
commit 3417b6ca9f
3 changed files with 18 additions and 5 deletions

View File

@ -13,6 +13,7 @@ import com.djrapitops.plan.system.file.FileSystem;
import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.info.InfoSystem;
import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.info.server.ServerInfo;
import com.djrapitops.plan.system.listeners.ListenerSystem; 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.locale.LocaleSystem;
import com.djrapitops.plan.system.processing.Processing; import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.settings.config.ConfigSystem; 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.api.utility.log.Log;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import java.util.function.Supplier;
/** /**
* PlanSystem contains everything Plan needs to run. * PlanSystem contains everything Plan needs to run.
* <p> * <p>
@ -57,8 +60,10 @@ public abstract class PlanSystem implements SubSystem {
protected PlanAPI planAPI; protected PlanAPI planAPI;
public PlanSystem() { public PlanSystem() {
processing = new Processing(); Supplier<Locale> localeSupplier = () -> getLocaleSystem().getLocale();
webServerSystem = new WebServerSystem(() -> getLocaleSystem().getLocale());
processing = new Processing(localeSupplier);
webServerSystem = new WebServerSystem(localeSupplier);
localeSystem = new LocaleSystem(); localeSystem = new LocaleSystem();
cacheSystem = new CacheSystem(this); cacheSystem = new CacheSystem(this);
} }

View File

@ -31,6 +31,8 @@ public enum PluginLang implements Lang {
DISABLED("Disable", "Player Analytics Disabled."), DISABLED("Disable", "Player Analytics Disabled."),
DISABLED_WEB_SERVER("Disable - WebServer", "Webserver has been 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_NEWEST("Version - Latest", "You're using the latest version."),
VERSION_AVAILABLE("Version - New", "New Release (${0}) is available ${1}"), VERSION_AVAILABLE("Version - New", "New Release (${0}) is available ${1}"),

View File

@ -4,19 +4,25 @@ import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.api.exceptions.EnableException;
import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.PlanSystem;
import com.djrapitops.plan.system.SubSystem; 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.StaticHolder;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import java.util.List; import java.util.List;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.function.Supplier;
public class Processing implements SubSystem { public class Processing implements SubSystem {
private final Supplier<Locale> locale;
private final ExecutorService nonCriticalExecutor; private final ExecutorService nonCriticalExecutor;
private final ExecutorService criticalExecutor; private final ExecutorService criticalExecutor;
public Processing() { public Processing(Supplier<Locale> locale) {
this.locale = locale;
nonCriticalExecutor = Executors.newFixedThreadPool(6); nonCriticalExecutor = Executors.newFixedThreadPool(6);
criticalExecutor = Executors.newFixedThreadPool(2); criticalExecutor = Executors.newFixedThreadPool(2);
saveInstance(nonCriticalExecutor); saveInstance(nonCriticalExecutor);
@ -129,7 +135,7 @@ public class Processing implements SubSystem {
public void disable() { public void disable() {
nonCriticalExecutor.shutdown(); nonCriticalExecutor.shutdown();
List<Runnable> criticalTasks = criticalExecutor.shutdownNow(); 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) { for (Runnable runnable : criticalTasks) {
try { try {
runnable.run(); runnable.run();
@ -137,6 +143,6 @@ public class Processing implements SubSystem {
Log.toLog(this.getClass(), e); Log.toLog(this.getClass(), e);
} }
} }
Log.info("Processing complete."); Log.info(locale.get().getString(PluginLang.DISABLED_PROCESSING_COMPLETE));
} }
} }