diff --git a/Core/src/main/java/com/plotsquared/core/uuid/ServiceFailure.java b/Core/src/main/java/com/plotsquared/core/uuid/ServiceFailure.java
deleted file mode 100644
index a2ce41555..000000000
--- a/Core/src/main/java/com/plotsquared/core/uuid/ServiceFailure.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * _____ _ _ _____ _
- * | __ \| | | | / ____| | |
- * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
- * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
- * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
- * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
- * | |
- * |_|
- * PlotSquared plot management system for Minecraft
- * Copyright (C) 2020 IntellectualSites
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.plotsquared.core.uuid;
-
-import java.util.concurrent.CompletableFuture;
-
-/**
- * Thrown by a {@link UUIDService} when it cannot
- * complete a request. This is not an error and
- * will be dealt with silently.
- */
-public class ServiceFailure extends Throwable {
-
- private static final ServiceFailure instance = new ServiceFailure();
-
- public static CompletableFuture getFuture() {
- final CompletableFuture completableFuture = new CompletableFuture<>();
- completableFuture.completeExceptionally(instance);
- return completableFuture;
- }
-
- @Override public Throwable fillInStackTrace() {
- return this;
- }
-
-}
diff --git a/Core/src/main/java/com/plotsquared/core/uuid/UUIDPipeline.java b/Core/src/main/java/com/plotsquared/core/uuid/UUIDPipeline.java
index 022bb687a..87ef3f529 100644
--- a/Core/src/main/java/com/plotsquared/core/uuid/UUIDPipeline.java
+++ b/Core/src/main/java/com/plotsquared/core/uuid/UUIDPipeline.java
@@ -28,8 +28,11 @@ package com.plotsquared.core.uuid;
import com.google.common.collect.Lists;
import org.jetbrains.annotations.NotNull;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.List;
-import java.util.ListIterator;
+import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
@@ -79,9 +82,7 @@ public class UUIDPipeline {
* @return Copy of service list
*/
public List getServiceListInstance() {
- final List serviceList = Lists.newLinkedList(this.serviceList);
- serviceList.add(EndOfPipeline.instance);
- return serviceList;
+ return Collections.unmodifiableList(this.serviceList);
}
private void consume(@NotNull final UUIDMapping mapping) {
@@ -93,74 +94,34 @@ public class UUIDPipeline {
/**
* Asynchronously attempt to fetch the mapping from a given UUID or username
*
- * @param request UUID or username
+ * @param requests UUIDs or usernames
* @return Future that may complete with the mapping
*/
- public CompletableFuture get(@NotNull final Object request) {
- if (!(request instanceof String) && !(request instanceof UUID)) {
- throw new IllegalArgumentException("Request has to be either a username or UUID");
- }
- final CompletableFuture future = new CompletableFuture<>();
- final ListIterator serviceListIterator
- = this.getServiceListInstance().listIterator();
- final Runnable[] runnable = new Runnable[1];
- runnable[0] = () -> {
- if (serviceListIterator.hasNext()) {
- final UUIDService uuidService = serviceListIterator.next();
- uuidService.get(request).whenCompleteAsync(((result, throwable) -> {
- if (throwable != null) {
- if (throwable instanceof ServiceFailure) {
- try {
- runnable[0].run();
- } catch (final Throwable inner) {
- future.completeExceptionally(inner);
- }
- } else {
- future.completeExceptionally(throwable);
- }
- } else {
+ public CompletableFuture> get(@NotNull final Collection