diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/NumberOneScoreFeedListener.java b/src/main/java/cc/fascinated/bat/features/scoresaber/NumberOneScoreFeedListener.java index b20744f..7a01469 100644 --- a/src/main/java/cc/fascinated/bat/features/scoresaber/NumberOneScoreFeedListener.java +++ b/src/main/java/cc/fascinated/bat/features/scoresaber/NumberOneScoreFeedListener.java @@ -2,7 +2,7 @@ package cc.fascinated.bat.features.scoresaber; import cc.fascinated.bat.common.NumberUtils; import cc.fascinated.bat.event.EventListener; -import cc.fascinated.bat.features.scoresaber.profile.GuildNumberOneScoreFeedProfile; +import cc.fascinated.bat.features.scoresaber.profile.guild.NumberOneScoreFeedProfile; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberLeaderboardToken; import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberPlayerScoreToken; @@ -49,12 +49,12 @@ public class NumberOneScoreFeedListener implements EventListener { if (batGuild == null) { continue; } - GuildNumberOneScoreFeedProfile profile = batGuild.getProfile(GuildNumberOneScoreFeedProfile.class); + NumberOneScoreFeedProfile profile = batGuild.getProfile(NumberOneScoreFeedProfile.class); if (profile == null || profile.getChannelId() == null) { continue; } - TextChannel channel = profile.getAsTextChannel(); + TextChannel channel = profile.getTextChannel(); if (channel == null) { log.error("Scoresaber user feed channel is null for guild {}, removing the stored channel.", guild.getId()); profile.setChannelId(null); diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/UserScoreFeedListener.java b/src/main/java/cc/fascinated/bat/features/scoresaber/UserScoreFeedListener.java index 0af493f..793976e 100644 --- a/src/main/java/cc/fascinated/bat/features/scoresaber/UserScoreFeedListener.java +++ b/src/main/java/cc/fascinated/bat/features/scoresaber/UserScoreFeedListener.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.features.scoresaber; import cc.fascinated.bat.event.EventListener; -import cc.fascinated.bat.features.scoresaber.profile.GuildUserScoreFeedProfile; +import cc.fascinated.bat.features.scoresaber.profile.guild.UserScoreFeedProfile; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberLeaderboardToken; import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberPlayerScoreToken; @@ -36,12 +36,12 @@ public class UserScoreFeedListener implements EventListener { if (batGuild == null) { continue; } - GuildUserScoreFeedProfile profile = batGuild.getProfile(GuildUserScoreFeedProfile.class); + UserScoreFeedProfile profile = batGuild.getProfile(UserScoreFeedProfile.class); if (profile == null || profile.getChannelId() == null || !profile.getTrackedUsers().contains(player.getId())) { continue; } - TextChannel channel = profile.getAsTextChannel(); + TextChannel channel = profile.getTextChannel(); if (channel == null) { log.error("Scoresaber user feed channel is null for guild {}, removing the stored channel.", guild.getId()); profile.setChannelId(null); diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/command/numberone/ChannelSubCommand.java b/src/main/java/cc/fascinated/bat/features/scoresaber/command/numberone/ChannelSubCommand.java index 984e583..64d6a07 100644 --- a/src/main/java/cc/fascinated/bat/features/scoresaber/command/numberone/ChannelSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/scoresaber/command/numberone/ChannelSubCommand.java @@ -4,7 +4,7 @@ import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.TextChannelUtils; -import cc.fascinated.bat.features.scoresaber.profile.GuildNumberOneScoreFeedProfile; +import cc.fascinated.bat.features.scoresaber.profile.guild.NumberOneScoreFeedProfile; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatUser; import cc.fascinated.bat.service.GuildService; @@ -35,7 +35,7 @@ public class ChannelSubCommand extends BatSubCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) { - GuildNumberOneScoreFeedProfile profile = guild.getProfile(GuildNumberOneScoreFeedProfile.class); + NumberOneScoreFeedProfile profile = guild.getProfile(NumberOneScoreFeedProfile.class); OptionMapping option = interaction.getOption("channel"); if (option == null) { if (!TextChannelUtils.isValidChannel(profile.getChannelId())) { diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/command/numberone/ResetSubCommand.java b/src/main/java/cc/fascinated/bat/features/scoresaber/command/numberone/ResetSubCommand.java index 8a43fe9..1018e37 100644 --- a/src/main/java/cc/fascinated/bat/features/scoresaber/command/numberone/ResetSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/scoresaber/command/numberone/ResetSubCommand.java @@ -3,7 +3,7 @@ package cc.fascinated.bat.features.scoresaber.command.numberone; import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; -import cc.fascinated.bat.features.scoresaber.profile.GuildNumberOneScoreFeedProfile; +import cc.fascinated.bat.features.scoresaber.profile.guild.NumberOneScoreFeedProfile; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatUser; import cc.fascinated.bat.service.GuildService; @@ -29,7 +29,7 @@ public class ResetSubCommand extends BatSubCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) { - GuildNumberOneScoreFeedProfile profile = guild.getProfile(GuildNumberOneScoreFeedProfile.class); + NumberOneScoreFeedProfile profile = guild.getProfile(NumberOneScoreFeedProfile.class); profile.reset(); guildService.saveGuild(guild); diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/LinkSubCommand.java b/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/LinkSubCommand.java index 491428d..0edf638 100644 --- a/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/LinkSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/LinkSubCommand.java @@ -3,7 +3,6 @@ package cc.fascinated.bat.features.scoresaber.command.scoresaber; import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; -import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatUser; import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberAccountToken; @@ -65,7 +64,7 @@ public class LinkSubCommand extends BatSubCommand { return; } - user.getProfile(UserScoreSaberProfile.class).setSteamId(id); + user.getScoreSaberProfile().setAccountId(id); userService.saveUser(user); interaction.replyEmbeds(EmbedUtils.successEmbed() .setDescription("Successfully linked your [ScoreSaber](%s) profile".formatted("https://scoresaber.com/u/%s".formatted(id))) diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/ResetSubCommand.java b/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/ResetSubCommand.java index 5ece8af..3aef5c8 100644 --- a/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/ResetSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/ResetSubCommand.java @@ -3,7 +3,7 @@ package cc.fascinated.bat.features.scoresaber.command.scoresaber; import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; -import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile; +import cc.fascinated.bat.features.scoresaber.profile.user.ScoreSaberProfile; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatUser; import cc.fascinated.bat.service.UserService; @@ -29,7 +29,7 @@ public class ResetSubCommand extends BatSubCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) { - UserScoreSaberProfile profile = guild.getProfile(UserScoreSaberProfile.class); + ScoreSaberProfile profile = user.getScoreSaberProfile(); profile.reset(); userService.saveUser(user); diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/ScoreSaberCommand.java b/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/ScoreSaberCommand.java index 27106ec..d08172e 100644 --- a/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/ScoreSaberCommand.java +++ b/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/ScoreSaberCommand.java @@ -7,7 +7,7 @@ import cc.fascinated.bat.common.DateUtils; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.NumberUtils; import cc.fascinated.bat.exception.RateLimitException; -import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile; +import cc.fascinated.bat.features.scoresaber.profile.user.ScoreSaberProfile; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatUser; import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberAccountToken; @@ -49,8 +49,8 @@ public class ScoreSaberCommand extends BatCommand { * @param interaction The interaction */ public static void sendProfileEmbed(boolean isSelf, BatUser user, ScoreSaberService scoreSaberService, SlashCommandInteraction interaction) { - UserScoreSaberProfile profile = user.getProfile(UserScoreSaberProfile.class); - if (profile.getSteamId() == null) { + ScoreSaberProfile profile = user.getScoreSaberProfile(); + if (profile.getAccountId() == null) { if (!isSelf) { interaction.replyEmbeds(EmbedUtils.errorEmbed() .setDescription("%s does not have a linked ScoreSaber account".formatted(user.getDiscordUser().getAsMention())) @@ -64,7 +64,7 @@ public class ScoreSaberCommand extends BatCommand { try { long before = System.currentTimeMillis(); - ScoreSaberAccountToken account = scoreSaberService.getAccount(profile.getSteamId()); + ScoreSaberAccountToken account = scoreSaberService.getAccount(profile.getAccountId()); if (account == null) { if (!isSelf) { interaction.replyEmbeds(EmbedUtils.errorEmbed() diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/ChannelSubCommand.java b/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/ChannelSubCommand.java index 7af65ac..081dc01 100644 --- a/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/ChannelSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/ChannelSubCommand.java @@ -4,7 +4,7 @@ import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.TextChannelUtils; -import cc.fascinated.bat.features.scoresaber.profile.GuildUserScoreFeedProfile; +import cc.fascinated.bat.features.scoresaber.profile.guild.UserScoreFeedProfile; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatUser; import cc.fascinated.bat.service.GuildService; @@ -35,7 +35,7 @@ public class ChannelSubCommand extends BatSubCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) { - GuildUserScoreFeedProfile profile = guild.getProfile(GuildUserScoreFeedProfile.class); + UserScoreFeedProfile profile = guild.getProfile(UserScoreFeedProfile.class); OptionMapping option = interaction.getOption("channel"); if (option == null) { if (!TextChannelUtils.isValidChannel(profile.getChannelId())) { diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/ResetSubCommand.java b/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/ResetSubCommand.java index c735874..30b6c5c 100644 --- a/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/ResetSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/ResetSubCommand.java @@ -3,7 +3,7 @@ package cc.fascinated.bat.features.scoresaber.command.userfeed; import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; -import cc.fascinated.bat.features.scoresaber.profile.GuildUserScoreFeedProfile; +import cc.fascinated.bat.features.scoresaber.profile.guild.UserScoreFeedProfile; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatUser; import cc.fascinated.bat.service.GuildService; @@ -29,7 +29,7 @@ public class ResetSubCommand extends BatSubCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) { - GuildUserScoreFeedProfile profile = guild.getProfile(GuildUserScoreFeedProfile.class); + UserScoreFeedProfile profile = guild.getProfile(UserScoreFeedProfile.class); profile.reset(); guildService.saveGuild(guild); diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/UserSubCommand.java b/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/UserSubCommand.java index 789d6ab..d0f12ed 100644 --- a/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/UserSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/UserSubCommand.java @@ -3,8 +3,8 @@ package cc.fascinated.bat.features.scoresaber.command.userfeed; import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; -import cc.fascinated.bat.features.scoresaber.profile.GuildUserScoreFeedProfile; -import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile; +import cc.fascinated.bat.features.scoresaber.profile.guild.UserScoreFeedProfile; +import cc.fascinated.bat.features.scoresaber.profile.user.ScoreSaberProfile; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatUser; import cc.fascinated.bat.service.GuildService; @@ -37,7 +37,7 @@ public class UserSubCommand extends BatSubCommand { @Override public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) { - GuildUserScoreFeedProfile profile = guild.getProfile(GuildUserScoreFeedProfile.class); + UserScoreFeedProfile profile = guild.getProfile(UserScoreFeedProfile.class); OptionMapping option = interaction.getOption("user"); if (option == null) { if (profile.getTrackedUsers().isEmpty()) { @@ -61,25 +61,28 @@ public class UserSubCommand extends BatSubCommand { User target = option.getAsUser(); BatUser targetUser = userService.getUser(target.getId()); - UserScoreSaberProfile targetProfile = targetUser.getProfile(UserScoreSaberProfile.class); - if (targetProfile.getSteamId() == null) { + ScoreSaberProfile targetProfile = targetUser.getScoreSaberProfile(); + if (targetProfile.getAccountId() == null) { interaction.replyEmbeds(EmbedUtils.errorEmbed() .setDescription("The user you are trying to track does not have a linked ScoreSaber profile") .build()).queue(); return; } - if (profile.getTrackedUsers().contains(targetProfile.getSteamId())) { - profile.getTrackedUsers().remove(targetProfile.getSteamId()); - interaction.replyEmbeds(EmbedUtils.successEmbed() - .setDescription("Successfully removed %s from the feed".formatted(target.getAsMention())) - .build()).queue(); + boolean added = false; + if (profile.isUserTracked(targetProfile.getAccountId())) { + profile.removeTrackedUser(targetProfile.getAccountId()); } else { - profile.getTrackedUsers().add(targetProfile.getSteamId()); - interaction.replyEmbeds(EmbedUtils.successEmbed() - .setDescription("Successfully added %s to the feed".formatted(target.getAsMention())) - .build()).queue(); + profile.addTrackedUser(targetProfile.getAccountId()); + added = true; } + + interaction.replyEmbeds(EmbedUtils.successEmbed() + .setDescription("Successfully %s %s from the feed".formatted( + added ? "added" : "removed", + target.getAsMention() + )) + .build()).queue(); guildService.saveGuild(guild); } } diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/profile/GuildNumberOneScoreFeedProfile.java b/src/main/java/cc/fascinated/bat/features/scoresaber/profile/guild/NumberOneScoreFeedProfile.java similarity index 76% rename from src/main/java/cc/fascinated/bat/features/scoresaber/profile/GuildNumberOneScoreFeedProfile.java rename to src/main/java/cc/fascinated/bat/features/scoresaber/profile/guild/NumberOneScoreFeedProfile.java index 1291bee..a035938 100644 --- a/src/main/java/cc/fascinated/bat/features/scoresaber/profile/GuildNumberOneScoreFeedProfile.java +++ b/src/main/java/cc/fascinated/bat/features/scoresaber/profile/guild/NumberOneScoreFeedProfile.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.features.scoresaber.profile; +package cc.fascinated.bat.features.scoresaber.profile.guild; import cc.fascinated.bat.common.Profile; import cc.fascinated.bat.service.DiscordService; @@ -11,13 +11,13 @@ import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; */ @Getter @Setter -public class GuildNumberOneScoreFeedProfile extends Profile { +public class NumberOneScoreFeedProfile extends Profile { /** * The channel ID of the score feed */ private String channelId; - public GuildNumberOneScoreFeedProfile() { + public NumberOneScoreFeedProfile() { super("scoresaber-number-one-score-feed"); } @@ -26,7 +26,7 @@ public class GuildNumberOneScoreFeedProfile extends Profile { * * @return the channel as a TextChannel */ - public TextChannel getAsTextChannel() { + public TextChannel getTextChannel() { return DiscordService.JDA.getTextChannelById(channelId); } diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/profile/GuildUserScoreFeedProfile.java b/src/main/java/cc/fascinated/bat/features/scoresaber/profile/guild/UserScoreFeedProfile.java similarity index 79% rename from src/main/java/cc/fascinated/bat/features/scoresaber/profile/GuildUserScoreFeedProfile.java rename to src/main/java/cc/fascinated/bat/features/scoresaber/profile/guild/UserScoreFeedProfile.java index 3d6ade3..0aa2cc0 100644 --- a/src/main/java/cc/fascinated/bat/features/scoresaber/profile/GuildUserScoreFeedProfile.java +++ b/src/main/java/cc/fascinated/bat/features/scoresaber/profile/guild/UserScoreFeedProfile.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.features.scoresaber.profile; +package cc.fascinated.bat.features.scoresaber.profile.guild; import cc.fascinated.bat.common.Profile; import cc.fascinated.bat.service.DiscordService; @@ -14,7 +14,7 @@ import java.util.List; */ @Getter @Setter -public class GuildUserScoreFeedProfile extends Profile { +public class UserScoreFeedProfile extends Profile { /** * The channel ID of the score feed */ @@ -25,20 +25,21 @@ public class GuildUserScoreFeedProfile extends Profile { */ private List trackedUsers; - public GuildUserScoreFeedProfile() { + public UserScoreFeedProfile() { super("scoresaber-user-score-feed"); } /** - * Gets the tracked users + * Checks if a user is being tracked * - * @return the tracked users + * @param userId the user ID to check + * @return if the user is being tracked */ - public List getTrackedUsers() { + public boolean isUserTracked(String userId) { if (this.trackedUsers == null) { this.trackedUsers = new ArrayList<>(); } - return this.trackedUsers; + return trackedUsers.contains(userId); } /** @@ -70,7 +71,7 @@ public class GuildUserScoreFeedProfile extends Profile { * * @return the channel as a TextChannel */ - public TextChannel getAsTextChannel() { + public TextChannel getTextChannel() { return DiscordService.JDA.getTextChannelById(channelId); } diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/profile/UserScoreSaberProfile.java b/src/main/java/cc/fascinated/bat/features/scoresaber/profile/user/ScoreSaberProfile.java similarity index 59% rename from src/main/java/cc/fascinated/bat/features/scoresaber/profile/UserScoreSaberProfile.java rename to src/main/java/cc/fascinated/bat/features/scoresaber/profile/user/ScoreSaberProfile.java index 799faf1..ce91d3d 100644 --- a/src/main/java/cc/fascinated/bat/features/scoresaber/profile/UserScoreSaberProfile.java +++ b/src/main/java/cc/fascinated/bat/features/scoresaber/profile/user/ScoreSaberProfile.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.features.scoresaber.profile; +package cc.fascinated.bat.features.scoresaber.profile.user; import cc.fascinated.bat.common.Profile; import lombok.Getter; @@ -9,18 +9,18 @@ import lombok.Setter; */ @Setter @Getter -public class UserScoreSaberProfile extends Profile { +public class ScoreSaberProfile extends Profile { /** * The Account ID of the ScoreSaber profile */ - private String steamId; + private String accountId; - public UserScoreSaberProfile() { + public ScoreSaberProfile() { super("scoresaber"); } @Override public void reset() { - this.steamId = null; + this.accountId = null; } } diff --git a/src/main/java/cc/fascinated/bat/model/BatUser.java b/src/main/java/cc/fascinated/bat/model/BatUser.java index 9347bce..c14b7d6 100644 --- a/src/main/java/cc/fascinated/bat/model/BatUser.java +++ b/src/main/java/cc/fascinated/bat/model/BatUser.java @@ -1,6 +1,7 @@ package cc.fascinated.bat.model; import cc.fascinated.bat.common.ProfileHolder; +import cc.fascinated.bat.features.scoresaber.profile.user.ScoreSaberProfile; import cc.fascinated.bat.service.DiscordService; import lombok.Getter; import lombok.NonNull; @@ -47,4 +48,13 @@ public class BatUser extends ProfileHolder { public User getDiscordUser() { return DiscordService.JDA.getUserById(id); } + + /** + * Gets the user's ScoreSaber profile + * + * @return the user's ScoreSaber profile + */ + public ScoreSaberProfile getScoreSaberProfile() { + return getProfile(ScoreSaberProfile.class); + } } diff --git a/src/main/java/cc/fascinated/bat/service/ScoreSaberService.java b/src/main/java/cc/fascinated/bat/service/ScoreSaberService.java index f2ea628..1dd8d4f 100644 --- a/src/main/java/cc/fascinated/bat/service/ScoreSaberService.java +++ b/src/main/java/cc/fascinated/bat/service/ScoreSaberService.java @@ -6,7 +6,7 @@ import cc.fascinated.bat.common.WebRequest; import cc.fascinated.bat.event.EventListener; import cc.fascinated.bat.exception.BadRequestException; import cc.fascinated.bat.exception.ResourceNotFoundException; -import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile; +import cc.fascinated.bat.features.scoresaber.profile.user.ScoreSaberProfile; import cc.fascinated.bat.model.token.beatsaber.scoresaber.*; import com.google.gson.JsonObject; import lombok.NonNull; @@ -81,9 +81,9 @@ public class ScoreSaberService extends TextWebSocketHandler { * @param page The page to get the scores from. * @return The scores. */ - public ScoreSaberScoresPageToken getPageScores(UserScoreSaberProfile profile, int page) { - log.info("Fetching scores for account '{}' from page {}.", profile.getSteamId(), page); - ScoreSaberScoresPageToken pageToken = WebRequest.getAsEntity(String.format(GET_PLAYER_SCORES_ENDPOINT, profile.getSteamId(), "recent", page), ScoreSaberScoresPageToken.class); + public ScoreSaberScoresPageToken getPageScores(ScoreSaberProfile profile, int page) { + log.info("Fetching scores for account '{}' from page {}.", profile.getAccountId(), page); + ScoreSaberScoresPageToken pageToken = WebRequest.getAsEntity(String.format(GET_PLAYER_SCORES_ENDPOINT, profile.getAccountId(), "recent", page), ScoreSaberScoresPageToken.class); if (pageToken == null) { // Check if the page doesn't exist. return null; } @@ -100,11 +100,11 @@ public class ScoreSaberService extends TextWebSocketHandler { * @param profile The profile. * @return The scores. */ - public List getScores(UserScoreSaberProfile profile) { + public List getScores(ScoreSaberProfile profile) { List scores = new ArrayList<>(List.of(getPageScores(profile, 1))); ScoreSaberPageMetadataToken metadata = scores.get(0).getMetadata(); int totalPages = (int) Math.ceil((double) metadata.getTotal() / metadata.getItemsPerPage()); - log.info("Fetching {} pages of scores for account '{}'.", totalPages, profile.getSteamId()); + log.info("Fetching {} pages of scores for account '{}'.", totalPages, profile.getAccountId()); for (int i = 2; i <= totalPages; i++) { scores.add(getPageScores(profile, i)); } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index b3779f0..a420698 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -10,7 +10,9 @@ sentry: # MongoDB Migration Configuration mongock: - change-logs-scan-package: "cc.fascinated.bat.changelog" + runner-type: InitializingBean + migration-scan-package: + - "cc.fascinated.bat.changelog" # Spotify Configuration spotify: