diff --git a/src/main/java/com/minecolonies/api/colony/requestsystem/resolver/IRequestResolver.java b/src/main/java/com/minecolonies/api/colony/requestsystem/resolver/IRequestResolver.java index b90ad1332c0..78c7ac780c2 100755 --- a/src/main/java/com/minecolonies/api/colony/requestsystem/resolver/IRequestResolver.java +++ b/src/main/java/com/minecolonies/api/colony/requestsystem/resolver/IRequestResolver.java @@ -134,4 +134,10 @@ default int getSuitabilityMetric(@NotNull final IRequestManager manager, @NotNul * @return The priority of this resolver. */ int getPriority(); + + /** + * If this resolver has valid data in it. + * @return true if so. + */ + boolean isValid(); } \ No newline at end of file diff --git a/src/main/java/com/minecolonies/core/colony/requestsystem/data/StandardRequestResolversIdentitiesDataStore.java b/src/main/java/com/minecolonies/core/colony/requestsystem/data/StandardRequestResolversIdentitiesDataStore.java index 1f8f091559c..eb2b37565c2 100755 --- a/src/main/java/com/minecolonies/core/colony/requestsystem/data/StandardRequestResolversIdentitiesDataStore.java +++ b/src/main/java/com/minecolonies/core/colony/requestsystem/data/StandardRequestResolversIdentitiesDataStore.java @@ -17,13 +17,11 @@ import net.minecraft.nbt.ListTag; import net.minecraft.nbt.Tag; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.util.Tuple; import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.Map; -import java.util.stream.Collectors; import static com.minecolonies.api.util.constant.NbtTagConstants.*; @@ -118,15 +116,18 @@ public StandardRequestResolversIdentitiesDataStore deserialize(@NotNull final IF { final IToken token = controller.deserialize(nbt.getCompound(TAG_TOKEN)); final ListTag list = nbt.getList(TAG_LIST, Tag.TAG_COMPOUND); + final BiMap, IRequestResolver> biMap = HashBiMap.create(); - final Map, IRequestResolver> map = NBTUtils.streamCompound(list).map(CompoundTag -> { - final IToken id = controller.deserialize(CompoundTag.getCompound(TAG_TOKEN)); - final IRequestResolver resolver = controller.deserialize(CompoundTag.getCompound(TAG_RESOLVER)); - - return new Tuple, IRequestResolver>(id, resolver); - }).collect(Collectors.toMap((Tuple, IRequestResolver> t) -> t.getA(), (Tuple, IRequestResolver> t) -> t.getB())); - - final BiMap, IRequestResolver> biMap = HashBiMap.create(map); + for (int i = 0; i < list.size(); i++) + { + final CompoundTag mapCompound = list.getCompound(i); + final IToken id = controller.deserialize(mapCompound.getCompound(TAG_TOKEN)); + final IRequestResolver resolver = controller.deserialize(mapCompound.getCompound(TAG_RESOLVER)); + if (resolver.isValid()) + { + biMap.put(id, resolver); + } + } return new StandardRequestResolversIdentitiesDataStore(token, biMap); } diff --git a/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/DeliverymenRequestResolver.java b/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/DeliverymenRequestResolver.java index 44418f55887..2b0ecb5b1cc 100644 --- a/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/DeliverymenRequestResolver.java +++ b/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/DeliverymenRequestResolver.java @@ -170,4 +170,11 @@ public MutableComponent getRequesterDisplayName( { return Component.translatable(TranslationConstants.COM_MINECOLONIES_COREMOD_JOB_DELIVERYMAN); } + + @Override + public boolean isValid() + { + // Always valid + return true; + } } diff --git a/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/StandardPlayerRequestResolver.java b/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/StandardPlayerRequestResolver.java index 3d59abcea9f..3cdc768b6dd 100755 --- a/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/StandardPlayerRequestResolver.java +++ b/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/StandardPlayerRequestResolver.java @@ -227,4 +227,11 @@ public void setAllAssignedRequests(final Set> assignedRequests) this.assignedRequests.clear(); this.assignedRequests.addAll(assignedRequests); } + + @Override + public boolean isValid() + { + // Always valid + return true; + } } diff --git a/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/StandardRetryingRequestResolver.java b/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/StandardRetryingRequestResolver.java index 331119eddf1..3f6a499d13f 100755 --- a/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/StandardRetryingRequestResolver.java +++ b/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/StandardRetryingRequestResolver.java @@ -306,4 +306,11 @@ public void onColonyUpdate(@NotNull final IRequestManager manager, @NotNull fina } }); } + + @Override + public boolean isValid() + { + // Always valid + return true; + } } diff --git a/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/WarehouseConcreteRequestResolver.java b/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/WarehouseConcreteRequestResolver.java index 0c72e4384e6..a78cef0735a 100755 --- a/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/WarehouseConcreteRequestResolver.java +++ b/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/WarehouseConcreteRequestResolver.java @@ -69,4 +69,11 @@ protected boolean internalCanResolve(final List wareHouses, } return false; } + + @Override + public boolean isValid() + { + // Always valid + return true; + } } diff --git a/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/core/AbstractBuildingDependentRequestResolver.java b/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/core/AbstractBuildingDependentRequestResolver.java index 1a35a6f5121..d42e726681a 100755 --- a/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/core/AbstractBuildingDependentRequestResolver.java +++ b/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/core/AbstractBuildingDependentRequestResolver.java @@ -64,4 +64,11 @@ public void resolveRequest(@NotNull final IRequestManager manager, @NotNull fina } public abstract void resolveForBuilding(@NotNull final IRequestManager manager, @NotNull final IRequest request, @NotNull final AbstractBuilding building); + + @Override + public boolean isValid() + { + // Always valid. + return true; + } } diff --git a/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/core/AbstractCraftingProductionResolver.java b/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/core/AbstractCraftingProductionResolver.java index e5d75ce43f6..1d7aa82ae20 100755 --- a/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/core/AbstractCraftingProductionResolver.java +++ b/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/core/AbstractCraftingProductionResolver.java @@ -261,4 +261,10 @@ public void resolveForBuilding(@NotNull final IRequestManager manager, @NotNull manager.updateRequestState(request.getId(), RequestState.RESOLVED); } + + @Override + public boolean isValid() + { + return jobEntry != null; + } } diff --git a/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/core/AbstractCraftingRequestResolver.java b/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/core/AbstractCraftingRequestResolver.java index cb521886c68..d06d76e6181 100755 --- a/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/core/AbstractCraftingRequestResolver.java +++ b/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/core/AbstractCraftingRequestResolver.java @@ -369,4 +369,10 @@ public void resolveForBuilding(@NotNull final IRequestManager manager, @NotNull { manager.updateRequestState(request.getId(), RequestState.RESOLVED); } + + @Override + public boolean isValid() + { + return jobEntry != null; + } } diff --git a/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/core/AbstractWarehouseRequestResolver.java b/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/core/AbstractWarehouseRequestResolver.java index 9ce378289b3..8652aeb85dd 100755 --- a/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/core/AbstractWarehouseRequestResolver.java +++ b/src/main/java/com/minecolonies/core/colony/requestsystem/resolvers/core/AbstractWarehouseRequestResolver.java @@ -325,4 +325,11 @@ public int getPriority() { return CONST_WAREHOUSE_RESOLVER_PRIORITY; } + + @Override + public boolean isValid() + { + // Always valid + return true; + } }