Caller updates now async

This commit is contained in:
Rsl1122 2019-04-01 20:32:18 +03:00
parent d9bf729f40
commit fb7e752300
2 changed files with 15 additions and 4 deletions

View File

@ -24,6 +24,7 @@ import com.djrapitops.plan.extension.implementation.providers.gathering.Provider
import com.djrapitops.plan.system.DebugChannels;
import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plan.system.info.server.ServerInfo;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.settings.config.PlanConfig;
import com.djrapitops.plugin.logging.L;
import com.djrapitops.plugin.logging.console.PluginLogger;
@ -48,6 +49,7 @@ public class ExtensionServiceImplementation implements ExtensionService {
private final PlanConfig config;
private final DBSystem dbSystem;
private final ServerInfo serverInfo;
private final Processing processing;
private final ExtensionRegister extensionRegister;
private final PluginLogger logger;
private final ErrorHandler errorHandler;
@ -59,6 +61,7 @@ public class ExtensionServiceImplementation implements ExtensionService {
PlanConfig config,
DBSystem dbSystem,
ServerInfo serverInfo,
Processing processing,
ExtensionRegister extensionRegister,
PluginLogger logger,
ErrorHandler errorHandler
@ -66,6 +69,7 @@ public class ExtensionServiceImplementation implements ExtensionService {
this.config = config;
this.dbSystem = dbSystem;
this.serverInfo = serverInfo;
this.processing = processing;
this.extensionRegister = extensionRegister;
this.logger = logger;
this.errorHandler = errorHandler;
@ -97,7 +101,7 @@ public class ExtensionServiceImplementation implements ExtensionService {
updateServerValues(gatherer, CallEvents.SERVER_EXTENSION_REGISTER);
logger.getDebugLogger().logOn(DebugChannels.DATA_EXTENSIONS, pluginName + " extension registered.");
return Optional.of(new CallerImplementation(gatherer, this));
return Optional.of(new CallerImplementation(gatherer, this, processing));
}
@Override

View File

@ -20,6 +20,7 @@ import com.djrapitops.plan.extension.CallEvents;
import com.djrapitops.plan.extension.Caller;
import com.djrapitops.plan.extension.ExtensionServiceImplementation;
import com.djrapitops.plan.extension.implementation.providers.gathering.ProviderValueGatherer;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plugin.utilities.Verify;
import java.util.UUID;
@ -33,21 +34,27 @@ public class CallerImplementation implements Caller {
private final ProviderValueGatherer gatherer;
private final ExtensionServiceImplementation extensionServiceImplementation;
private final Processing processing;
public CallerImplementation(ProviderValueGatherer gatherer, ExtensionServiceImplementation extensionServiceImplementation) {
public CallerImplementation(
ProviderValueGatherer gatherer,
ExtensionServiceImplementation extensionServiceImplementation,
Processing processing
) {
this.gatherer = gatherer;
this.extensionServiceImplementation = extensionServiceImplementation;
this.processing = processing;
}
@Override
public void updatePlayerData(UUID playerUUID, String playerName) throws IllegalArgumentException {
Verify.nullCheck(playerUUID, () -> new IllegalArgumentException("'playerUUID' can not be null!"));
Verify.nullCheck(playerName, () -> new IllegalArgumentException("'playerName' can not be null!"));
extensionServiceImplementation.updatePlayerValues(gatherer, playerUUID, playerName, CallEvents.MANUAL);
processing.submitNonCritical(() -> extensionServiceImplementation.updatePlayerValues(gatherer, playerUUID, playerName, CallEvents.MANUAL));
}
@Override
public void updateServerData() {
extensionServiceImplementation.updateServerValues(gatherer, CallEvents.MANUAL);
processing.submitNonCritical(() -> extensionServiceImplementation.updateServerValues(gatherer, CallEvents.MANUAL));
}
}