2017-01-30 01:43:34 +01:00
|
|
|
package tc.oc.api.minecraft.maps;
|
|
|
|
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.Collections;
|
|
|
|
import javax.inject.Inject;
|
|
|
|
import javax.inject.Singleton;
|
|
|
|
|
|
|
|
import com.google.common.util.concurrent.Futures;
|
|
|
|
import com.google.common.util.concurrent.ListenableFuture;
|
|
|
|
import tc.oc.api.docs.MapRating;
|
|
|
|
import tc.oc.api.docs.virtual.MapDoc;
|
|
|
|
import tc.oc.api.maps.MapRatingsRequest;
|
|
|
|
import tc.oc.api.maps.MapRatingsResponse;
|
|
|
|
import tc.oc.api.maps.MapService;
|
2017-02-02 09:51:51 +01:00
|
|
|
import tc.oc.api.maps.UpdateMapsResponse;
|
|
|
|
import tc.oc.api.message.types.UpdateMultiResponse;
|
2017-01-30 01:43:34 +01:00
|
|
|
import tc.oc.api.minecraft.users.UserStore;
|
|
|
|
import tc.oc.api.model.NullModelService;
|
2017-02-02 09:51:51 +01:00
|
|
|
import tc.oc.api.users.UserService;
|
|
|
|
import tc.oc.api.util.UUIDs;
|
2017-01-30 01:43:34 +01:00
|
|
|
import tc.oc.commons.core.stream.Collectors;
|
|
|
|
import tc.oc.minecraft.api.entity.Player;
|
|
|
|
|
|
|
|
@Singleton
|
|
|
|
public class LocalMapService extends NullModelService<MapDoc, MapDoc> implements MapService {
|
|
|
|
|
|
|
|
@Inject private UserStore<Player> userStore;
|
2017-02-02 09:51:51 +01:00
|
|
|
@Inject private UserService userService;
|
2017-01-30 01:43:34 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public ListenableFuture<?> rate(MapRating rating) {
|
|
|
|
return Futures.immediateFuture(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ListenableFuture<MapRatingsResponse> getRatings(MapRatingsRequest request) {
|
|
|
|
return Futures.immediateFuture(Collections::emptyMap);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-02-02 09:51:51 +01:00
|
|
|
public UpdateMapsResponse updateMaps(Collection<? extends MapDoc> maps) {
|
|
|
|
return new UpdateMapsResponse(
|
|
|
|
Futures.immediateFuture(UpdateMultiResponse.EMPTY),
|
2017-01-30 01:43:34 +01:00
|
|
|
maps.stream()
|
2017-02-02 09:51:51 +01:00
|
|
|
.flatMap(MapDoc::authorAndContributorUuids)
|
|
|
|
.distinct()
|
|
|
|
.collect(Collectors.mappingTo(uuid -> (ListenableFuture) userService.find(() -> UUIDs.normalize(uuid))))
|
|
|
|
);
|
2017-01-30 01:43:34 +01:00
|
|
|
}
|
|
|
|
}
|