From e7159ad514eb77aa16f30702edc2f2e7c0db8637 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 26 Jun 2024 11:11:13 +0100 Subject: [PATCH] cleanup --- .../scoresaber/ScoreSaberFeature.java | 54 +++++++++++-------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/ScoreSaberFeature.java b/src/main/java/cc/fascinated/bat/features/scoresaber/ScoreSaberFeature.java index b34f9d7..287e3e6 100644 --- a/src/main/java/cc/fascinated/bat/features/scoresaber/ScoreSaberFeature.java +++ b/src/main/java/cc/fascinated/bat/features/scoresaber/ScoreSaberFeature.java @@ -23,7 +23,6 @@ import org.springframework.stereotype.Component; */ @Component public class ScoreSaberFeature extends Feature { - @Autowired public ScoreSaberFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) { super("ScoreSaber"); @@ -43,28 +42,39 @@ public class ScoreSaberFeature extends Feature { ScoreSaberScoreToken scoreToken = score.getScore(); ScoreSaberLeaderboardToken leaderboardToken = score.getLeaderboard(); ScoreSaberScoreToken.LeaderboardPlayerInfo playerInfo = scoreToken.getLeaderboardPlayerInfo(); + + String thumbnailUrl = String.format("https://cdn.scoresaber.com/covers/%s.png", leaderboardToken.getSongHash()); + String authorUrl = String.format("https://scoresaber.com/u/%s", playerInfo.getId()); + String description = String.format("**%s** (%s%s)\n[[Map Link]](%s) [[SS Profile]](%s)", + leaderboardToken.getSongName(), + ScoreSaberUtils.getFormattedDifficulty(leaderboardToken.getDifficulty().getDifficulty()), + leaderboardToken.isRanked() ? " " + leaderboardToken.getStars() + " ⭐" : "", + String.format("https://scoresaber.com/leaderboard/%s", leaderboardToken.getId()), + authorUrl + ); + + String accuracy = leaderboardToken.getMaxScore() == 0 ? "N/A" : + String.format("%s%%", NumberUtils.formatNumberCommas(((double) scoreToken.getBaseScore() / leaderboardToken.getMaxScore()) * 100)); + + String rawPp = scoreToken.getPp() == 0 ? "Unranked" : NumberUtils.formatNumberCommas(scoreToken.getPp()); + String rank = String.format("#%s", NumberUtils.formatNumberCommas(scoreToken.getRank())); + String misses = String.format("%s", scoreToken.getMissedNotes()); + String badCuts = String.format("%s", scoreToken.getBadCuts()); + String maxCombo = String.format("%s %s", + scoreToken.getMaxCombo(), + scoreToken.getMaxCombo() == leaderboardToken.getMaxScore() ? "(FC)" : "" + ); + return EmbedUtils.genericEmbed() - .setThumbnail("https://cdn.scoresaber.com/covers/%s.png".formatted(leaderboardToken.getSongHash())) - .setAuthor(playerInfo.getName() + " just set a new score!", "https://scoresaber.com/u/%s".formatted(playerInfo.getId()), - "https://cdn.scoresaber.com/avatars/%s.jpg".formatted(playerInfo.getId())) - .setDescription("**%s** (%s%s)\n[[Map Link]](%s) [[SS Profile]](%s)".formatted( - leaderboardToken.getSongName(), - ScoreSaberUtils.getFormattedDifficulty(leaderboardToken.getDifficulty().getDifficulty()), - leaderboardToken.isRanked() ? " " + leaderboardToken.getStars() + " ⭐" : "", - "https://scoresaber.com/leaderboard/%s".formatted(leaderboardToken.getId()), - "https://scoresaber.com/u/%s".formatted(playerInfo.getId()) - )) - .addField("Accuracy", "%s%%".formatted( - leaderboardToken.getMaxScore() == 0 ? "N/A" : NumberUtils.formatNumberCommas(((double) scoreToken.getBaseScore() / leaderboardToken.getMaxScore()) * 100) - ), true) - .addField("Raw PP", scoreToken.getPp() == 0 ? "Unranked" : NumberUtils.formatNumberCommas(scoreToken.getPp()), true) - .addField("Rank", "#%s".formatted(NumberUtils.formatNumberCommas(scoreToken.getRank())), true) - .addField("Misses", "%s".formatted(scoreToken.getMissedNotes()), true) - .addField("Bad Cuts", "%s".formatted(scoreToken.getBadCuts()), true) - .addField("Max Combo", "%s %s".formatted( - scoreToken.getMaxCombo(), - scoreToken.getMaxCombo() == leaderboardToken.getMaxScore() ? "(FC)" : "" - ), true) + .setThumbnail(thumbnailUrl) + .setAuthor(playerInfo.getName() + " just set a new score!", authorUrl, playerInfo.getProfilePicture()) + .setDescription(description) + .addField("Accuracy", accuracy, true) + .addField("Raw PP", rawPp, true) + .addField("Rank", rank, true) + .addField("Misses", misses, true) + .addField("Bad Cuts", badCuts, true) + .addField("Max Combo", maxCombo, true) .setTimestamp(DateUtils.getDateFromString(scoreToken.getTimeSet()).toInstant()) .build(); }