diff --git a/src/main/java/cc/fascinated/bat/features/base/BaseFeature.java b/src/main/java/cc/fascinated/bat/features/base/BaseFeature.java index ee48d86..07faad2 100644 --- a/src/main/java/cc/fascinated/bat/features/base/BaseFeature.java +++ b/src/main/java/cc/fascinated/bat/features/base/BaseFeature.java @@ -2,7 +2,7 @@ package cc.fascinated.bat.features.base; import cc.fascinated.bat.features.Feature; import cc.fascinated.bat.features.FeatureProfile; -import cc.fascinated.bat.features.base.commands.botadmin.premium.PremiumAdminCommand; +import cc.fascinated.bat.features.base.commands.botadmin.BotAdminCommand; import cc.fascinated.bat.features.base.commands.fun.EightBallCommand; import cc.fascinated.bat.features.base.commands.fun.image.ImageCommand; import cc.fascinated.bat.features.base.commands.general.*; @@ -28,7 +28,7 @@ public class BaseFeature extends Feature { super("Base", FeatureProfile.FeatureState.DISABLED, false); super.registerCommand(commandService, context.getBean(PremiumCommand.class)); - super.registerCommand(commandService, context.getBean(PremiumAdminCommand.class)); + super.registerCommand(commandService, context.getBean(BotAdminCommand.class)); super.registerCommand(commandService, context.getBean(MemberCountCommand.class)); super.registerCommand(commandService, context.getBean(ChannelCommand.class)); super.registerCommand(commandService, context.getBean(VoteCommand.class)); diff --git a/src/main/java/cc/fascinated/bat/features/base/commands/botadmin/BotAdminCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/botadmin/BotAdminCommand.java new file mode 100644 index 0000000..f591fb1 --- /dev/null +++ b/src/main/java/cc/fascinated/bat/features/base/commands/botadmin/BotAdminCommand.java @@ -0,0 +1,25 @@ +package cc.fascinated.bat.features.base.commands.botadmin; + +import cc.fascinated.bat.command.BatCommand; +import cc.fascinated.bat.command.CommandInfo; +import cc.fascinated.bat.features.base.commands.botadmin.premium.PremiumRemoveSubCommand; +import cc.fascinated.bat.features.base.commands.botadmin.premium.PremiumSetSubCommand; +import lombok.NonNull; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Component; + +/** + * @author Fascinated (fascinated7) + */ +@Component +@CommandInfo(name = "bot-admin", description = "Bot admin commands", botOwnerOnly = true) +public class BotAdminCommand extends BatCommand { + @Autowired + public BotAdminCommand(@NonNull ApplicationContext context) { + super.addSubCommands( + context.getBean(PremiumSetSubCommand.class), + context.getBean(PremiumRemoveSubCommand.class) + ); + } +} diff --git a/src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/PremiumAdminCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/PremiumAdminCommand.java deleted file mode 100644 index 8580cc4..0000000 --- a/src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/PremiumAdminCommand.java +++ /dev/null @@ -1,23 +0,0 @@ -package cc.fascinated.bat.features.base.commands.botadmin.premium; - -import cc.fascinated.bat.command.BatCommand; -import cc.fascinated.bat.command.CommandInfo; -import lombok.NonNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.stereotype.Component; - -/** - * @author Fascinated (fascinated7) - */ -@Component -@CommandInfo(name = "premiumadmin", description = "Set a guild as premium", botOwnerOnly = true) -public class PremiumAdminCommand extends BatCommand { - @Autowired - public PremiumAdminCommand(@NonNull ApplicationContext context) { - super.addSubCommands( - context.getBean(SetSubCommand.class), - context.getBean(RemoveSubCommand.class) - ); - } -} diff --git a/src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/RemoveSubCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/PremiumRemoveSubCommand.java similarity index 91% rename from src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/RemoveSubCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/PremiumRemoveSubCommand.java index 92dafd0..d5befda 100644 --- a/src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/RemoveSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/PremiumRemoveSubCommand.java @@ -20,12 +20,12 @@ import org.springframework.stereotype.Component; * @author Fascinated (fascinated7) */ @Component -@CommandInfo(name = "remove", description = "Remove premium from a guild") -public class RemoveSubCommand extends BatCommand { +@CommandInfo(name = "premium-remove", description = "Remove premium from a guild") +public class PremiumRemoveSubCommand extends BatCommand { private final GuildService guildService; @Autowired - public RemoveSubCommand(GuildService guildService) { + public PremiumRemoveSubCommand(GuildService guildService) { this.guildService = guildService; super.addOptions(new OptionData(OptionType.STRING, "guild", "The guild id to set as premium", true)); } diff --git a/src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/SetSubCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/PremiumSetSubCommand.java similarity index 93% rename from src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/SetSubCommand.java rename to src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/PremiumSetSubCommand.java index 0ff4c65..c901282 100644 --- a/src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/SetSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/botadmin/premium/PremiumSetSubCommand.java @@ -20,12 +20,12 @@ import org.springframework.stereotype.Component; * @author Fascinated (fascinated7) */ @Component -@CommandInfo(name = "set", description = "Adds premium to a guild") -public class SetSubCommand extends BatCommand { +@CommandInfo(name = "premium-set", description = "Adds premium to a guild") +public class PremiumSetSubCommand extends BatCommand { private final GuildService guildService; @Autowired - public SetSubCommand(@NonNull GuildService guildService) { + public PremiumSetSubCommand(@NonNull GuildService guildService) { this.guildService = guildService; super.addOptions( new OptionData(OptionType.STRING, "guild", "The guild id to set as premium", true), diff --git a/src/main/java/cc/fascinated/bat/features/leveling/UserLevel.java b/src/main/java/cc/fascinated/bat/features/leveling/UserLevel.java index acf9556..fdb20cc 100644 --- a/src/main/java/cc/fascinated/bat/features/leveling/UserLevel.java +++ b/src/main/java/cc/fascinated/bat/features/leveling/UserLevel.java @@ -39,7 +39,7 @@ public class UserLevel { public boolean canLevelUp() { // Handle XP cooldown long cooldown = System.currentTimeMillis() - this.lastXpTimestamp; - if (cooldown > 30_000) { + if (cooldown < 30_000) { return false; } this.lastXpTimestamp = System.currentTimeMillis(); @@ -50,7 +50,12 @@ public class UserLevel { * Levels up the user. */ public void levelup() { - this.level++; + do { + if (this.currentXp < LevelingFeature.getNeededXP(this.level + 1, this.currentXp)) { + break; + } + this.level++; + } while (this.currentXp >= LevelingFeature.getNeededXP(this.level + 1, this.currentXp)); } /**