use of com.minecolonies.api.colony.requestsystem.factory.IFactoryController in project minecolonies by Minecolonies.
the class StandardRetryingRequestResolverFactory method deserialize.
@NotNull
@Override
public StandardRetryingRequestResolver deserialize(@NotNull final IFactoryController controller, @NotNull final NBTTagCompound nbt) {
final Map<IToken<?>, Integer> assignments = NBTUtils.streamCompound(nbt.getTagList(NBT_TRIES, Constants.NBT.TAG_COMPOUND)).map(assignmentCompound -> {
IToken token = controller.deserialize(assignmentCompound.getCompoundTag(NBT_TOKEN));
Integer tries = assignmentCompound.getInteger(NBT_VALUE);
return new HashMap.SimpleEntry<>(token, tries);
}).collect(Collectors.toMap(HashMap.SimpleEntry::getKey, HashMap.SimpleEntry::getValue));
final Map<IToken<?>, Integer> delays = NBTUtils.streamCompound(nbt.getTagList(NBT_DELAYS, Constants.NBT.TAG_COMPOUND)).map(assignmentCompound -> {
IToken token = controller.deserialize(assignmentCompound.getCompoundTag(NBT_TOKEN));
Integer tries = assignmentCompound.getInteger(NBT_VALUE);
return new HashMap.SimpleEntry<>(token, tries);
}).collect(Collectors.toMap(HashMap.SimpleEntry::getKey, HashMap.SimpleEntry::getValue));
final IToken<?> token = controller.deserialize(nbt.getCompoundTag(NBT_TOKEN));
final ILocation location = controller.deserialize(nbt.getCompoundTag(NBT_LOCATION));
final StandardRetryingRequestResolver retryingRequestResolver = new StandardRetryingRequestResolver(token, location);
retryingRequestResolver.updateData(assignments, delays);
return retryingRequestResolver;
}
use of com.minecolonies.api.colony.requestsystem.factory.IFactoryController in project minecolonies by Minecolonies.
the class StandardPlayerRequestResolverFactory method deserialize.
@NotNull
@Override
public StandardPlayerRequestResolver deserialize(@NotNull final IFactoryController controller, @NotNull final NBTTagCompound nbt) {
final IToken token = controller.deserialize(nbt.getCompoundTag(NBT_TOKEN));
final ILocation location = controller.deserialize(nbt.getCompoundTag(NBT_LOCATION));
final Set<IToken<?>> assignedRequests = NBTUtils.streamCompound(nbt.getTagList(NBT_ASSIGNED_REQUESTS, Constants.NBT.TAG_COMPOUND)).map(c -> (IToken<?>) controller.deserialize(c)).collect(Collectors.toSet());
final StandardPlayerRequestResolver resolver = new StandardPlayerRequestResolver(location, token);
resolver.setAllAssignedRequests(assignedRequests);
return resolver;
}
Aggregations