use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.
the class ModDetailController method setModVersion.
public void setModVersion(ModVersion modVersion) {
this.modVersion = modVersion;
thumbnailImageView.setImage(modService.loadThumbnail(modVersion));
nameLabel.setText(modVersion.getDisplayName());
authorLabel.setText(modVersion.getUploader());
boolean modInstalled = modService.isModInstalled(modVersion.getUid());
installButton.setVisible(!modInstalled);
uninstallButton.setVisible(modInstalled);
modDescriptionLabel.setText(modVersion.getDescription());
modService.getInstalledModVersions().addListener(new WeakListChangeListener<>(installStatusChangeListener));
setInstalled(modService.isModInstalled(modVersion.getUid()));
updatedLabel.setText(timeService.asDate(modVersion.getUpdateTime()));
sizeLabel.setText(Bytes.formatSize(getModSize(), i18n.getUserSpecificLocale()));
installationsLabel.setText(String.format(i18n.getUserSpecificLocale(), "%d", modVersion.getDownloads()));
versionLabel.setText(modVersion.getVersion().toString());
Player player = playerService.getCurrentPlayer().orElseThrow(() -> new IllegalStateException("No current player is available"));
reviewsController.setCanWriteReview(modService.isModInstalled(modVersion.getUid()));
reviewsController.setOnSendReviewListener(this::onSendReview);
reviewsController.setOnDeleteReviewListener(this::onDeleteReview);
reviewsController.setReviews(modVersion.getReviews());
reviewsController.setOwnReview(modVersion.getReviews().stream().filter(review -> review.getPlayer().getId() == player.getId()).findFirst());
}
use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.
the class ModDetailController method onSendReview.
private void onSendReview(Review review) {
boolean isNew = review.getId() == null;
Player player = playerService.getCurrentPlayer().orElseThrow(() -> new IllegalStateException("No current player is available"));
review.setPlayer(player);
reviewService.saveModVersionReview(review, modVersion.getId()).thenRun(() -> {
if (isNew) {
modVersion.getReviews().add(review);
}
reviewsController.setOwnReview(Optional.of(review));
}).exceptionally(throwable -> {
log.warn("Review could not be saved", throwable);
return null;
});
}
use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.
the class MapDetailController method onSendReview.
private void onSendReview(Review review) {
boolean isNew = review.getId() == null;
Player player = playerService.getCurrentPlayer().orElseThrow(() -> new IllegalStateException("No current player is available"));
review.setPlayer(player);
reviewService.saveMapVersionReview(review, map.getId()).thenRun(() -> {
if (isNew) {
map.getReviews().add(review);
}
reviewsController.setOwnReview(Optional.of(review));
}).exceptionally(throwable -> {
log.warn("Review could not be saved", throwable);
return null;
});
}
use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.
the class ReplayDetailController method onSendReview.
private void onSendReview(Review review) {
boolean isNew = review.getId() == null;
Player player = playerService.getCurrentPlayer().orElseThrow(() -> new IllegalStateException("No current player is available"));
review.setPlayer(player);
reviewService.saveGameReview(review, replay.getId()).thenRun(() -> {
if (isNew) {
replay.getReviews().add(review);
}
reviewsController.setOwnReview(Optional.of(review));
}).exceptionally(throwable -> {
log.warn("Review could not be saved", throwable);
return null;
});
}
use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.
the class AchievementServiceImplTest method setUp.
@Before
public void setUp() throws Exception {
instance = new AchievementServiceImpl(fafService, playerService, assetService);
Player player = new Player("abc");
player.setId(PLAYER_ID);
when(playerService.getCurrentPlayer()).thenReturn(Optional.of(player));
instance.postConstruct();
}
Aggregations