Search in sources :

Example 21 with Player

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);
}
Also used : Player(com.faforever.client.player.Player) Game(com.faforever.client.api.dto.Game) GameReview(com.faforever.client.api.dto.GameReview) Async(org.springframework.scheduling.annotation.Async)

Example 22 with Player

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);
}
Also used : Player(com.faforever.client.player.Player) MapVersionReview(com.faforever.client.api.dto.MapVersionReview) MapVersion(com.faforever.client.api.dto.MapVersion) Async(org.springframework.scheduling.annotation.Async)

Example 23 with Player

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;
}
Also used : Player(com.faforever.client.player.Player)

Example 24 with Player

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);
    }
}
Also used : Player(com.faforever.client.player.Player) InputStreamReader(java.io.InputStreamReader) ArrayList(java.util.ArrayList) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) URL(java.net.URL)

Example 25 with Player

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));
    }
}
Also used : Player(com.faforever.client.player.Player) UnreadPrivateMessageEvent(com.faforever.client.chat.event.UnreadPrivateMessageEvent) ChatPrefs(com.faforever.client.preferences.ChatPrefs)

Aggregations

Player (com.faforever.client.player.Player)51 AbstractPlainJavaFxTest (com.faforever.client.test.AbstractPlainJavaFxTest)17 Test (org.junit.Test)17 Pane (javafx.scene.layout.Pane)8 I18n (com.faforever.client.i18n.I18n)7 PlayerService (com.faforever.client.player.PlayerService)7 UiService (com.faforever.client.theme.UiService)7 ClientProperties (com.faforever.client.config.ClientProperties)6 Controller (com.faforever.client.fx.Controller)6 ArrayList (java.util.ArrayList)6 Platform (javafx.application.Platform)6 Node (javafx.scene.Node)6 Scope (org.springframework.context.annotation.Scope)6 Component (org.springframework.stereotype.Component)6 JavaFxUtil (com.faforever.client.fx.JavaFxUtil)5 NotificationService (com.faforever.client.notification.NotificationService)5 TimeService (com.faforever.client.util.TimeService)5 Collection (java.util.Collection)5 List (java.util.List)5 Map (java.util.Map)5