From ea546f02caa67c2d4d206d0fc927c0ed94e36902 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 30 Jun 2024 08:00:03 +0100 Subject: [PATCH] cleanup features and move all misc commands into a base feature --- .../cc/fascinated/bat/features/Feature.java | 10 ++++- .../bat/features/afk/AfkFeature.java | 2 +- .../features/autorole/AutoRoleFeature.java | 2 +- .../bat/features/base/BaseFeature.java | 43 +++++++++++++++++++ .../botadmin/premium/PremiumAdminCommand.java | 2 +- .../botadmin/premium/RemoveSubCommand.java | 2 +- .../botadmin/premium/SetSubCommand.java | 2 +- .../commands}/fun/image/CatSubCommand.java | 2 +- .../commands}/fun/image/DogSubCommand.java | 2 +- .../commands}/fun/image/DuckSubCommand.java | 2 +- .../commands}/fun/image/FoxSubCommand.java | 2 +- .../commands}/fun/image/ImageCommand.java | 2 +- .../commands}/general/BotStatsCommand.java | 2 +- .../base/commands}/general/HelpCommand.java | 2 +- .../base/commands}/general/InviteCommand.java | 2 +- .../base/commands}/general/PingCommand.java | 2 +- .../base/commands}/general/VoteCommand.java | 2 +- .../general/avatar/AvatarCommand.java | 2 +- .../general/avatar/GuildSubCommand.java | 2 +- .../general/avatar/UserSubCommand.java | 2 +- .../general/banner/BannerCommand.java | 2 +- .../general/banner/GuildSubCommand.java | 2 +- .../general/banner/UserSubCommand.java | 2 +- .../commands}/server/MemberCountCommand.java | 2 +- .../base/commands}/server/PremiumCommand.java | 2 +- .../server/channel/ChannelCommand.java | 2 +- .../server/channel/RemoveTopicSubCommand.java | 2 +- .../server/channel/SetTopicSubCommand.java | 2 +- .../server/channel/ViewTopicSubCommand.java | 2 +- .../server/feature}/DisableSubCommand.java | 11 ++++- .../server/feature}/EnableSubCommand.java | 4 +- .../server/feature}/FeatureCommand.java | 5 ++- .../server/feature}/ListSubCommand.java | 4 +- .../{ => base/profile}/FeatureProfile.java | 3 +- .../features/birthday/BirthdayFeature.java | 2 +- .../namehistory/NameHistoryFeature.java | 12 +++++- .../scoresaber/ScoreSaberFeature.java | 2 +- .../bat/features/spotify/SpotifyFeature.java | 9 +++- .../cc/fascinated/bat/model/BatGuild.java | 2 +- .../bat/service/CommandService.java | 2 +- .../bat/service/FeatureService.java | 6 ++- 41 files changed, 122 insertions(+), 47 deletions(-) create mode 100644 src/main/java/cc/fascinated/bat/features/base/BaseFeature.java rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/botadmin/premium/PremiumAdminCommand.java (92%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/botadmin/premium/RemoveSubCommand.java (96%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/botadmin/premium/SetSubCommand.java (97%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/fun/image/CatSubCommand.java (96%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/fun/image/DogSubCommand.java (95%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/fun/image/DuckSubCommand.java (95%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/fun/image/FoxSubCommand.java (95%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/fun/image/ImageCommand.java (93%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/general/BotStatsCommand.java (97%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/general/HelpCommand.java (99%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/general/InviteCommand.java (95%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/general/PingCommand.java (95%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/general/VoteCommand.java (95%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/general/avatar/AvatarCommand.java (91%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/general/avatar/GuildSubCommand.java (95%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/general/avatar/UserSubCommand.java (96%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/general/banner/BannerCommand.java (91%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/general/banner/GuildSubCommand.java (95%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/general/banner/UserSubCommand.java (97%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/server/MemberCountCommand.java (97%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/server/PremiumCommand.java (96%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/server/channel/ChannelCommand.java (92%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/server/channel/RemoveTopicSubCommand.java (97%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/server/channel/SetTopicSubCommand.java (97%) rename src/main/java/cc/fascinated/bat/{command/impl => features/base/commands}/server/channel/ViewTopicSubCommand.java (97%) rename src/main/java/cc/fascinated/bat/features/{command => base/commands/server/feature}/DisableSubCommand.java (87%) rename src/main/java/cc/fascinated/bat/features/{command => base/commands/server/feature}/EnableSubCommand.java (95%) rename src/main/java/cc/fascinated/bat/features/{command => base/commands/server/feature}/FeatureCommand.java (79%) rename src/main/java/cc/fascinated/bat/features/{command => base/commands/server/feature}/ListSubCommand.java (92%) rename src/main/java/cc/fascinated/bat/features/{ => base/profile}/FeatureProfile.java (93%) diff --git a/src/main/java/cc/fascinated/bat/features/Feature.java b/src/main/java/cc/fascinated/bat/features/Feature.java index da16f58..da20511 100644 --- a/src/main/java/cc/fascinated/bat/features/Feature.java +++ b/src/main/java/cc/fascinated/bat/features/Feature.java @@ -20,6 +20,11 @@ public abstract class Feature { */ private final String name; + /** + * The description of the feature + */ + public final boolean canBeDisabled; + /** * The category of the feature */ @@ -32,7 +37,10 @@ public abstract class Feature { * @param command The command to register */ public void registerCommand(@NonNull CommandService commandService, @NonNull BatCommand command) { - command.setCategory(category); + // If the command using the default category then set the category to the feature's category + if (command.getCategory() == Category.GENERAL) { + command.setCategory(this.category); + } command.setFeature(this); commandService.registerCommand(command); } diff --git a/src/main/java/cc/fascinated/bat/features/afk/AfkFeature.java b/src/main/java/cc/fascinated/bat/features/afk/AfkFeature.java index 1e7fcf5..6af35fa 100644 --- a/src/main/java/cc/fascinated/bat/features/afk/AfkFeature.java +++ b/src/main/java/cc/fascinated/bat/features/afk/AfkFeature.java @@ -14,7 +14,7 @@ import org.springframework.stereotype.Component; @Component public class AfkFeature extends Feature { public AfkFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) { - super("AFK", Category.GENERAL); + super("AFK", true, Category.GENERAL); registerCommand(commandService, context.getBean(AfkCommand.class)); } diff --git a/src/main/java/cc/fascinated/bat/features/autorole/AutoRoleFeature.java b/src/main/java/cc/fascinated/bat/features/autorole/AutoRoleFeature.java index bed6c49..f76b400 100644 --- a/src/main/java/cc/fascinated/bat/features/autorole/AutoRoleFeature.java +++ b/src/main/java/cc/fascinated/bat/features/autorole/AutoRoleFeature.java @@ -16,7 +16,7 @@ import org.springframework.stereotype.Component; public class AutoRoleFeature extends Feature { @Autowired public AutoRoleFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) { - super("Auto Role", Category.SERVER); + super("Auto Role",true, Category.SERVER); registerCommand(commandService, context.getBean(AutoRoleCommand.class)); } diff --git a/src/main/java/cc/fascinated/bat/features/base/BaseFeature.java b/src/main/java/cc/fascinated/bat/features/base/BaseFeature.java new file mode 100644 index 0000000..129df85 --- /dev/null +++ b/src/main/java/cc/fascinated/bat/features/base/BaseFeature.java @@ -0,0 +1,43 @@ +package cc.fascinated.bat.features.base; + +import cc.fascinated.bat.command.Category; +import cc.fascinated.bat.features.Feature; +import cc.fascinated.bat.features.base.commands.botadmin.premium.PremiumAdminCommand; +import cc.fascinated.bat.features.base.commands.fun.image.ImageCommand; +import cc.fascinated.bat.features.base.commands.general.*; +import cc.fascinated.bat.features.base.commands.general.avatar.AvatarCommand; +import cc.fascinated.bat.features.base.commands.general.banner.BannerCommand; +import cc.fascinated.bat.features.base.commands.server.MemberCountCommand; +import cc.fascinated.bat.features.base.commands.server.PremiumCommand; +import cc.fascinated.bat.features.base.commands.server.channel.ChannelCommand; +import cc.fascinated.bat.features.base.commands.server.feature.FeatureCommand; +import cc.fascinated.bat.service.CommandService; +import lombok.NonNull; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Component; + +/** + * @author Fascinated (fascinated7) + */ +@Component +public class BaseFeature extends Feature { + @Autowired + public BaseFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) { + super("Base", false, Category.GENERAL); + + super.registerCommand(commandService, context.getBean(PremiumCommand.class)); + super.registerCommand(commandService, context.getBean(PremiumAdminCommand.class)); + super.registerCommand(commandService, context.getBean(MemberCountCommand.class)); + super.registerCommand(commandService, context.getBean(ChannelCommand.class)); + super.registerCommand(commandService, context.getBean(VoteCommand.class)); + super.registerCommand(commandService, context.getBean(PingCommand.class)); + super.registerCommand(commandService, context.getBean(InviteCommand.class)); + super.registerCommand(commandService, context.getBean(HelpCommand.class)); + super.registerCommand(commandService, context.getBean(BotStatsCommand.class)); + super.registerCommand(commandService, context.getBean(BannerCommand.class)); + super.registerCommand(commandService, context.getBean(AvatarCommand.class)); + super.registerCommand(commandService, context.getBean(ImageCommand.class)); + super.registerCommand(commandService, context.getBean(FeatureCommand.class)); + } +} diff --git a/src/main/java/cc/fascinated/bat/command/impl/botadmin/premium/PremiumAdminCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/PremiumAdminCommand.java similarity index 92% rename from src/main/java/cc/fascinated/bat/command/impl/botadmin/premium/PremiumAdminCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/PremiumAdminCommand.java index de4891a..07aba0b 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/botadmin/premium/PremiumAdminCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/PremiumAdminCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.botadmin.premium; +package cc.fascinated.bat.features.base.commands.botadmin.premium; import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.Category; diff --git a/src/main/java/cc/fascinated/bat/command/impl/botadmin/premium/RemoveSubCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/RemoveSubCommand.java similarity index 96% rename from src/main/java/cc/fascinated/bat/command/impl/botadmin/premium/RemoveSubCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/RemoveSubCommand.java index e78cdee..a70a29f 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/botadmin/premium/RemoveSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/RemoveSubCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.botadmin.premium; +package cc.fascinated.bat.features.base.commands.botadmin.premium; import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; diff --git a/src/main/java/cc/fascinated/bat/command/impl/botadmin/premium/SetSubCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/SetSubCommand.java similarity index 97% rename from src/main/java/cc/fascinated/bat/command/impl/botadmin/premium/SetSubCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/SetSubCommand.java index ad3b0f8..811a6fc 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/botadmin/premium/SetSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/SetSubCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.botadmin.premium; +package cc.fascinated.bat.features.base.commands.botadmin.premium; import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; diff --git a/src/main/java/cc/fascinated/bat/command/impl/fun/image/CatSubCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/fun/image/CatSubCommand.java similarity index 96% rename from src/main/java/cc/fascinated/bat/command/impl/fun/image/CatSubCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/fun/image/CatSubCommand.java index c276b6a..ff9764e 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/fun/image/CatSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/fun/image/CatSubCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.fun.image; +package cc.fascinated.bat.features.base.commands.fun.image; import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; diff --git a/src/main/java/cc/fascinated/bat/command/impl/fun/image/DogSubCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/fun/image/DogSubCommand.java similarity index 95% rename from src/main/java/cc/fascinated/bat/command/impl/fun/image/DogSubCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/fun/image/DogSubCommand.java index 07bd9ef..c66935d 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/fun/image/DogSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/fun/image/DogSubCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.fun.image; +package cc.fascinated.bat.features.base.commands.fun.image; import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; diff --git a/src/main/java/cc/fascinated/bat/command/impl/fun/image/DuckSubCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/fun/image/DuckSubCommand.java similarity index 95% rename from src/main/java/cc/fascinated/bat/command/impl/fun/image/DuckSubCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/fun/image/DuckSubCommand.java index 73f4cc6..a849e3a 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/fun/image/DuckSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/fun/image/DuckSubCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.fun.image; +package cc.fascinated.bat.features.base.commands.fun.image; import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; diff --git a/src/main/java/cc/fascinated/bat/command/impl/fun/image/FoxSubCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/fun/image/FoxSubCommand.java similarity index 95% rename from src/main/java/cc/fascinated/bat/command/impl/fun/image/FoxSubCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/fun/image/FoxSubCommand.java index 03ec1d0..d1d67ec 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/fun/image/FoxSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/fun/image/FoxSubCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.fun.image; +package cc.fascinated.bat.features.base.commands.fun.image; import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; diff --git a/src/main/java/cc/fascinated/bat/command/impl/fun/image/ImageCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/fun/image/ImageCommand.java similarity index 93% rename from src/main/java/cc/fascinated/bat/command/impl/fun/image/ImageCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/fun/image/ImageCommand.java index afc60d1..8e421d3 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/fun/image/ImageCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/fun/image/ImageCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.fun.image; +package cc.fascinated.bat.features.base.commands.fun.image; import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.Category; diff --git a/src/main/java/cc/fascinated/bat/command/impl/general/BotStatsCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/general/BotStatsCommand.java similarity index 97% rename from src/main/java/cc/fascinated/bat/command/impl/general/BotStatsCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/general/BotStatsCommand.java index 000ad5e..726cb6e 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/general/BotStatsCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/general/BotStatsCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.general; +package cc.fascinated.bat.features.base.commands.general; import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.CommandInfo; diff --git a/src/main/java/cc/fascinated/bat/command/impl/general/HelpCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/general/HelpCommand.java similarity index 99% rename from src/main/java/cc/fascinated/bat/command/impl/general/HelpCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/general/HelpCommand.java index 7408eaa..1586385 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/general/HelpCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/general/HelpCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.general; +package cc.fascinated.bat.features.base.commands.general; import cc.fascinated.bat.Consts; import cc.fascinated.bat.command.BatCommand; diff --git a/src/main/java/cc/fascinated/bat/command/impl/general/InviteCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/general/InviteCommand.java similarity index 95% rename from src/main/java/cc/fascinated/bat/command/impl/general/InviteCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/general/InviteCommand.java index 7ce205f..acfed21 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/general/InviteCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/general/InviteCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.general; +package cc.fascinated.bat.features.base.commands.general; import cc.fascinated.bat.Consts; import cc.fascinated.bat.command.BatCommand; diff --git a/src/main/java/cc/fascinated/bat/command/impl/general/PingCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/general/PingCommand.java similarity index 95% rename from src/main/java/cc/fascinated/bat/command/impl/general/PingCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/general/PingCommand.java index f2272d7..a8a48ad 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/general/PingCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/general/PingCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.general; +package cc.fascinated.bat.features.base.commands.general; import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.CommandInfo; diff --git a/src/main/java/cc/fascinated/bat/command/impl/general/VoteCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/general/VoteCommand.java similarity index 95% rename from src/main/java/cc/fascinated/bat/command/impl/general/VoteCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/general/VoteCommand.java index cf448fe..d5fef0a 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/general/VoteCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/general/VoteCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.general; +package cc.fascinated.bat.features.base.commands.general; import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.CommandInfo; diff --git a/src/main/java/cc/fascinated/bat/command/impl/general/avatar/AvatarCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/general/avatar/AvatarCommand.java similarity index 91% rename from src/main/java/cc/fascinated/bat/command/impl/general/avatar/AvatarCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/general/avatar/AvatarCommand.java index b606a91..67f7905 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/general/avatar/AvatarCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/general/avatar/AvatarCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.general.avatar; +package cc.fascinated.bat.features.base.commands.general.avatar; import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.CommandInfo; diff --git a/src/main/java/cc/fascinated/bat/command/impl/general/avatar/GuildSubCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/general/avatar/GuildSubCommand.java similarity index 95% rename from src/main/java/cc/fascinated/bat/command/impl/general/avatar/GuildSubCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/general/avatar/GuildSubCommand.java index 82590d8..4bafd7d 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/general/avatar/GuildSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/general/avatar/GuildSubCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.general.avatar; +package cc.fascinated.bat.features.base.commands.general.avatar; import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; diff --git a/src/main/java/cc/fascinated/bat/command/impl/general/avatar/UserSubCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/general/avatar/UserSubCommand.java similarity index 96% rename from src/main/java/cc/fascinated/bat/command/impl/general/avatar/UserSubCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/general/avatar/UserSubCommand.java index 19e3fda..faf01f1 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/general/avatar/UserSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/general/avatar/UserSubCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.general.avatar; +package cc.fascinated.bat.features.base.commands.general.avatar; import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; diff --git a/src/main/java/cc/fascinated/bat/command/impl/general/banner/BannerCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/general/banner/BannerCommand.java similarity index 91% rename from src/main/java/cc/fascinated/bat/command/impl/general/banner/BannerCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/general/banner/BannerCommand.java index 19e85ab..cadc23b 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/general/banner/BannerCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/general/banner/BannerCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.general.banner; +package cc.fascinated.bat.features.base.commands.general.banner; import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.CommandInfo; diff --git a/src/main/java/cc/fascinated/bat/command/impl/general/banner/GuildSubCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/general/banner/GuildSubCommand.java similarity index 95% rename from src/main/java/cc/fascinated/bat/command/impl/general/banner/GuildSubCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/general/banner/GuildSubCommand.java index 5cf462d..c828c47 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/general/banner/GuildSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/general/banner/GuildSubCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.general.banner; +package cc.fascinated.bat.features.base.commands.general.banner; import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; diff --git a/src/main/java/cc/fascinated/bat/command/impl/general/banner/UserSubCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/general/banner/UserSubCommand.java similarity index 97% rename from src/main/java/cc/fascinated/bat/command/impl/general/banner/UserSubCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/general/banner/UserSubCommand.java index b11f1e3..c0e2137 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/general/banner/UserSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/general/banner/UserSubCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.general.banner; +package cc.fascinated.bat.features.base.commands.general.banner; import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; diff --git a/src/main/java/cc/fascinated/bat/command/impl/server/MemberCountCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/server/MemberCountCommand.java similarity index 97% rename from src/main/java/cc/fascinated/bat/command/impl/server/MemberCountCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/server/MemberCountCommand.java index 8d2e13f..fd8152f 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/server/MemberCountCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/server/MemberCountCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.server; +package cc.fascinated.bat.features.base.commands.server; import cc.fascinated.bat.Emojis; import cc.fascinated.bat.command.BatCommand; diff --git a/src/main/java/cc/fascinated/bat/command/impl/server/PremiumCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/server/PremiumCommand.java similarity index 96% rename from src/main/java/cc/fascinated/bat/command/impl/server/PremiumCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/server/PremiumCommand.java index b5a35cf..742b92a 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/server/PremiumCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/server/PremiumCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.server; +package cc.fascinated.bat.features.base.commands.server; import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.CommandInfo; diff --git a/src/main/java/cc/fascinated/bat/command/impl/server/channel/ChannelCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/server/channel/ChannelCommand.java similarity index 92% rename from src/main/java/cc/fascinated/bat/command/impl/server/channel/ChannelCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/server/channel/ChannelCommand.java index dae9dd6..8c21278 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/server/channel/ChannelCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/server/channel/ChannelCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.server.channel; +package cc.fascinated.bat.features.base.commands.server.channel; import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.Category; diff --git a/src/main/java/cc/fascinated/bat/command/impl/server/channel/RemoveTopicSubCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/server/channel/RemoveTopicSubCommand.java similarity index 97% rename from src/main/java/cc/fascinated/bat/command/impl/server/channel/RemoveTopicSubCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/server/channel/RemoveTopicSubCommand.java index 9735985..e1e9913 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/server/channel/RemoveTopicSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/server/channel/RemoveTopicSubCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.server.channel; +package cc.fascinated.bat.features.base.commands.server.channel; import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; diff --git a/src/main/java/cc/fascinated/bat/command/impl/server/channel/SetTopicSubCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/server/channel/SetTopicSubCommand.java similarity index 97% rename from src/main/java/cc/fascinated/bat/command/impl/server/channel/SetTopicSubCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/server/channel/SetTopicSubCommand.java index 23c3467..475fa12 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/server/channel/SetTopicSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/server/channel/SetTopicSubCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.server.channel; +package cc.fascinated.bat.features.base.commands.server.channel; import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; diff --git a/src/main/java/cc/fascinated/bat/command/impl/server/channel/ViewTopicSubCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/server/channel/ViewTopicSubCommand.java similarity index 97% rename from src/main/java/cc/fascinated/bat/command/impl/server/channel/ViewTopicSubCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/server/channel/ViewTopicSubCommand.java index c8d6ccd..d04e0c1 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/server/channel/ViewTopicSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/server/channel/ViewTopicSubCommand.java @@ -1,4 +1,4 @@ -package cc.fascinated.bat.command.impl.server.channel; +package cc.fascinated.bat.features.base.commands.server.channel; import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; diff --git a/src/main/java/cc/fascinated/bat/features/command/DisableSubCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/server/feature/DisableSubCommand.java similarity index 87% rename from src/main/java/cc/fascinated/bat/features/command/DisableSubCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/server/feature/DisableSubCommand.java index 63f926c..c3d75c9 100644 --- a/src/main/java/cc/fascinated/bat/features/command/DisableSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/server/feature/DisableSubCommand.java @@ -1,10 +1,10 @@ -package cc.fascinated.bat.features.command; +package cc.fascinated.bat.features.base.commands.server.feature; import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.features.Feature; -import cc.fascinated.bat.features.FeatureProfile; +import cc.fascinated.bat.features.base.profile.FeatureProfile; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatUser; import cc.fascinated.bat.service.FeatureService; @@ -50,6 +50,13 @@ public class DisableSubCommand extends BatSubCommand { return; } Feature feature = FeatureService.INSTANCE.getFeature(featureName); + if (!feature.isCanBeDisabled()) { + interaction.replyEmbeds(EmbedUtils.errorEmbed() + .setDescription("The feature `%s` cannot be disabled".formatted(feature.getName())) + .build()).queue(); + return; + } + if (featureProfile.isFeatureDisabled(feature)) { interaction.replyEmbeds(EmbedUtils.errorEmbed() .setDescription("The feature `%s` is already disabled".formatted(feature.getName())) diff --git a/src/main/java/cc/fascinated/bat/features/command/EnableSubCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/server/feature/EnableSubCommand.java similarity index 95% rename from src/main/java/cc/fascinated/bat/features/command/EnableSubCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/server/feature/EnableSubCommand.java index 9313188..64b83f4 100644 --- a/src/main/java/cc/fascinated/bat/features/command/EnableSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/server/feature/EnableSubCommand.java @@ -1,10 +1,10 @@ -package cc.fascinated.bat.features.command; +package cc.fascinated.bat.features.base.commands.server.feature; import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.features.Feature; -import cc.fascinated.bat.features.FeatureProfile; +import cc.fascinated.bat.features.base.profile.FeatureProfile; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatUser; import cc.fascinated.bat.service.FeatureService; diff --git a/src/main/java/cc/fascinated/bat/features/command/FeatureCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/server/feature/FeatureCommand.java similarity index 79% rename from src/main/java/cc/fascinated/bat/features/command/FeatureCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/server/feature/FeatureCommand.java index ce5b7ff..7e4dbf0 100644 --- a/src/main/java/cc/fascinated/bat/features/command/FeatureCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/server/feature/FeatureCommand.java @@ -1,6 +1,7 @@ -package cc.fascinated.bat.features.command; +package cc.fascinated.bat.features.base.commands.server.feature; import cc.fascinated.bat.command.BatCommand; +import cc.fascinated.bat.command.Category; import cc.fascinated.bat.command.CommandInfo; import lombok.NonNull; import net.dv8tion.jda.api.Permission; @@ -12,7 +13,7 @@ import org.springframework.stereotype.Component; * @author Fascinated (fascinated7) */ @Component -@CommandInfo(name = "feature", description = "Configure features in your guild", requiredPermissions = Permission.ADMINISTRATOR) +@CommandInfo(name = "feature", description = "Configure features in your guild", requiredPermissions = Permission.ADMINISTRATOR, category = Category.SERVER) public class FeatureCommand extends BatCommand { @Autowired public FeatureCommand(@NonNull ApplicationContext context) { diff --git a/src/main/java/cc/fascinated/bat/features/command/ListSubCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/server/feature/ListSubCommand.java similarity index 92% rename from src/main/java/cc/fascinated/bat/features/command/ListSubCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/server/feature/ListSubCommand.java index 5184281..d5dccc6 100644 --- a/src/main/java/cc/fascinated/bat/features/command/ListSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/server/feature/ListSubCommand.java @@ -1,10 +1,10 @@ -package cc.fascinated.bat.features.command; +package cc.fascinated.bat.features.base.commands.server.feature; import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.CommandInfo; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.features.Feature; -import cc.fascinated.bat.features.FeatureProfile; +import cc.fascinated.bat.features.base.profile.FeatureProfile; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatUser; import cc.fascinated.bat.service.FeatureService; diff --git a/src/main/java/cc/fascinated/bat/features/FeatureProfile.java b/src/main/java/cc/fascinated/bat/features/base/profile/FeatureProfile.java similarity index 93% rename from src/main/java/cc/fascinated/bat/features/FeatureProfile.java rename to src/main/java/cc/fascinated/bat/features/base/profile/FeatureProfile.java index c829ab2..3ae69a9 100644 --- a/src/main/java/cc/fascinated/bat/features/FeatureProfile.java +++ b/src/main/java/cc/fascinated/bat/features/base/profile/FeatureProfile.java @@ -1,6 +1,7 @@ -package cc.fascinated.bat.features; +package cc.fascinated.bat.features.base.profile; import cc.fascinated.bat.common.Profile; +import cc.fascinated.bat.features.Feature; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/cc/fascinated/bat/features/birthday/BirthdayFeature.java b/src/main/java/cc/fascinated/bat/features/birthday/BirthdayFeature.java index afab2aa..54cc7b3 100644 --- a/src/main/java/cc/fascinated/bat/features/birthday/BirthdayFeature.java +++ b/src/main/java/cc/fascinated/bat/features/birthday/BirthdayFeature.java @@ -23,7 +23,7 @@ public class BirthdayFeature extends Feature implements EventListener { private final GuildService guildService; public BirthdayFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService, @NonNull GuildService guildService) { - super("Birthday", Category.UTILITY); + super("Birthday", true, Category.UTILITY); this.guildService = guildService; registerCommand(commandService, context.getBean(BirthdayCommand.class)); diff --git a/src/main/java/cc/fascinated/bat/features/namehistory/NameHistoryFeature.java b/src/main/java/cc/fascinated/bat/features/namehistory/NameHistoryFeature.java index 555efa6..4582135 100644 --- a/src/main/java/cc/fascinated/bat/features/namehistory/NameHistoryFeature.java +++ b/src/main/java/cc/fascinated/bat/features/namehistory/NameHistoryFeature.java @@ -2,6 +2,11 @@ package cc.fascinated.bat.features.namehistory; import cc.fascinated.bat.command.Category; import cc.fascinated.bat.features.Feature; +import cc.fascinated.bat.features.namehistory.command.NameHistoryCommand; +import cc.fascinated.bat.service.CommandService; +import lombok.NonNull; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; /** @@ -11,7 +16,10 @@ import org.springframework.stereotype.Component; public class NameHistoryFeature extends Feature { public static final int NAME_HISTORY_SIZE = 25; - public NameHistoryFeature() { - super("Name History", Category.UTILITY); + @Autowired + public NameHistoryFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) { + super("Name History", true,Category.UTILITY); + + super.registerCommand(commandService, context.getBean(NameHistoryCommand.class)); } } 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 382f608..1c95714 100644 --- a/src/main/java/cc/fascinated/bat/features/scoresaber/ScoreSaberFeature.java +++ b/src/main/java/cc/fascinated/bat/features/scoresaber/ScoreSaberFeature.java @@ -26,7 +26,7 @@ import org.springframework.stereotype.Component; public class ScoreSaberFeature extends Feature { @Autowired public ScoreSaberFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) { - super("ScoreSaber", Category.BEAT_SABER); + super("ScoreSaber", true, Category.BEAT_SABER); registerCommand(commandService, context.getBean(ScoreSaberCommand.class)); registerCommand(commandService, context.getBean(UserFeedCommand.class)); diff --git a/src/main/java/cc/fascinated/bat/features/spotify/SpotifyFeature.java b/src/main/java/cc/fascinated/bat/features/spotify/SpotifyFeature.java index e3af5af..2351415 100644 --- a/src/main/java/cc/fascinated/bat/features/spotify/SpotifyFeature.java +++ b/src/main/java/cc/fascinated/bat/features/spotify/SpotifyFeature.java @@ -6,13 +6,16 @@ import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.SpotifyUtils; import cc.fascinated.bat.exception.BatException; import cc.fascinated.bat.features.Feature; +import cc.fascinated.bat.features.spotify.command.SpotifyCommand; import cc.fascinated.bat.features.spotify.profile.SpotifyProfile; import cc.fascinated.bat.model.BatUser; +import cc.fascinated.bat.service.CommandService; import cc.fascinated.bat.service.SpotifyService; import lombok.NonNull; import lombok.SneakyThrows; import net.dv8tion.jda.api.EmbedBuilder; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; import se.michaelthelin.spotify.model_objects.miscellaneous.CurrentlyPlaying; import se.michaelthelin.spotify.model_objects.specification.AlbumSimplified; @@ -25,8 +28,10 @@ import se.michaelthelin.spotify.model_objects.specification.Track; @Component public class SpotifyFeature extends Feature { @Autowired - public SpotifyFeature() { - super("Spotify", Category.MUSIC); + public SpotifyFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) { + super("Spotify", true,Category.MUSIC); + + super.registerCommand(commandService, context.getBean(SpotifyCommand.class)); } /** diff --git a/src/main/java/cc/fascinated/bat/model/BatGuild.java b/src/main/java/cc/fascinated/bat/model/BatGuild.java index d3d4322..e6713db 100644 --- a/src/main/java/cc/fascinated/bat/model/BatGuild.java +++ b/src/main/java/cc/fascinated/bat/model/BatGuild.java @@ -1,7 +1,7 @@ package cc.fascinated.bat.model; import cc.fascinated.bat.common.ProfileHolder; -import cc.fascinated.bat.features.FeatureProfile; +import cc.fascinated.bat.features.base.profile.FeatureProfile; import cc.fascinated.bat.features.namehistory.profile.guild.NameHistoryProfile; import cc.fascinated.bat.service.DiscordService; import lombok.*; diff --git a/src/main/java/cc/fascinated/bat/service/CommandService.java b/src/main/java/cc/fascinated/bat/service/CommandService.java index 19b1d08..1371da8 100644 --- a/src/main/java/cc/fascinated/bat/service/CommandService.java +++ b/src/main/java/cc/fascinated/bat/service/CommandService.java @@ -4,7 +4,7 @@ import cc.fascinated.bat.Consts; import cc.fascinated.bat.command.*; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.config.Config; -import cc.fascinated.bat.features.FeatureProfile; +import cc.fascinated.bat.features.base.profile.FeatureProfile; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatUser; import lombok.Getter; diff --git a/src/main/java/cc/fascinated/bat/service/FeatureService.java b/src/main/java/cc/fascinated/bat/service/FeatureService.java index 4f4ee0e..b3e5c6a 100644 --- a/src/main/java/cc/fascinated/bat/service/FeatureService.java +++ b/src/main/java/cc/fascinated/bat/service/FeatureService.java @@ -2,7 +2,7 @@ package cc.fascinated.bat.service; import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.features.Feature; -import cc.fascinated.bat.features.command.FeatureCommand; +import cc.fascinated.bat.features.base.commands.server.feature.FeatureCommand; import jakarta.annotation.PostConstruct; import lombok.Getter; import lombok.NonNull; @@ -50,7 +50,9 @@ public class FeatureService { context.getBeansOfType(BatCommand.class) .values() .forEach((command) -> { - commandService.registerCommand(context.getBean(command.getClass())); + if (command.getFeature() == null) { + log.error("Command \"{}\" does not belong to a feature, not registering it...", command.getCommandInfo().name()); + } }); commandService.registerCommand(context.getBean(FeatureCommand.class));