Revert multiple mapping of stacks to each item

This commit is contained in:
DBotThePony 2022-06-29 21:43:49 +07:00
parent ca9b6cf5fb
commit eb74baffb8
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 4 additions and 4 deletions

View File

@ -120,7 +120,7 @@ interface IStorageProvider<T : IStorageStack> : IStorageEventProducer<T> {
* @param key stack we want to find UUID of * @param key stack we want to find UUID of
* @return UUID of stack if present * @return UUID of stack if present
*/ */
operator fun get(key: T): List<UUID> { operator fun get(key: T): UUID? {
val key1 = key.let { if (it.count == BigInteger.ONE) it else it.key() } val key1 = key.let { if (it.count == BigInteger.ONE) it else it.key() }
return stacks.filter { return stacks.filter {
@ -129,7 +129,7 @@ interface IStorageProvider<T : IStorageStack> : IStorageEventProducer<T> {
} else { } else {
return@filter it.stack.key() == key1 return@filter it.stack.key() == key1
} }
}.collect(Collectors.toList()).map { it.id } }.findFirst().orElse(null)?.id
} }
val stacks: Stream<IStorageTuple<T>> val stacks: Stream<IStorageTuple<T>>

View File

@ -124,8 +124,8 @@ open class VirtualComponent<T : IStorageStack>(type: StorageStackType<T>) : IVir
return ArrayList<IStorageTuple<T>>(hashedTuples.size).also { it.addAll(hashedTuples.values) }.stream() return ArrayList<IStorageTuple<T>>(hashedTuples.size).also { it.addAll(hashedTuples.values) }.stream()
} }
override fun get(key: T): List<UUID> { override fun get(key: T): UUID? {
return hashedTuples[key.key()]?.id?.let(::listOf) ?: emptyList() return hashedTuples[key.key()]?.id
} }
@Suppress("unchecked_cast") @Suppress("unchecked_cast")