Search in sources :

Example 1 with IRetryingRequestResolver

use of com.minecolonies.api.colony.requestsystem.resolver.retrying.IRetryingRequestResolver in project minecolonies by Minecolonies.

the class WindowClipBoard method getOpenRequests.

private ImmutableList<IRequest> getOpenRequests() {
    final ArrayList<IRequest> requests = Lists.newArrayList();
    final ColonyView view = ColonyManager.getColonyView(colonyId);
    if (view == null) {
        return ImmutableList.of();
    }
    final IPlayerRequestResolver resolver = view.getRequestManager().getPlayerResolver();
    final IRetryingRequestResolver retryingRequestResolver = view.getRequestManager().getRetryingRequestResolver();
    final Set<IToken> requestTokens = new HashSet<>();
    requestTokens.addAll(resolver.getAllAssignedRequests());
    requestTokens.addAll(retryingRequestResolver.getAllAssignedRequests());
    requests.addAll(requestTokens.stream().map(view.getRequestManager()::getRequestForToken).filter(Objects::nonNull).collect(Collectors.toSet()));
    final BlockPos playerPos = Minecraft.getMinecraft().player.getPosition();
    requests.sort(Comparator.comparing((IRequest request) -> request.getRequester().getDeliveryLocation().getInDimensionLocation().getDistance(playerPos.getX(), playerPos.getY(), playerPos.getZ())).thenComparingInt(request -> request.getToken().hashCode()));
    return ImmutableList.copyOf(requests);
}
Also used : IRequest(com.minecolonies.api.colony.requestsystem.request.IRequest) java.util(java.util) Button(com.minecolonies.blockout.controls.Button) IToken(com.minecolonies.api.colony.requestsystem.token.IToken) ItemIcon(com.minecolonies.blockout.controls.ItemIcon) ColonyView(com.minecolonies.coremod.colony.ColonyView) ItemStack(net.minecraft.item.ItemStack) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) ColonyManager(com.minecolonies.coremod.colony.ColonyManager) Minecraft(net.minecraft.client.Minecraft) IRetryingRequestResolver(com.minecolonies.api.colony.requestsystem.resolver.retrying.IRetryingRequestResolver) Constants(com.minecolonies.api.util.constant.Constants) RequestState(com.minecolonies.api.colony.requestsystem.request.RequestState) BlockPos(net.minecraft.util.math.BlockPos) ScrollingList(com.minecolonies.blockout.views.ScrollingList) Collectors(java.util.stream.Collectors) UpdateRequestStateMessage(com.minecolonies.coremod.network.messages.UpdateRequestStateMessage) IPlayerRequestResolver(com.minecolonies.api.colony.requestsystem.resolver.player.IPlayerRequestResolver) Nullable(org.jetbrains.annotations.Nullable) GuiScreen(net.minecraft.client.gui.GuiScreen) MineColonies(com.minecolonies.coremod.MineColonies) Image(com.minecolonies.blockout.controls.Image) Label(com.minecolonies.blockout.controls.Label) NotNull(org.jetbrains.annotations.NotNull) ColonyView(com.minecolonies.coremod.colony.ColonyView) IToken(com.minecolonies.api.colony.requestsystem.token.IToken) IPlayerRequestResolver(com.minecolonies.api.colony.requestsystem.resolver.player.IPlayerRequestResolver) BlockPos(net.minecraft.util.math.BlockPos) IRequest(com.minecolonies.api.colony.requestsystem.request.IRequest) IRetryingRequestResolver(com.minecolonies.api.colony.requestsystem.resolver.retrying.IRetryingRequestResolver)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 Lists (com.google.common.collect.Lists)1 IRequest (com.minecolonies.api.colony.requestsystem.request.IRequest)1 RequestState (com.minecolonies.api.colony.requestsystem.request.RequestState)1 IPlayerRequestResolver (com.minecolonies.api.colony.requestsystem.resolver.player.IPlayerRequestResolver)1 IRetryingRequestResolver (com.minecolonies.api.colony.requestsystem.resolver.retrying.IRetryingRequestResolver)1 IToken (com.minecolonies.api.colony.requestsystem.token.IToken)1 Constants (com.minecolonies.api.util.constant.Constants)1 Button (com.minecolonies.blockout.controls.Button)1 Image (com.minecolonies.blockout.controls.Image)1 ItemIcon (com.minecolonies.blockout.controls.ItemIcon)1 Label (com.minecolonies.blockout.controls.Label)1 ScrollingList (com.minecolonies.blockout.views.ScrollingList)1 MineColonies (com.minecolonies.coremod.MineColonies)1 ColonyManager (com.minecolonies.coremod.colony.ColonyManager)1 ColonyView (com.minecolonies.coremod.colony.ColonyView)1 UpdateRequestStateMessage (com.minecolonies.coremod.network.messages.UpdateRequestStateMessage)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 Minecraft (net.minecraft.client.Minecraft)1