diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/API.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/API.kt index a5e134a0d..8b6558614 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/API.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/API.kt @@ -120,7 +120,7 @@ interface IStorageProvider : IStorageEventProducer { * @param key stack we want to find UUID of * @return UUID of stack if present */ - operator fun get(key: T): List { + operator fun get(key: T): UUID? { val key1 = key.let { if (it.count == BigInteger.ONE) it else it.key() } return stacks.filter { @@ -129,7 +129,7 @@ interface IStorageProvider : IStorageEventProducer { } else { return@filter it.stack.key() == key1 } - }.collect(Collectors.toList()).map { it.id } + }.findFirst().orElse(null)?.id } val stacks: Stream> diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt index 1c3d1e96f..201cdb8be 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt @@ -124,8 +124,8 @@ open class VirtualComponent(type: StorageStackType) : IVir return ArrayList>(hashedTuples.size).also { it.addAll(hashedTuples.values) }.stream() } - override fun get(key: T): List { - return hashedTuples[key.key()]?.id?.let(::listOf) ?: emptyList() + override fun get(key: T): UUID? { + return hashedTuples[key.key()]?.id } @Suppress("unchecked_cast")