Upate getInstance(UUID) to return nullable instance

This commit is contained in:
KrystilizeNevaDies 2021-01-25 17:25:51 +10:00
parent 6807217608
commit d733dbbc3f

View File

@ -161,11 +161,12 @@ public final class InstanceManager {
* @return {@link Optional#empty()} if instance is not found
*/
@NotNull
public Optional<Instance> getInstance(UUID uuid) {
return getInstances()
.stream()
.filter(instance -> instance.getUniqueId().equals(uuid))
.findFirst();
public @Nullable Instance getInstance(UUID uuid) {
Optional<Instance> instance = getInstances()
.stream()
.filter(someInstance -> someInstance.getUniqueId().equals(uuid))
.findFirst();
return instance.orElse(null);
}
/**