use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.
the class FafServiceImpl method saveGameReview.
@Override
@Async
public CompletableFuture<Void> saveGameReview(Review review, int gameId) {
GameReview gameReview = (GameReview) new GameReview().setScore(review.getScore().byteValue()).setText(review.getText());
if (review.getId() == null) {
Assert.notNull(review.getPlayer(), "Player ID must be set");
GameReview updatedReview = fafApiAccessor.createGameReview((GameReview) gameReview.setGame(new Game().setId(String.valueOf(gameId))).setPlayer(new com.faforever.client.api.dto.Player().setId(String.valueOf(review.getPlayer().getId()))));
review.setId(updatedReview.getId());
} else {
fafApiAccessor.updateGameReview((GameReview) gameReview.setId(String.valueOf(review.getId())));
}
return CompletableFuture.completedFuture(null);
}
use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.
the class FafServiceImpl method saveMapVersionReview.
@Override
@Async
public CompletableFuture<Void> saveMapVersionReview(Review review, String mapVersionId) {
MapVersionReview mapVersionReview = (MapVersionReview) new MapVersionReview().setScore(review.getScore().byteValue()).setText(review.getText());
if (review.getId() == null) {
Assert.notNull(review.getPlayer(), "Player ID must be set");
MapVersionReview updatedReview = fafApiAccessor.createMapVersionReview((MapVersionReview) mapVersionReview.setMapVersion(new MapVersion().setId(mapVersionId)).setId(String.valueOf(review.getId())).setPlayer(new com.faforever.client.api.dto.Player().setId(String.valueOf(review.getPlayer().getId()))));
review.setId(updatedReview.getId());
} else {
fafApiAccessor.updateMapVersionReview((MapVersionReview) mapVersionReview.setId(String.valueOf(review.getId())));
}
return CompletableFuture.completedFuture(null);
}
use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.
the class AbstractChatTabController method getMessageCssClass.
protected String getMessageCssClass(String login) {
String cssClass;
Player player = playerService.getPlayerForUsername(login);
if (player == null) {
return CSS_CLASS_CHAT_ONLY;
} else {
cssClass = player.getSocialStatus().getCssClass();
}
if (cssClass.equals("") && player.isChatOnly()) {
cssClass = CSS_CLASS_CHAT_ONLY;
}
return cssClass;
}
use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.
the class AbstractChatTabController method addChatSection.
private void addChatSection(ChatMessage chatMessage) throws IOException {
Player player = playerService.getPlayerForUsername(chatMessage.getUsername());
try (Reader reader = new InputStreamReader(uiService.getThemeFileUrl(CHAT_ENTRY).openStream())) {
String login = chatMessage.getUsername();
String html = CharStreams.toString(reader);
String avatarUrl = "";
String clanTag = "";
String countryFlagUrl = "";
if (player != null) {
avatarUrl = player.getAvatarUrl();
countryFlagUrl = countryFlagService.getCountryFlagUrl(player.getCountry()).map(URL::toString).orElse("");
if (StringUtils.isNotEmpty(player.getClan())) {
clanTag = i18n.get("chat.clanTagFormat", player.getClan());
}
}
String timeString = timeService.asShortTime(chatMessage.getTime());
html = html.replace("{time}", timeString).replace("{avatar}", StringUtils.defaultString(avatarUrl)).replace("{username}", login).replace("{clan-tag}", clanTag).replace("{country-flag}", StringUtils.defaultString(countryFlagUrl)).replace("{section-id}", String.valueOf(++lastEntryId));
Collection<String> cssClasses = new ArrayList<>();
cssClasses.add(String.format("user-%s", chatMessage.getUsername()));
Optional.ofNullable(getMessageCssClass(login)).ifPresent(cssClasses::add);
html = html.replace("{css-classes}", Joiner.on(' ').join(cssClasses));
html = html.replace("{inline-style}", getInlineStyle(login));
addToMessageContainer(html, MESSAGE_CONTAINER_ID);
}
}
use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.
the class PrivateChatTabController method onChatMessage.
@Override
public void onChatMessage(ChatMessage chatMessage) {
Player player = playerService.getPlayerForUsername(chatMessage.getUsername());
ChatPrefs chatPrefs = preferencesService.getPreferences().getChat();
if (player != null && player.getSocialStatus() == FOE && chatPrefs.getHideFoeMessages()) {
return;
}
super.onChatMessage(chatMessage);
if (!hasFocus()) {
audioService.playPrivateMessageSound();
showNotificationIfNecessary(chatMessage);
setUnread(true);
incrementUnreadMessagesCount(1);
eventBus.post(new UnreadPrivateMessageEvent(chatMessage));
}
}
Aggregations