From 3d5edc729e684b3031cfaf9c846926137b0a3686 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Thu, 24 Aug 2023 23:44:28 +0200 Subject: [PATCH 1/2] refactor: expose storage channel types --- .../refinedstorage2/platform/api/PlatformApi.java | 4 ++++ .../refinedstorage2/platform/api/PlatformApiProxy.java | 10 ++++++++++ .../platform/common/PlatformApiImpl.java | 10 ++++++++++ 3 files changed, 24 insertions(+) diff --git a/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApi.java b/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApi.java index 64524468d..a6b236360 100644 --- a/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApi.java +++ b/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApi.java @@ -108,8 +108,12 @@ GridScrollingStrategy createGridScrollingStrategy(AbstractContainerMenu containe ResourceFactory getItemResourceFactory(); + PlatformStorageChannelType getItemStorageChannelType(); + ResourceFactory getFluidResourceFactory(); + PlatformStorageChannelType getFluidStorageChannelType(); + Set> getAlternativeResourceFactories(); void registerResourceRendering(Class resourceClass, ResourceRendering rendering); diff --git a/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApiProxy.java b/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApiProxy.java index f370f3ff1..2b62645e3 100644 --- a/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApiProxy.java +++ b/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApiProxy.java @@ -204,11 +204,21 @@ public ResourceFactory getItemResourceFactory() { return ensureLoaded().getItemResourceFactory(); } + @Override + public PlatformStorageChannelType getItemStorageChannelType() { + return ensureLoaded().getItemStorageChannelType(); + } + @Override public ResourceFactory getFluidResourceFactory() { return ensureLoaded().getFluidResourceFactory(); } + @Override + public PlatformStorageChannelType getFluidStorageChannelType() { + return ensureLoaded().getFluidStorageChannelType(); + } + @Override public Set> getAlternativeResourceFactories() { return ensureLoaded().getAlternativeResourceFactories(); diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/PlatformApiImpl.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/PlatformApiImpl.java index 4ced31cce..ead36fd29 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/PlatformApiImpl.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/PlatformApiImpl.java @@ -319,11 +319,21 @@ public ResourceFactory getItemResourceFactory() { return itemResourceFactory; } + @Override + public PlatformStorageChannelType getItemStorageChannelType() { + return StorageChannelTypes.ITEM; + } + @Override public ResourceFactory getFluidResourceFactory() { return fluidResourceFactory; } + @Override + public PlatformStorageChannelType getFluidStorageChannelType() { + return StorageChannelTypes.FLUID; + } + @Override public Set> getAlternativeResourceFactories() { return resourceFactories; From 81f983b7fb9e3da10665bfa63ceb7e15810b9e91 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Fri, 25 Aug 2023 00:11:10 +0200 Subject: [PATCH 2/2] refactor: expose platform storage creation --- .../platform/api/PlatformApi.java | 4 ++ .../platform/api/PlatformApiProxy.java | 10 +++ .../api/storage/type/StorageType.java | 4 ++ .../common/AbstractModInitializer.java | 3 +- .../platform/common/PlatformApiImpl.java | 14 +++- .../AbstractStorageBlockBlockEntity.java | 3 +- .../storage/FluidStorageBlockBlockEntity.java | 26 ++------ .../storage/ItemStorageBlockBlockEntity.java | 36 ++-------- .../storage/type/FluidStorageType.java | 66 +++++++++++-------- .../storage/type/ItemStorageType.java | 60 +++++++++-------- .../internal/storage/type/StorageTypes.java | 9 +++ .../common/item/FluidStorageDiskItem.java | 33 +--------- .../common/item/ItemStorageDiskItem.java | 33 +--------- .../platform/common/PlatformTestFixtures.java | 4 +- .../storage/LimitedPlatformStorageTest.java | 6 +- .../internal/storage/PlatformStorageTest.java | 6 +- .../storage/StorageRepositoryImplTest.java | 10 +-- .../storage/type/FluidStorageTypeTest.java | 8 +-- .../storage/type/ItemStorageTypeTest.java | 8 +-- 19 files changed, 148 insertions(+), 195 deletions(-) create mode 100644 refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/type/StorageTypes.java diff --git a/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApi.java b/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApi.java index a6b236360..4d08529c5 100644 --- a/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApi.java +++ b/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApi.java @@ -110,10 +110,14 @@ GridScrollingStrategy createGridScrollingStrategy(AbstractContainerMenu containe PlatformStorageChannelType getItemStorageChannelType(); + StorageType getItemStorageType(); + ResourceFactory getFluidResourceFactory(); PlatformStorageChannelType getFluidStorageChannelType(); + StorageType getFluidStorageType(); + Set> getAlternativeResourceFactories(); void registerResourceRendering(Class resourceClass, ResourceRendering rendering); diff --git a/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApiProxy.java b/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApiProxy.java index 2b62645e3..0dad49244 100644 --- a/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApiProxy.java +++ b/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/PlatformApiProxy.java @@ -209,6 +209,11 @@ public PlatformStorageChannelType getItemStorageChannelType() { return ensureLoaded().getItemStorageChannelType(); } + @Override + public StorageType getItemStorageType() { + return ensureLoaded().getItemStorageType(); + } + @Override public ResourceFactory getFluidResourceFactory() { return ensureLoaded().getFluidResourceFactory(); @@ -219,6 +224,11 @@ public PlatformStorageChannelType getFluidStorageChannelType() { return ensureLoaded().getFluidStorageChannelType(); } + @Override + public StorageType getFluidStorageType() { + return ensureLoaded().getFluidStorageType(); + } + @Override public Set> getAlternativeResourceFactories() { return ensureLoaded().getAlternativeResourceFactories(); diff --git a/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/storage/type/StorageType.java b/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/storage/type/StorageType.java index b83b0f91a..1811cad1a 100644 --- a/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/storage/type/StorageType.java +++ b/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/storage/type/StorageType.java @@ -2,11 +2,15 @@ import com.refinedmods.refinedstorage2.api.storage.Storage; +import javax.annotation.Nullable; + import net.minecraft.nbt.CompoundTag; import org.apiguardian.api.API; @API(status = API.Status.STABLE, since = "2.0.0-milestone.1.4") public interface StorageType { + Storage create(@Nullable Long capacity, Runnable listener); + Storage fromTag(CompoundTag tag, Runnable listener); CompoundTag toTag(Storage storage); diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/AbstractModInitializer.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/AbstractModInitializer.java index 5c64e28ef..3b64c1e01 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/AbstractModInitializer.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/AbstractModInitializer.java @@ -64,6 +64,7 @@ import com.refinedmods.refinedstorage2.platform.common.internal.storage.channel.StorageChannelTypes; import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.FluidStorageType; import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.ItemStorageType; +import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.StorageTypes; import com.refinedmods.refinedstorage2.platform.common.internal.upgrade.UpgradeDestinations; import com.refinedmods.refinedstorage2.platform.common.item.FluidStorageDiskItem; import com.refinedmods.refinedstorage2.platform.common.item.FortuneUpgradeItem; @@ -150,7 +151,7 @@ protected final void initializePlatformApi() { private void registerAdditionalStorageTypes() { PlatformApi.INSTANCE.getStorageTypeRegistry().register( createIdentifier(FLUID_REGISTRY_KEY), - FluidStorageType.INSTANCE + StorageTypes.FLUID ); } diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/PlatformApiImpl.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/PlatformApiImpl.java index ead36fd29..e8d46135a 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/PlatformApiImpl.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/PlatformApiImpl.java @@ -47,7 +47,7 @@ import com.refinedmods.refinedstorage2.platform.common.internal.storage.ClientStorageRepository; import com.refinedmods.refinedstorage2.platform.common.internal.storage.StorageRepositoryImpl; import com.refinedmods.refinedstorage2.platform.common.internal.storage.channel.StorageChannelTypes; -import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.ItemStorageType; +import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.StorageTypes; import com.refinedmods.refinedstorage2.platform.common.internal.upgrade.UpgradeRegistryImpl; import com.refinedmods.refinedstorage2.platform.common.screen.grid.hint.GridInsertionHintsImpl; import com.refinedmods.refinedstorage2.platform.common.screen.grid.hint.ItemGridInsertionHint; @@ -86,7 +86,7 @@ public class PlatformApiImpl implements PlatformApi { private final NetworkBuilder networkBuilder = new NetworkBuilderImpl(new NetworkFactory(networkComponentMapFactory)); private final PlatformRegistry> storageTypeRegistry = - new PlatformRegistryImpl<>(createIdentifier(ITEM_REGISTRY_KEY), ItemStorageType.INSTANCE); + new PlatformRegistryImpl<>(createIdentifier(ITEM_REGISTRY_KEY), StorageTypes.ITEM); private final PlatformRegistry> storageChannelTypeRegistry = new PlatformRegistryImpl<>(createIdentifier(ITEM_REGISTRY_KEY), StorageChannelTypes.ITEM); private final PlatformRegistry gridSynchronizerRegistry = @@ -324,6 +324,11 @@ public PlatformStorageChannelType getItemStorageChannelType() { return StorageChannelTypes.ITEM; } + @Override + public StorageType getItemStorageType() { + return StorageTypes.ITEM; + } + @Override public ResourceFactory getFluidResourceFactory() { return fluidResourceFactory; @@ -334,6 +339,11 @@ public PlatformStorageChannelType getFluidStorageChannelType() { return StorageChannelTypes.FLUID; } + @Override + public StorageType getFluidStorageType() { + return StorageTypes.FLUID; + } + @Override public Set> getAlternativeResourceFactories() { return resourceFactories; diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/storage/AbstractStorageBlockBlockEntity.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/storage/AbstractStorageBlockBlockEntity.java index 39d671065..ccce42bcf 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/storage/AbstractStorageBlockBlockEntity.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/storage/AbstractStorageBlockBlockEntity.java @@ -10,7 +10,6 @@ import com.refinedmods.refinedstorage2.platform.common.block.entity.FilterWithFuzzyMode; import com.refinedmods.refinedstorage2.platform.common.block.entity.StorageConfigurationContainerImpl; import com.refinedmods.refinedstorage2.platform.common.internal.resource.ResourceContainerImpl; -import com.refinedmods.refinedstorage2.platform.common.internal.storage.PlatformStorage; import com.refinedmods.refinedstorage2.platform.common.menu.ExtendedMenuProvider; import java.util.Objects; @@ -61,7 +60,7 @@ protected AbstractStorageBlockBlockEntity(final BlockEntityType type, getNode().setNormalizer(filter.createNormalizer()); } - protected abstract PlatformStorage createStorage(Runnable listener); + protected abstract Storage createStorage(Runnable listener); @Override @SuppressWarnings("unchecked") diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/storage/FluidStorageBlockBlockEntity.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/storage/FluidStorageBlockBlockEntity.java index 48e0f1728..3c5fafc96 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/storage/FluidStorageBlockBlockEntity.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/storage/FluidStorageBlockBlockEntity.java @@ -1,20 +1,15 @@ package com.refinedmods.refinedstorage2.platform.common.block.entity.storage; import com.refinedmods.refinedstorage2.api.network.impl.node.storage.StorageNetworkNode; -import com.refinedmods.refinedstorage2.api.storage.InMemoryStorageImpl; -import com.refinedmods.refinedstorage2.api.storage.limited.LimitedStorageImpl; -import com.refinedmods.refinedstorage2.api.storage.tracked.InMemoryTrackedStorageRepository; -import com.refinedmods.refinedstorage2.api.storage.tracked.TrackedStorageImpl; -import com.refinedmods.refinedstorage2.api.storage.tracked.TrackedStorageRepository; +import com.refinedmods.refinedstorage2.api.storage.Storage; import com.refinedmods.refinedstorage2.platform.api.PlatformApi; import com.refinedmods.refinedstorage2.platform.api.resource.FluidResource; import com.refinedmods.refinedstorage2.platform.common.Platform; import com.refinedmods.refinedstorage2.platform.common.containermenu.storage.block.FluidStorageBlockContainerMenu; import com.refinedmods.refinedstorage2.platform.common.content.BlockEntities; -import com.refinedmods.refinedstorage2.platform.common.internal.storage.LimitedPlatformStorage; -import com.refinedmods.refinedstorage2.platform.common.internal.storage.PlatformStorage; import com.refinedmods.refinedstorage2.platform.common.internal.storage.channel.StorageChannelTypes; import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.FluidStorageType; +import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.StorageTypes; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; @@ -58,21 +53,8 @@ private static long getEnergyUsage(final FluidStorageType.Variant variant) { } @Override - protected PlatformStorage createStorage(final Runnable listener) { - final TrackedStorageRepository trackingRepository = new InMemoryTrackedStorageRepository<>(); - if (!variant.hasCapacity()) { - final TrackedStorageImpl delegate = new TrackedStorageImpl<>( - new InMemoryStorageImpl<>(), - trackingRepository, - System::currentTimeMillis - ); - return new PlatformStorage<>(delegate, FluidStorageType.INSTANCE, trackingRepository, listener); - } - final LimitedStorageImpl delegate = new LimitedStorageImpl<>( - new TrackedStorageImpl<>(new InMemoryStorageImpl<>(), trackingRepository, System::currentTimeMillis), - variant.getCapacityInBuckets() * Platform.INSTANCE.getBucketAmount() - ); - return new LimitedPlatformStorage<>(delegate, FluidStorageType.INSTANCE, trackingRepository, listener); + protected Storage createStorage(final Runnable listener) { + return StorageTypes.FLUID.create(variant.getCapacity(), listener); } @Override diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/storage/ItemStorageBlockBlockEntity.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/storage/ItemStorageBlockBlockEntity.java index b0cefa025..50e06c8dd 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/storage/ItemStorageBlockBlockEntity.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/block/entity/storage/ItemStorageBlockBlockEntity.java @@ -1,20 +1,15 @@ package com.refinedmods.refinedstorage2.platform.common.block.entity.storage; import com.refinedmods.refinedstorage2.api.network.impl.node.storage.StorageNetworkNode; -import com.refinedmods.refinedstorage2.api.storage.InMemoryStorageImpl; -import com.refinedmods.refinedstorage2.api.storage.limited.LimitedStorageImpl; -import com.refinedmods.refinedstorage2.api.storage.tracked.InMemoryTrackedStorageRepository; -import com.refinedmods.refinedstorage2.api.storage.tracked.TrackedStorageImpl; -import com.refinedmods.refinedstorage2.api.storage.tracked.TrackedStorageRepository; +import com.refinedmods.refinedstorage2.api.storage.Storage; import com.refinedmods.refinedstorage2.platform.api.PlatformApi; import com.refinedmods.refinedstorage2.platform.api.resource.ItemResource; import com.refinedmods.refinedstorage2.platform.common.Platform; import com.refinedmods.refinedstorage2.platform.common.containermenu.storage.block.ItemStorageBlockContainerMenu; import com.refinedmods.refinedstorage2.platform.common.content.BlockEntities; -import com.refinedmods.refinedstorage2.platform.common.internal.storage.LimitedPlatformStorage; -import com.refinedmods.refinedstorage2.platform.common.internal.storage.PlatformStorage; import com.refinedmods.refinedstorage2.platform.common.internal.storage.channel.StorageChannelTypes; import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.ItemStorageType; +import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.StorageTypes; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; @@ -54,31 +49,8 @@ private static long getEnergyUsage(final ItemStorageType.Variant variant) { } @Override - protected PlatformStorage createStorage(final Runnable listener) { - final TrackedStorageRepository trackingRepository = new InMemoryTrackedStorageRepository<>(); - if (!variant.hasCapacity()) { - final TrackedStorageImpl delegate = new TrackedStorageImpl<>( - new InMemoryStorageImpl<>(), - trackingRepository, - System::currentTimeMillis - ); - return new PlatformStorage<>( - delegate, - ItemStorageType.INSTANCE, - trackingRepository, - listener - ); - } - final LimitedStorageImpl delegate = new LimitedStorageImpl<>( - new TrackedStorageImpl<>(new InMemoryStorageImpl<>(), trackingRepository, System::currentTimeMillis), - variant.getCapacity() - ); - return new LimitedPlatformStorage<>( - delegate, - ItemStorageType.INSTANCE, - trackingRepository, - listener - ); + protected Storage createStorage(final Runnable listener) { + return StorageTypes.ITEM.create(variant.getCapacity(), listener); } @Override diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/type/FluidStorageType.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/type/FluidStorageType.java index 9e0d9ce27..d56a8d2c1 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/type/FluidStorageType.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/type/FluidStorageType.java @@ -12,62 +12,69 @@ import com.refinedmods.refinedstorage2.platform.api.resource.FluidResource; import com.refinedmods.refinedstorage2.platform.api.storage.PlayerActor; import com.refinedmods.refinedstorage2.platform.api.storage.type.StorageType; +import com.refinedmods.refinedstorage2.platform.common.Platform; import com.refinedmods.refinedstorage2.platform.common.internal.storage.LimitedPlatformStorage; import com.refinedmods.refinedstorage2.platform.common.internal.storage.PlatformStorage; +import javax.annotation.Nullable; + import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.Tag; public class FluidStorageType implements StorageType { - public static final FluidStorageType INSTANCE = new FluidStorageType(); - private static final String TAG_CAPACITY = "cap"; private static final String TAG_STACKS = "stacks"; private static final String TAG_CHANGED_BY = "cb"; private static final String TAG_CHANGED_AT = "ca"; - private FluidStorageType() { + FluidStorageType() { + } + + @Override + public Storage create(@Nullable final Long capacity, final Runnable listener) { + return innerCreate(capacity, listener); } @Override public Storage fromTag(final CompoundTag tag, final Runnable listener) { - final PlatformStorage storage = createStorage(tag, listener); + final PlatformStorage storage = innerCreate( + tag.contains(TAG_CAPACITY) ? tag.getLong(TAG_CAPACITY) : null, + listener + ); final ListTag stacks = tag.getList(TAG_STACKS, Tag.TAG_COMPOUND); for (final Tag stackTag : stacks) { - FluidResource - .fromTagWithAmount((CompoundTag) stackTag) - .ifPresent(resourceAmount -> storage.load( - resourceAmount.getResource(), - resourceAmount.getAmount(), - ((CompoundTag) stackTag).getString(TAG_CHANGED_BY), - ((CompoundTag) stackTag).getLong(TAG_CHANGED_AT) - )); + FluidResource.fromTagWithAmount((CompoundTag) stackTag).ifPresent(resourceAmount -> storage.load( + resourceAmount.getResource(), + resourceAmount.getAmount(), + ((CompoundTag) stackTag).getString(TAG_CHANGED_BY), + ((CompoundTag) stackTag).getLong(TAG_CHANGED_AT) + )); } return storage; } - private PlatformStorage createStorage(final CompoundTag tag, final Runnable listener) { + private PlatformStorage innerCreate(@Nullable final Long capacity, final Runnable listener) { final TrackedStorageRepository trackingRepository = new InMemoryTrackedStorageRepository<>(); - if (tag.contains(TAG_CAPACITY)) { + if (capacity != null) { final LimitedStorageImpl delegate = new LimitedStorageImpl<>( new TrackedStorageImpl<>( new InMemoryStorageImpl<>(), trackingRepository, System::currentTimeMillis ), - tag.getLong(TAG_CAPACITY) + capacity ); return new LimitedPlatformStorage<>( delegate, - FluidStorageType.INSTANCE, + StorageTypes.FLUID, trackingRepository, listener ); } return new PlatformStorage<>( new TrackedStorageImpl<>(new InMemoryStorageImpl<>(), trackingRepository, System::currentTimeMillis), - FluidStorageType.INSTANCE, + StorageTypes.FLUID, trackingRepository, listener ); @@ -102,16 +109,17 @@ private CompoundTag toTag(final Storage storage, } public enum Variant { - SIXTY_FOUR_B("64b", 64), - TWO_HUNDRED_FIFTY_SIX_B("256b", 256), - THOUSAND_TWENTY_FOUR_B("1024b", 1024), - FOUR_THOUSAND_NINETY_SIX_B("4096b", 4096), - CREATIVE("creative", 0); + SIXTY_FOUR_B("64b", 64L), + TWO_HUNDRED_FIFTY_SIX_B("256b", 256L), + THOUSAND_TWENTY_FOUR_B("1024b", 1024L), + FOUR_THOUSAND_NINETY_SIX_B("4096b", 4096L), + CREATIVE("creative", null); private final String name; - private final long capacityInBuckets; + @Nullable + private final Long capacityInBuckets; - Variant(final String name, final long capacityInBuckets) { + Variant(final String name, @Nullable final Long capacityInBuckets) { this.name = name; this.capacityInBuckets = capacityInBuckets; } @@ -120,12 +128,16 @@ public String getName() { return name; } - public long getCapacityInBuckets() { - return capacityInBuckets; + @Nullable + public Long getCapacity() { + if (capacityInBuckets == null) { + return null; + } + return capacityInBuckets * Platform.INSTANCE.getBucketAmount(); } public boolean hasCapacity() { - return capacityInBuckets > 0; + return capacityInBuckets != null; } } } diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/type/ItemStorageType.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/type/ItemStorageType.java index 16b407287..f2270d09f 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/type/ItemStorageType.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/type/ItemStorageType.java @@ -15,59 +15,65 @@ import com.refinedmods.refinedstorage2.platform.common.internal.storage.LimitedPlatformStorage; import com.refinedmods.refinedstorage2.platform.common.internal.storage.PlatformStorage; +import javax.annotation.Nullable; + import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.Tag; public class ItemStorageType implements StorageType { - public static final ItemStorageType INSTANCE = new ItemStorageType(); - private static final String TAG_CAPACITY = "cap"; private static final String TAG_STACKS = "stacks"; private static final String TAG_CHANGED_BY = "cb"; private static final String TAG_CHANGED_AT = "ca"; - private ItemStorageType() { + ItemStorageType() { + } + + @Override + public Storage create(@Nullable final Long capacity, final Runnable listener) { + return innerCreate(capacity, listener); } @Override public Storage fromTag(final CompoundTag tag, final Runnable listener) { - final PlatformStorage storage = createStorage(tag, listener); + final PlatformStorage storage = innerCreate( + tag.contains(TAG_CAPACITY) ? tag.getLong(TAG_CAPACITY) : null, + listener + ); final ListTag stacks = tag.getList(TAG_STACKS, Tag.TAG_COMPOUND); for (final Tag stackTag : stacks) { - ItemResource - .fromTagWithAmount((CompoundTag) stackTag) - .ifPresent(resourceAmount -> storage.load( - resourceAmount.getResource(), - resourceAmount.getAmount(), - ((CompoundTag) stackTag).getString(TAG_CHANGED_BY), - ((CompoundTag) stackTag).getLong(TAG_CHANGED_AT) - )); + ItemResource.fromTagWithAmount((CompoundTag) stackTag).ifPresent(resourceAmount -> storage.load( + resourceAmount.getResource(), + resourceAmount.getAmount(), + ((CompoundTag) stackTag).getString(TAG_CHANGED_BY), + ((CompoundTag) stackTag).getLong(TAG_CHANGED_AT) + )); } return storage; } - private PlatformStorage createStorage(final CompoundTag tag, final Runnable listener) { + private PlatformStorage innerCreate(@Nullable final Long capacity, final Runnable listener) { final TrackedStorageRepository trackingRepository = new InMemoryTrackedStorageRepository<>(); - if (tag.contains(TAG_CAPACITY)) { + if (capacity != null) { final LimitedStorageImpl delegate = new LimitedStorageImpl<>( new TrackedStorageImpl<>( new InMemoryStorageImpl<>(), trackingRepository, System::currentTimeMillis ), - tag.getLong(TAG_CAPACITY) + capacity ); return new LimitedPlatformStorage<>( delegate, - ItemStorageType.INSTANCE, + StorageTypes.ITEM, trackingRepository, listener ); } return new PlatformStorage<>( new TrackedStorageImpl<>(new InMemoryStorageImpl<>(), trackingRepository, System::currentTimeMillis), - ItemStorageType.INSTANCE, + StorageTypes.ITEM, trackingRepository, listener ); @@ -101,16 +107,17 @@ private CompoundTag toTag(final Storage storage, final ResourceAmo } public enum Variant { - ONE_K("1k", 1024), - FOUR_K("4k", 1024 * 4), - SIXTEEN_K("16k", 1024 * 4 * 4), - SIXTY_FOUR_K("64k", 1024 * 4 * 4 * 4), - CREATIVE("creative", 0); + ONE_K("1k", 1024L), + FOUR_K("4k", 1024 * 4L), + SIXTEEN_K("16k", 1024 * 4 * 4L), + SIXTY_FOUR_K("64k", 1024 * 4 * 4 * 4L), + CREATIVE("creative", null); private final String name; - private final int capacity; + @Nullable + private final Long capacity; - Variant(final String name, final int capacity) { + Variant(final String name, @Nullable final Long capacity) { this.name = name; this.capacity = capacity; } @@ -119,12 +126,13 @@ public String getName() { return name; } - public int getCapacity() { + @Nullable + public Long getCapacity() { return capacity; } public boolean hasCapacity() { - return capacity > 0; + return capacity != null; } } } diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/type/StorageTypes.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/type/StorageTypes.java new file mode 100644 index 000000000..d1700aa35 --- /dev/null +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/type/StorageTypes.java @@ -0,0 +1,9 @@ +package com.refinedmods.refinedstorage2.platform.common.internal.storage.type; + +public final class StorageTypes { + public static final ItemStorageType ITEM = new ItemStorageType(); + public static final FluidStorageType FLUID = new FluidStorageType(); + + private StorageTypes() { + } +} diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/item/FluidStorageDiskItem.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/item/FluidStorageDiskItem.java index d439ac758..70b8f7187 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/item/FluidStorageDiskItem.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/item/FluidStorageDiskItem.java @@ -1,21 +1,15 @@ package com.refinedmods.refinedstorage2.platform.common.item; -import com.refinedmods.refinedstorage2.api.storage.InMemoryStorageImpl; import com.refinedmods.refinedstorage2.api.storage.Storage; -import com.refinedmods.refinedstorage2.api.storage.limited.LimitedStorageImpl; -import com.refinedmods.refinedstorage2.api.storage.tracked.InMemoryTrackedStorageRepository; -import com.refinedmods.refinedstorage2.api.storage.tracked.TrackedStorageImpl; -import com.refinedmods.refinedstorage2.api.storage.tracked.TrackedStorageRepository; import com.refinedmods.refinedstorage2.platform.api.PlatformApi; import com.refinedmods.refinedstorage2.platform.api.item.AbstractStorageContainerItem; import com.refinedmods.refinedstorage2.platform.api.resource.FluidResource; import com.refinedmods.refinedstorage2.platform.api.storage.StorageRepository; import com.refinedmods.refinedstorage2.platform.common.Platform; import com.refinedmods.refinedstorage2.platform.common.content.Items; -import com.refinedmods.refinedstorage2.platform.common.internal.storage.LimitedPlatformStorage; -import com.refinedmods.refinedstorage2.platform.common.internal.storage.PlatformStorage; import com.refinedmods.refinedstorage2.platform.common.internal.storage.channel.StorageChannelTypes; import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.FluidStorageType; +import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.StorageTypes; import javax.annotation.Nullable; @@ -46,30 +40,7 @@ protected String formatAmount(final long amount) { @Override protected Storage createStorage(final StorageRepository storageRepository) { - final TrackedStorageRepository trackingRepository = new InMemoryTrackedStorageRepository<>(); - if (!variant.hasCapacity()) { - final TrackedStorageImpl delegate = new TrackedStorageImpl<>( - new InMemoryStorageImpl<>(), - trackingRepository, - System::currentTimeMillis - ); - return new PlatformStorage<>( - delegate, - FluidStorageType.INSTANCE, - trackingRepository, - storageRepository::markAsChanged - ); - } - final LimitedStorageImpl delegate = new LimitedStorageImpl<>( - new TrackedStorageImpl<>(new InMemoryStorageImpl<>(), trackingRepository, System::currentTimeMillis), - variant.getCapacityInBuckets() * Platform.INSTANCE.getBucketAmount() - ); - return new LimitedPlatformStorage<>( - delegate, - FluidStorageType.INSTANCE, - trackingRepository, - storageRepository::markAsChanged - ); + return StorageTypes.FLUID.create(variant.getCapacity(), storageRepository::markAsChanged); } @Override diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/item/ItemStorageDiskItem.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/item/ItemStorageDiskItem.java index e9efa237b..456cb365c 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/item/ItemStorageDiskItem.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/item/ItemStorageDiskItem.java @@ -1,21 +1,15 @@ package com.refinedmods.refinedstorage2.platform.common.item; -import com.refinedmods.refinedstorage2.api.storage.InMemoryStorageImpl; import com.refinedmods.refinedstorage2.api.storage.Storage; -import com.refinedmods.refinedstorage2.api.storage.limited.LimitedStorageImpl; -import com.refinedmods.refinedstorage2.api.storage.tracked.InMemoryTrackedStorageRepository; -import com.refinedmods.refinedstorage2.api.storage.tracked.TrackedStorageImpl; -import com.refinedmods.refinedstorage2.api.storage.tracked.TrackedStorageRepository; import com.refinedmods.refinedstorage2.platform.api.PlatformApi; import com.refinedmods.refinedstorage2.platform.api.item.AbstractStorageContainerItem; import com.refinedmods.refinedstorage2.platform.api.resource.ItemResource; import com.refinedmods.refinedstorage2.platform.api.storage.StorageRepository; import com.refinedmods.refinedstorage2.platform.api.util.AmountFormatting; import com.refinedmods.refinedstorage2.platform.common.content.Items; -import com.refinedmods.refinedstorage2.platform.common.internal.storage.LimitedPlatformStorage; -import com.refinedmods.refinedstorage2.platform.common.internal.storage.PlatformStorage; import com.refinedmods.refinedstorage2.platform.common.internal.storage.channel.StorageChannelTypes; import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.ItemStorageType; +import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.StorageTypes; import javax.annotation.Nullable; @@ -46,30 +40,7 @@ protected String formatAmount(final long amount) { @Override protected Storage createStorage(final StorageRepository storageRepository) { - final TrackedStorageRepository trackingRepository = new InMemoryTrackedStorageRepository<>(); - if (!variant.hasCapacity()) { - final TrackedStorageImpl delegate = new TrackedStorageImpl<>( - new InMemoryStorageImpl<>(), - trackingRepository, - System::currentTimeMillis - ); - return new PlatformStorage<>( - delegate, - ItemStorageType.INSTANCE, - trackingRepository, - storageRepository::markAsChanged - ); - } - final LimitedStorageImpl delegate = new LimitedStorageImpl<>( - new TrackedStorageImpl<>(new InMemoryStorageImpl<>(), trackingRepository, System::currentTimeMillis), - variant.getCapacity() - ); - return new LimitedPlatformStorage<>( - delegate, - ItemStorageType.INSTANCE, - trackingRepository, - storageRepository::markAsChanged - ); + return StorageTypes.ITEM.create(variant.getCapacity(), storageRepository::markAsChanged); } @Override diff --git a/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/PlatformTestFixtures.java b/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/PlatformTestFixtures.java index 81e3922ac..7aaefa6f5 100644 --- a/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/PlatformTestFixtures.java +++ b/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/PlatformTestFixtures.java @@ -3,14 +3,14 @@ import com.refinedmods.refinedstorage2.platform.api.registry.PlatformRegistry; import com.refinedmods.refinedstorage2.platform.api.storage.type.StorageType; import com.refinedmods.refinedstorage2.platform.common.internal.registry.PlatformRegistryImpl; -import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.ItemStorageType; +import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.StorageTypes; import net.minecraft.resources.ResourceLocation; public final class PlatformTestFixtures { public static final PlatformRegistry> STORAGE_TYPE_REGISTRY = new PlatformRegistryImpl<>( new ResourceLocation("item"), - ItemStorageType.INSTANCE + StorageTypes.ITEM ); private PlatformTestFixtures() { diff --git a/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/LimitedPlatformStorageTest.java b/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/LimitedPlatformStorageTest.java index 28d5f3d94..357dd4943 100644 --- a/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/LimitedPlatformStorageTest.java +++ b/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/LimitedPlatformStorageTest.java @@ -4,7 +4,7 @@ import com.refinedmods.refinedstorage2.api.storage.limited.LimitedStorage; import com.refinedmods.refinedstorage2.api.storage.limited.LimitedStorageImpl; import com.refinedmods.refinedstorage2.platform.api.resource.ItemResource; -import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.ItemStorageType; +import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.StorageTypes; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -18,13 +18,13 @@ class LimitedPlatformStorageTest { @SuppressWarnings("ConstantConditions") void setUp() { final LimitedStorageImpl delegate = new LimitedStorageImpl<>(new InMemoryStorageImpl<>(), 100); - sut = new LimitedPlatformStorage<>(delegate, ItemStorageType.INSTANCE, null, null); + sut = new LimitedPlatformStorage<>(delegate, StorageTypes.ITEM, null, null); } @Test void testSetup() { // Assert - assertThat(sut.getType()).isEqualTo(ItemStorageType.INSTANCE); + assertThat(sut.getType()).isEqualTo(StorageTypes.ITEM); assertThat(sut).isInstanceOf(LimitedStorage.class); assertThat(sut.getCapacity()).isEqualTo(100); } diff --git a/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/PlatformStorageTest.java b/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/PlatformStorageTest.java index f89864edf..1b1a3ddec 100644 --- a/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/PlatformStorageTest.java +++ b/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/PlatformStorageTest.java @@ -12,7 +12,7 @@ import com.refinedmods.refinedstorage2.platform.api.resource.ItemResource; import com.refinedmods.refinedstorage2.platform.api.storage.PlayerActor; import com.refinedmods.refinedstorage2.platform.common.SimpleListener; -import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.ItemStorageType; +import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.StorageTypes; import com.refinedmods.refinedstorage2.platform.test.SetupMinecraft; import net.minecraft.world.item.Items; @@ -38,13 +38,13 @@ void setUp() { () -> 0L ); listener = new SimpleListener(); - sut = new PlatformStorage<>(delegate, ItemStorageType.INSTANCE, trackedStorageRepository, listener); + sut = new PlatformStorage<>(delegate, StorageTypes.ITEM, trackedStorageRepository, listener); } @Test void testInitialState() { // Assert - assertThat(sut.getType()).isEqualTo(ItemStorageType.INSTANCE); + assertThat(sut.getType()).isEqualTo(StorageTypes.ITEM); assertThat(sut).isNotInstanceOf(LimitedStorage.class); } diff --git a/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/StorageRepositoryImplTest.java b/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/StorageRepositoryImplTest.java index dbdf37f1e..366ce95a3 100644 --- a/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/StorageRepositoryImplTest.java +++ b/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/StorageRepositoryImplTest.java @@ -14,7 +14,7 @@ import com.refinedmods.refinedstorage2.platform.api.resource.ItemResource; import com.refinedmods.refinedstorage2.platform.api.storage.PlayerActor; import com.refinedmods.refinedstorage2.platform.common.PlatformTestFixtures; -import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.ItemStorageType; +import com.refinedmods.refinedstorage2.platform.common.internal.storage.type.StorageTypes; import com.refinedmods.refinedstorage2.platform.test.SetupMinecraft; import java.util.Optional; @@ -43,7 +43,7 @@ private PlatformStorage createSerializableStorage(final Storage limitedStorage) { return new LimitedPlatformStorage<>( limitedStorage, - ItemStorageType.INSTANCE, + StorageTypes.ITEM, new InMemoryTrackedStorageRepository<>(), () -> { } @@ -51,7 +51,7 @@ private PlatformStorage createSerializableStorage(final Storage( storage, - ItemStorageType.INSTANCE, + StorageTypes.ITEM, new InMemoryTrackedStorageRepository<>(), () -> { } @@ -234,13 +234,13 @@ void shouldSerializeAndDeserialize() { final InMemoryTrackedStorageRepository repository = new InMemoryTrackedStorageRepository<>(); final PlatformStorage a = new PlatformStorage<>( new TrackedStorageImpl<>(new InMemoryStorageImpl<>(), repository, () -> 123L), - ItemStorageType.INSTANCE, + StorageTypes.ITEM, repository, sut::markAsChanged ); final PlatformStorage b = new LimitedPlatformStorage<>( new LimitedStorageImpl<>(new InMemoryStorageImpl<>(), 100), - ItemStorageType.INSTANCE, + StorageTypes.ITEM, new InMemoryTrackedStorageRepository<>(), sut::markAsChanged ); diff --git a/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/type/FluidStorageTypeTest.java b/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/type/FluidStorageTypeTest.java index a3e0230fc..88a4f496d 100644 --- a/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/type/FluidStorageTypeTest.java +++ b/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/type/FluidStorageTypeTest.java @@ -28,7 +28,7 @@ @SetupMinecraft class FluidStorageTypeTest { - FluidStorageType sut = FluidStorageType.INSTANCE; + FluidStorageType sut = StorageTypes.FLUID; SimpleListener listener; @BeforeEach @@ -42,7 +42,7 @@ void shouldSerializeAndDeserializeRegularStorage() { final InMemoryTrackedStorageRepository tracker = new InMemoryTrackedStorageRepository<>(); final Storage storage = new PlatformStorage<>( new TrackedStorageImpl<>(new InMemoryStorageImpl<>(), tracker, () -> 123L), - FluidStorageType.INSTANCE, + StorageTypes.FLUID, tracker, () -> { } @@ -78,7 +78,7 @@ void shouldCallListenerOnDeserializedStorage() { final InMemoryTrackedStorageRepository tracker = new InMemoryTrackedStorageRepository<>(); final Storage storage = new PlatformStorage<>( new TrackedStorageImpl<>(new InMemoryStorageImpl<>(), tracker, () -> 123L), - FluidStorageType.INSTANCE, + StorageTypes.FLUID, tracker, () -> { } @@ -107,7 +107,7 @@ void shouldSerializeLimitedStorage() { new TrackedStorageImpl<>(new InMemoryStorageImpl<>(), tracker, () -> 123L), 100 ), - FluidStorageType.INSTANCE, + StorageTypes.FLUID, tracker, () -> { } diff --git a/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/type/ItemStorageTypeTest.java b/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/type/ItemStorageTypeTest.java index 8c4842a4d..60cba8e9e 100644 --- a/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/type/ItemStorageTypeTest.java +++ b/refinedstorage2-platform-common/src/test/java/com/refinedmods/refinedstorage2/platform/common/internal/storage/type/ItemStorageTypeTest.java @@ -28,7 +28,7 @@ @SetupMinecraft class ItemStorageTypeTest { - ItemStorageType sut = ItemStorageType.INSTANCE; + ItemStorageType sut = StorageTypes.ITEM; SimpleListener listener; @BeforeEach @@ -42,7 +42,7 @@ void shouldSerializeAndDeserializeRegularStorage() { final InMemoryTrackedStorageRepository tracker = new InMemoryTrackedStorageRepository<>(); final Storage storage = new PlatformStorage<>( new TrackedStorageImpl<>(new InMemoryStorageImpl<>(), tracker, () -> 123L), - ItemStorageType.INSTANCE, + StorageTypes.ITEM, tracker, () -> { } @@ -78,7 +78,7 @@ void shouldCallListenerOnDeserializedStorage() { final InMemoryTrackedStorageRepository tracker = new InMemoryTrackedStorageRepository<>(); final Storage storage = new PlatformStorage<>( new TrackedStorageImpl<>(new InMemoryStorageImpl<>(), tracker, () -> 123L), - ItemStorageType.INSTANCE, + StorageTypes.ITEM, tracker, () -> { } @@ -104,7 +104,7 @@ void shouldSerializeLimitedStorage() { final InMemoryTrackedStorageRepository tracker = new InMemoryTrackedStorageRepository<>(); final Storage storage = new LimitedPlatformStorage<>( new LimitedStorageImpl<>(new TrackedStorageImpl<>(new InMemoryStorageImpl<>(), tracker, () -> 123L), 100), - ItemStorageType.INSTANCE, + StorageTypes.ITEM, tracker, () -> { }