uuids);
/**
- * Get a stored username from the service if it exists.
- * This should not trigger any fetching of
- * usernames from other services.
- *
- * If the username isn't stored in this service,
- * this completes with an empty optional.
+ * Attempt to complete the given requests. Returns the mappings
+ * that could be created by this server
*
- * @param uuid Player UUID
- * @return Optional that may contain the username if it exists
+ * @param usernames Requests
+ * @return Completed requests
*/
- @NotNull Optional get(@NotNull final UUID uuid);
-
- /**
- * Get a stored UUID from the service if it exists.
- * This should not trigger any fetching of
- * UUID from other services.
- *
- * If the UUID isn't stored in this service,
- * this completes with an empty optional.
- *
- * @param username Player username
- * @return Optional that may contain the UUID if it exists
- */
- @NotNull Optional get(@NotNull final String username);
+ @NotNull List getUUIDs(@NotNull final List usernames);
}
diff --git a/Core/src/main/java/com/plotsquared/core/uuid/offline/OfflineModeUUIDService.java b/Core/src/main/java/com/plotsquared/core/uuid/offline/OfflineModeUUIDService.java
index 7e397119e..49f038db8 100644
--- a/Core/src/main/java/com/plotsquared/core/uuid/offline/OfflineModeUUIDService.java
+++ b/Core/src/main/java/com/plotsquared/core/uuid/offline/OfflineModeUUIDService.java
@@ -27,11 +27,14 @@ package com.plotsquared.core.uuid.offline;
import com.google.common.base.Charsets;
import com.plotsquared.core.configuration.Settings;
+import com.plotsquared.core.uuid.UUIDMapping;
import com.plotsquared.core.uuid.UUIDService;
import org.jetbrains.annotations.NotNull;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import java.util.Locale;
-import java.util.Optional;
import java.util.UUID;
/**
@@ -46,12 +49,16 @@ public class OfflineModeUUIDService implements UUIDService {
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes(Charsets.UTF_8));
}
- @Override @NotNull public Optional get(@NotNull final UUID uuid) {
- return Optional.empty();
+ @Override @NotNull public List getNames(@NotNull final List uuids) {
+ return Collections.emptyList();
}
- @Override @NotNull public Optional get(@NotNull final String username) {
- return Optional.of(this.getFromUsername(username));
+ @Override @NotNull public List getUUIDs(@NotNull List usernames) {
+ final List mappings = new ArrayList<>(usernames.size());
+ for (final String username : usernames) {
+ mappings.add(new UUIDMapping(getFromUsername(username), username));
+ }
+ return mappings;
}
}