mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 09:00:28 +08:00
Made Caller more resilient to null player identifiers
It is now possible to call Caller#updatePlayerData with only one of the parameters
This commit is contained in:
parent
92e32e68cf
commit
d3c4fd1f92
@ -36,9 +36,9 @@ public interface Caller {
|
|||||||
*
|
*
|
||||||
* @param playerUUID UUID of the player.
|
* @param playerUUID UUID of the player.
|
||||||
* @param playerName Name of the player.
|
* @param playerName Name of the player.
|
||||||
* @throws IllegalArgumentException If playerUUID or playerName is null.
|
* @throws IllegalArgumentException If playerUUID AND playerName is null.
|
||||||
*/
|
*/
|
||||||
void updatePlayerData(UUID playerUUID, String playerName) throws IllegalArgumentException;
|
void updatePlayerData(UUID playerUUID, String playerName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls all server methods of the associated {@link DataExtension}.
|
* Calls all server methods of the associated {@link DataExtension}.
|
||||||
|
@ -23,6 +23,7 @@ import com.djrapitops.plan.extension.implementation.ExtensionWrapper;
|
|||||||
import com.djrapitops.plan.extension.implementation.builder.ExtDataBuilder;
|
import com.djrapitops.plan.extension.implementation.builder.ExtDataBuilder;
|
||||||
import com.djrapitops.plan.extension.implementation.providers.gathering.DataValueGatherer;
|
import com.djrapitops.plan.extension.implementation.providers.gathering.DataValueGatherer;
|
||||||
import com.djrapitops.plan.identification.ServerInfo;
|
import com.djrapitops.plan.identification.ServerInfo;
|
||||||
|
import com.djrapitops.plan.identification.UUIDUtility;
|
||||||
import com.djrapitops.plan.processing.Processing;
|
import com.djrapitops.plan.processing.Processing;
|
||||||
import com.djrapitops.plan.settings.config.ExtensionSettings;
|
import com.djrapitops.plan.settings.config.ExtensionSettings;
|
||||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||||
@ -52,6 +53,7 @@ public class ExtensionSvc implements ExtensionService {
|
|||||||
private final ServerInfo serverInfo;
|
private final ServerInfo serverInfo;
|
||||||
private final Processing processing;
|
private final Processing processing;
|
||||||
private final ExtensionRegister extensionRegister;
|
private final ExtensionRegister extensionRegister;
|
||||||
|
private final UUIDUtility uuidUtility;
|
||||||
private final PluginLogger logger;
|
private final PluginLogger logger;
|
||||||
private final ErrorLogger errorLogger;
|
private final ErrorLogger errorLogger;
|
||||||
|
|
||||||
@ -64,6 +66,7 @@ public class ExtensionSvc implements ExtensionService {
|
|||||||
ServerInfo serverInfo,
|
ServerInfo serverInfo,
|
||||||
Processing processing,
|
Processing processing,
|
||||||
ExtensionRegister extensionRegister,
|
ExtensionRegister extensionRegister,
|
||||||
|
UUIDUtility uuidUtility,
|
||||||
PluginLogger logger,
|
PluginLogger logger,
|
||||||
ErrorLogger errorLogger
|
ErrorLogger errorLogger
|
||||||
) {
|
) {
|
||||||
@ -72,6 +75,7 @@ public class ExtensionSvc implements ExtensionService {
|
|||||||
this.serverInfo = serverInfo;
|
this.serverInfo = serverInfo;
|
||||||
this.processing = processing;
|
this.processing = processing;
|
||||||
this.extensionRegister = extensionRegister;
|
this.extensionRegister = extensionRegister;
|
||||||
|
this.uuidUtility = uuidUtility;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.errorLogger = errorLogger;
|
this.errorLogger = errorLogger;
|
||||||
|
|
||||||
@ -157,7 +161,12 @@ public class ExtensionSvc implements ExtensionService {
|
|||||||
if (gatherer.shouldSkipEvent(event)) return;
|
if (gatherer.shouldSkipEvent(event)) return;
|
||||||
if (playerUUID == null && playerName == null) return;
|
if (playerUUID == null && playerName == null) return;
|
||||||
|
|
||||||
gatherer.updateValues(playerUUID, playerName);
|
UUID realUUID = playerUUID != null ? playerUUID : uuidUtility.getUUIDOf(playerName);
|
||||||
|
String realPlayerName = playerName != null ?
|
||||||
|
playerName :
|
||||||
|
uuidUtility.getNameOf(realUUID).orElse(null);
|
||||||
|
|
||||||
|
gatherer.updateValues(realUUID, realPlayerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateServerValues(CallEvents event) {
|
public void updateServerValues(CallEvents event) {
|
||||||
|
@ -47,6 +47,9 @@ public class CallerImplementation implements Caller {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updatePlayerData(UUID playerUUID, String playerName) {
|
public void updatePlayerData(UUID playerUUID, String playerName) {
|
||||||
|
if (playerUUID == null && playerName == null) {
|
||||||
|
throw new IllegalArgumentException("playerUUID and name were null, can not update unidentifiable player!");
|
||||||
|
}
|
||||||
processing.submitNonCritical(() -> extensionService.updatePlayerValues(gatherer, playerUUID, playerName, CallEvents.MANUAL));
|
processing.submitNonCritical(() -> extensionService.updatePlayerValues(gatherer, playerUUID, playerName, CallEvents.MANUAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user