use of com.neovisionaries.i18n.CountryCode in project steve by RWTH-i5-IDSG.
the class ControllerHelper method populateCountryCodes.
private static Map<String, String> populateCountryCodes() {
CountryCode[] codes = CountryCode.values();
Arrays.sort(codes, Comparator.comparing(CountryCode::getName));
Map<String, String> map = new LinkedHashMap<>(codes.length + 1);
map.put("", EMPTY_OPTION);
for (CountryCode c : codes) {
if (shouldInclude(c)) {
map.put(c.getAlpha2(), c.getName());
}
}
return map;
}
use of com.neovisionaries.i18n.CountryCode in project spotifybot by NotEchoDE.
the class PlayCommand method exec.
@SneakyThrows
@Override
public void exec(String userName, String id, UserLevel userLevel, String[] args) {
ModuleEntry sPlay = getModule().getEntry("sPlay");
if (!userLevel.isHigherOrEquals(sPlay.getUserLevel())) {
sendMessage(getModule(ModuleType.SYSTEM).getEntry("noPerms"), "$USER", userName, "$ROLE", sPlay.getUserLevel().getPrettyName());
return;
}
if (args.length >= 1) {
StringBuilder searchQuery = new StringBuilder();
for (int i = 0; i < args.length; i++) if (i != 0)
searchQuery.append(" ");
else
searchQuery.append(args[i]);
Paging<Track> search = getRoot().getSpotifyApi().searchTracks(searchQuery.toString()).build().execute();
if (search.getTotal() == 0) {
sendMessage(getModule(ModuleType.SONGREQUEST).getEntry("notFound"), "$USER", userName);
return;
}
String uri = search.getItems()[0].getUri();
CountryCode country = getRoot().getSpotifyApi().getCurrentUsersProfile().build().execute().getCountry();
Track track = getRoot().getSpotifyApi().getTrack(uri.replace("spotify:track:", "")).build().execute();
if (Arrays.stream(track.getAvailableMarkets()).noneMatch(countryCode -> countryCode.equals(CountryCode.DE))) {
sendMessage(getModule(ModuleType.SONGREQUEST).getEntry("notAvailable"), "$USER", userName, "$SONG", track.getName());
return;
}
getRoot().getSpotifyApi().addItemToUsersPlaybackQueue(uri).build().execute();
getRoot().getSpotifyApi().skipUsersPlaybackToNextTrack().build().execute();
sendMessage(sPlay, "$USER", userName, "$SONG", track.getName());
return;
}
getRoot().getSpotifyApi().startResumeUsersPlayback().build().execute();
String uri = SpotifyUtils.getUriFromJson(getRoot().getSpotifyApi().getUsersCurrentlyPlayingTrack().build().getJson());
Track track = getRoot().getSpotifyApi().getTrack(SpotifyUtils.getIdFromUri(uri)).build().execute();
sendMessage(sPlay, "$USER", userName, "$SONG", track.getName(), "$ARTISTS", SpotifyUtils.getArtists(track));
}
use of com.neovisionaries.i18n.CountryCode in project downlords-faf-client by FAForever.
the class UserInfoWindowController method setPlayer.
public void setPlayer(Player player) {
this.player = player;
usernameLabel.setText(player.getUsername());
countryFlagService.loadCountryFlag(player.getCountry()).ifPresent(image -> countryImageView.setImage(image));
avatarImageView.setImage(IdenticonUtil.createIdenticon(player.getId()));
gamesPlayedLabel.setText(i18n.number(player.getNumberOfGames()));
ratingLabelGlobal.setText(i18n.number(RatingUtil.getGlobalRating(player)));
ratingLabel1v1.setText(i18n.number(RatingUtil.getLeaderboardRating(player)));
updateNameHistory(player);
CountryCode countryCode = CountryCode.getByCode(player.getCountry());
if (countryCode != null) {
// Country code is unknown to CountryCode, like A1 or A2 (from GeoIP)
countryLabel.setText(countryCode.getName());
} else {
countryLabel.setText(player.getCountry());
}
globalButton.fire();
globalButton.setSelected(true);
loadAchievements();
eventService.getPlayerEvents(player.getId()).thenAccept(events -> {
plotFactionsChart(events);
plotUnitsByCategoriesChart(events);
plotTechBuiltChart(events);
plotGamesPlayedChart();
}).exceptionally(throwable -> {
notificationService.addImmediateErrorNotification(throwable, "userInfo.statistics.errorLoading");
log.warn("Could not load player events", throwable);
return null;
});
}
use of com.neovisionaries.i18n.CountryCode in project downlords-faf-client by FAForever.
the class PrivateUserInfoController method setPlayer.
public void setPlayer(Player player) {
this.player = player;
CountryCode countryCode = CountryCode.getByCode(player.getCountry());
usernameLabel.setText(player.getUsername());
userImageView.setImage(IdenticonUtil.createIdenticon(player.getId()));
countryFlagService.loadCountryFlag(player.getCountry()).ifPresent(image -> countryImageView.setImage(image));
countryLabel.setText(countryCode == null ? player.getCountry() : countryCode.getName());
player.globalRatingMeanProperty().addListener((observable) -> loadReceiverGlobalRatingInformation(player));
player.globalRatingDeviationProperty().addListener((observable) -> loadReceiverGlobalRatingInformation(player));
loadReceiverGlobalRatingInformation(player);
player.leaderboardRatingMeanProperty().addListener((observable) -> loadReceiverLadderRatingInformation(player));
player.leaderboardRatingDeviationProperty().addListener((observable) -> loadReceiverLadderRatingInformation(player));
loadReceiverLadderRatingInformation(player);
player.gameProperty().addListener(new WeakInvalidationListener(gameInvalidationListener));
gameInvalidationListener.invalidated(player.gameProperty());
gamesPlayedLabel.textProperty().bind(player.numberOfGamesProperty().asString());
populateUnlockedAchievementsLabel(player);
}
use of com.neovisionaries.i18n.CountryCode in project commercetools-jvm-sdk by commercetools.
the class TaxCategoryUpdateCommandIntegrationTest method addTaxRate.
@Test
public void addTaxRate() {
withUpdateableTaxCategory(client(), taxCategory -> {
// add tax rate
final String name = "ag7";
final CountryCode countryCode = CountryCode.AG;
final TaxRateDraft de7 = TaxRateDraftBuilder.of(name, 0.07, true, countryCode).build();
final TaxCategory taxCategoryWithTaRate = client().executeBlocking(TaxCategoryUpdateCommand.of(taxCategory, AddTaxRate.of(de7)));
final TaxRate actual = taxCategoryWithTaRate.getTaxRates().stream().filter(rate -> name.equals(rate.getName())).findFirst().get();
assertThat(actual.getCountry()).isEqualTo(countryCode);
assertThat(actual.getAmount()).isEqualTo(0.07);
assertThat(actual.getId()).overridingErrorMessage("the tax rate fetched from API has an id").isNotNull();
assertThat(actual.getName()).isEqualTo(de7.getName());
// remove tax rate
final TaxCategory updatedTaxCategory = client().executeBlocking(TaxCategoryUpdateCommand.of(taxCategoryWithTaRate, RemoveTaxRate.of(actual.getId())));
assertThat(updatedTaxCategory.getTaxRates()).matches(rates -> !rates.stream().anyMatch(rate -> name.equals(rate.getName())));
return updatedTaxCategory;
});
}
Aggregations