diff --git a/Plan/api/src/main/java/com/djrapitops/plan/extension/Caller.java b/Plan/api/src/main/java/com/djrapitops/plan/extension/Caller.java index 85e1e3fc3..6a8aa704d 100644 --- a/Plan/api/src/main/java/com/djrapitops/plan/extension/Caller.java +++ b/Plan/api/src/main/java/com/djrapitops/plan/extension/Caller.java @@ -36,9 +36,9 @@ public interface Caller { * * @param playerUUID UUID 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}. diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/ExtensionSvc.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/ExtensionSvc.java index 876050ebf..0dd5f885a 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/extension/ExtensionSvc.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/ExtensionSvc.java @@ -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.providers.gathering.DataValueGatherer; import com.djrapitops.plan.identification.ServerInfo; +import com.djrapitops.plan.identification.UUIDUtility; import com.djrapitops.plan.processing.Processing; import com.djrapitops.plan.settings.config.ExtensionSettings; import com.djrapitops.plan.settings.config.PlanConfig; @@ -52,6 +53,7 @@ public class ExtensionSvc implements ExtensionService { private final ServerInfo serverInfo; private final Processing processing; private final ExtensionRegister extensionRegister; + private final UUIDUtility uuidUtility; private final PluginLogger logger; private final ErrorLogger errorLogger; @@ -64,6 +66,7 @@ public class ExtensionSvc implements ExtensionService { ServerInfo serverInfo, Processing processing, ExtensionRegister extensionRegister, + UUIDUtility uuidUtility, PluginLogger logger, ErrorLogger errorLogger ) { @@ -72,6 +75,7 @@ public class ExtensionSvc implements ExtensionService { this.serverInfo = serverInfo; this.processing = processing; this.extensionRegister = extensionRegister; + this.uuidUtility = uuidUtility; this.logger = logger; this.errorLogger = errorLogger; @@ -157,7 +161,12 @@ public class ExtensionSvc implements ExtensionService { if (gatherer.shouldSkipEvent(event)) 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) { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/CallerImplementation.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/CallerImplementation.java index c3bf670a5..18ae42155 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/CallerImplementation.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/CallerImplementation.java @@ -47,6 +47,9 @@ public class CallerImplementation implements Caller { @Override 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)); }