From 781c1dfa32b17bade32fbacccac07544f5784297 Mon Sep 17 00:00:00 2001 From: RyanLandDev Date: Fri, 16 Jul 2021 15:28:17 +0200 Subject: [PATCH 1/8] categorized some commands and modified DiscordBoostersCommand --- .../helpbot/bot/HelpBotInstance.java | 7 +- .../command/executor/checks/MutedCheck.java | 2 +- .../other/{ => dumps}/ActionDumpCommand.java | 2 +- .../other/{ => dumps}/ImageDumpCommand.java | 2 +- .../other/{ => dumps}/SoundListCommand.java | 3 +- .../other/{ => fun}/EightBallCommand.java | 2 +- .../impl/other/{ => fun}/GarfieldCommand.java | 2 +- .../impl/other/{ => fun}/IdeaCommand.java | 2 +- .../impl/other/{ => fun}/NbsCommand.java | 2 +- .../impl/other/{ => fun}/OcrCommand.java | 2 +- .../other/{ => fun}/SamQuotesCommand.java | 2 +- .../impl/other/{ => info}/HelpCommand.java | 2 +- .../impl/other/{ => info}/InfoCommand.java | 2 +- .../other/{ => info}/PermUnlocksCommand.java | 2 +- .../impl/other/{ => info}/PolicyCommand.java | 2 +- .../impl/other/{ => info}/RulesCommand.java | 2 +- .../{ => util}/AbstractFileListCommand.java | 2 +- .../other/{ => util}/BulkExecuteCommand.java | 5 +- .../other/{ => util}/ChannelMuteCommand.java | 2 +- .../impl/other/{ => util}/DisableCommand.java | 2 +- .../{ => util}/DiscussionMuteCommand.java | 2 +- .../impl/other/{ => util}/EnableCommand.java | 2 +- .../impl/other/{ => util}/EvalCommand.java | 2 +- .../other/{ => util}/FetchDataCommand.java | 2 +- .../impl/other/{ => util}/MimicCommand.java | 2 +- .../impl/other/{ => util}/MuteCommand.java | 2 +- .../impl/other/{ => util}/MutedCommand.java | 2 +- .../impl/other/{ => util}/PollCommand.java | 2 +- .../impl/other/{ => util}/QueryCommand.java | 2 +- .../impl/other/{ => util}/RestartCommand.java | 2 +- .../impl/other/{ => util}/UnmuteCommand.java | 2 +- .../impl/other/{ => util}/VerifyCommand.java | 2 +- .../AbstractPlayerUUIDCommand.java | 2 +- .../impl/stats/individualized/CpCommand.java | 1 - .../stats/individualized/HistoryCommand.java | 1 - .../individualized/LastJoinedCommand.java | 2 - .../stats/individualized/NamesCommand.java | 1 - .../stats/individualized/PlotsCommand.java | 1 - .../stats/individualized/ProfileCommand.java | 1 - .../stats/individualized/SkinCommand.java | 1 - .../stats/individualized/UuidCommand.java | 1 - .../stats/{ => metrics}/BoostersCommand.java | 2 +- .../{ => metrics}/CpRequirementsCommand.java | 2 +- .../stats/{ => metrics}/JoinDataCommand.java | 2 +- .../stats/{ => metrics}/JoinsCommand.java | 96 +++++++++---------- .../{ => metrics}/NewPlayersCommand.java | 2 +- .../stats/{ => metrics}/PlayersCommand.java | 2 +- .../support/AbstractSessionLogCommand.java | 2 +- .../support/FindSupporteeNamesCommand.java | 2 +- .../impl/stats/support/HelpedByCommand.java | 2 +- .../stats/{ => support}/QueueCommand.java | 2 +- .../impl/stats/support/StatsCommand.java | 2 +- .../impl/stats/support/StatsGraphCommand.java | 2 +- .../stats/support/SupporteeStatsCommand.java | 2 +- .../impl/stats/support/WhoHelpedCommand.java | 2 +- .../{ => top}/AbstractLeaderboardCommand.java | 2 +- .../stats/{ => top}/ActivePlotsCommand.java | 2 +- .../impl/stats/{ => top}/CpTopCommand.java | 2 +- .../{ => top}/DiscordBoostersCommand.java | 33 +++++-- .../impl/stats/{ => top}/TokenTopCommand.java | 2 +- .../stats/{ => top}/TrendingPlotsCommand.java | 2 +- .../stats/{ => top}/VoteGivenLeaderboard.java | 2 +- .../sys/message/acceptors/VerifyAcceptor.java | 2 +- .../sys/tasks/impl/CodeDatabaseTask.java | 2 +- .../sys/tasks/impl/MuteExpireTask.java | 3 +- 65 files changed, 134 insertions(+), 124 deletions(-) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => dumps}/ActionDumpCommand.java (94%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => dumps}/ImageDumpCommand.java (97%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => dumps}/SoundListCommand.java (86%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => fun}/EightBallCommand.java (97%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => fun}/GarfieldCommand.java (97%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => fun}/IdeaCommand.java (99%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => fun}/NbsCommand.java (98%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => fun}/OcrCommand.java (98%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => fun}/SamQuotesCommand.java (99%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => info}/HelpCommand.java (98%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => info}/InfoCommand.java (97%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => info}/PermUnlocksCommand.java (97%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => info}/PolicyCommand.java (97%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => info}/RulesCommand.java (99%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => util}/AbstractFileListCommand.java (96%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => util}/BulkExecuteCommand.java (94%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => util}/ChannelMuteCommand.java (98%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => util}/DisableCommand.java (97%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => util}/DiscussionMuteCommand.java (98%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => util}/EnableCommand.java (97%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => util}/EvalCommand.java (98%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => util}/FetchDataCommand.java (99%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => util}/MimicCommand.java (95%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => util}/MuteCommand.java (98%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => util}/MutedCommand.java (97%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => util}/PollCommand.java (98%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => util}/QueryCommand.java (98%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => util}/RestartCommand.java (95%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => util}/UnmuteCommand.java (98%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{ => util}/VerifyCommand.java (98%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/{ => individualized}/AbstractPlayerUUIDCommand.java (94%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/{ => metrics}/BoostersCommand.java (97%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/{ => metrics}/CpRequirementsCommand.java (96%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/{ => metrics}/JoinDataCommand.java (99%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/{ => metrics}/JoinsCommand.java (94%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/{ => metrics}/NewPlayersCommand.java (97%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/{ => metrics}/PlayersCommand.java (97%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/{ => support}/QueueCommand.java (97%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/{ => top}/AbstractLeaderboardCommand.java (97%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/{ => top}/ActivePlotsCommand.java (97%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/{ => top}/CpTopCommand.java (97%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/{ => top}/DiscordBoostersCommand.java (67%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/{ => top}/TokenTopCommand.java (97%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/{ => top}/TrendingPlotsCommand.java (97%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/{ => top}/VoteGivenLeaderboard.java (97%) diff --git a/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java b/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java index 72a35bf7..14d2897d 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java +++ b/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java @@ -2,12 +2,17 @@ import com.diamondfire.helpbot.bot.command.CommandHandler; import com.diamondfire.helpbot.bot.command.impl.codeblock.*; -import com.diamondfire.helpbot.bot.command.impl.other.*; +import com.diamondfire.helpbot.bot.command.impl.other.dumps.*; +import com.diamondfire.helpbot.bot.command.impl.other.fun.*; +import com.diamondfire.helpbot.bot.command.impl.other.info.*; +import com.diamondfire.helpbot.bot.command.impl.other.util.*; import com.diamondfire.helpbot.bot.command.impl.stats.*; import com.diamondfire.helpbot.bot.command.impl.stats.graph.*; import com.diamondfire.helpbot.bot.command.impl.stats.individualized.*; +import com.diamondfire.helpbot.bot.command.impl.stats.metrics.*; import com.diamondfire.helpbot.bot.command.impl.stats.plot.*; import com.diamondfire.helpbot.bot.command.impl.stats.support.*; +import com.diamondfire.helpbot.bot.command.impl.stats.top.*; import com.diamondfire.helpbot.bot.config.Config; import com.diamondfire.helpbot.bot.events.*; import com.diamondfire.helpbot.sys.tasks.TaskRegistry; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/executor/checks/MutedCheck.java b/src/main/java/com/diamondfire/helpbot/bot/command/executor/checks/MutedCheck.java index 1352b30a..58d84c24 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/executor/checks/MutedCheck.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/executor/checks/MutedCheck.java @@ -1,6 +1,6 @@ package com.diamondfire.helpbot.bot.command.executor.checks; -import com.diamondfire.helpbot.bot.command.impl.other.MuteCommand; +import com.diamondfire.helpbot.bot.command.impl.other.util.MuteCommand; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.events.CommandEvent; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/ActionDumpCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dumps/ActionDumpCommand.java similarity index 94% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/ActionDumpCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dumps/ActionDumpCommand.java index f15f4d00..1e48bcd0 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/ActionDumpCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dumps/ActionDumpCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.dumps; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/ImageDumpCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dumps/ImageDumpCommand.java similarity index 97% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/ImageDumpCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dumps/ImageDumpCommand.java index 2e8281d4..4c333d50 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/ImageDumpCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dumps/ImageDumpCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.dumps; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/SoundListCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dumps/SoundListCommand.java similarity index 86% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/SoundListCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dumps/SoundListCommand.java index 0099754c..c740c18f 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/SoundListCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dumps/SoundListCommand.java @@ -1,6 +1,7 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.dumps; import com.diamondfire.helpbot.bot.command.help.*; +import com.diamondfire.helpbot.bot.command.impl.other.util.AbstractFileListCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.events.CommandEvent; import com.diamondfire.helpbot.df.codeinfo.codedatabase.db.CodeDatabase; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/EightBallCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/EightBallCommand.java similarity index 97% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/EightBallCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/EightBallCommand.java index b45242ba..52ed829e 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/EightBallCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/EightBallCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.fun; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/GarfieldCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/GarfieldCommand.java similarity index 97% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/GarfieldCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/GarfieldCommand.java index 441c3f68..00a50e08 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/GarfieldCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/GarfieldCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.fun; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/IdeaCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/IdeaCommand.java similarity index 99% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/IdeaCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/IdeaCommand.java index c8144dbd..c5a3074a 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/IdeaCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/IdeaCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.fun; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/NbsCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/NbsCommand.java similarity index 98% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/NbsCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/NbsCommand.java index 5da1bebe..b966e0fc 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/NbsCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/NbsCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.fun; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.CommandCategory; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/OcrCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/OcrCommand.java similarity index 98% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/OcrCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/OcrCommand.java index d38c9dbb..887c25c1 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/OcrCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/OcrCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.fun; import com.diamondfire.helpbot.HelpBot; import com.diamondfire.helpbot.bot.HelpBotInstance; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/SamQuotesCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/SamQuotesCommand.java similarity index 99% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/SamQuotesCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/SamQuotesCommand.java index a262587b..0928c27e 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/SamQuotesCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/SamQuotesCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.fun; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.SingleArgumentContainer; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/HelpCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/HelpCommand.java similarity index 98% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/HelpCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/HelpCommand.java index 63df0137..716296e7 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/HelpCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/HelpCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.info; import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.CommandHandler; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/InfoCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/InfoCommand.java similarity index 97% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/InfoCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/InfoCommand.java index 2c41ec27..672fecdf 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/InfoCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/InfoCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.info; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/PermUnlocksCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/PermUnlocksCommand.java similarity index 97% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/PermUnlocksCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/PermUnlocksCommand.java index a7c5d9f3..ee4c2e93 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/PermUnlocksCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/PermUnlocksCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.info; import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.CommandHandler; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/PolicyCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/PolicyCommand.java similarity index 97% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/PolicyCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/PolicyCommand.java index bffca2c7..6f24423a 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/PolicyCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/PolicyCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.info; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/RulesCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/RulesCommand.java similarity index 99% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/RulesCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/RulesCommand.java index 037d388a..c9743aaa 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/RulesCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/RulesCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.info; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/AbstractFileListCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/AbstractFileListCommand.java similarity index 96% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/AbstractFileListCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/AbstractFileListCommand.java index 0ce9c7f8..c327a46d 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/AbstractFileListCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/AbstractFileListCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.util; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.impl.Command; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/BulkExecuteCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/BulkExecuteCommand.java similarity index 94% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/BulkExecuteCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/BulkExecuteCommand.java index 38792e17..2f8cb4de 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/BulkExecuteCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/BulkExecuteCommand.java @@ -1,13 +1,12 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.util; -import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.CommandHandler; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.MultiArgumentContainer; import com.diamondfire.helpbot.bot.command.argument.impl.types.*; import com.diamondfire.helpbot.bot.command.help.*; import com.diamondfire.helpbot.bot.command.impl.Command; -import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; +import com.diamondfire.helpbot.bot.command.impl.stats.individualized.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/ChannelMuteCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/ChannelMuteCommand.java similarity index 98% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/ChannelMuteCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/ChannelMuteCommand.java index 9fd41661..b5646a78 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/ChannelMuteCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/ChannelMuteCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.util; import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/DisableCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/DisableCommand.java similarity index 97% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/DisableCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/DisableCommand.java index 8e47af31..5a394f29 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/DisableCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/DisableCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.util; import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.CommandHandler; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/DiscussionMuteCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/DiscussionMuteCommand.java similarity index 98% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/DiscussionMuteCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/DiscussionMuteCommand.java index ec3118e8..64309db8 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/DiscussionMuteCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/DiscussionMuteCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.util; import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/EnableCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/EnableCommand.java similarity index 97% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/EnableCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/EnableCommand.java index 42ab8d50..a1358c59 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/EnableCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/EnableCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.util; import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.CommandHandler; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/EvalCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/EvalCommand.java similarity index 98% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/EvalCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/EvalCommand.java index 1f06305e..4a2386fb 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/EvalCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/EvalCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.util; import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/FetchDataCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/FetchDataCommand.java similarity index 99% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/FetchDataCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/FetchDataCommand.java index f8b02db6..eda6595e 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/FetchDataCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/FetchDataCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.util; import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/MimicCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/MimicCommand.java similarity index 95% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/MimicCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/MimicCommand.java index 5580d8a6..77188ff3 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/MimicCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/MimicCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.util; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.MessageArgument; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/MuteCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/MuteCommand.java similarity index 98% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/MuteCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/MuteCommand.java index 8f5a7483..0367a1e2 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/MuteCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/MuteCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.util; import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/MutedCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/MutedCommand.java similarity index 97% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/MutedCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/MutedCommand.java index 72a5be77..c8515ef2 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/MutedCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/MutedCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.util; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/PollCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/PollCommand.java similarity index 98% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/PollCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/PollCommand.java index 7a9cef95..5410690e 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/PollCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/PollCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.util; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.MessageArgument; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/QueryCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/QueryCommand.java similarity index 98% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/QueryCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/QueryCommand.java index d0b8febd..483fa7e4 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/QueryCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/QueryCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.util; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.MessageArgument; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/RestartCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/RestartCommand.java similarity index 95% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/RestartCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/RestartCommand.java index 008d3e2f..f7bed449 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/RestartCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/RestartCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.util; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/UnmuteCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/UnmuteCommand.java similarity index 98% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/UnmuteCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/UnmuteCommand.java index 3f172237..1a522d7a 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/UnmuteCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/UnmuteCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.util; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/VerifyCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/VerifyCommand.java similarity index 98% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/VerifyCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/VerifyCommand.java index af75980b..8683fa8e 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/VerifyCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/VerifyCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other; +package com.diamondfire.helpbot.bot.command.impl.other.util; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.types.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/AbstractPlayerUUIDCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/AbstractPlayerUUIDCommand.java similarity index 94% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/AbstractPlayerUUIDCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/AbstractPlayerUUIDCommand.java index 0728bae2..265ccd59 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/AbstractPlayerUUIDCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/AbstractPlayerUUIDCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.stats; +package com.diamondfire.helpbot.bot.command.impl.stats.individualized; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.SingleArgumentContainer; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/CpCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/CpCommand.java index b91b5166..bfc4f764 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/CpCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/CpCommand.java @@ -1,7 +1,6 @@ package com.diamondfire.helpbot.bot.command.impl.stats.individualized; import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/HistoryCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/HistoryCommand.java index 48186ae6..c2a8596a 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/HistoryCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/HistoryCommand.java @@ -1,7 +1,6 @@ package com.diamondfire.helpbot.bot.command.impl.stats.individualized; import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/LastJoinedCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/LastJoinedCommand.java index a7aa9605..2e4ea00d 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/LastJoinedCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/LastJoinedCommand.java @@ -1,7 +1,6 @@ package com.diamondfire.helpbot.bot.command.impl.stats.individualized; import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; @@ -14,7 +13,6 @@ import java.sql.*; import java.time.temporal.ChronoUnit; -import java.util.concurrent.TimeUnit; public class LastJoinedCommand extends AbstractPlayerUUIDCommand { diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/NamesCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/NamesCommand.java index f4a502a9..d99a72c4 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/NamesCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/NamesCommand.java @@ -1,7 +1,6 @@ package com.diamondfire.helpbot.bot.command.impl.stats.individualized; import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/PlotsCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/PlotsCommand.java index 9d3c333f..ba2cfe2d 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/PlotsCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/PlotsCommand.java @@ -1,7 +1,6 @@ package com.diamondfire.helpbot.bot.command.impl.stats.individualized; import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/ProfileCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/ProfileCommand.java index 56748f8f..616a24fc 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/ProfileCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/ProfileCommand.java @@ -1,7 +1,6 @@ package com.diamondfire.helpbot.bot.command.impl.stats.individualized; import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/SkinCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/SkinCommand.java index 4cc19504..c6b5d940 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/SkinCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/SkinCommand.java @@ -1,7 +1,6 @@ package com.diamondfire.helpbot.bot.command.impl.stats.individualized; import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/UuidCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/UuidCommand.java index 8b0d9edd..23aec690 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/UuidCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/UuidCommand.java @@ -1,7 +1,6 @@ package com.diamondfire.helpbot.bot.command.impl.stats.individualized; import com.diamondfire.helpbot.bot.command.help.HelpContext; -import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/BoostersCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/BoostersCommand.java similarity index 97% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/BoostersCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/BoostersCommand.java index f1a84c73..34284882 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/BoostersCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/BoostersCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.stats; +package com.diamondfire.helpbot.bot.command.impl.stats.metrics; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/CpRequirementsCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/CpRequirementsCommand.java similarity index 96% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/CpRequirementsCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/CpRequirementsCommand.java index 56dae817..bede77ce 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/CpRequirementsCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/CpRequirementsCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.stats; +package com.diamondfire.helpbot.bot.command.impl.stats.metrics; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/JoinDataCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/JoinDataCommand.java similarity index 99% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/JoinDataCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/JoinDataCommand.java index 626f414c..c1070e35 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/JoinDataCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/JoinDataCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.stats; +package com.diamondfire.helpbot.bot.command.impl.stats.metrics; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.SingleArgumentContainer; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/JoinsCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/JoinsCommand.java similarity index 94% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/JoinsCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/JoinsCommand.java index 983c5b53..b4bf73ba 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/JoinsCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/JoinsCommand.java @@ -1,48 +1,48 @@ -package com.diamondfire.helpbot.bot.command.impl.stats; - -import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; -import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.Command; -import com.diamondfire.helpbot.bot.command.permissions.Permission; -import com.diamondfire.helpbot.bot.events.CommandEvent; -import com.diamondfire.helpbot.sys.database.impl.DatabaseQuery; -import com.diamondfire.helpbot.sys.database.impl.queries.BasicQuery; -import com.diamondfire.helpbot.util.FormatUtil; -import net.dv8tion.jda.api.EmbedBuilder; - -public class JoinsCommand extends Command { - - @Override - public String getName() { return "joins"; } - - @Override - public HelpContext getHelpContext() { - return new HelpContext() - .description("Shows the total amount of unique players that have joined DiamondFire before.") - .category(CommandCategory.GENERAL_STATS); - } - - @Override - public ArgumentSet compileArguments() { return new ArgumentSet(); } - - @Override - public Permission getPermission() { return Permission.USER; } - - @Override - public void run(CommandEvent event) { - EmbedBuilder builder = new EmbedBuilder(); - - builder.setTitle("Total Joins"); - - // gets the total amount of players that have joined before - new DatabaseQuery() - .query(new BasicQuery("SELECT COUNT(*) AS count FROM players")) - .compile() - .run((result) -> { - String count = FormatUtil.formatNumber(result.getResult().getInt("count")); - builder.setDescription(String.format("A total of %s players have joined DiamondFire before!", count)); - }); - - event.getChannel().sendMessage(builder.build()).queue(); - } -} +package com.diamondfire.helpbot.bot.command.impl.stats.metrics; + +import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; +import com.diamondfire.helpbot.bot.command.help.*; +import com.diamondfire.helpbot.bot.command.impl.Command; +import com.diamondfire.helpbot.bot.command.permissions.Permission; +import com.diamondfire.helpbot.bot.events.CommandEvent; +import com.diamondfire.helpbot.sys.database.impl.DatabaseQuery; +import com.diamondfire.helpbot.sys.database.impl.queries.BasicQuery; +import com.diamondfire.helpbot.util.FormatUtil; +import net.dv8tion.jda.api.EmbedBuilder; + +public class JoinsCommand extends Command { + + @Override + public String getName() { return "joins"; } + + @Override + public HelpContext getHelpContext() { + return new HelpContext() + .description("Shows the total amount of unique players that have joined DiamondFire before.") + .category(CommandCategory.GENERAL_STATS); + } + + @Override + public ArgumentSet compileArguments() { return new ArgumentSet(); } + + @Override + public Permission getPermission() { return Permission.USER; } + + @Override + public void run(CommandEvent event) { + EmbedBuilder builder = new EmbedBuilder(); + + builder.setTitle("Total Joins"); + + // gets the total amount of players that have joined before + new DatabaseQuery() + .query(new BasicQuery("SELECT COUNT(*) AS count FROM players")) + .compile() + .run((result) -> { + String count = FormatUtil.formatNumber(result.getResult().getInt("count")); + builder.setDescription(String.format("A total of %s players have joined DiamondFire before!", count)); + }); + + event.getChannel().sendMessage(builder.build()).queue(); + } +} diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/NewPlayersCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/NewPlayersCommand.java similarity index 97% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/NewPlayersCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/NewPlayersCommand.java index c39cae10..f221c26a 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/NewPlayersCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/NewPlayersCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.stats; +package com.diamondfire.helpbot.bot.command.impl.stats.metrics; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/PlayersCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/PlayersCommand.java similarity index 97% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/PlayersCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/PlayersCommand.java index bc4e3bb4..02ef9dfc 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/PlayersCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/PlayersCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.stats; +package com.diamondfire.helpbot.bot.command.impl.stats.metrics; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/AbstractSessionLogCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/AbstractSessionLogCommand.java index e91555ea..142758a2 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/AbstractSessionLogCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/AbstractSessionLogCommand.java @@ -1,6 +1,6 @@ package com.diamondfire.helpbot.bot.command.impl.stats.support; -import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; +import com.diamondfire.helpbot.bot.command.impl.stats.individualized.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.events.CommandEvent; import com.diamondfire.helpbot.sys.externalfile.ExternalFileUtil; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/FindSupporteeNamesCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/FindSupporteeNamesCommand.java index 64302441..9be981c8 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/FindSupporteeNamesCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/FindSupporteeNamesCommand.java @@ -1,7 +1,7 @@ package com.diamondfire.helpbot.bot.command.impl.stats.support; import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; +import com.diamondfire.helpbot.bot.command.impl.stats.individualized.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/HelpedByCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/HelpedByCommand.java index 3d811159..6547b366 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/HelpedByCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/HelpedByCommand.java @@ -1,7 +1,7 @@ package com.diamondfire.helpbot.bot.command.impl.stats.support; import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; +import com.diamondfire.helpbot.bot.command.impl.stats.individualized.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/QueueCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/QueueCommand.java similarity index 97% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/QueueCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/QueueCommand.java index 3a1302f9..cf8dbed0 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/QueueCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/QueueCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.stats; +package com.diamondfire.helpbot.bot.command.impl.stats.support; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/StatsCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/StatsCommand.java index 470dffcf..4ea21f27 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/StatsCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/StatsCommand.java @@ -4,7 +4,7 @@ import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.SingleArgumentContainer; import com.diamondfire.helpbot.bot.command.argument.impl.types.TimeOffsetArgument; import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; +import com.diamondfire.helpbot.bot.command.impl.stats.individualized.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/StatsGraphCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/StatsGraphCommand.java index 3296b356..53a201b7 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/StatsGraphCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/StatsGraphCommand.java @@ -1,7 +1,7 @@ package com.diamondfire.helpbot.bot.command.impl.stats.support; import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; +import com.diamondfire.helpbot.bot.command.impl.stats.individualized.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.events.CommandEvent; import com.diamondfire.helpbot.sys.database.impl.DatabaseQuery; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/SupporteeStatsCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/SupporteeStatsCommand.java index 9be2cbe6..ac98144d 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/SupporteeStatsCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/SupporteeStatsCommand.java @@ -1,7 +1,7 @@ package com.diamondfire.helpbot.bot.command.impl.stats.support; import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; +import com.diamondfire.helpbot.bot.command.impl.stats.individualized.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/WhoHelpedCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/WhoHelpedCommand.java index c473da5c..83320e6c 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/WhoHelpedCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/WhoHelpedCommand.java @@ -1,7 +1,7 @@ package com.diamondfire.helpbot.bot.command.impl.stats.support; import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; +import com.diamondfire.helpbot.bot.command.impl.stats.individualized.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/AbstractLeaderboardCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/AbstractLeaderboardCommand.java similarity index 97% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/AbstractLeaderboardCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/AbstractLeaderboardCommand.java index 096c6486..9b1e7ee3 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/AbstractLeaderboardCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/AbstractLeaderboardCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.stats; +package com.diamondfire.helpbot.bot.command.impl.stats.top; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.SingleArgumentContainer; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/ActivePlotsCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/ActivePlotsCommand.java similarity index 97% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/ActivePlotsCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/ActivePlotsCommand.java index 5ce3e26b..ff9a1bf1 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/ActivePlotsCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/ActivePlotsCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.stats; +package com.diamondfire.helpbot.bot.command.impl.stats.top; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/CpTopCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/CpTopCommand.java similarity index 97% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/CpTopCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/CpTopCommand.java index d869a9e0..818f992a 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/CpTopCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/CpTopCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.stats; +package com.diamondfire.helpbot.bot.command.impl.stats.top; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.SingleArgumentContainer; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/DiscordBoostersCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/DiscordBoostersCommand.java similarity index 67% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/DiscordBoostersCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/DiscordBoostersCommand.java index 9ab574a4..e9043ee2 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/DiscordBoostersCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/DiscordBoostersCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.stats; +package com.diamondfire.helpbot.bot.command.impl.stats.top; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; @@ -7,12 +7,13 @@ import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; import com.diamondfire.helpbot.bot.events.CommandEvent; -import com.diamondfire.helpbot.util.StringUtil; import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.entities.*; import java.awt.*; +import java.text.SimpleDateFormat; import java.util.Comparator; +import java.util.List; public class DiscordBoostersCommand extends Command { @@ -48,22 +49,34 @@ public void run(CommandEvent event) { Guild guild = event.getGuild(); PresetBuilder preset = new PresetBuilder() .withPreset( - new InformativeReply(InformativeReplyType.INFO, "Current Discord Boosters", null) + new InformativeReply(InformativeReplyType.INFO, "Discord Server Boosters", null) ); EmbedBuilder embed = preset.getEmbed(); embed.setThumbnail("https://cdn.discordapp.com/emojis/699936318398136341.png?v=1"); event.getGuild().findMembers((member -> member.getTimeBoosted() != null)).onSuccess((members) -> { - embed.setDescription(StringUtil.listView("> ", true, members.stream() - .sorted(Comparator.comparing(Member::getTimeBoosted)) - .map(Member::getEffectiveName) - .toArray(String[]::new))); + members.sort(Comparator.comparing(Member::getTimeBoosted)); + embed.setDescription("A list of members that are currently boosting this Discord server.\n\n"+ + getFormattedBoosters(members)); embed.setColor(new Color(255, 115, 250)); event.reply(preset); guild.pruneMemberCache(); }); } -} - - + private String getFormattedBoosters(List members) { + if (members.size() == 0) return "*None*"; + else { + SimpleDateFormat format = new SimpleDateFormat("y'y'M'm'D'd'"); + String result = ""; + + for (Member member : members) { + String timeBoosted = format.format(member.getTimeBoosted()); + result += "<@" + member.getId() + "> - " + timeBoosted + "\n"; + } + + return result; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/TokenTopCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/TokenTopCommand.java similarity index 97% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/TokenTopCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/TokenTopCommand.java index d13ca3d9..daaeb3ae 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/TokenTopCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/TokenTopCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.stats; +package com.diamondfire.helpbot.bot.command.impl.stats.top; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/TrendingPlotsCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/TrendingPlotsCommand.java similarity index 97% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/TrendingPlotsCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/TrendingPlotsCommand.java index 5fe26fe9..3e25f3ee 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/TrendingPlotsCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/TrendingPlotsCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.stats; +package com.diamondfire.helpbot.bot.command.impl.stats.top; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/VoteGivenLeaderboard.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/VoteGivenLeaderboard.java similarity index 97% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/VoteGivenLeaderboard.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/VoteGivenLeaderboard.java index a1a141bb..fd8727b8 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/VoteGivenLeaderboard.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/VoteGivenLeaderboard.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.stats; +package com.diamondfire.helpbot.bot.command.impl.stats.top; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; diff --git a/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/VerifyAcceptor.java b/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/VerifyAcceptor.java index f71f127b..3ae7e715 100644 --- a/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/VerifyAcceptor.java +++ b/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/VerifyAcceptor.java @@ -1,6 +1,6 @@ package com.diamondfire.helpbot.sys.message.acceptors; -import com.diamondfire.helpbot.bot.command.impl.other.VerifyCommand; +import com.diamondfire.helpbot.bot.command.impl.other.util.VerifyCommand; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; import com.diamondfire.helpbot.sys.database.impl.DatabaseQuery; diff --git a/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/CodeDatabaseTask.java b/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/CodeDatabaseTask.java index 6acea964..ee1911f8 100644 --- a/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/CodeDatabaseTask.java +++ b/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/CodeDatabaseTask.java @@ -1,6 +1,6 @@ package com.diamondfire.helpbot.sys.tasks.impl; -import com.diamondfire.helpbot.bot.command.impl.other.FetchDataCommand; +import com.diamondfire.helpbot.bot.command.impl.other.util.FetchDataCommand; import com.diamondfire.helpbot.sys.tasks.MidnightTask; public class CodeDatabaseTask implements MidnightTask { diff --git a/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/MuteExpireTask.java b/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/MuteExpireTask.java index 458b800d..0767f94d 100644 --- a/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/MuteExpireTask.java +++ b/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/MuteExpireTask.java @@ -1,7 +1,8 @@ package com.diamondfire.helpbot.sys.tasks.impl; import com.diamondfire.helpbot.bot.HelpBotInstance; -import com.diamondfire.helpbot.bot.command.impl.other.*; +import com.diamondfire.helpbot.bot.command.impl.other.util.DiscussionMuteCommand; +import com.diamondfire.helpbot.bot.command.impl.other.util.MuteCommand; import com.diamondfire.helpbot.sys.database.impl.DatabaseQuery; import com.diamondfire.helpbot.sys.database.impl.queries.BasicQuery; import com.diamondfire.helpbot.sys.tasks.OneTimeTask; From b03f1ef0de0e1707970d0401c5123ae6c87f421d Mon Sep 17 00:00:00 2001 From: RyanLandDev Date: Sat, 17 Jul 2021 02:02:19 +0200 Subject: [PATCH 2/8] + Added Tags system (Expert+) + Re-categorised some commands backend --- .../helpbot/bot/HelpBotInstance.java | 8 ++ .../command/executor/checks/MutedCheck.java | 2 +- .../other/{util => dev}/DisableCommand.java | 2 +- .../other/{util => dev}/EnableCommand.java | 2 +- .../impl/other/{util => dev}/EvalCommand.java | 2 +- .../other/{util => dev}/FetchDataCommand.java | 2 +- .../other/{util => dev}/QueryCommand.java | 2 +- .../other/{util => dev}/RestartCommand.java | 2 +- .../{util => mod}/ChannelMuteCommand.java | 2 +- .../{util => mod}/DiscussionMuteCommand.java | 2 +- .../impl/other/{util => mod}/MuteCommand.java | 2 +- .../other/{util => mod}/MutedCommand.java | 2 +- .../other/{util => mod}/UnmuteCommand.java | 2 +- .../other/{util => mod}/VerifyCommand.java | 2 +- .../bot/command/impl/other/tag/Tag.java | 98 ++++++++++++++++ .../other/tag/TagAlreadyExistsException.java | 8 ++ .../other/tag/TagDoesntExistException.java | 7 ++ .../command/impl/other/tag/TagHandler.java | 80 +++++++++++++ .../command/impl/other/tag/TagProperty.java | 32 ++++++ .../impl/other/tag/impl/DelTagCommand.java | 71 ++++++++++++ .../impl/other/tag/impl/EditTagCommand.java | 105 ++++++++++++++++++ .../impl/other/tag/impl/ListTagsCommand.java | 76 +++++++++++++ .../impl/other/tag/impl/NewTagCommand.java | 87 +++++++++++++++ .../sys/externalfile/ExternalFiles.java | 6 + .../sys/message/acceptors/TagAcceptor.java | 34 ++++++ .../sys/message/acceptors/VerifyAcceptor.java | 2 +- .../sys/tasks/impl/CodeDatabaseTask.java | 2 +- .../sys/tasks/impl/MuteExpireTask.java | 4 +- 28 files changed, 629 insertions(+), 17 deletions(-) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{util => dev}/DisableCommand.java (97%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{util => dev}/EnableCommand.java (97%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{util => dev}/EvalCommand.java (98%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{util => dev}/FetchDataCommand.java (99%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{util => dev}/QueryCommand.java (98%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{util => dev}/RestartCommand.java (95%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{util => mod}/ChannelMuteCommand.java (98%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{util => mod}/DiscussionMuteCommand.java (98%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{util => mod}/MuteCommand.java (98%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{util => mod}/MutedCommand.java (97%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{util => mod}/UnmuteCommand.java (98%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/{util => mod}/VerifyCommand.java (98%) create mode 100644 src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/Tag.java create mode 100644 src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagAlreadyExistsException.java create mode 100644 src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagDoesntExistException.java create mode 100644 src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagHandler.java create mode 100644 src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagProperty.java create mode 100644 src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/DelTagCommand.java create mode 100644 src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/EditTagCommand.java create mode 100644 src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/ListTagsCommand.java create mode 100644 src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/NewTagCommand.java create mode 100644 src/main/java/com/diamondfire/helpbot/sys/message/acceptors/TagAcceptor.java diff --git a/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java b/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java index 14d2897d..9a7413a1 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java +++ b/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java @@ -2,9 +2,12 @@ import com.diamondfire.helpbot.bot.command.CommandHandler; import com.diamondfire.helpbot.bot.command.impl.codeblock.*; +import com.diamondfire.helpbot.bot.command.impl.other.dev.*; import com.diamondfire.helpbot.bot.command.impl.other.dumps.*; import com.diamondfire.helpbot.bot.command.impl.other.fun.*; import com.diamondfire.helpbot.bot.command.impl.other.info.*; +import com.diamondfire.helpbot.bot.command.impl.other.mod.*; +import com.diamondfire.helpbot.bot.command.impl.other.tag.impl.*; import com.diamondfire.helpbot.bot.command.impl.other.util.*; import com.diamondfire.helpbot.bot.command.impl.stats.*; import com.diamondfire.helpbot.bot.command.impl.stats.graph.*; @@ -72,6 +75,11 @@ public static void initialize() throws LoginException { new VerifyCommand(), new PollCommand(), new IdeaCommand(), + + new NewTagCommand(), + new DelTagCommand(), + new EditTagCommand(), + new ListTagsCommand(), //new ChannelMuteCommand(), // statsbot new StatsCommand(), diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/executor/checks/MutedCheck.java b/src/main/java/com/diamondfire/helpbot/bot/command/executor/checks/MutedCheck.java index 58d84c24..fd88cc76 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/executor/checks/MutedCheck.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/executor/checks/MutedCheck.java @@ -1,6 +1,6 @@ package com.diamondfire.helpbot.bot.command.executor.checks; -import com.diamondfire.helpbot.bot.command.impl.other.util.MuteCommand; +import com.diamondfire.helpbot.bot.command.impl.other.mod.MuteCommand; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.events.CommandEvent; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/DisableCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/DisableCommand.java similarity index 97% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/DisableCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/DisableCommand.java index 5a394f29..6ca57217 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/DisableCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/DisableCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other.util; +package com.diamondfire.helpbot.bot.command.impl.other.dev; import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.CommandHandler; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/EnableCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/EnableCommand.java similarity index 97% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/EnableCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/EnableCommand.java index a1358c59..93b583eb 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/EnableCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/EnableCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other.util; +package com.diamondfire.helpbot.bot.command.impl.other.dev; import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.CommandHandler; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/EvalCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/EvalCommand.java similarity index 98% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/EvalCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/EvalCommand.java index 4a2386fb..c8949612 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/EvalCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/EvalCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other.util; +package com.diamondfire.helpbot.bot.command.impl.other.dev; import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/FetchDataCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/FetchDataCommand.java similarity index 99% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/FetchDataCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/FetchDataCommand.java index eda6595e..b1497b7b 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/FetchDataCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/FetchDataCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other.util; +package com.diamondfire.helpbot.bot.command.impl.other.dev; import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/QueryCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/QueryCommand.java similarity index 98% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/QueryCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/QueryCommand.java index 483fa7e4..848ee77f 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/QueryCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/QueryCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other.util; +package com.diamondfire.helpbot.bot.command.impl.other.dev; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.MessageArgument; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/RestartCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/RestartCommand.java similarity index 95% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/RestartCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/RestartCommand.java index f7bed449..4a54dcf4 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/RestartCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/RestartCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other.util; +package com.diamondfire.helpbot.bot.command.impl.other.dev; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/ChannelMuteCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/mod/ChannelMuteCommand.java similarity index 98% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/ChannelMuteCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/mod/ChannelMuteCommand.java index b5646a78..207d2b3a 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/ChannelMuteCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/mod/ChannelMuteCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other.util; +package com.diamondfire.helpbot.bot.command.impl.other.mod; import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/DiscussionMuteCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/mod/DiscussionMuteCommand.java similarity index 98% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/DiscussionMuteCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/mod/DiscussionMuteCommand.java index 64309db8..610af367 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/DiscussionMuteCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/mod/DiscussionMuteCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other.util; +package com.diamondfire.helpbot.bot.command.impl.other.mod; import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/MuteCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/mod/MuteCommand.java similarity index 98% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/MuteCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/mod/MuteCommand.java index 0367a1e2..b616d6d9 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/MuteCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/mod/MuteCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other.util; +package com.diamondfire.helpbot.bot.command.impl.other.mod; import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/MutedCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/mod/MutedCommand.java similarity index 97% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/MutedCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/mod/MutedCommand.java index c8515ef2..580030d4 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/MutedCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/mod/MutedCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other.util; +package com.diamondfire.helpbot.bot.command.impl.other.mod; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/UnmuteCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/mod/UnmuteCommand.java similarity index 98% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/UnmuteCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/mod/UnmuteCommand.java index 1a522d7a..fa2fc488 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/UnmuteCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/mod/UnmuteCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other.util; +package com.diamondfire.helpbot.bot.command.impl.other.mod; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/VerifyCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/mod/VerifyCommand.java similarity index 98% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/VerifyCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/mod/VerifyCommand.java index 8683fa8e..a0c46702 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/VerifyCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/mod/VerifyCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other.util; +package com.diamondfire.helpbot.bot.command.impl.other.mod; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.types.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/Tag.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/Tag.java new file mode 100644 index 00000000..b380c149 --- /dev/null +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/Tag.java @@ -0,0 +1,98 @@ +package com.diamondfire.helpbot.bot.command.impl.other.tag; + +import com.google.gson.JsonObject; +import net.dv8tion.jda.api.EmbedBuilder; +import net.dv8tion.jda.api.entities.*; + +public class Tag implements Cloneable { + + private String activator; + private String title; + private String response; + private long authorId; + private String image; + + public Tag(String activator, String title, String response, long authorId, String image) { + this.activator = activator; + this.title = title; + this.response = response; + this.authorId = authorId; + this.image = image; + } + + public String getActivator() { + return activator; + } + + public void setActivator(String activator) { + this.activator = activator.replaceAll(" ", ""); + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getResponse() { + return this.response; + } + + public void setResponse(String response) { + this.response = response; + } + + public long getAuthorId() { + return this.authorId; + } + + public void setAuthorId(long authorId) { + this.authorId = authorId; + } + + public String getImage() { + return this.image; + } + + public void setImage(String image) { + this.image = image; + } + + public void set(TagProperty property, String newValue) { + if (property == TagProperty.ACTIVATOR) setActivator(newValue); + else if (property == TagProperty.TITLE) setTitle(newValue); + else if (property == TagProperty.RESPONSE) setResponse(newValue); + else if (property == TagProperty.IMAGE) setImage(newValue); + } + + public JsonObject asJson() { + JsonObject json = new JsonObject(); + json.addProperty("activator", this.activator); + json.addProperty("title", this.title); + json.addProperty("response", this.response); + json.addProperty("authorId", this.authorId); + json.addProperty("image", this.image); + + return json; + } + + public void sendResponse(TextChannel channel) { + User user = channel.getJDA().retrieveUserById(getAuthorId()).complete(); + + EmbedBuilder embed = new EmbedBuilder() + .setTitle(getTitle()) + .setDescription(getResponse()+"\n\u200b") + .setColor(0x969dba) + .setFooter("Written by "+user.getAsTag(), user.getAvatarUrl()); + if (!getImage().equals("")) embed.setImage(getImage()); + + channel.sendMessage(embed.build()).queue(); + } + + @Override + public Tag clone() throws CloneNotSupportedException { + return (Tag) super.clone(); + } +} diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagAlreadyExistsException.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagAlreadyExistsException.java new file mode 100644 index 00000000..4b0a9cc3 --- /dev/null +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagAlreadyExistsException.java @@ -0,0 +1,8 @@ +package com.diamondfire.helpbot.bot.command.impl.other.tag; + +public class TagAlreadyExistsException extends Exception { + public TagAlreadyExistsException(String message) { + super(message); + } + +} diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagDoesntExistException.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagDoesntExistException.java new file mode 100644 index 00000000..24a1fa85 --- /dev/null +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagDoesntExistException.java @@ -0,0 +1,7 @@ +package com.diamondfire.helpbot.bot.command.impl.other.tag; + +public class TagDoesntExistException extends Exception { + public TagDoesntExistException(String message) { + super(message); + } +} diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagHandler.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagHandler.java new file mode 100644 index 00000000..8e8ceb0f --- /dev/null +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagHandler.java @@ -0,0 +1,80 @@ +package com.diamondfire.helpbot.bot.command.impl.other.tag; + +import com.diamondfire.helpbot.sys.externalfile.ExternalFiles; +import com.google.gson.*; + +import java.io.*; +import java.nio.file.*; + +public class TagHandler { + + private static JsonObject json = null; + private static final File FILE = ExternalFiles.TAGS; + + public static JsonObject getTags() throws IOException { + // gets the cached json, and caches it if it is not yet cached + if (json == null) cacheJson(); + return json; + } + + private static void cacheJson() throws IOException { + // read the file and update the cache + String content = new String(Files.readAllBytes(FILE.toPath())); + if (content.length() == 0) content = "{}"; + json = JsonParser.parseString(content).getAsJsonObject(); + } + + private static void updateJson(JsonObject newJson) throws IOException { + // rewrite file + FILE.delete(); + FILE.createNewFile(); + Files.write(FILE.toPath(), newJson.toString().getBytes(), StandardOpenOption.WRITE); + + // update cache + json = newJson; + } + + public static void newTag(Tag tag) throws TagAlreadyExistsException, IOException { + // check if tag with equal activator already exists + JsonObject tagJson = getTags().getAsJsonObject(tag.getActivator()); + if (tagJson != null) throw new TagAlreadyExistsException("A tag with this activator already exists."); + + // implement the new tag + json.add(tag.getActivator(), tag.asJson()); + updateJson(json); + } + + public static void deleteTag(String activator) throws TagDoesntExistException, IOException { + // get tag + check if it exists + Tag tag = getTag(activator); + + // remove the tag from the json + json.remove(activator); + updateJson(json); + } + + public static void deleteTag(Tag tag) throws TagDoesntExistException, IOException { + deleteTag(tag.getActivator()); + } + + public static Tag getTag(String activator) throws TagDoesntExistException, IOException { + JsonObject tagJson = getTags().getAsJsonObject(activator); + if (tagJson == null) throw new TagDoesntExistException("A tag with activator `"+activator+"` does not exist."); + return new Tag( + tagJson.get("activator").getAsString(), + tagJson.get("title").getAsString(), + tagJson.get("response").getAsString(), + tagJson.get("authorId").getAsLong(), + tagJson.get("image").getAsString() + ); + } + + public static Tag getTag(Tag tag) throws TagDoesntExistException, IOException { + return getTag(tag.getActivator()); + } + + public static void editTag(Tag oldTag, Tag newTag) throws TagDoesntExistException, TagAlreadyExistsException, IOException { + deleteTag(oldTag); + newTag(newTag); + } +} diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagProperty.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagProperty.java new file mode 100644 index 00000000..33cb6d89 --- /dev/null +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagProperty.java @@ -0,0 +1,32 @@ +package com.diamondfire.helpbot.bot.command.impl.other.tag; + +public enum TagProperty { + ACTIVATOR("activator", true), + TITLE("title", true), + RESPONSE("response", true), + AUTHOR_ID("authorId", false), + IMAGE("image", true); + + private final String property; + private final boolean modifiable; + + TagProperty(String property, boolean modifiable) { + this.property = property; + this.modifiable = modifiable; + } + + public String getProperty() { + return property; + } + + public boolean isModifiable() { + return modifiable; + } + + public static TagProperty getByProperty(String prop) { + for (TagProperty tagProperty : TagProperty.values()) { + if (tagProperty.getProperty().equals(prop)) return tagProperty; + } + return null; + } +} diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/DelTagCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/DelTagCommand.java new file mode 100644 index 00000000..04770fc5 --- /dev/null +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/DelTagCommand.java @@ -0,0 +1,71 @@ +package com.diamondfire.helpbot.bot.command.impl.other.tag.impl; + +import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; +import com.diamondfire.helpbot.bot.command.argument.impl.types.StringArgument; +import com.diamondfire.helpbot.bot.command.help.*; +import com.diamondfire.helpbot.bot.command.impl.Command; +import com.diamondfire.helpbot.bot.command.impl.other.tag.*; +import com.diamondfire.helpbot.bot.command.permissions.Permission; +import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; +import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; +import com.diamondfire.helpbot.bot.events.CommandEvent; + +import java.io.IOException; + +public class DelTagCommand extends Command { + + @Override + public String getName() { + return "deltag"; + } + + @Override + public HelpContext getHelpContext() { + return new HelpContext() + .description("Deletes a custom command tag by activator.") + .category(CommandCategory.OTHER) + .addArgument( + new HelpContextArgument() + .name("activator") + ); + } + + @Override + public ArgumentSet compileArguments() { + return new ArgumentSet().addArgument("activator", + new StringArgument() + ); + } + + @Override + public Permission getPermission() { + return Permission.EXPERT; + } + + @Override + public void run(CommandEvent event) { + // Get activator + String activator = event.getArgument("activator"); + + try { + TagHandler.deleteTag(activator); + PresetBuilder preset = new PresetBuilder() + .withPreset( + new InformativeReply(InformativeReplyType.SUCCESS, "Success", + "Successfully deleted tag with activator `"+activator+"`.") + ); + event.reply(preset); + + } catch (TagDoesntExistException | IOException err) { + PresetBuilder preset = new PresetBuilder() + .withPreset( + new InformativeReply(InformativeReplyType.ERROR, "Error!", + err.getMessage()) + ); + event.reply(preset); + } + } + +} + + diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/EditTagCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/EditTagCommand.java new file mode 100644 index 00000000..15dde0e0 --- /dev/null +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/EditTagCommand.java @@ -0,0 +1,105 @@ +package com.diamondfire.helpbot.bot.command.impl.other.tag.impl; + +import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; +import com.diamondfire.helpbot.bot.command.argument.impl.types.StringArgument; +import com.diamondfire.helpbot.bot.command.help.*; +import com.diamondfire.helpbot.bot.command.impl.Command; +import com.diamondfire.helpbot.bot.command.impl.other.tag.*; +import com.diamondfire.helpbot.bot.command.permissions.Permission; +import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; +import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; +import com.diamondfire.helpbot.bot.events.CommandEvent; + +import java.io.IOException; +import java.util.*; + +public class EditTagCommand extends Command { + + private final String PROPERTIES = "activator/title/response/image"; + + @Override + public String getName() { + return "edittag"; + } + + @Override + public HelpContext getHelpContext() { + return new HelpContext() + .description("Edits a new custom command tag property. Use 'none' for the image to remove it.") + .category(CommandCategory.OTHER) + .addArgument( + new HelpContextArgument() + .name("activator"), + new HelpContextArgument() + .name(PROPERTIES), + new HelpContextArgument() + .name("new value") + ); + } + + @Override + public ArgumentSet compileArguments() { + return new ArgumentSet().addArgument("activator", + new StringArgument() + ).addArgument(PROPERTIES, + new StringArgument() + ).addArgument("new value", + new StringArgument() + ); + } + + @Override + public Permission getPermission() { + return Permission.EXPERT; + } + + @Override + public void run(CommandEvent event) { + // Get activator and property + String activator = event.getArgument("activator"); + String prop = event.getArgument(PROPERTIES); + + // Check if property is valid + TagProperty property = TagProperty.getByProperty(prop); + if (property == null || !property.isModifiable()) { + PresetBuilder preset = new PresetBuilder() + .withPreset( + new InformativeReply(InformativeReplyType.ERROR, + "This is not a valid property. Choose from: `activator`, `title`, `response`, `image`") + ); + event.reply(preset); + return; + } + + // Get new value + List splitArgs = new LinkedList<>(Arrays.asList(event.getMessage().getContentRaw() + .split(" +"))); + String newValue = String.join(" ", splitArgs.subList(3, splitArgs.size())); + if (property == TagProperty.IMAGE && newValue.equals("none")) newValue = ""; + + try { + Tag oldTag = TagHandler.getTag(activator); + Tag newTag = oldTag.clone(); + newTag.set(property, newValue); + + TagHandler.editTag(oldTag, newTag); + + PresetBuilder preset = new PresetBuilder() + .withPreset( + new InformativeReply(InformativeReplyType.SUCCESS, "Success", "Successfully modified tag.") + ); + event.reply(preset); + + } catch (TagDoesntExistException | TagAlreadyExistsException | IOException | CloneNotSupportedException err) { + PresetBuilder preset = new PresetBuilder() + .withPreset( + new InformativeReply(InformativeReplyType.ERROR, "Error!", err.getMessage()) + ); + event.reply(preset); + err.printStackTrace(); + } + } + +} + + diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/ListTagsCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/ListTagsCommand.java new file mode 100644 index 00000000..bb7e5a75 --- /dev/null +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/ListTagsCommand.java @@ -0,0 +1,76 @@ +package com.diamondfire.helpbot.bot.command.impl.other.tag.impl; + +import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; +import com.diamondfire.helpbot.bot.command.help.*; +import com.diamondfire.helpbot.bot.command.impl.Command; +import com.diamondfire.helpbot.bot.command.impl.other.tag.TagHandler; +import com.diamondfire.helpbot.bot.command.permissions.Permission; +import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; +import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; +import com.diamondfire.helpbot.bot.events.CommandEvent; +import com.google.gson.JsonObject; +import net.dv8tion.jda.api.entities.*; + +import java.io.IOException; +import java.util.Set; + +public class ListTagsCommand extends Command { + + @Override + public String getName() { + return "listtags"; + } + + @Override + public HelpContext getHelpContext() { + return new HelpContext() + .description("Lists all custom command tags.") + .category(CommandCategory.OTHER); + } + + @Override + public ArgumentSet compileArguments() { + return new ArgumentSet(); + } + + @Override + public Permission getPermission() { + return Permission.USER; + } + + @Override + public void run(CommandEvent event) { + try { + JsonObject tags = TagHandler.getTags(); + String string = ""; + Set keySet = tags.keySet(); + + if (keySet.size() == 0) { + string = "*None*"; + + } else { + for (String key : keySet) { + JsonObject tag = tags.get(key).getAsJsonObject(); + string += "`" + tag.get("activator").getAsString() + "` "; + } + } + + PresetBuilder preset = new PresetBuilder() + .withPreset( + new InformativeReply(InformativeReplyType.INFO, "Tags", + "A list of all custom command tags added.\n\n"+string+"\n\u200b") + ); + + User ryanland = event.getJDA().retrieveUserById(808966728201666620L).complete(); + MessageEmbed embed = preset.getEmbed().setFooter("Tag system by "+ryanland.getAsTag(), ryanland.getAvatarUrl()) + .build(); + event.getChannel().sendMessage(embed).queue(); + + } catch (IOException e) { + e.printStackTrace(); + } + } + +} + + diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/NewTagCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/NewTagCommand.java new file mode 100644 index 00000000..43c1dd39 --- /dev/null +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/NewTagCommand.java @@ -0,0 +1,87 @@ +package com.diamondfire.helpbot.bot.command.impl.other.tag.impl; + +import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; +import com.diamondfire.helpbot.bot.command.argument.impl.types.StringArgument; +import com.diamondfire.helpbot.bot.command.help.*; +import com.diamondfire.helpbot.bot.command.impl.Command; +import com.diamondfire.helpbot.bot.command.impl.other.tag.*; +import com.diamondfire.helpbot.bot.command.permissions.Permission; +import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; +import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; +import com.diamondfire.helpbot.bot.events.CommandEvent; + +import java.io.IOException; +import java.util.*; + +public class NewTagCommand extends Command { + + @Override + public String getName() { + return "newtag"; + } + + @Override + public HelpContext getHelpContext() { + return new HelpContext() + .description("Creates a new custom command tag. Use \"%space%\" in the title to add a space.") + .category(CommandCategory.OTHER) + .addArgument( + new HelpContextArgument() + .name("activator"), + new HelpContextArgument() + .name("title"), + new HelpContextArgument() + .name("response") + ); + } + + @Override + public ArgumentSet compileArguments() { + return new ArgumentSet().addArgument("activator", + new StringArgument() + ).addArgument("title", + new StringArgument() + ).addArgument("response", + new StringArgument() + ); + } + + @Override + public Permission getPermission() { + return Permission.EXPERT; + } + + @Override + public void run(CommandEvent event) { + // Get new activator and title + String activator = event.getArgument("activator"); + String title = ((String) event.getArgument("title")).replaceAll("%space%", " "); + + // Get response + List splitArgs = new LinkedList<>(Arrays.asList(event.getMessage().getContentRaw() + .split(" +"))); + String response = String.join(" ", splitArgs.subList(3, splitArgs.size())); + + // Construct Tag + Tag tag = new Tag(activator, title, response, event.getAuthor().getIdLong(), ""); + + try { + TagHandler.newTag(tag); + PresetBuilder preset = new PresetBuilder() + .withPreset( + new InformativeReply(InformativeReplyType.SUCCESS, "Success", "Successfully added a new tag.") + ); + event.reply(preset); + + } catch (TagAlreadyExistsException | IOException err) { + PresetBuilder preset = new PresetBuilder() + .withPreset( + new InformativeReply(InformativeReplyType.ERROR, "Error!", err.getMessage()) + ); + event.reply(preset); + } + } + +} + + diff --git a/src/main/java/com/diamondfire/helpbot/sys/externalfile/ExternalFiles.java b/src/main/java/com/diamondfire/helpbot/sys/externalfile/ExternalFiles.java index 95799afc..361a6608 100644 --- a/src/main/java/com/diamondfire/helpbot/sys/externalfile/ExternalFiles.java +++ b/src/main/java/com/diamondfire/helpbot/sys/externalfile/ExternalFiles.java @@ -55,4 +55,10 @@ public interface ExternalFiles { .setName("samman") .setFileType("png") .buildFile(); + + File TAGS = new ExternalFileBuilder() + .isDirectory(false) + .setName("tags") + .setFileType("json") + .buildFile(); } diff --git a/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/TagAcceptor.java b/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/TagAcceptor.java new file mode 100644 index 00000000..8764926c --- /dev/null +++ b/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/TagAcceptor.java @@ -0,0 +1,34 @@ +package com.diamondfire.helpbot.sys.message.acceptors; + +import com.diamondfire.helpbot.bot.HelpBotInstance; +import com.diamondfire.helpbot.bot.command.impl.other.tag.*; +import net.dv8tion.jda.api.entities.Message; + +import java.io.IOException; + +public class TagAcceptor implements MessageAcceptor { + + @Override + public boolean accept(Message message) { + if (message.getContentDisplay().startsWith(HelpBotInstance.getConfig().getPrefix()) && !message.getAuthor().isBot()) { + String parsedText = message.getContentStripped().substring(HelpBotInstance.getConfig().getPrefix().length()) + .replaceFirst(" .*$", ""); + + try { + // Get Tag and send response + Tag tag = TagHandler.getTag(parsedText); + tag.sendResponse(message.getTextChannel()); + + // Delete origin message + message.delete().queue(); + + } catch (TagDoesntExistException | IOException ignored) { + return false; + } + + return true; + } + + return false; + } +} diff --git a/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/VerifyAcceptor.java b/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/VerifyAcceptor.java index 3ae7e715..b1493bf9 100644 --- a/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/VerifyAcceptor.java +++ b/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/VerifyAcceptor.java @@ -1,6 +1,6 @@ package com.diamondfire.helpbot.sys.message.acceptors; -import com.diamondfire.helpbot.bot.command.impl.other.util.VerifyCommand; +import com.diamondfire.helpbot.bot.command.impl.other.mod.VerifyCommand; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; import com.diamondfire.helpbot.sys.database.impl.DatabaseQuery; diff --git a/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/CodeDatabaseTask.java b/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/CodeDatabaseTask.java index ee1911f8..20b2b007 100644 --- a/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/CodeDatabaseTask.java +++ b/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/CodeDatabaseTask.java @@ -1,6 +1,6 @@ package com.diamondfire.helpbot.sys.tasks.impl; -import com.diamondfire.helpbot.bot.command.impl.other.util.FetchDataCommand; +import com.diamondfire.helpbot.bot.command.impl.other.dev.FetchDataCommand; import com.diamondfire.helpbot.sys.tasks.MidnightTask; public class CodeDatabaseTask implements MidnightTask { diff --git a/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/MuteExpireTask.java b/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/MuteExpireTask.java index 0767f94d..12214a9e 100644 --- a/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/MuteExpireTask.java +++ b/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/MuteExpireTask.java @@ -1,8 +1,8 @@ package com.diamondfire.helpbot.sys.tasks.impl; import com.diamondfire.helpbot.bot.HelpBotInstance; -import com.diamondfire.helpbot.bot.command.impl.other.util.DiscussionMuteCommand; -import com.diamondfire.helpbot.bot.command.impl.other.util.MuteCommand; +import com.diamondfire.helpbot.bot.command.impl.other.mod.DiscussionMuteCommand; +import com.diamondfire.helpbot.bot.command.impl.other.mod.MuteCommand; import com.diamondfire.helpbot.sys.database.impl.DatabaseQuery; import com.diamondfire.helpbot.sys.database.impl.queries.BasicQuery; import com.diamondfire.helpbot.sys.tasks.OneTimeTask; From a51a9762d852d16471e57428f936a883571cfca6 Mon Sep 17 00:00:00 2001 From: RyanLandDev Date: Sat, 17 Jul 2021 12:13:54 +0200 Subject: [PATCH 3/8] Complete all requested changes except subcommands + Better Tag cache --- .../java/com/diamondfire/helpbot/HelpBot.java | 5 +- .../helpbot/bot/HelpBotInstance.java | 5 +- .../other/tag/{impl => }/DelTagCommand.java | 4 +- .../other/tag/{impl => }/EditTagCommand.java | 16 ++-- .../other/tag/{impl => }/ListTagsCommand.java | 23 ++--- .../other/tag/{impl => }/NewTagCommand.java | 4 +- .../command/impl/other/tag/TagHandler.java | 80 ------------------ .../command/impl/other/tag/TagProperty.java | 32 ------- .../stats/top/DiscordBoostersCommand.java | 15 ++-- .../sys/message/acceptors/TagAcceptor.java | 4 +- .../command/impl/other => sys}/tag/Tag.java | 16 +--- .../tag/TagAlreadyExistsException.java | 2 +- .../tag/TagDoesntExistException.java | 2 +- .../helpbot/sys/tag/TagHandler.java | 84 +++++++++++++++++++ .../helpbot/sys/tag/TagProperty.java | 59 +++++++++++++ 15 files changed, 187 insertions(+), 164 deletions(-) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/{impl => }/DelTagCommand.java (94%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/{impl => }/EditTagCommand.java (88%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/{impl => }/ListTagsCommand.java (67%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/{impl => }/NewTagCommand.java (95%) delete mode 100644 src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagHandler.java delete mode 100644 src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagProperty.java rename src/main/java/com/diamondfire/helpbot/{bot/command/impl/other => sys}/tag/Tag.java (79%) rename src/main/java/com/diamondfire/helpbot/{bot/command/impl/other => sys}/tag/TagAlreadyExistsException.java (71%) rename src/main/java/com/diamondfire/helpbot/{bot/command/impl/other => sys}/tag/TagDoesntExistException.java (70%) create mode 100644 src/main/java/com/diamondfire/helpbot/sys/tag/TagHandler.java create mode 100644 src/main/java/com/diamondfire/helpbot/sys/tag/TagProperty.java diff --git a/src/main/java/com/diamondfire/helpbot/HelpBot.java b/src/main/java/com/diamondfire/helpbot/HelpBot.java index ec980141..bba770ef 100644 --- a/src/main/java/com/diamondfire/helpbot/HelpBot.java +++ b/src/main/java/com/diamondfire/helpbot/HelpBot.java @@ -4,13 +4,16 @@ import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.df.codeinfo.codedatabase.changelog.CodeDifferenceHandler; import com.diamondfire.helpbot.df.codeinfo.codedatabase.db.CodeDatabase; +import com.diamondfire.helpbot.sys.tag.TagHandler; import javax.security.auth.login.LoginException; +import java.io.IOException; public class HelpBot { - public static void main(String[] args) throws LoginException { + public static void main(String[] args) throws LoginException, IOException { CodeDatabase.initialize(); + TagHandler.cacheJson(); HelpBotInstance.initialize(); CodeDifferenceHandler.refresh(); } diff --git a/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java b/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java index 9a7413a1..cd5077ac 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java +++ b/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java @@ -7,7 +7,10 @@ import com.diamondfire.helpbot.bot.command.impl.other.fun.*; import com.diamondfire.helpbot.bot.command.impl.other.info.*; import com.diamondfire.helpbot.bot.command.impl.other.mod.*; -import com.diamondfire.helpbot.bot.command.impl.other.tag.impl.*; +import com.diamondfire.helpbot.bot.command.impl.other.tag.DelTagCommand; +import com.diamondfire.helpbot.bot.command.impl.other.tag.EditTagCommand; +import com.diamondfire.helpbot.bot.command.impl.other.tag.ListTagsCommand; +import com.diamondfire.helpbot.bot.command.impl.other.tag.NewTagCommand; import com.diamondfire.helpbot.bot.command.impl.other.util.*; import com.diamondfire.helpbot.bot.command.impl.stats.*; import com.diamondfire.helpbot.bot.command.impl.stats.graph.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/DelTagCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/DelTagCommand.java similarity index 94% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/DelTagCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/DelTagCommand.java index 04770fc5..738d6c8c 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/DelTagCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/DelTagCommand.java @@ -1,14 +1,14 @@ -package com.diamondfire.helpbot.bot.command.impl.other.tag.impl; +package com.diamondfire.helpbot.bot.command.impl.other.tag; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.types.StringArgument; import com.diamondfire.helpbot.bot.command.help.*; import com.diamondfire.helpbot.bot.command.impl.Command; -import com.diamondfire.helpbot.bot.command.impl.other.tag.*; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; import com.diamondfire.helpbot.bot.events.CommandEvent; +import com.diamondfire.helpbot.sys.tag.*; import java.io.IOException; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/EditTagCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/EditTagCommand.java similarity index 88% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/EditTagCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/EditTagCommand.java index 15dde0e0..90b16da7 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/EditTagCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/EditTagCommand.java @@ -1,14 +1,14 @@ -package com.diamondfire.helpbot.bot.command.impl.other.tag.impl; +package com.diamondfire.helpbot.bot.command.impl.other.tag; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.types.StringArgument; import com.diamondfire.helpbot.bot.command.help.*; import com.diamondfire.helpbot.bot.command.impl.Command; -import com.diamondfire.helpbot.bot.command.impl.other.tag.*; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; import com.diamondfire.helpbot.bot.events.CommandEvent; +import com.diamondfire.helpbot.sys.tag.*; import java.io.IOException; import java.util.*; @@ -76,13 +76,11 @@ public void run(CommandEvent event) { .split(" +"))); String newValue = String.join(" ", splitArgs.subList(3, splitArgs.size())); if (property == TagProperty.IMAGE && newValue.equals("none")) newValue = ""; - + try { - Tag oldTag = TagHandler.getTag(activator); - Tag newTag = oldTag.clone(); - newTag.set(property, newValue); - - TagHandler.editTag(oldTag, newTag); + Tag tag = TagHandler.getTag(activator); + property.edit(tag, newValue); + TagHandler.saveToJson(); PresetBuilder preset = new PresetBuilder() .withPreset( @@ -90,7 +88,7 @@ public void run(CommandEvent event) { ); event.reply(preset); - } catch (TagDoesntExistException | TagAlreadyExistsException | IOException | CloneNotSupportedException err) { + } catch (TagDoesntExistException | IOException err) { PresetBuilder preset = new PresetBuilder() .withPreset( new InformativeReply(InformativeReplyType.ERROR, "Error!", err.getMessage()) diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/ListTagsCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/ListTagsCommand.java similarity index 67% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/ListTagsCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/ListTagsCommand.java index bb7e5a75..fd27b1f0 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/ListTagsCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/ListTagsCommand.java @@ -1,9 +1,9 @@ -package com.diamondfire.helpbot.bot.command.impl.other.tag.impl; +package com.diamondfire.helpbot.bot.command.impl.other.tag; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; import com.diamondfire.helpbot.bot.command.impl.Command; -import com.diamondfire.helpbot.bot.command.impl.other.tag.TagHandler; +import com.diamondfire.helpbot.sys.tag.*; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; @@ -12,7 +12,7 @@ import net.dv8tion.jda.api.entities.*; import java.io.IOException; -import java.util.Set; +import java.util.*; public class ListTagsCommand extends Command { @@ -41,30 +41,25 @@ public Permission getPermission() { @Override public void run(CommandEvent event) { try { - JsonObject tags = TagHandler.getTags(); + List tags = TagHandler.getTags(); String string = ""; - Set keySet = tags.keySet(); - if (keySet.size() == 0) { + if (tags.size() == 0) { string = "*None*"; } else { - for (String key : keySet) { - JsonObject tag = tags.get(key).getAsJsonObject(); - string += "`" + tag.get("activator").getAsString() + "` "; + for (Tag tag : tags) { + string += "`" + tag.getActivator() + "` "; } } PresetBuilder preset = new PresetBuilder() .withPreset( new InformativeReply(InformativeReplyType.INFO, "Tags", - "A list of all custom command tags added.\n\n"+string+"\n\u200b") + "A list of all custom command tags added.\n\n"+string) ); - User ryanland = event.getJDA().retrieveUserById(808966728201666620L).complete(); - MessageEmbed embed = preset.getEmbed().setFooter("Tag system by "+ryanland.getAsTag(), ryanland.getAvatarUrl()) - .build(); - event.getChannel().sendMessage(embed).queue(); + event.reply(preset); } catch (IOException e) { e.printStackTrace(); diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/NewTagCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/NewTagCommand.java similarity index 95% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/NewTagCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/NewTagCommand.java index 43c1dd39..f2972930 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/impl/NewTagCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/NewTagCommand.java @@ -1,14 +1,14 @@ -package com.diamondfire.helpbot.bot.command.impl.other.tag.impl; +package com.diamondfire.helpbot.bot.command.impl.other.tag; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.types.StringArgument; import com.diamondfire.helpbot.bot.command.help.*; import com.diamondfire.helpbot.bot.command.impl.Command; -import com.diamondfire.helpbot.bot.command.impl.other.tag.*; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; import com.diamondfire.helpbot.bot.events.CommandEvent; +import com.diamondfire.helpbot.sys.tag.*; import java.io.IOException; import java.util.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagHandler.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagHandler.java deleted file mode 100644 index 8e8ceb0f..00000000 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagHandler.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.diamondfire.helpbot.bot.command.impl.other.tag; - -import com.diamondfire.helpbot.sys.externalfile.ExternalFiles; -import com.google.gson.*; - -import java.io.*; -import java.nio.file.*; - -public class TagHandler { - - private static JsonObject json = null; - private static final File FILE = ExternalFiles.TAGS; - - public static JsonObject getTags() throws IOException { - // gets the cached json, and caches it if it is not yet cached - if (json == null) cacheJson(); - return json; - } - - private static void cacheJson() throws IOException { - // read the file and update the cache - String content = new String(Files.readAllBytes(FILE.toPath())); - if (content.length() == 0) content = "{}"; - json = JsonParser.parseString(content).getAsJsonObject(); - } - - private static void updateJson(JsonObject newJson) throws IOException { - // rewrite file - FILE.delete(); - FILE.createNewFile(); - Files.write(FILE.toPath(), newJson.toString().getBytes(), StandardOpenOption.WRITE); - - // update cache - json = newJson; - } - - public static void newTag(Tag tag) throws TagAlreadyExistsException, IOException { - // check if tag with equal activator already exists - JsonObject tagJson = getTags().getAsJsonObject(tag.getActivator()); - if (tagJson != null) throw new TagAlreadyExistsException("A tag with this activator already exists."); - - // implement the new tag - json.add(tag.getActivator(), tag.asJson()); - updateJson(json); - } - - public static void deleteTag(String activator) throws TagDoesntExistException, IOException { - // get tag + check if it exists - Tag tag = getTag(activator); - - // remove the tag from the json - json.remove(activator); - updateJson(json); - } - - public static void deleteTag(Tag tag) throws TagDoesntExistException, IOException { - deleteTag(tag.getActivator()); - } - - public static Tag getTag(String activator) throws TagDoesntExistException, IOException { - JsonObject tagJson = getTags().getAsJsonObject(activator); - if (tagJson == null) throw new TagDoesntExistException("A tag with activator `"+activator+"` does not exist."); - return new Tag( - tagJson.get("activator").getAsString(), - tagJson.get("title").getAsString(), - tagJson.get("response").getAsString(), - tagJson.get("authorId").getAsLong(), - tagJson.get("image").getAsString() - ); - } - - public static Tag getTag(Tag tag) throws TagDoesntExistException, IOException { - return getTag(tag.getActivator()); - } - - public static void editTag(Tag oldTag, Tag newTag) throws TagDoesntExistException, TagAlreadyExistsException, IOException { - deleteTag(oldTag); - newTag(newTag); - } -} diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagProperty.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagProperty.java deleted file mode 100644 index 33cb6d89..00000000 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagProperty.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.diamondfire.helpbot.bot.command.impl.other.tag; - -public enum TagProperty { - ACTIVATOR("activator", true), - TITLE("title", true), - RESPONSE("response", true), - AUTHOR_ID("authorId", false), - IMAGE("image", true); - - private final String property; - private final boolean modifiable; - - TagProperty(String property, boolean modifiable) { - this.property = property; - this.modifiable = modifiable; - } - - public String getProperty() { - return property; - } - - public boolean isModifiable() { - return modifiable; - } - - public static TagProperty getByProperty(String prop) { - for (TagProperty tagProperty : TagProperty.values()) { - if (tagProperty.getProperty().equals(prop)) return tagProperty; - } - return null; - } -} diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/DiscordBoostersCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/DiscordBoostersCommand.java index e9043ee2..e136fb40 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/DiscordBoostersCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/DiscordBoostersCommand.java @@ -12,7 +12,7 @@ import java.awt.*; import java.text.SimpleDateFormat; -import java.util.Comparator; +import java.util.*; import java.util.List; public class DiscordBoostersCommand extends Command { @@ -64,19 +64,22 @@ public void run(CommandEvent event) { }); } - private String getFormattedBoosters(List members) { + private static String getFormattedBoosters(List members) { if (members.size() == 0) return "*None*"; + else { SimpleDateFormat format = new SimpleDateFormat("y'y'M'm'D'd'"); - String result = ""; + List elements = new ArrayList<>(); for (Member member : members) { String timeBoosted = format.format(member.getTimeBoosted()); - result += "<@" + member.getId() + "> - " + timeBoosted + "\n"; + elements.add(member.getAsMention() + " - " + timeBoosted); } - return result; + return String.join("\n", elements); } } -} \ No newline at end of file +} + + diff --git a/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/TagAcceptor.java b/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/TagAcceptor.java index 8764926c..77c95221 100644 --- a/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/TagAcceptor.java +++ b/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/TagAcceptor.java @@ -1,7 +1,9 @@ package com.diamondfire.helpbot.sys.message.acceptors; import com.diamondfire.helpbot.bot.HelpBotInstance; -import com.diamondfire.helpbot.bot.command.impl.other.tag.*; +import com.diamondfire.helpbot.sys.tag.Tag; +import com.diamondfire.helpbot.sys.tag.TagDoesntExistException; +import com.diamondfire.helpbot.sys.tag.TagHandler; import net.dv8tion.jda.api.entities.Message; import java.io.IOException; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/Tag.java b/src/main/java/com/diamondfire/helpbot/sys/tag/Tag.java similarity index 79% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/Tag.java rename to src/main/java/com/diamondfire/helpbot/sys/tag/Tag.java index b380c149..cce56291 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/Tag.java +++ b/src/main/java/com/diamondfire/helpbot/sys/tag/Tag.java @@ -1,10 +1,10 @@ -package com.diamondfire.helpbot.bot.command.impl.other.tag; +package com.diamondfire.helpbot.sys.tag; import com.google.gson.JsonObject; import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.entities.*; -public class Tag implements Cloneable { +public class Tag { private String activator; private String title; @@ -60,13 +60,6 @@ public void setImage(String image) { this.image = image; } - public void set(TagProperty property, String newValue) { - if (property == TagProperty.ACTIVATOR) setActivator(newValue); - else if (property == TagProperty.TITLE) setTitle(newValue); - else if (property == TagProperty.RESPONSE) setResponse(newValue); - else if (property == TagProperty.IMAGE) setImage(newValue); - } - public JsonObject asJson() { JsonObject json = new JsonObject(); json.addProperty("activator", this.activator); @@ -90,9 +83,4 @@ public void sendResponse(TextChannel channel) { channel.sendMessage(embed.build()).queue(); } - - @Override - public Tag clone() throws CloneNotSupportedException { - return (Tag) super.clone(); - } } diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagAlreadyExistsException.java b/src/main/java/com/diamondfire/helpbot/sys/tag/TagAlreadyExistsException.java similarity index 71% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagAlreadyExistsException.java rename to src/main/java/com/diamondfire/helpbot/sys/tag/TagAlreadyExistsException.java index 4b0a9cc3..7713406e 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagAlreadyExistsException.java +++ b/src/main/java/com/diamondfire/helpbot/sys/tag/TagAlreadyExistsException.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other.tag; +package com.diamondfire.helpbot.sys.tag; public class TagAlreadyExistsException extends Exception { public TagAlreadyExistsException(String message) { diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagDoesntExistException.java b/src/main/java/com/diamondfire/helpbot/sys/tag/TagDoesntExistException.java similarity index 70% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagDoesntExistException.java rename to src/main/java/com/diamondfire/helpbot/sys/tag/TagDoesntExistException.java index 24a1fa85..d420efab 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagDoesntExistException.java +++ b/src/main/java/com/diamondfire/helpbot/sys/tag/TagDoesntExistException.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.other.tag; +package com.diamondfire.helpbot.sys.tag; public class TagDoesntExistException extends Exception { public TagDoesntExistException(String message) { diff --git a/src/main/java/com/diamondfire/helpbot/sys/tag/TagHandler.java b/src/main/java/com/diamondfire/helpbot/sys/tag/TagHandler.java new file mode 100644 index 00000000..ce84cec8 --- /dev/null +++ b/src/main/java/com/diamondfire/helpbot/sys/tag/TagHandler.java @@ -0,0 +1,84 @@ +package com.diamondfire.helpbot.sys.tag; + +import com.diamondfire.helpbot.sys.externalfile.ExternalFiles; +import com.google.gson.*; + +import java.io.*; +import java.nio.file.*; +import java.util.*; +import java.util.stream.Collectors; + +public class TagHandler { + + private static List tags = new ArrayList<>(); + private static final File FILE = ExternalFiles.TAGS; + + public static List getTags() throws IOException { + return tags; + } + + public static void cacheJson() throws IOException { + // read the file and update the cache + String content = new String(Files.readAllBytes(FILE.toPath())); + if (content.length() == 0) content = "{}"; + JsonObject obj = JsonParser.parseString(content).getAsJsonObject(); + + for (String key : obj.keySet()) { + JsonObject tag = obj.get(key).getAsJsonObject(); + tags.add(new Tag(tag.get("activator").getAsString(), + tag.get("title").getAsString(), + tag.get("response").getAsString(), + tag.get("authorId").getAsLong(), + tag.get("image").getAsString())); + } + } + + public static void saveToJson() throws IOException { + JsonObject json = new JsonObject(); + + for (Tag tag : tags) { + JsonObject obj = new JsonObject(); + obj.addProperty("activator", tag.getActivator()); + obj.addProperty("title", tag.getTitle()); + obj.addProperty("response", tag.getResponse()); + obj.addProperty("authorId", tag.getAuthorId()); + obj.addProperty("image", tag.getImage()); + + json.add(tag.getActivator(), obj); + } + + FILE.delete(); + FILE.createNewFile(); + Files.write(FILE.toPath(), json.toString().getBytes(), StandardOpenOption.WRITE); + } + + public static void newTag(Tag tag) throws TagAlreadyExistsException, IOException { + // check if tag with equal activator already exists + if (tags.stream().anyMatch(t -> t.getActivator().equals(tag.getActivator()))) { + throw new TagAlreadyExistsException("A tag with this activator already exists."); + } + + // implement the new tag + tags.add(tag); + saveToJson(); + } + + public static void deleteTag(String activator) throws TagDoesntExistException, IOException { + // get tag + check if it exists + Tag tag = getTag(activator); + + // remove the tag + tags.remove(tag); + saveToJson(); + } + + public static void deleteTag(Tag tag) throws TagDoesntExistException, IOException { + deleteTag(tag.getActivator()); + } + + public static Tag getTag(String activator) throws TagDoesntExistException, IOException { + List tag = tags.stream().filter(t -> t.getActivator().equals(activator)).collect(Collectors.toList()); + if (tag.size() == 0) throw new TagDoesntExistException("A tag with activator `"+activator+"` does not exist."); + return tag.get(0); + } +} diff --git a/src/main/java/com/diamondfire/helpbot/sys/tag/TagProperty.java b/src/main/java/com/diamondfire/helpbot/sys/tag/TagProperty.java new file mode 100644 index 00000000..5172e552 --- /dev/null +++ b/src/main/java/com/diamondfire/helpbot/sys/tag/TagProperty.java @@ -0,0 +1,59 @@ +package com.diamondfire.helpbot.sys.tag; + +public enum TagProperty { + ACTIVATOR("activator", true){ + @Override + public void edit(Tag tag, String newValue) { + tag.setActivator(newValue); + } + }, + TITLE("title", true) { + @Override + public void edit(Tag tag, String newValue) { + tag.setTitle(newValue); + } + }, + RESPONSE("response", true) { + @Override + public void edit(Tag tag, String newValue) { + tag.setResponse(newValue); + } + }, + AUTHOR_ID("authorId", false) { + @Override + public void edit(Tag tag, String newValue) { + throw new UnsupportedOperationException("The `"+this.getProperty()+"` property cannot be modified."); + } + }, + IMAGE("image", true) { + @Override + public void edit(Tag tag, String newValue) { + tag.setImage(newValue); + } + }; + + private final String property; + private final boolean modifiable; + + TagProperty(String property, boolean modifiable) { + this.property = property; + this.modifiable = modifiable; + } + + public String getProperty() { + return property; + } + + public boolean isModifiable() { + return modifiable; + } + + public static TagProperty getByProperty(String prop) { + for (TagProperty tagProperty : TagProperty.values()) { + if (tagProperty.getProperty().equals(prop)) return tagProperty; + } + return null; + } + + public abstract void edit(Tag tag, String newValue); +} From 8065b9ee4dea17f3b3eae175720296ee37727bda Mon Sep 17 00:00:00 2001 From: RyanLandDev Date: Sun, 18 Jul 2021 04:50:39 +0200 Subject: [PATCH 4/8] Add Subcommands system + Adapt Tag commands to use it --- .../helpbot/bot/HelpBotInstance.java | 23 +++--- .../bot/command/SubCommandHandler.java | 24 ++++++ .../bot/command/executor/CommandExecutor.java | 1 + .../executor/checks/SubCommandCheck.java | 78 +++++++++++++++++++ .../helpbot/bot/command/impl/SubCommand.java | 17 ++++ .../bot/command/impl/SubCommandReceiver.java | 20 +++++ .../command/impl/codeblock/TagsCommand.java | 2 +- ...wTagCommand.java => AddTagSubCommand.java} | 45 +++++------ ...TagCommand.java => EditTagSubCommand.java} | 43 +++------- ...gsCommand.java => ListTagsSubCommand.java} | 28 +++---- ...gCommand.java => RemoveTagSubCommand.java} | 27 ++----- .../impl/other/tag/TagCommandReceiver.java | 68 ++++++++++++++++ .../helpbot/bot/events/SubCommandEvent.java | 50 ++++++++++++ 13 files changed, 319 insertions(+), 107 deletions(-) create mode 100644 src/main/java/com/diamondfire/helpbot/bot/command/SubCommandHandler.java create mode 100644 src/main/java/com/diamondfire/helpbot/bot/command/executor/checks/SubCommandCheck.java create mode 100644 src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommand.java create mode 100644 src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommandReceiver.java rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/{NewTagCommand.java => AddTagSubCommand.java} (62%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/{EditTagCommand.java => EditTagSubCommand.java} (64%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/{ListTagsCommand.java => ListTagsSubCommand.java} (66%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/{DelTagCommand.java => RemoveTagSubCommand.java} (67%) create mode 100644 src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagCommandReceiver.java create mode 100644 src/main/java/com/diamondfire/helpbot/bot/events/SubCommandEvent.java diff --git a/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java b/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java index cd5077ac..1fbcaecf 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java +++ b/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java @@ -1,16 +1,14 @@ package com.diamondfire.helpbot.bot; -import com.diamondfire.helpbot.bot.command.CommandHandler; +import com.diamondfire.helpbot.bot.command.*; import com.diamondfire.helpbot.bot.command.impl.codeblock.*; +import com.diamondfire.helpbot.bot.command.impl.other.tag.TagCommandReceiver; import com.diamondfire.helpbot.bot.command.impl.other.dev.*; import com.diamondfire.helpbot.bot.command.impl.other.dumps.*; import com.diamondfire.helpbot.bot.command.impl.other.fun.*; import com.diamondfire.helpbot.bot.command.impl.other.info.*; import com.diamondfire.helpbot.bot.command.impl.other.mod.*; -import com.diamondfire.helpbot.bot.command.impl.other.tag.DelTagCommand; -import com.diamondfire.helpbot.bot.command.impl.other.tag.EditTagCommand; -import com.diamondfire.helpbot.bot.command.impl.other.tag.ListTagsCommand; -import com.diamondfire.helpbot.bot.command.impl.other.tag.NewTagCommand; +import com.diamondfire.helpbot.bot.command.impl.other.tag.*; import com.diamondfire.helpbot.bot.command.impl.other.util.*; import com.diamondfire.helpbot.bot.command.impl.stats.*; import com.diamondfire.helpbot.bot.command.impl.stats.graph.*; @@ -78,11 +76,6 @@ public static void initialize() throws LoginException { new VerifyCommand(), new PollCommand(), new IdeaCommand(), - - new NewTagCommand(), - new DelTagCommand(), - new EditTagCommand(), - new ListTagsCommand(), //new ChannelMuteCommand(), // statsbot new StatsCommand(), @@ -135,6 +128,16 @@ public static void initialize() throws LoginException { new JoinsCommand() ); + SubCommandHandler.registerReceivers( + new TagCommandReceiver() + ); + SubCommandHandler.registerSubCommands( + new AddTagSubCommand(), + new EditTagSubCommand(), + new RemoveTagSubCommand(), + new ListTagsSubCommand() + ); + JDABuilder builder = JDABuilder.createDefault(config.getToken()) .enableIntents(GatewayIntent.GUILD_MEMBERS) .setStatus(OnlineStatus.ONLINE) diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/SubCommandHandler.java b/src/main/java/com/diamondfire/helpbot/bot/command/SubCommandHandler.java new file mode 100644 index 00000000..65c6bd1f --- /dev/null +++ b/src/main/java/com/diamondfire/helpbot/bot/command/SubCommandHandler.java @@ -0,0 +1,24 @@ +package com.diamondfire.helpbot.bot.command; + +import com.diamondfire.helpbot.bot.command.impl.*; + +import java.util.HashMap; + +public class SubCommandHandler { + + private static HashMap RECEIVERS = new HashMap<>(); + private static HashMap SUBCOMMANDS = new HashMap<>(); + + public static void registerReceivers(SubCommandReceiver... receivers) { + for (SubCommandReceiver receiver : receivers) { + RECEIVERS.put(receiver.getName().toLowerCase(), receiver); + CommandHandler.getInstance().register(receiver); + } + } + + public static void registerSubCommands(SubCommand... subcommands) { + for (SubCommand subcommand : subcommands) { + SUBCOMMANDS.put(subcommand.getName().toLowerCase(), subcommand); + } + } +} diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/executor/CommandExecutor.java b/src/main/java/com/diamondfire/helpbot/bot/command/executor/CommandExecutor.java index 4d4d099b..696748eb 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/executor/CommandExecutor.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/executor/CommandExecutor.java @@ -20,6 +20,7 @@ public class CommandExecutor { new DisabledCheck(), new PermissionCheck(), new CommandLog(), + new SubCommandCheck() }; public void run(CommandEvent e) { diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/executor/checks/SubCommandCheck.java b/src/main/java/com/diamondfire/helpbot/bot/command/executor/checks/SubCommandCheck.java new file mode 100644 index 00000000..8f890909 --- /dev/null +++ b/src/main/java/com/diamondfire/helpbot/bot/command/executor/checks/SubCommandCheck.java @@ -0,0 +1,78 @@ +package com.diamondfire.helpbot.bot.command.executor.checks; + +import com.diamondfire.helpbot.bot.command.CommandHandler; +import com.diamondfire.helpbot.bot.command.argument.impl.parsing.exceptions.MissingArgumentException; +import com.diamondfire.helpbot.bot.command.help.HelpContextArgument; +import com.diamondfire.helpbot.bot.command.impl.*; +import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; +import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; +import com.diamondfire.helpbot.bot.events.*; + +import java.util.*; + +public class SubCommandCheck implements CommandCheck { + + @Override + public boolean check(CommandEvent event) { + // Abort if this is not a SubCommandReceiver + if (!(event.getCommand() instanceof SubCommandReceiver)) return true; + + // Get receiver object + SubCommandReceiver command = (SubCommandReceiver) event.getCommand(); + + // Find the requested subcommand, or error if there is none + List splitArgs = new LinkedList<>(Arrays.asList(event.getMessage().getContentRaw() + .split(" +"))); + if (splitArgs.size() <= 1) { + replyInvalidSubcommand(event); + return false; + } + String request = String.join(" ", splitArgs.get(1)); + + // Iterate through receiver subcommand list to find a match + // (hashmap? may not be worth it because there's not a lot of subcommands) + for (SubCommand subcommand : command.getSubCommands()) { + if (subcommand.getName().equals(request)) { + // Check if the user has permissions, if true run + if (subcommand.getPermission().hasPermission(event.getMember())) { + // Check if the argument requirements are in order + int i = 0; + for (HelpContextArgument arg : subcommand.getHelpContext().getArguments()) { + if (arg.isOptional()) break; + + if (splitArgs.size()-3 < i) { + MissingArgumentException exception = new MissingArgumentException( + "Expected an argument, but got nothing."); + exception.setContext(command, i+1); + event.reply(new PresetBuilder().withPreset( + new InformativeReply(InformativeReplyType.ERROR, + "Invalid Argument!", exception.getEmbedMessage()) + )); + return false; + } + + i++; + } + subcommand.run(new SubCommandEvent(event.getMessage(), subcommand)); + } + return true; + } + } + + replyInvalidSubcommand(event); + return false; + } + + private void replyInvalidSubcommand(CommandEvent event) { + event.reply(new PresetBuilder().withPreset( + new InformativeReply(InformativeReplyType.ERROR, + "Invalid subcommand! Choose from: "+((SubCommandReceiver) event.getCommand()) + .getFormattedSubCommands(event)) + ) + ); + } + + @Override + public void buildMessage(CommandEvent event, PresetBuilder builder) { + } +} diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommand.java new file mode 100644 index 00000000..f43a9ad0 --- /dev/null +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommand.java @@ -0,0 +1,17 @@ +package com.diamondfire.helpbot.bot.command.impl; + +import com.diamondfire.helpbot.bot.command.help.HelpContext; +import com.diamondfire.helpbot.bot.command.permissions.Permission; +import com.diamondfire.helpbot.bot.events.SubCommandEvent; + +public abstract class SubCommand { + + public abstract String getName(); + + public abstract HelpContext getHelpContext(); + + public abstract Permission getPermission(); + + public abstract void run(SubCommandEvent event); + +} diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommandReceiver.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommandReceiver.java new file mode 100644 index 00000000..5240ff61 --- /dev/null +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommandReceiver.java @@ -0,0 +1,20 @@ +package com.diamondfire.helpbot.bot.command.impl; + +import com.diamondfire.helpbot.bot.events.CommandEvent; + +import java.util.List; + +public abstract class SubCommandReceiver extends Command { + + public abstract List getSubCommands(); + + public String getFormattedSubCommands(CommandEvent event) { + String result = ""; + for (SubCommand subcommand : getSubCommands()) { + if (subcommand.getPermission().hasPermission(event.getMember())) { + result += "`" + subcommand.getName() + "` "; + } + } + return result; + } +} diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/codeblock/TagsCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/codeblock/TagsCommand.java index 32edad71..f57dd592 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/codeblock/TagsCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/codeblock/TagsCommand.java @@ -77,7 +77,7 @@ public String getName() { @Override public String[] getAliases() { - return new String[]{"codetags", "tag"}; + return new String[]{"codetags"}; } @Override diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/NewTagCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/AddTagSubCommand.java similarity index 62% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/NewTagCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/AddTagSubCommand.java index f2972930..22a47b68 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/NewTagCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/AddTagSubCommand.java @@ -1,30 +1,32 @@ package com.diamondfire.helpbot.bot.command.impl.other.tag; -import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; -import com.diamondfire.helpbot.bot.command.argument.impl.types.StringArgument; -import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.Command; +import com.diamondfire.helpbot.bot.command.help.HelpContext; +import com.diamondfire.helpbot.bot.command.help.HelpContextArgument; +import com.diamondfire.helpbot.bot.command.impl.SubCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; -import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; -import com.diamondfire.helpbot.bot.events.CommandEvent; -import com.diamondfire.helpbot.sys.tag.*; +import com.diamondfire.helpbot.bot.command.reply.feature.informative.InformativeReply; +import com.diamondfire.helpbot.bot.command.reply.feature.informative.InformativeReplyType; +import com.diamondfire.helpbot.bot.events.SubCommandEvent; +import com.diamondfire.helpbot.sys.tag.Tag; +import com.diamondfire.helpbot.sys.tag.TagAlreadyExistsException; +import com.diamondfire.helpbot.sys.tag.TagHandler; import java.io.IOException; -import java.util.*; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; -public class NewTagCommand extends Command { +public class AddTagSubCommand extends SubCommand { @Override public String getName() { - return "newtag"; + return "add"; } @Override public HelpContext getHelpContext() { return new HelpContext() - .description("Creates a new custom command tag. Use \"%space%\" in the title to add a space.") - .category(CommandCategory.OTHER) .addArgument( new HelpContextArgument() .name("activator"), @@ -35,32 +37,21 @@ public HelpContext getHelpContext() { ); } - @Override - public ArgumentSet compileArguments() { - return new ArgumentSet().addArgument("activator", - new StringArgument() - ).addArgument("title", - new StringArgument() - ).addArgument("response", - new StringArgument() - ); - } - @Override public Permission getPermission() { return Permission.EXPERT; } @Override - public void run(CommandEvent event) { + public void run(SubCommandEvent event) { // Get new activator and title String activator = event.getArgument("activator"); - String title = ((String) event.getArgument("title")).replaceAll("%space%", " "); + String title = event.getArgument("title").replaceAll("%space%", " "); // Get response List splitArgs = new LinkedList<>(Arrays.asList(event.getMessage().getContentRaw() .split(" +"))); - String response = String.join(" ", splitArgs.subList(3, splitArgs.size())); + String response = String.join(" ", splitArgs.subList(4, splitArgs.size())); // Construct Tag Tag tag = new Tag(activator, title, response, event.getAuthor().getIdLong(), ""); @@ -76,7 +67,7 @@ public void run(CommandEvent event) { } catch (TagAlreadyExistsException | IOException err) { PresetBuilder preset = new PresetBuilder() .withPreset( - new InformativeReply(InformativeReplyType.ERROR, "Error!", err.getMessage()) + new InformativeReply(InformativeReplyType.ERROR, err.getMessage()) ); event.reply(preset); } diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/EditTagCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/EditTagSubCommand.java similarity index 64% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/EditTagCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/EditTagSubCommand.java index 90b16da7..d75dae06 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/EditTagCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/EditTagSubCommand.java @@ -1,63 +1,44 @@ package com.diamondfire.helpbot.bot.command.impl.other.tag; -import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; -import com.diamondfire.helpbot.bot.command.argument.impl.types.StringArgument; import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.Command; +import com.diamondfire.helpbot.bot.command.impl.SubCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; -import com.diamondfire.helpbot.bot.events.CommandEvent; +import com.diamondfire.helpbot.bot.events.SubCommandEvent; import com.diamondfire.helpbot.sys.tag.*; import java.io.IOException; import java.util.*; -public class EditTagCommand extends Command { - - private final String PROPERTIES = "activator/title/response/image"; +public class EditTagSubCommand extends SubCommand { @Override public String getName() { - return "edittag"; + return "edit"; } @Override public HelpContext getHelpContext() { return new HelpContext() - .description("Edits a new custom command tag property. Use 'none' for the image to remove it.") - .category(CommandCategory.OTHER) .addArgument( new HelpContextArgument() - .name("activator"), - new HelpContextArgument() - .name(PROPERTIES), + .name("activator"), new HelpContextArgument() - .name("new value") + .name("property") ); } - @Override - public ArgumentSet compileArguments() { - return new ArgumentSet().addArgument("activator", - new StringArgument() - ).addArgument(PROPERTIES, - new StringArgument() - ).addArgument("new value", - new StringArgument() - ); - } - @Override public Permission getPermission() { return Permission.EXPERT; } @Override - public void run(CommandEvent event) { + public void run(SubCommandEvent event) { // Get activator and property String activator = event.getArgument("activator"); - String prop = event.getArgument(PROPERTIES); + String prop = event.getArgument("property"); // Check if property is valid TagProperty property = TagProperty.getByProperty(prop); @@ -74,9 +55,9 @@ public void run(CommandEvent event) { // Get new value List splitArgs = new LinkedList<>(Arrays.asList(event.getMessage().getContentRaw() .split(" +"))); - String newValue = String.join(" ", splitArgs.subList(3, splitArgs.size())); + String newValue = String.join(" ", splitArgs.subList(4, splitArgs.size())); if (property == TagProperty.IMAGE && newValue.equals("none")) newValue = ""; - + try { Tag tag = TagHandler.getTag(activator); property.edit(tag, newValue); @@ -84,14 +65,14 @@ public void run(CommandEvent event) { PresetBuilder preset = new PresetBuilder() .withPreset( - new InformativeReply(InformativeReplyType.SUCCESS, "Success", "Successfully modified tag.") + new InformativeReply(InformativeReplyType.SUCCESS, "Successfully modified tag.") ); event.reply(preset); } catch (TagDoesntExistException | IOException err) { PresetBuilder preset = new PresetBuilder() .withPreset( - new InformativeReply(InformativeReplyType.ERROR, "Error!", err.getMessage()) + new InformativeReply(InformativeReplyType.ERROR, err.getMessage()) ); event.reply(preset); err.printStackTrace(); diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/ListTagsCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/ListTagsSubCommand.java similarity index 66% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/ListTagsCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/ListTagsSubCommand.java index fd27b1f0..a137f0d6 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/ListTagsCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/ListTagsSubCommand.java @@ -1,36 +1,26 @@ package com.diamondfire.helpbot.bot.command.impl.other.tag; -import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; -import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.Command; -import com.diamondfire.helpbot.sys.tag.*; +import com.diamondfire.helpbot.bot.command.help.HelpContext; +import com.diamondfire.helpbot.bot.command.impl.SubCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; -import com.diamondfire.helpbot.bot.events.CommandEvent; -import com.google.gson.JsonObject; -import net.dv8tion.jda.api.entities.*; +import com.diamondfire.helpbot.bot.events.SubCommandEvent; +import com.diamondfire.helpbot.sys.tag.*; import java.io.IOException; -import java.util.*; +import java.util.List; -public class ListTagsCommand extends Command { +public class ListTagsSubCommand extends SubCommand { @Override public String getName() { - return "listtags"; + return "list"; } @Override public HelpContext getHelpContext() { - return new HelpContext() - .description("Lists all custom command tags.") - .category(CommandCategory.OTHER); - } - - @Override - public ArgumentSet compileArguments() { - return new ArgumentSet(); + return new HelpContext(); } @Override @@ -39,7 +29,7 @@ public Permission getPermission() { } @Override - public void run(CommandEvent event) { + public void run(SubCommandEvent event) { try { List tags = TagHandler.getTags(); String string = ""; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/DelTagCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/RemoveTagSubCommand.java similarity index 67% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/DelTagCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/RemoveTagSubCommand.java index 738d6c8c..92caaccd 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/DelTagCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/RemoveTagSubCommand.java @@ -1,49 +1,38 @@ package com.diamondfire.helpbot.bot.command.impl.other.tag; -import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; -import com.diamondfire.helpbot.bot.command.argument.impl.types.StringArgument; import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.Command; +import com.diamondfire.helpbot.bot.command.impl.SubCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; -import com.diamondfire.helpbot.bot.events.CommandEvent; +import com.diamondfire.helpbot.bot.events.SubCommandEvent; import com.diamondfire.helpbot.sys.tag.*; import java.io.IOException; -public class DelTagCommand extends Command { +public class RemoveTagSubCommand extends SubCommand { @Override public String getName() { - return "deltag"; + return "remove"; } @Override public HelpContext getHelpContext() { return new HelpContext() - .description("Deletes a custom command tag by activator.") - .category(CommandCategory.OTHER) .addArgument( new HelpContextArgument() - .name("activator") + .name("activator") ); } - @Override - public ArgumentSet compileArguments() { - return new ArgumentSet().addArgument("activator", - new StringArgument() - ); - } - @Override public Permission getPermission() { return Permission.EXPERT; } @Override - public void run(CommandEvent event) { + public void run(SubCommandEvent event) { // Get activator String activator = event.getArgument("activator"); @@ -51,7 +40,7 @@ public void run(CommandEvent event) { TagHandler.deleteTag(activator); PresetBuilder preset = new PresetBuilder() .withPreset( - new InformativeReply(InformativeReplyType.SUCCESS, "Success", + new InformativeReply(InformativeReplyType.SUCCESS, "Successfully deleted tag with activator `"+activator+"`.") ); event.reply(preset); @@ -59,7 +48,7 @@ public void run(CommandEvent event) { } catch (TagDoesntExistException | IOException err) { PresetBuilder preset = new PresetBuilder() .withPreset( - new InformativeReply(InformativeReplyType.ERROR, "Error!", + new InformativeReply(InformativeReplyType.ERROR, err.getMessage()) ); event.reply(preset); diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagCommandReceiver.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagCommandReceiver.java new file mode 100644 index 00000000..2b71b9cd --- /dev/null +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagCommandReceiver.java @@ -0,0 +1,68 @@ +package com.diamondfire.helpbot.bot.command.impl.other.tag; + +import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; +import com.diamondfire.helpbot.bot.command.argument.impl.types.StringArgument; +import com.diamondfire.helpbot.bot.command.help.*; +import com.diamondfire.helpbot.bot.command.impl.*; +import com.diamondfire.helpbot.bot.command.permissions.Permission; +import com.diamondfire.helpbot.bot.events.CommandEvent; + +import java.util.*; + +public class TagCommandReceiver extends SubCommandReceiver { + + @Override + public String getName() { + return "tag"; + } + + @Override + public HelpContext getHelpContext() { + return new HelpContext() + .description("Controls custom command tags. Notes:\n- New: Use \"%space%\" in the title for spaces."+ + "\n- Edit: Use \"none\" for image to remove the image.") + .category(CommandCategory.OTHER) + .addArgument( + new HelpContextArgument() + .name("add/edit/remove/list"), + new HelpContextArgument() + .name("add edit remove: activator") + .optional(), + new HelpContextArgument() + .name("add: title/edit: property") + .optional(), + new HelpContextArgument() + .name("add: response/edit: new value") + .optional() + + ); + } + + @Override + public ArgumentSet compileArguments() { + return new ArgumentSet().addArgument("add/edit/remove/list", + new StringArgument() + ); + } + + @Override + public Permission getPermission() { + return Permission.USER; + } + + @Override + public void run(CommandEvent event) { + } + + @Override + public List getSubCommands() { + return Arrays.asList( + new AddTagSubCommand(), + new EditTagSubCommand(), + new RemoveTagSubCommand(), + new ListTagsSubCommand() + ); + } +} + + diff --git a/src/main/java/com/diamondfire/helpbot/bot/events/SubCommandEvent.java b/src/main/java/com/diamondfire/helpbot/bot/events/SubCommandEvent.java new file mode 100644 index 00000000..8dd129d1 --- /dev/null +++ b/src/main/java/com/diamondfire/helpbot/bot/events/SubCommandEvent.java @@ -0,0 +1,50 @@ +package com.diamondfire.helpbot.bot.events; + +import com.diamondfire.helpbot.bot.command.help.HelpContextArgument; +import com.diamondfire.helpbot.bot.command.impl.SubCommand; +import net.dv8tion.jda.api.entities.Message; + +import java.util.*; + +public class SubCommandEvent extends CommandEvent { + + private final SubCommand subcommand; + private final Map arguments; + + public SubCommandEvent(Message message, SubCommand subCommand) { + super(message); + this.subcommand = subCommand; + this.arguments = generateArguments(); + } + + private Map generateArguments() { + List splitArgs = new LinkedList<>(Arrays.asList(this.getMessage().getContentRaw() + .split(" +"))); + splitArgs = splitArgs.subList(2, splitArgs.size()); + + Map result = new HashMap<>(); + List context = subcommand.getHelpContext().getArguments(); + + int i = 0; + for (String arg : splitArgs) { + if (context.size() <= i) break; + result.put(context.get(i).getArgumentName(), arg); + i++; + } + return result; + } + + @Override + public Map getArguments() { + return arguments; + } + + @Override + public String getArgument(String code) { + return (String) arguments.get(code); + } + + public SubCommand getSubCommand() { + return this.subcommand; + } +} From a76f42d2f09d4ef498fa0ce9803a1c24a4888e24 Mon Sep 17 00:00:00 2001 From: RyanLandDev Date: Sun, 18 Jul 2021 04:58:59 +0200 Subject: [PATCH 5/8] Made SubCommand an interface --- .../helpbot/bot/command/impl/SubCommand.java | 10 +++++----- .../bot/command/impl/other/tag/AddTagSubCommand.java | 2 +- .../bot/command/impl/other/tag/EditTagSubCommand.java | 2 +- .../bot/command/impl/other/tag/ListTagsSubCommand.java | 2 +- .../command/impl/other/tag/RemoveTagSubCommand.java | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommand.java index f43a9ad0..d1af64ce 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommand.java @@ -4,14 +4,14 @@ import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.events.SubCommandEvent; -public abstract class SubCommand { +public interface SubCommand { - public abstract String getName(); + String getName(); - public abstract HelpContext getHelpContext(); + HelpContext getHelpContext(); - public abstract Permission getPermission(); + Permission getPermission(); - public abstract void run(SubCommandEvent event); + void run(SubCommandEvent event); } diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/AddTagSubCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/AddTagSubCommand.java index 22a47b68..bf4625d1 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/AddTagSubCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/AddTagSubCommand.java @@ -17,7 +17,7 @@ import java.util.LinkedList; import java.util.List; -public class AddTagSubCommand extends SubCommand { +public class AddTagSubCommand implements SubCommand { @Override public String getName() { diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/EditTagSubCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/EditTagSubCommand.java index d75dae06..a3e79924 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/EditTagSubCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/EditTagSubCommand.java @@ -11,7 +11,7 @@ import java.io.IOException; import java.util.*; -public class EditTagSubCommand extends SubCommand { +public class EditTagSubCommand implements SubCommand { @Override public String getName() { diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/ListTagsSubCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/ListTagsSubCommand.java index a137f0d6..ac012b1a 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/ListTagsSubCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/ListTagsSubCommand.java @@ -11,7 +11,7 @@ import java.io.IOException; import java.util.List; -public class ListTagsSubCommand extends SubCommand { +public class ListTagsSubCommand implements SubCommand { @Override public String getName() { diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/RemoveTagSubCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/RemoveTagSubCommand.java index 92caaccd..c5b6110a 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/RemoveTagSubCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/RemoveTagSubCommand.java @@ -10,7 +10,7 @@ import java.io.IOException; -public class RemoveTagSubCommand extends SubCommand { +public class RemoveTagSubCommand implements SubCommand { @Override public String getName() { From 00db0d8c5b64ad9b70bf901b6eb4e62c27104efd Mon Sep 17 00:00:00 2001 From: RyanLandDev Date: Sun, 18 Jul 2021 05:14:34 +0200 Subject: [PATCH 6/8] test --- .../java/com/diamondfire/helpbot/bot/HelpBotInstance.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java b/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java index 1fbcaecf..e48f19f4 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java +++ b/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java @@ -2,7 +2,6 @@ import com.diamondfire.helpbot.bot.command.*; import com.diamondfire.helpbot.bot.command.impl.codeblock.*; -import com.diamondfire.helpbot.bot.command.impl.other.tag.TagCommandReceiver; import com.diamondfire.helpbot.bot.command.impl.other.dev.*; import com.diamondfire.helpbot.bot.command.impl.other.dumps.*; import com.diamondfire.helpbot.bot.command.impl.other.fun.*; @@ -128,15 +127,19 @@ public static void initialize() throws LoginException { new JoinsCommand() ); + // ------------ Subcommands ------------------ + // Register receivers here (NOTE: Do NOT register these in the command registerer as well!) SubCommandHandler.registerReceivers( new TagCommandReceiver() ); + // Register subcommands here SubCommandHandler.registerSubCommands( new AddTagSubCommand(), new EditTagSubCommand(), new RemoveTagSubCommand(), new ListTagsSubCommand() ); + // -------------------------------------------- JDABuilder builder = JDABuilder.createDefault(config.getToken()) .enableIntents(GatewayIntent.GUILD_MEMBERS) From 51185cda8ab4f91238b7048e08bafdb5792e3023 Mon Sep 17 00:00:00 2001 From: RyanLandDev Date: Fri, 23 Jul 2021 20:34:01 +0200 Subject: [PATCH 7/8] Reworked Subcommands --- .../helpbot/bot/HelpBotInstance.java | 21 +---- .../helpbot/bot/command/CommandHandler.java | 7 +- .../bot/command/SubCommandHandler.java | 24 ------ .../parsing/exceptions/ArgumentException.java | 12 ++- .../parser/AlternateArgumentParser.java | 5 +- .../impl/parsing/parser/ArgumentParser.java | 11 +-- .../parsing/parser/MultiArgumentParser.java | 5 +- .../parsing/parser/SingleArgumentParser.java | 5 +- .../impl/parsing/types/MessageArgument.java | 3 +- .../impl/types/AbstractOffsetArgument.java | 3 +- .../types/AbstractSimpleValueArgument.java | 7 +- .../command/argument/impl/types/Argument.java | 3 +- .../impl/types/ClampedIntegerArgument.java | 5 +- .../argument/impl/types/DateArgument.java | 3 +- .../impl/types/DefinedObjectArgument.java | 3 +- .../impl/types/DiscordUserArgument.java | 3 +- .../argument/impl/types/IntegerArgument.java | 3 +- .../argument/impl/types/LongArgument.java | 3 +- .../types/MinecraftPlayerUUIDArgument.java | 3 +- .../argument/impl/types/StringArgument.java | 3 +- .../impl/types/SubCommandArgument.java | 24 ++++++ .../bot/command/executor/CommandExecutor.java | 7 +- .../executor/checks/DisabledCheck.java | 1 - .../executor/checks/SubCommandCheck.java | 78 ------------------- .../helpbot/bot/command/impl/SubCommand.java | 15 +--- .../bot/command/impl/SubCommandHolder.java | 35 +++++++++ .../bot/command/impl/SubCommandReceiver.java | 20 ----- .../impl/other/dev/DisableCommand.java | 1 - .../command/impl/other/dev/EnableCommand.java | 1 - .../command/impl/other/dev/EvalCommand.java | 10 +-- .../command/impl/other/fun/IdeaCommand.java | 1 + .../command/impl/other/fun/NbsCommand.java | 13 +--- .../command/impl/other/fun/OcrCommand.java | 1 - .../command/impl/other/info/HelpCommand.java | 1 - .../impl/other/info/PermUnlocksCommand.java | 1 - .../impl/other/tag/AddTagSubCommand.java | 36 +++++---- .../impl/other/tag/EditTagSubCommand.java | 17 +++- .../impl/other/tag/ListTagsSubCommand.java | 12 ++- .../impl/other/tag/RemoveTagSubCommand.java | 16 +++- ...agCommandReceiver.java => TagCommand.java} | 33 ++------ .../impl/other/util/BulkExecuteCommand.java | 2 +- .../AbstractPlayerUUIDCommand.java | 2 +- .../stats/{metrics => }/BoostersCommand.java | 7 +- .../{metrics => }/CpRequirementsCommand.java | 2 +- .../stats/graph/AbstractGraphCommand.java | 1 - .../impl/stats/individualized/CpCommand.java | 1 + .../stats/individualized/HistoryCommand.java | 1 + .../individualized/LastJoinedCommand.java | 1 + .../stats/individualized/NamesCommand.java | 1 + .../stats/individualized/PlotsCommand.java | 1 + .../stats/individualized/ProfileCommand.java | 1 + .../stats/individualized/SkinCommand.java | 1 + .../stats/individualized/UuidCommand.java | 1 + .../support/AbstractSessionLogCommand.java | 2 +- .../support/FindSupporteeNamesCommand.java | 2 +- .../impl/stats/support/HelpedByCommand.java | 2 +- .../impl/stats/support/SessionsCommand.java | 2 +- .../impl/stats/support/StatsCommand.java | 2 +- .../impl/stats/support/StatsGraphCommand.java | 2 +- .../stats/support/SupporteeStatsCommand.java | 2 +- .../impl/stats/support/WhoHelpedCommand.java | 2 +- .../stats/top/DiscordBoostersCommand.java | 6 +- .../informative/InformativeReplyType.java | 4 +- .../helpbot/bot/events/CommandEvent.java | 14 +++- .../helpbot/bot/events/GuildJoinEvent.java | 1 - .../helpbot/bot/events/MessageEvent.java | 1 + .../helpbot/bot/events/SubCommandEvent.java | 50 ------------ .../db/datatypes/DisplayIcon.java | 1 - .../viewables/constants/CodeBlockEnum.java | 1 - .../sys/externalfile/ExternalFiles.java | 1 - .../message/acceptors/CommandAcceptor.java | 2 +- .../sys/message/acceptors/ReportAcceptor.java | 6 +- .../sys/message/acceptors/TagAcceptor.java | 4 +- .../message/filter/filters/SwearFilter.java | 8 +- .../sys/multiselector/MultiSelector.java | 1 - .../helpbot/sys/tag/TagHandler.java | 4 +- .../helpbot/sys/tasks/MidnightTask.java | 1 - .../sys/tasks/impl/GraphChannelTask.java | 1 - .../sys/tasks/impl/MuteExpireTask.java | 3 +- .../diamondfire/helpbot/util/DateUtil.java | 3 +- .../com/diamondfire/helpbot/util/IOUtil.java | 2 +- .../helpbot/util/nbs/NBSDecoder.java | 4 +- .../helpbot/util/nbs/NBSToTemplate.java | 8 +- .../helpbot/util/textgen/CacheData.java | 3 +- 84 files changed, 251 insertions(+), 371 deletions(-) delete mode 100644 src/main/java/com/diamondfire/helpbot/bot/command/SubCommandHandler.java create mode 100644 src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/SubCommandArgument.java delete mode 100644 src/main/java/com/diamondfire/helpbot/bot/command/executor/checks/SubCommandCheck.java create mode 100644 src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommandHolder.java delete mode 100644 src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommandReceiver.java rename src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/{TagCommandReceiver.java => TagCommand.java} (53%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/{individualized => }/AbstractPlayerUUIDCommand.java (94%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/{metrics => }/BoostersCommand.java (92%) rename src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/{metrics => }/CpRequirementsCommand.java (96%) delete mode 100644 src/main/java/com/diamondfire/helpbot/bot/events/SubCommandEvent.java diff --git a/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java b/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java index e48f19f4..2d29dc99 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java +++ b/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java @@ -1,13 +1,13 @@ package com.diamondfire.helpbot.bot; -import com.diamondfire.helpbot.bot.command.*; +import com.diamondfire.helpbot.bot.command.CommandHandler; import com.diamondfire.helpbot.bot.command.impl.codeblock.*; import com.diamondfire.helpbot.bot.command.impl.other.dev.*; import com.diamondfire.helpbot.bot.command.impl.other.dumps.*; import com.diamondfire.helpbot.bot.command.impl.other.fun.*; import com.diamondfire.helpbot.bot.command.impl.other.info.*; import com.diamondfire.helpbot.bot.command.impl.other.mod.*; -import com.diamondfire.helpbot.bot.command.impl.other.tag.*; +import com.diamondfire.helpbot.bot.command.impl.other.tag.TagCommand; import com.diamondfire.helpbot.bot.command.impl.other.util.*; import com.diamondfire.helpbot.bot.command.impl.stats.*; import com.diamondfire.helpbot.bot.command.impl.stats.graph.*; @@ -124,23 +124,10 @@ public static void initialize() throws LoginException { new DailySessionsCommand(), new EightBallCommand(), new OcrCommand(), - new JoinsCommand() + new JoinsCommand(), + new TagCommand() ); - // ------------ Subcommands ------------------ - // Register receivers here (NOTE: Do NOT register these in the command registerer as well!) - SubCommandHandler.registerReceivers( - new TagCommandReceiver() - ); - // Register subcommands here - SubCommandHandler.registerSubCommands( - new AddTagSubCommand(), - new EditTagSubCommand(), - new RemoveTagSubCommand(), - new ListTagsSubCommand() - ); - // -------------------------------------------- - JDABuilder builder = JDABuilder.createDefault(config.getToken()) .enableIntents(GatewayIntent.GUILD_MEMBERS) .setStatus(OnlineStatus.ONLINE) diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/CommandHandler.java b/src/main/java/com/diamondfire/helpbot/bot/command/CommandHandler.java index f1b8db72..9f3a9e30 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/CommandHandler.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/CommandHandler.java @@ -1,6 +1,5 @@ package com.diamondfire.helpbot.bot.command; -import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.disable.DisableCommandHandler; import com.diamondfire.helpbot.bot.command.executor.CommandExecutor; import com.diamondfire.helpbot.bot.command.impl.Command; @@ -44,8 +43,12 @@ public void register(Command... commands) { } + public void run(CommandEvent e, String[] args) { + COMMAND_EXECUTOR.run(e, args); + } + public void run(CommandEvent e) { - COMMAND_EXECUTOR.run(e); + run(e, e.getRawArgs()); } public HashMap getCommands() { diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/SubCommandHandler.java b/src/main/java/com/diamondfire/helpbot/bot/command/SubCommandHandler.java deleted file mode 100644 index 65c6bd1f..00000000 --- a/src/main/java/com/diamondfire/helpbot/bot/command/SubCommandHandler.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.diamondfire.helpbot.bot.command; - -import com.diamondfire.helpbot.bot.command.impl.*; - -import java.util.HashMap; - -public class SubCommandHandler { - - private static HashMap RECEIVERS = new HashMap<>(); - private static HashMap SUBCOMMANDS = new HashMap<>(); - - public static void registerReceivers(SubCommandReceiver... receivers) { - for (SubCommandReceiver receiver : receivers) { - RECEIVERS.put(receiver.getName().toLowerCase(), receiver); - CommandHandler.getInstance().register(receiver); - } - } - - public static void registerSubCommands(SubCommand... subcommands) { - for (SubCommand subcommand : subcommands) { - SUBCOMMANDS.put(subcommand.getName().toLowerCase(), subcommand); - } - } -} diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/exceptions/ArgumentException.java b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/exceptions/ArgumentException.java index 513d87b4..b04f9379 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/exceptions/ArgumentException.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/exceptions/ArgumentException.java @@ -1,6 +1,8 @@ package com.diamondfire.helpbot.bot.command.argument.impl.parsing.exceptions; -import com.diamondfire.helpbot.bot.command.impl.Command; +import com.diamondfire.helpbot.bot.HelpBotInstance; +import com.diamondfire.helpbot.bot.command.impl.*; +import com.diamondfire.helpbot.bot.events.CommandEvent; import com.diamondfire.helpbot.util.FormatUtil; public class ArgumentException extends Exception { @@ -16,11 +18,17 @@ public String getEmbedMessage() { return message; } - public void setContext(Command command, int pos) { + public void setContext(Command command, int pos, CommandEvent event) { String[] args = FormatUtil.getArgumentDisplay(command.getHelpContext()); args[pos] = "**" + args[pos] + "**"; String argMessage = FormatUtil.displayCommand(command) + " " + String.join(" ", args); + if (command instanceof SubCommand) { + String prefix = HelpBotInstance.getConfig().getPrefix(); + + argMessage = event.getRawArgs()[0] + " " + argMessage.substring(prefix.length()); + } + message = argMessage + "\n\n" + getMessage(); } diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/parser/AlternateArgumentParser.java b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/parser/AlternateArgumentParser.java index 0b7b0458..aa794e5b 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/parser/AlternateArgumentParser.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/parser/AlternateArgumentParser.java @@ -3,6 +3,7 @@ import com.diamondfire.helpbot.bot.command.argument.impl.parsing.*; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.exceptions.*; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.*; +import com.diamondfire.helpbot.bot.events.CommandEvent; public class AlternateArgumentParser extends ArgumentParser, A> { @@ -11,10 +12,10 @@ public AlternateArgumentParser(AlternateArgumentContainer container) { } @Override - public ParsedArgument parse(String identifier, ArgumentStack.RawArgumentStack args) throws ArgumentException { + public ParsedArgument parse(String identifier, ArgumentStack.RawArgumentStack args, CommandEvent event) throws ArgumentException { for (ArgumentContainer container : getContainer().getAlternatives()) { try { - return new ParsedArgument<>(identifier, container.getParser().parse(identifier, args).getValue()); + return new ParsedArgument<>(identifier, container.getParser().parse(identifier, args, event).getValue()); } catch (ArgumentException ignored) { } } diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/parser/ArgumentParser.java b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/parser/ArgumentParser.java index 4e6bce11..31b96766 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/parser/ArgumentParser.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/parser/ArgumentParser.java @@ -4,6 +4,7 @@ import com.diamondfire.helpbot.bot.command.argument.impl.parsing.exceptions.*; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.ArgumentContainer; import com.diamondfire.helpbot.bot.command.impl.Command; +import com.diamondfire.helpbot.bot.events.CommandEvent; import java.util.*; @@ -16,7 +17,7 @@ public ArgumentParser(T container) { this.container = container; } - public static ParsedArgumentSet parseArgs(Command command, String[] args) throws ArgumentException { + public static ParsedArgumentSet parseArgs(Command command, String[] args, CommandEvent event) throws ArgumentException { Map> parsedArgs = new HashMap<>(); ArgumentStack stack = new ArgumentStack(command.getArguments().getArguments(), Arrays.asList(args)); int arguments = stack.getArguments().size(); @@ -28,17 +29,17 @@ public static ParsedArgumentSet parseArgs(Command command, String[] args) throws String identifier = argument.getIdentifier(); try { - parsedArgs.put(identifier, argumentContainer.getParser().parse(identifier, rawArguments)); + parsedArgs.put(identifier, argumentContainer.getParser().parse(identifier, rawArguments, event)); rawArguments.pushStack(); } catch (MissingArgumentException exception) { if (argumentContainer.isOptional()) { parsedArgs.put(identifier, new ParsedArgument<>(identifier, argumentContainer.getDefaultValue())); } else { - exception.setContext(command, i); + exception.setContext(command, i, event); throw exception; } } catch (MalformedArgumentException exception) { - exception.setContext(command, i); + exception.setContext(command, i, event); throw exception; } } @@ -46,7 +47,7 @@ public static ParsedArgumentSet parseArgs(Command command, String[] args) throws return new ParsedArgumentSet(parsedArgs); } - public abstract ParsedArgument parse(String identifier, ArgumentStack.RawArgumentStack args) throws ArgumentException; + public abstract ParsedArgument parse(String identifier, ArgumentStack.RawArgumentStack args, CommandEvent event) throws ArgumentException; protected T getContainer() { return container; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/parser/MultiArgumentParser.java b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/parser/MultiArgumentParser.java index 1da2a3b7..251ea868 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/parser/MultiArgumentParser.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/parser/MultiArgumentParser.java @@ -4,6 +4,7 @@ import com.diamondfire.helpbot.bot.command.argument.impl.parsing.exceptions.*; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.MultiArgumentContainer; import com.diamondfire.helpbot.bot.command.argument.impl.types.Argument; +import com.diamondfire.helpbot.bot.events.CommandEvent; import java.util.*; @@ -14,7 +15,7 @@ public MultiArgumentParser(MultiArgumentContainer container) { } @Override - public ParsedArgument parse(String identifier, ArgumentStack.RawArgumentStack args) throws ArgumentException { + public ParsedArgument parse(String identifier, ArgumentStack.RawArgumentStack args, CommandEvent event) throws ArgumentException { Deque rawArgs = args.popStack(); List approvedArgumentValues = new ArrayList<>(); Argument arg = getContainer().getArgument(); @@ -22,7 +23,7 @@ public ParsedArgument parse(String identifier, ArgumentStack.RawArgumentStack for (int i = 0; i < arguments; i++) { try { - approvedArgumentValues.add(arg.parseValue(rawArgs)); + approvedArgumentValues.add(arg.parseValue(rawArgs, event)); } catch (Exception e) { break; } diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/parser/SingleArgumentParser.java b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/parser/SingleArgumentParser.java index 287cff41..120f846f 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/parser/SingleArgumentParser.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/parser/SingleArgumentParser.java @@ -4,6 +4,7 @@ import com.diamondfire.helpbot.bot.command.argument.impl.parsing.exceptions.*; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.SingleArgumentContainer; import com.diamondfire.helpbot.bot.command.argument.impl.types.Argument; +import com.diamondfire.helpbot.bot.events.CommandEvent; import java.util.Deque; @@ -15,7 +16,7 @@ public SingleArgumentParser(SingleArgumentContainer container) { } @Override - public ParsedArgument parse(String identifier, ArgumentStack.RawArgumentStack args) throws ArgumentException { + public ParsedArgument parse(String identifier, ArgumentStack.RawArgumentStack args, CommandEvent event) throws ArgumentException { Deque rawArgs = args.popStack(); Argument arg = getContainer().getArgument(); @@ -23,6 +24,6 @@ public ParsedArgument parse(String identifier, ArgumentStack.RawArgumentStack throw new MissingArgumentException("Expected an argument, but got nothing."); } - return new ParsedArgument<>(identifier, arg.parseValue(rawArgs)); + return new ParsedArgument<>(identifier, arg.parseValue(rawArgs, event)); } } diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/types/MessageArgument.java b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/types/MessageArgument.java index fc6adeb6..45087da0 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/types/MessageArgument.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/parsing/types/MessageArgument.java @@ -2,6 +2,7 @@ import com.diamondfire.helpbot.bot.command.argument.impl.parsing.exceptions.ArgumentException; import com.diamondfire.helpbot.bot.command.argument.impl.types.Argument; +import com.diamondfire.helpbot.bot.events.CommandEvent; import org.jetbrains.annotations.NotNull; import java.util.Deque; @@ -9,7 +10,7 @@ public class MessageArgument implements Argument { @Override - public String parseValue(@NotNull Deque args) throws ArgumentException { + public String parseValue(@NotNull Deque args, CommandEvent event) throws ArgumentException { return String.join(" ", args); } } diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/AbstractOffsetArgument.java b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/AbstractOffsetArgument.java index ebbe6db7..00b1dbb3 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/AbstractOffsetArgument.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/AbstractOffsetArgument.java @@ -1,6 +1,7 @@ package com.diamondfire.helpbot.bot.command.argument.impl.types; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.exceptions.*; +import com.diamondfire.helpbot.bot.events.CommandEvent; import org.jetbrains.annotations.NotNull; import java.util.*; @@ -18,7 +19,7 @@ public AbstractOffsetArgument(boolean reverse) { } @Override - protected Date parse(@NotNull String argument) throws ArgumentException { + protected Date parse(@NotNull String argument, CommandEvent event) throws ArgumentException { Calendar calendar = Calendar.getInstance(); int offset = 0; boolean modified = false; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/AbstractSimpleValueArgument.java b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/AbstractSimpleValueArgument.java index dcb81ec5..14ca00d8 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/AbstractSimpleValueArgument.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/AbstractSimpleValueArgument.java @@ -1,6 +1,7 @@ package com.diamondfire.helpbot.bot.command.argument.impl.types; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.exceptions.ArgumentException; +import com.diamondfire.helpbot.bot.events.CommandEvent; import org.jetbrains.annotations.NotNull; import java.util.Deque; @@ -8,10 +9,10 @@ public abstract class AbstractSimpleValueArgument implements Argument { @Override - public T parseValue(@NotNull Deque args) throws ArgumentException { - return parse(args.pop()); + public T parseValue(@NotNull Deque args, CommandEvent event) throws ArgumentException { + return parse(args.pop(), event); } - protected abstract T parse(@NotNull String argument) throws ArgumentException; + protected abstract T parse(@NotNull String argument, CommandEvent event) throws ArgumentException; } diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/Argument.java b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/Argument.java index b6f671e4..d7ac58f1 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/Argument.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/Argument.java @@ -2,6 +2,7 @@ import com.diamondfire.helpbot.bot.command.argument.impl.parsing.exceptions.ArgumentException; +import com.diamondfire.helpbot.bot.events.CommandEvent; import org.jetbrains.annotations.NotNull; import java.util.Deque; @@ -14,7 +15,7 @@ */ public interface Argument { - T parseValue(@NotNull Deque args) throws ArgumentException; + T parseValue(@NotNull Deque args, CommandEvent event) throws ArgumentException; } diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/ClampedIntegerArgument.java b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/ClampedIntegerArgument.java index 8ef2ceea..79f496a7 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/ClampedIntegerArgument.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/ClampedIntegerArgument.java @@ -1,6 +1,7 @@ package com.diamondfire.helpbot.bot.command.argument.impl.types; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.exceptions.ArgumentException; +import com.diamondfire.helpbot.bot.events.CommandEvent; import com.diamondfire.helpbot.util.Util; import org.jetbrains.annotations.NotNull; @@ -20,8 +21,8 @@ public ClampedIntegerArgument(int min, int max) { } @Override - public Integer parse(@NotNull String msg) throws ArgumentException { - int num = super.parse(msg); + public Integer parse(@NotNull String msg, CommandEvent event) throws ArgumentException { + int num = super.parse(msg, event); if (num <= max && num >= min) { return num; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/DateArgument.java b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/DateArgument.java index 815fdae6..c50c699f 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/DateArgument.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/DateArgument.java @@ -1,6 +1,7 @@ package com.diamondfire.helpbot.bot.command.argument.impl.types; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.exceptions.*; +import com.diamondfire.helpbot.bot.events.CommandEvent; import org.jetbrains.annotations.NotNull; import java.text.*; @@ -19,7 +20,7 @@ public DateArgument(String format) { } @Override - public Date parse(@NotNull String msg) throws ArgumentException { + public Date parse(@NotNull String msg, CommandEvent event) throws ArgumentException { try { return format.parse(msg); } catch (ParseException parseException) { diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/DefinedObjectArgument.java b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/DefinedObjectArgument.java index f22b5991..c06d463d 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/DefinedObjectArgument.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/DefinedObjectArgument.java @@ -2,6 +2,7 @@ import com.diamondfire.helpbot.bot.command.argument.impl.parsing.exceptions.*; +import com.diamondfire.helpbot.bot.events.CommandEvent; import com.diamondfire.helpbot.util.JaroWinkler; import org.jetbrains.annotations.NotNull; @@ -26,7 +27,7 @@ public DefinedObjectArgument(boolean trailing, @NotNull T... options) { } @Override - public T parseValue(@NotNull Deque args) throws ArgumentException { + public T parseValue(@NotNull Deque args, CommandEvent event) throws ArgumentException { String compareString; if (trailing) { compareString = String.join(" ", args); diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/DiscordUserArgument.java b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/DiscordUserArgument.java index 85bce2e9..b0eef190 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/DiscordUserArgument.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/DiscordUserArgument.java @@ -1,6 +1,7 @@ package com.diamondfire.helpbot.bot.command.argument.impl.types; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.exceptions.MalformedArgumentException; +import com.diamondfire.helpbot.bot.events.CommandEvent; import net.dv8tion.jda.api.utils.MiscUtil; import org.jetbrains.annotations.NotNull; @@ -11,7 +12,7 @@ public class DiscordUserArgument extends AbstractSimpleValueArgument { private final Pattern pattern = Pattern.compile("<@!?(\\d+)>"); @Override - public Long parse(@NotNull String msg) throws MalformedArgumentException { + public Long parse(@NotNull String msg, CommandEvent event) throws MalformedArgumentException { try { return Long.parseLong(msg); diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/IntegerArgument.java b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/IntegerArgument.java index d30b42a4..c2061cfe 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/IntegerArgument.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/IntegerArgument.java @@ -1,12 +1,13 @@ package com.diamondfire.helpbot.bot.command.argument.impl.types; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.exceptions.*; +import com.diamondfire.helpbot.bot.events.CommandEvent; import org.jetbrains.annotations.NotNull; public class IntegerArgument extends AbstractSimpleValueArgument { @Override - public Integer parse(@NotNull String msg) throws ArgumentException { + public Integer parse(@NotNull String msg, CommandEvent event) throws ArgumentException { try { return Integer.parseInt(msg); } catch (NumberFormatException exception) { diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/LongArgument.java b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/LongArgument.java index dad4cc9c..3be8d19d 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/LongArgument.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/LongArgument.java @@ -1,12 +1,13 @@ package com.diamondfire.helpbot.bot.command.argument.impl.types; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.exceptions.ArgumentException; +import com.diamondfire.helpbot.bot.events.CommandEvent; import org.jetbrains.annotations.NotNull; public class LongArgument extends AbstractSimpleValueArgument{ @Override - protected Long parse(@NotNull String argument) throws ArgumentException { + protected Long parse(@NotNull String argument, CommandEvent event) throws ArgumentException { return Long.parseLong(argument); } } diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/MinecraftPlayerUUIDArgument.java b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/MinecraftPlayerUUIDArgument.java index 30802910..035d735e 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/MinecraftPlayerUUIDArgument.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/MinecraftPlayerUUIDArgument.java @@ -2,6 +2,7 @@ import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.exceptions.ArgumentException; +import com.diamondfire.helpbot.bot.events.CommandEvent; import com.google.gson.*; import okhttp3.*; import org.jetbrains.annotations.NotNull; @@ -12,7 +13,7 @@ public class MinecraftPlayerUUIDArgument extends AbstractSimpleValueArgument { @Override - protected UUID parse(@NotNull String argument) throws ArgumentException { + protected UUID parse(@NotNull String argument, CommandEvent event) throws ArgumentException { if (argument.contains("-") || argument.length() > 16) { return UUID.fromString(argument); } else { diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/StringArgument.java b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/StringArgument.java index a50da829..e8b56065 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/StringArgument.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/StringArgument.java @@ -1,11 +1,12 @@ package com.diamondfire.helpbot.bot.command.argument.impl.types; +import com.diamondfire.helpbot.bot.events.CommandEvent; import org.jetbrains.annotations.NotNull; public class StringArgument extends AbstractSimpleValueArgument { @Override - public String parse(@NotNull String msg) { + public String parse(@NotNull String msg, CommandEvent event) { return msg; } } diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/SubCommandArgument.java b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/SubCommandArgument.java new file mode 100644 index 00000000..c4153ea2 --- /dev/null +++ b/src/main/java/com/diamondfire/helpbot/bot/command/argument/impl/types/SubCommandArgument.java @@ -0,0 +1,24 @@ +package com.diamondfire.helpbot.bot.command.argument.impl.types; + +import com.diamondfire.helpbot.bot.command.argument.impl.parsing.exceptions.*; +import com.diamondfire.helpbot.bot.command.impl.*; +import com.diamondfire.helpbot.bot.events.CommandEvent; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; +import java.util.stream.Collectors; + +public class SubCommandArgument extends AbstractSimpleValueArgument { + + @Override + public SubCommand parse(@NotNull String msg, CommandEvent event) throws ArgumentException { + try { + return Arrays.stream(((SubCommandHolder) event.getCommand()).getSubCommands()) + .filter(s -> s.getName().equals(msg)).collect(Collectors.toList()).get(0); + } catch (IndexOutOfBoundsException e) { + throw new MalformedArgumentException( + "Not a valid subcommand. Choose from " + event.getCommand().getHelpContext().getArguments().get(0).getArgumentName()); + } + } + +} diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/executor/CommandExecutor.java b/src/main/java/com/diamondfire/helpbot/bot/command/executor/CommandExecutor.java index 696748eb..72a1b4af 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/executor/CommandExecutor.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/executor/CommandExecutor.java @@ -19,11 +19,10 @@ public class CommandExecutor { new MutedCheck(), new DisabledCheck(), new PermissionCheck(), - new CommandLog(), - new SubCommandCheck() + new CommandLog() }; - public void run(CommandEvent e) { + public void run(CommandEvent e, String[] args) { Command command = e.getCommand(); if (command == null) { return; @@ -39,7 +38,7 @@ public void run(CommandEvent e) { } } - e.pushArguments(e.getMessage().getContentRaw().split(" ")); + e.pushArguments(args); command.run(e); } catch (ArgumentException exception) { builder.withPreset( diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/executor/checks/DisabledCheck.java b/src/main/java/com/diamondfire/helpbot/bot/command/executor/checks/DisabledCheck.java index f0351920..8f43e4d9 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/executor/checks/DisabledCheck.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/executor/checks/DisabledCheck.java @@ -1,6 +1,5 @@ package com.diamondfire.helpbot.bot.command.executor.checks; -import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.CommandHandler; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/executor/checks/SubCommandCheck.java b/src/main/java/com/diamondfire/helpbot/bot/command/executor/checks/SubCommandCheck.java deleted file mode 100644 index 8f890909..00000000 --- a/src/main/java/com/diamondfire/helpbot/bot/command/executor/checks/SubCommandCheck.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.diamondfire.helpbot.bot.command.executor.checks; - -import com.diamondfire.helpbot.bot.command.CommandHandler; -import com.diamondfire.helpbot.bot.command.argument.impl.parsing.exceptions.MissingArgumentException; -import com.diamondfire.helpbot.bot.command.help.HelpContextArgument; -import com.diamondfire.helpbot.bot.command.impl.*; -import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; -import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; -import com.diamondfire.helpbot.bot.events.*; - -import java.util.*; - -public class SubCommandCheck implements CommandCheck { - - @Override - public boolean check(CommandEvent event) { - // Abort if this is not a SubCommandReceiver - if (!(event.getCommand() instanceof SubCommandReceiver)) return true; - - // Get receiver object - SubCommandReceiver command = (SubCommandReceiver) event.getCommand(); - - // Find the requested subcommand, or error if there is none - List splitArgs = new LinkedList<>(Arrays.asList(event.getMessage().getContentRaw() - .split(" +"))); - if (splitArgs.size() <= 1) { - replyInvalidSubcommand(event); - return false; - } - String request = String.join(" ", splitArgs.get(1)); - - // Iterate through receiver subcommand list to find a match - // (hashmap? may not be worth it because there's not a lot of subcommands) - for (SubCommand subcommand : command.getSubCommands()) { - if (subcommand.getName().equals(request)) { - // Check if the user has permissions, if true run - if (subcommand.getPermission().hasPermission(event.getMember())) { - // Check if the argument requirements are in order - int i = 0; - for (HelpContextArgument arg : subcommand.getHelpContext().getArguments()) { - if (arg.isOptional()) break; - - if (splitArgs.size()-3 < i) { - MissingArgumentException exception = new MissingArgumentException( - "Expected an argument, but got nothing."); - exception.setContext(command, i+1); - event.reply(new PresetBuilder().withPreset( - new InformativeReply(InformativeReplyType.ERROR, - "Invalid Argument!", exception.getEmbedMessage()) - )); - return false; - } - - i++; - } - subcommand.run(new SubCommandEvent(event.getMessage(), subcommand)); - } - return true; - } - } - - replyInvalidSubcommand(event); - return false; - } - - private void replyInvalidSubcommand(CommandEvent event) { - event.reply(new PresetBuilder().withPreset( - new InformativeReply(InformativeReplyType.ERROR, - "Invalid subcommand! Choose from: "+((SubCommandReceiver) event.getCommand()) - .getFormattedSubCommands(event)) - ) - ); - } - - @Override - public void buildMessage(CommandEvent event, PresetBuilder builder) { - } -} diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommand.java index d1af64ce..52771daa 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommand.java @@ -1,17 +1,4 @@ package com.diamondfire.helpbot.bot.command.impl; -import com.diamondfire.helpbot.bot.command.help.HelpContext; -import com.diamondfire.helpbot.bot.command.permissions.Permission; -import com.diamondfire.helpbot.bot.events.SubCommandEvent; - -public interface SubCommand { - - String getName(); - - HelpContext getHelpContext(); - - Permission getPermission(); - - void run(SubCommandEvent event); - +public abstract class SubCommand extends Command { } diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommandHolder.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommandHolder.java new file mode 100644 index 00000000..babcf0a8 --- /dev/null +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommandHolder.java @@ -0,0 +1,35 @@ +package com.diamondfire.helpbot.bot.command.impl; + +import com.diamondfire.helpbot.bot.HelpBotInstance; +import com.diamondfire.helpbot.bot.command.CommandHandler; +import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; +import com.diamondfire.helpbot.bot.command.argument.impl.types.SubCommandArgument; +import com.diamondfire.helpbot.bot.events.CommandEvent; + +import java.util.*; + +public abstract class SubCommandHolder extends Command { + + @Override + public ArgumentSet compileArguments() { + return new ArgumentSet().addArgument( + "subcommand", new SubCommandArgument() + ); + } + + @Override + public void run(CommandEvent event) { + SubCommand subcommand = event.getArgument("subcommand"); + event.setCommand(subcommand); + + String[] rawArgs = event.getRawArgs(); + rawArgs[0] = rawArgs[0].substring(HelpBotInstance.getConfig().getPrefix().length()); + + List args = new ArrayList<>(Arrays.asList(rawArgs)); + args.remove(1); + + CommandHandler.getInstance().run(event, args.toArray(String[]::new)); + } + + public abstract SubCommand[] getSubCommands(); +} diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommandReceiver.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommandReceiver.java deleted file mode 100644 index 5240ff61..00000000 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/SubCommandReceiver.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.diamondfire.helpbot.bot.command.impl; - -import com.diamondfire.helpbot.bot.events.CommandEvent; - -import java.util.List; - -public abstract class SubCommandReceiver extends Command { - - public abstract List getSubCommands(); - - public String getFormattedSubCommands(CommandEvent event) { - String result = ""; - for (SubCommand subcommand : getSubCommands()) { - if (subcommand.getPermission().hasPermission(event.getMember())) { - result += "`" + subcommand.getName() + "` "; - } - } - return result; - } -} diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/DisableCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/DisableCommand.java index 6ca57217..02b56f26 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/DisableCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/DisableCommand.java @@ -1,6 +1,5 @@ package com.diamondfire.helpbot.bot.command.impl.other.dev; -import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.CommandHandler; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.types.StringArgument; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/EnableCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/EnableCommand.java index 93b583eb..8e64b32a 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/EnableCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/EnableCommand.java @@ -1,6 +1,5 @@ package com.diamondfire.helpbot.bot.command.impl.other.dev; -import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.CommandHandler; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.types.StringArgument; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/EvalCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/EvalCommand.java index c8949612..8d23dae3 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/EvalCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/dev/EvalCommand.java @@ -3,20 +3,16 @@ import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.MessageArgument; -import com.diamondfire.helpbot.bot.command.help.CommandCategory; -import com.diamondfire.helpbot.bot.command.help.HelpContext; -import com.diamondfire.helpbot.bot.command.help.HelpContextArgument; +import com.diamondfire.helpbot.bot.command.help.*; import com.diamondfire.helpbot.bot.command.impl.Command; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.events.CommandEvent; import com.diamondfire.helpbot.util.EmbedUtil; import net.dv8tion.jda.api.EmbedBuilder; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; +import javax.script.*; import java.awt.*; -import java.io.PrintWriter; -import java.io.StringWriter; +import java.io.*; import java.util.List; import java.util.stream.Collectors; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/IdeaCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/IdeaCommand.java index c5a3074a..ab0280d8 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/IdeaCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/IdeaCommand.java @@ -6,6 +6,7 @@ import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.events.CommandEvent; import net.dv8tion.jda.api.EmbedBuilder; + import java.util.Random; public class IdeaCommand extends Command { diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/NbsCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/NbsCommand.java index b966e0fc..b18ca2f9 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/NbsCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/NbsCommand.java @@ -1,26 +1,21 @@ package com.diamondfire.helpbot.bot.command.impl.other.fun; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; -import com.diamondfire.helpbot.bot.command.help.CommandCategory; -import com.diamondfire.helpbot.bot.command.help.HelpContext; +import com.diamondfire.helpbot.bot.command.help.*; import com.diamondfire.helpbot.bot.command.impl.Command; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; -import com.diamondfire.helpbot.bot.command.reply.feature.informative.InformativeReply; -import com.diamondfire.helpbot.bot.command.reply.feature.informative.InformativeReplyType; +import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; import com.diamondfire.helpbot.bot.events.CommandEvent; import com.diamondfire.helpbot.util.nbs.*; -import com.google.gson.Gson; -import com.google.gson.JsonObject; +import com.google.gson.*; import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.entities.Message; -import net.dv8tion.jda.api.entities.TextChannel; +import net.dv8tion.jda.api.entities.*; import java.awt.*; import java.io.*; import java.net.*; import java.nio.charset.StandardCharsets; - import java.util.Scanner; public class NbsCommand extends Command { diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/OcrCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/OcrCommand.java index 887c25c1..1f9f5b7b 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/OcrCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/fun/OcrCommand.java @@ -1,6 +1,5 @@ package com.diamondfire.helpbot.bot.command.impl.other.fun; -import com.diamondfire.helpbot.HelpBot; import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.SingleArgumentContainer; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/HelpCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/HelpCommand.java index 716296e7..d027f00b 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/HelpCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/HelpCommand.java @@ -1,6 +1,5 @@ package com.diamondfire.helpbot.bot.command.impl.other.info; -import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.CommandHandler; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.SingleArgumentContainer; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/PermUnlocksCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/PermUnlocksCommand.java index ee4c2e93..cf0c418f 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/PermUnlocksCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/info/PermUnlocksCommand.java @@ -1,6 +1,5 @@ package com.diamondfire.helpbot.bot.command.impl.other.info; -import com.diamondfire.helpbot.bot.HelpBotInstance; import com.diamondfire.helpbot.bot.command.CommandHandler; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.types.DefinedObjectArgument; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/AddTagSubCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/AddTagSubCommand.java index bf4625d1..6597ed6b 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/AddTagSubCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/AddTagSubCommand.java @@ -1,23 +1,19 @@ package com.diamondfire.helpbot.bot.command.impl.other.tag; -import com.diamondfire.helpbot.bot.command.help.HelpContext; -import com.diamondfire.helpbot.bot.command.help.HelpContextArgument; +import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; +import com.diamondfire.helpbot.bot.command.argument.impl.types.StringArgument; +import com.diamondfire.helpbot.bot.command.help.*; import com.diamondfire.helpbot.bot.command.impl.SubCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; -import com.diamondfire.helpbot.bot.command.reply.feature.informative.InformativeReply; -import com.diamondfire.helpbot.bot.command.reply.feature.informative.InformativeReplyType; -import com.diamondfire.helpbot.bot.events.SubCommandEvent; -import com.diamondfire.helpbot.sys.tag.Tag; -import com.diamondfire.helpbot.sys.tag.TagAlreadyExistsException; -import com.diamondfire.helpbot.sys.tag.TagHandler; +import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; +import com.diamondfire.helpbot.bot.events.CommandEvent; +import com.diamondfire.helpbot.sys.tag.*; import java.io.IOException; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; +import java.util.*; -public class AddTagSubCommand implements SubCommand { +public class AddTagSubCommand extends SubCommand { @Override public String getName() { @@ -37,16 +33,28 @@ public HelpContext getHelpContext() { ); } + @Override + protected ArgumentSet compileArguments() { + return new ArgumentSet().addArgument( + "activator", new StringArgument() + ).addArgument( + "title", new StringArgument() + ).addArgument( + "response", new StringArgument() + ); + } + @Override public Permission getPermission() { return Permission.EXPERT; } @Override - public void run(SubCommandEvent event) { + public void run(CommandEvent event) { // Get new activator and title String activator = event.getArgument("activator"); - String title = event.getArgument("title").replaceAll("%space%", " "); + String title = event.getArgument("title"); + title = title.replaceAll("%space%", " "); // Get response List splitArgs = new LinkedList<>(Arrays.asList(event.getMessage().getContentRaw() diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/EditTagSubCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/EditTagSubCommand.java index a3e79924..8a615fcb 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/EditTagSubCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/EditTagSubCommand.java @@ -1,17 +1,19 @@ package com.diamondfire.helpbot.bot.command.impl.other.tag; +import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; +import com.diamondfire.helpbot.bot.command.argument.impl.types.StringArgument; import com.diamondfire.helpbot.bot.command.help.*; import com.diamondfire.helpbot.bot.command.impl.SubCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; -import com.diamondfire.helpbot.bot.events.SubCommandEvent; +import com.diamondfire.helpbot.bot.events.CommandEvent; import com.diamondfire.helpbot.sys.tag.*; import java.io.IOException; import java.util.*; -public class EditTagSubCommand implements SubCommand { +public class EditTagSubCommand extends SubCommand { @Override public String getName() { @@ -29,13 +31,22 @@ public HelpContext getHelpContext() { ); } + @Override + protected ArgumentSet compileArguments() { + return new ArgumentSet().addArgument( + "activator", new StringArgument() + ).addArgument( + "property", new StringArgument() + ); + } + @Override public Permission getPermission() { return Permission.EXPERT; } @Override - public void run(SubCommandEvent event) { + public void run(CommandEvent event) { // Get activator and property String activator = event.getArgument("activator"); String prop = event.getArgument("property"); diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/ListTagsSubCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/ListTagsSubCommand.java index ac012b1a..fed351bf 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/ListTagsSubCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/ListTagsSubCommand.java @@ -1,17 +1,18 @@ package com.diamondfire.helpbot.bot.command.impl.other.tag; +import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.HelpContext; import com.diamondfire.helpbot.bot.command.impl.SubCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; -import com.diamondfire.helpbot.bot.events.SubCommandEvent; +import com.diamondfire.helpbot.bot.events.CommandEvent; import com.diamondfire.helpbot.sys.tag.*; import java.io.IOException; import java.util.List; -public class ListTagsSubCommand implements SubCommand { +public class ListTagsSubCommand extends SubCommand { @Override public String getName() { @@ -23,13 +24,18 @@ public HelpContext getHelpContext() { return new HelpContext(); } + @Override + protected ArgumentSet compileArguments() { + return new ArgumentSet(); + } + @Override public Permission getPermission() { return Permission.USER; } @Override - public void run(SubCommandEvent event) { + public void run(CommandEvent event) { try { List tags = TagHandler.getTags(); String string = ""; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/RemoveTagSubCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/RemoveTagSubCommand.java index c5b6110a..6511d6f9 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/RemoveTagSubCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/RemoveTagSubCommand.java @@ -1,16 +1,18 @@ package com.diamondfire.helpbot.bot.command.impl.other.tag; +import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; +import com.diamondfire.helpbot.bot.command.argument.impl.types.StringArgument; import com.diamondfire.helpbot.bot.command.help.*; import com.diamondfire.helpbot.bot.command.impl.SubCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; -import com.diamondfire.helpbot.bot.events.SubCommandEvent; +import com.diamondfire.helpbot.bot.events.CommandEvent; import com.diamondfire.helpbot.sys.tag.*; import java.io.IOException; -public class RemoveTagSubCommand implements SubCommand { +public class RemoveTagSubCommand extends SubCommand { @Override public String getName() { @@ -26,13 +28,21 @@ public HelpContext getHelpContext() { ); } + @Override + protected ArgumentSet compileArguments() { + return new ArgumentSet() + .addArgument( + "activator", new StringArgument() + ); + } + @Override public Permission getPermission() { return Permission.EXPERT; } @Override - public void run(SubCommandEvent event) { + public void run(CommandEvent event) { // Get activator String activator = event.getArgument("activator"); diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagCommandReceiver.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagCommand.java similarity index 53% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagCommandReceiver.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagCommand.java index 2b71b9cd..70d16cb4 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagCommandReceiver.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/tag/TagCommand.java @@ -1,15 +1,10 @@ package com.diamondfire.helpbot.bot.command.impl.other.tag; -import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; -import com.diamondfire.helpbot.bot.command.argument.impl.types.StringArgument; import com.diamondfire.helpbot.bot.command.help.*; import com.diamondfire.helpbot.bot.command.impl.*; import com.diamondfire.helpbot.bot.command.permissions.Permission; -import com.diamondfire.helpbot.bot.events.CommandEvent; -import java.util.*; - -public class TagCommandReceiver extends SubCommandReceiver { +public class TagCommand extends SubCommandHolder { @Override public String getName() { @@ -26,42 +21,24 @@ public HelpContext getHelpContext() { new HelpContextArgument() .name("add/edit/remove/list"), new HelpContextArgument() - .name("add edit remove: activator") - .optional(), - new HelpContextArgument() - .name("add: title/edit: property") - .optional(), - new HelpContextArgument() - .name("add: response/edit: new value") + .name("...") .optional() - ); } - @Override - public ArgumentSet compileArguments() { - return new ArgumentSet().addArgument("add/edit/remove/list", - new StringArgument() - ); - } - @Override public Permission getPermission() { return Permission.USER; } @Override - public void run(CommandEvent event) { - } - - @Override - public List getSubCommands() { - return Arrays.asList( + public SubCommand[] getSubCommands() { + return new SubCommand[]{ new AddTagSubCommand(), new EditTagSubCommand(), new RemoveTagSubCommand(), new ListTagsSubCommand() - ); + }; } } diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/BulkExecuteCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/BulkExecuteCommand.java index 2f8cb4de..5f57a99b 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/BulkExecuteCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/util/BulkExecuteCommand.java @@ -6,7 +6,7 @@ import com.diamondfire.helpbot.bot.command.argument.impl.types.*; import com.diamondfire.helpbot.bot.command.help.*; import com.diamondfire.helpbot.bot.command.impl.Command; -import com.diamondfire.helpbot.bot.command.impl.stats.individualized.AbstractPlayerUUIDCommand; +import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/AbstractPlayerUUIDCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/AbstractPlayerUUIDCommand.java similarity index 94% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/AbstractPlayerUUIDCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/AbstractPlayerUUIDCommand.java index 265ccd59..0728bae2 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/AbstractPlayerUUIDCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/AbstractPlayerUUIDCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.stats.individualized; +package com.diamondfire.helpbot.bot.command.impl.stats; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.SingleArgumentContainer; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/BoostersCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/BoostersCommand.java similarity index 92% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/BoostersCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/BoostersCommand.java index 34284882..a8dd705d 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/BoostersCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/BoostersCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.stats.metrics; +package com.diamondfire.helpbot.bot.command.impl.stats; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; @@ -9,15 +9,14 @@ import com.diamondfire.helpbot.bot.events.CommandEvent; import com.diamondfire.helpbot.sys.database.impl.DatabaseQuery; import com.diamondfire.helpbot.sys.database.impl.queries.BasicQuery; -import com.diamondfire.helpbot.util.FormatUtil; -import com.diamondfire.helpbot.util.Util; +import com.diamondfire.helpbot.util.*; import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.entities.Emote; import java.sql.ResultSet; public class BoostersCommand extends Command { - private static long[] emotes = new long[]{809172442957217812L, 809172442496630815L}; + private static final long[] emotes = new long[]{809172442957217812L, 809172442496630815L}; @Override public String getName() { diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/CpRequirementsCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/CpRequirementsCommand.java similarity index 96% rename from src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/CpRequirementsCommand.java rename to src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/CpRequirementsCommand.java index bede77ce..56dae817 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/metrics/CpRequirementsCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/CpRequirementsCommand.java @@ -1,4 +1,4 @@ -package com.diamondfire.helpbot.bot.command.impl.stats.metrics; +package com.diamondfire.helpbot.bot.command.impl.stats; import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; import com.diamondfire.helpbot.bot.command.help.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/graph/AbstractGraphCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/graph/AbstractGraphCommand.java index ca7aea34..2e868836 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/graph/AbstractGraphCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/graph/AbstractGraphCommand.java @@ -6,7 +6,6 @@ import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.events.CommandEvent; import com.diamondfire.helpbot.sys.graph.generators.*; -import com.diamondfire.helpbot.sys.graph.generators.context.TimeGraphContext; public abstract class AbstractGraphCommand extends Command { diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/CpCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/CpCommand.java index bfc4f764..b91b5166 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/CpCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/CpCommand.java @@ -1,6 +1,7 @@ package com.diamondfire.helpbot.bot.command.impl.stats.individualized; import com.diamondfire.helpbot.bot.command.help.*; +import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/HistoryCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/HistoryCommand.java index c2a8596a..48186ae6 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/HistoryCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/HistoryCommand.java @@ -1,6 +1,7 @@ package com.diamondfire.helpbot.bot.command.impl.stats.individualized; import com.diamondfire.helpbot.bot.command.help.*; +import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/LastJoinedCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/LastJoinedCommand.java index 2e4ea00d..fb82a4fe 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/LastJoinedCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/LastJoinedCommand.java @@ -1,6 +1,7 @@ package com.diamondfire.helpbot.bot.command.impl.stats.individualized; import com.diamondfire.helpbot.bot.command.help.*; +import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/NamesCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/NamesCommand.java index d99a72c4..f4a502a9 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/NamesCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/NamesCommand.java @@ -1,6 +1,7 @@ package com.diamondfire.helpbot.bot.command.impl.stats.individualized; import com.diamondfire.helpbot.bot.command.help.*; +import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/PlotsCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/PlotsCommand.java index ba2cfe2d..9d3c333f 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/PlotsCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/PlotsCommand.java @@ -1,6 +1,7 @@ package com.diamondfire.helpbot.bot.command.impl.stats.individualized; import com.diamondfire.helpbot.bot.command.help.*; +import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/ProfileCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/ProfileCommand.java index 616a24fc..56748f8f 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/ProfileCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/ProfileCommand.java @@ -1,6 +1,7 @@ package com.diamondfire.helpbot.bot.command.impl.stats.individualized; import com.diamondfire.helpbot.bot.command.help.*; +import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/SkinCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/SkinCommand.java index c6b5d940..4cc19504 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/SkinCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/SkinCommand.java @@ -1,6 +1,7 @@ package com.diamondfire.helpbot.bot.command.impl.stats.individualized; import com.diamondfire.helpbot.bot.command.help.*; +import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/UuidCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/UuidCommand.java index 23aec690..8b0d9edd 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/UuidCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/individualized/UuidCommand.java @@ -1,6 +1,7 @@ package com.diamondfire.helpbot.bot.command.impl.stats.individualized; import com.diamondfire.helpbot.bot.command.help.HelpContext; +import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.informative.*; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/AbstractSessionLogCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/AbstractSessionLogCommand.java index 142758a2..e91555ea 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/AbstractSessionLogCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/AbstractSessionLogCommand.java @@ -1,6 +1,6 @@ package com.diamondfire.helpbot.bot.command.impl.stats.support; -import com.diamondfire.helpbot.bot.command.impl.stats.individualized.AbstractPlayerUUIDCommand; +import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.events.CommandEvent; import com.diamondfire.helpbot.sys.externalfile.ExternalFileUtil; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/FindSupporteeNamesCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/FindSupporteeNamesCommand.java index 9be981c8..64302441 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/FindSupporteeNamesCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/FindSupporteeNamesCommand.java @@ -1,7 +1,7 @@ package com.diamondfire.helpbot.bot.command.impl.stats.support; import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.stats.individualized.AbstractPlayerUUIDCommand; +import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/HelpedByCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/HelpedByCommand.java index 6547b366..3d811159 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/HelpedByCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/HelpedByCommand.java @@ -1,7 +1,7 @@ package com.diamondfire.helpbot.bot.command.impl.stats.support; import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.stats.individualized.AbstractPlayerUUIDCommand; +import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/SessionsCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/SessionsCommand.java index b5781ca4..0e76bf03 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/SessionsCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/SessionsCommand.java @@ -27,7 +27,7 @@ public HelpContext getHelpContext() { } @Override - protected List getSessions(String player) { + protected List getSessions(String player) { List sessions = new ArrayList<>(); new DatabaseQuery() .query(new BasicQuery("SELECT * FROM support_sessions WHERE staff = ? ORDER BY time", (statement) -> statement.setString(1, player))) diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/StatsCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/StatsCommand.java index 4ea21f27..470dffcf 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/StatsCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/StatsCommand.java @@ -4,7 +4,7 @@ import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.SingleArgumentContainer; import com.diamondfire.helpbot.bot.command.argument.impl.types.TimeOffsetArgument; import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.stats.individualized.AbstractPlayerUUIDCommand; +import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/StatsGraphCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/StatsGraphCommand.java index 53a201b7..3296b356 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/StatsGraphCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/StatsGraphCommand.java @@ -1,7 +1,7 @@ package com.diamondfire.helpbot.bot.command.impl.stats.support; import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.stats.individualized.AbstractPlayerUUIDCommand; +import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.events.CommandEvent; import com.diamondfire.helpbot.sys.database.impl.DatabaseQuery; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/SupporteeStatsCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/SupporteeStatsCommand.java index ac98144d..9be2cbe6 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/SupporteeStatsCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/SupporteeStatsCommand.java @@ -1,7 +1,7 @@ package com.diamondfire.helpbot.bot.command.impl.stats.support; import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.stats.individualized.AbstractPlayerUUIDCommand; +import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/WhoHelpedCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/WhoHelpedCommand.java index 83320e6c..c473da5c 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/WhoHelpedCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/support/WhoHelpedCommand.java @@ -1,7 +1,7 @@ package com.diamondfire.helpbot.bot.command.impl.stats.support; import com.diamondfire.helpbot.bot.command.help.*; -import com.diamondfire.helpbot.bot.command.impl.stats.individualized.AbstractPlayerUUIDCommand; +import com.diamondfire.helpbot.bot.command.impl.stats.AbstractPlayerUUIDCommand; import com.diamondfire.helpbot.bot.command.permissions.Permission; import com.diamondfire.helpbot.bot.command.reply.PresetBuilder; import com.diamondfire.helpbot.bot.command.reply.feature.MinecraftUserPreset; diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/DiscordBoostersCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/DiscordBoostersCommand.java index e136fb40..d623bcb1 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/DiscordBoostersCommand.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/stats/top/DiscordBoostersCommand.java @@ -12,8 +12,8 @@ import java.awt.*; import java.text.SimpleDateFormat; -import java.util.*; import java.util.List; +import java.util.*; public class DiscordBoostersCommand extends Command { @@ -69,13 +69,13 @@ private static String getFormattedBoosters(List members) { else { SimpleDateFormat format = new SimpleDateFormat("y'y'M'm'D'd'"); - + List elements = new ArrayList<>(); for (Member member : members) { String timeBoosted = format.format(member.getTimeBoosted()); elements.add(member.getAsMention() + " - " + timeBoosted); } - + return String.join("\n", elements); } } diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/reply/feature/informative/InformativeReplyType.java b/src/main/java/com/diamondfire/helpbot/bot/command/reply/feature/informative/InformativeReplyType.java index bef112af..53b373a2 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/command/reply/feature/informative/InformativeReplyType.java +++ b/src/main/java/com/diamondfire/helpbot/bot/command/reply/feature/informative/InformativeReplyType.java @@ -5,9 +5,9 @@ import java.awt.*; public enum InformativeReplyType { - SUCCESS("Success!", Color.GREEN), + SUCCESS("Success!", new Color(46, 204, 113)), INFO("Notice!", null), - ERROR("Error!", Color.RED); + ERROR("Error!", new Color(231, 76, 60)); private final String title; private final Color color; diff --git a/src/main/java/com/diamondfire/helpbot/bot/events/CommandEvent.java b/src/main/java/com/diamondfire/helpbot/bot/events/CommandEvent.java index c0bf75d9..4a5bcac7 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/events/CommandEvent.java +++ b/src/main/java/com/diamondfire/helpbot/bot/events/CommandEvent.java @@ -7,7 +7,6 @@ import com.diamondfire.helpbot.bot.command.argument.impl.parsing.parser.ArgumentParser; import com.diamondfire.helpbot.bot.command.impl.Command; import com.diamondfire.helpbot.bot.command.reply.*; -import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; @@ -15,7 +14,7 @@ public class CommandEvent extends GuildMessageReceivedEvent { - private final Command command; + private Command command; private final ReplyHandler replyHandler = new ReplyHandler(getChannel()); //TODO Cleanup and refactor this. // I'd like to see stuff like replying be put into it's whole own section and refactored as well. @@ -27,7 +26,6 @@ public CommandEvent(Message message) { String[] rawArgs = getMessage().getContentDisplay().split(" "); String commandPrefix = rawArgs[0].substring(HelpBotInstance.getConfig().getPrefix().length()).toLowerCase(); - Command cmd = CommandHandler.getInstance().getCommands().get(commandPrefix.toLowerCase()); if (cmd == null) { this.aliasedUsed = commandPrefix.toLowerCase(); @@ -38,13 +36,17 @@ public CommandEvent(Message message) { } public void pushArguments(String[] rawArgs) throws ArgumentException { - this.parsedArgumentSet = ArgumentParser.parseArgs(command, Arrays.copyOfRange(rawArgs, 1, rawArgs.length)); + this.parsedArgumentSet = ArgumentParser.parseArgs(command, Arrays.copyOfRange(rawArgs, 1, rawArgs.length), this); } public Command getCommand() { return command; } + public void setCommand(Command command) { + this.command = command; + } + public void reply(PresetBuilder preset) { replyHandler.reply(preset, getChannel()); } @@ -64,4 +66,8 @@ public ReplyHandler getReplyHandler() { public String getAliasUsed() { return aliasedUsed; } + + public String[] getRawArgs() { + return getMessage().getContentRaw().split("\\s+"); + } } diff --git a/src/main/java/com/diamondfire/helpbot/bot/events/GuildJoinEvent.java b/src/main/java/com/diamondfire/helpbot/bot/events/GuildJoinEvent.java index d3ed8928..0080879d 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/events/GuildJoinEvent.java +++ b/src/main/java/com/diamondfire/helpbot/bot/events/GuildJoinEvent.java @@ -1,7 +1,6 @@ package com.diamondfire.helpbot.bot.events; import com.diamondfire.helpbot.bot.HelpBotInstance; -import com.diamondfire.helpbot.sys.rolereact.RoleReactListener; import com.diamondfire.helpbot.sys.tasks.impl.MuteExpireTask; import com.diamondfire.helpbot.util.Util; import net.dv8tion.jda.api.entities.Member; diff --git a/src/main/java/com/diamondfire/helpbot/bot/events/MessageEvent.java b/src/main/java/com/diamondfire/helpbot/bot/events/MessageEvent.java index dd91a836..0286059b 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/events/MessageEvent.java +++ b/src/main/java/com/diamondfire/helpbot/bot/events/MessageEvent.java @@ -12,6 +12,7 @@ public class MessageEvent extends ListenerAdapter { private static final MessageAcceptor[] acceptors = { new ReportAcceptor(), new FilterAcceptor(), + new TagAcceptor(), new CommandAcceptor(), new VerifyAcceptor() }; diff --git a/src/main/java/com/diamondfire/helpbot/bot/events/SubCommandEvent.java b/src/main/java/com/diamondfire/helpbot/bot/events/SubCommandEvent.java deleted file mode 100644 index 8dd129d1..00000000 --- a/src/main/java/com/diamondfire/helpbot/bot/events/SubCommandEvent.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.diamondfire.helpbot.bot.events; - -import com.diamondfire.helpbot.bot.command.help.HelpContextArgument; -import com.diamondfire.helpbot.bot.command.impl.SubCommand; -import net.dv8tion.jda.api.entities.Message; - -import java.util.*; - -public class SubCommandEvent extends CommandEvent { - - private final SubCommand subcommand; - private final Map arguments; - - public SubCommandEvent(Message message, SubCommand subCommand) { - super(message); - this.subcommand = subCommand; - this.arguments = generateArguments(); - } - - private Map generateArguments() { - List splitArgs = new LinkedList<>(Arrays.asList(this.getMessage().getContentRaw() - .split(" +"))); - splitArgs = splitArgs.subList(2, splitArgs.size()); - - Map result = new HashMap<>(); - List context = subcommand.getHelpContext().getArguments(); - - int i = 0; - for (String arg : splitArgs) { - if (context.size() <= i) break; - result.put(context.get(i).getArgumentName(), arg); - i++; - } - return result; - } - - @Override - public Map getArguments() { - return arguments; - } - - @Override - public String getArgument(String code) { - return (String) arguments.get(code); - } - - public SubCommand getSubCommand() { - return this.subcommand; - } -} diff --git a/src/main/java/com/diamondfire/helpbot/df/codeinfo/codedatabase/db/datatypes/DisplayIcon.java b/src/main/java/com/diamondfire/helpbot/df/codeinfo/codedatabase/db/datatypes/DisplayIcon.java index 148b14a3..07364aba 100644 --- a/src/main/java/com/diamondfire/helpbot/df/codeinfo/codedatabase/db/datatypes/DisplayIcon.java +++ b/src/main/java/com/diamondfire/helpbot/df/codeinfo/codedatabase/db/datatypes/DisplayIcon.java @@ -2,7 +2,6 @@ import com.diamondfire.helpbot.util.*; import com.google.gson.*; -import org.jetbrains.annotations.Nullable; import java.util.*; diff --git a/src/main/java/com/diamondfire/helpbot/df/codeinfo/viewables/constants/CodeBlockEnum.java b/src/main/java/com/diamondfire/helpbot/df/codeinfo/viewables/constants/CodeBlockEnum.java index 47c9ab9b..71fbde28 100644 --- a/src/main/java/com/diamondfire/helpbot/df/codeinfo/viewables/constants/CodeBlockEnum.java +++ b/src/main/java/com/diamondfire/helpbot/df/codeinfo/viewables/constants/CodeBlockEnum.java @@ -1,6 +1,5 @@ package com.diamondfire.helpbot.df.codeinfo.viewables.constants; -import com.diamondfire.helpbot.HelpBot; import com.diamondfire.helpbot.bot.HelpBotInstance; import net.dv8tion.jda.api.entities.Emote; diff --git a/src/main/java/com/diamondfire/helpbot/sys/externalfile/ExternalFiles.java b/src/main/java/com/diamondfire/helpbot/sys/externalfile/ExternalFiles.java index 361a6608..49a2616c 100644 --- a/src/main/java/com/diamondfire/helpbot/sys/externalfile/ExternalFiles.java +++ b/src/main/java/com/diamondfire/helpbot/sys/externalfile/ExternalFiles.java @@ -1,7 +1,6 @@ package com.diamondfire.helpbot.sys.externalfile; import java.io.File; -import java.net.URL; public interface ExternalFiles { diff --git a/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/CommandAcceptor.java b/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/CommandAcceptor.java index 5b48c619..32aa4562 100644 --- a/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/CommandAcceptor.java +++ b/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/CommandAcceptor.java @@ -16,4 +16,4 @@ public boolean accept(Message message) { return false; } -} +} \ No newline at end of file diff --git a/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/ReportAcceptor.java b/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/ReportAcceptor.java index 9b7b523f..5b0219fa 100644 --- a/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/ReportAcceptor.java +++ b/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/ReportAcceptor.java @@ -4,12 +4,10 @@ import club.minnced.discord.webhook.external.JDAWebhookClient; import club.minnced.discord.webhook.send.WebhookMessageBuilder; import com.diamondfire.helpbot.bot.HelpBotInstance; -import net.dv8tion.jda.api.entities.Message; -import net.dv8tion.jda.api.entities.User; +import net.dv8tion.jda.api.entities.*; import java.net.URL; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; +import java.util.concurrent.*; public class ReportAcceptor implements MessageAcceptor { diff --git a/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/TagAcceptor.java b/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/TagAcceptor.java index 77c95221..09f886de 100644 --- a/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/TagAcceptor.java +++ b/src/main/java/com/diamondfire/helpbot/sys/message/acceptors/TagAcceptor.java @@ -1,9 +1,7 @@ package com.diamondfire.helpbot.sys.message.acceptors; import com.diamondfire.helpbot.bot.HelpBotInstance; -import com.diamondfire.helpbot.sys.tag.Tag; -import com.diamondfire.helpbot.sys.tag.TagDoesntExistException; -import com.diamondfire.helpbot.sys.tag.TagHandler; +import com.diamondfire.helpbot.sys.tag.*; import net.dv8tion.jda.api.entities.Message; import java.io.IOException; diff --git a/src/main/java/com/diamondfire/helpbot/sys/message/filter/filters/SwearFilter.java b/src/main/java/com/diamondfire/helpbot/sys/message/filter/filters/SwearFilter.java index 91a5dbeb..7c381d92 100644 --- a/src/main/java/com/diamondfire/helpbot/sys/message/filter/filters/SwearFilter.java +++ b/src/main/java/com/diamondfire/helpbot/sys/message/filter/filters/SwearFilter.java @@ -67,12 +67,8 @@ public boolean filterString(String message, FilterData data) { // This is fairly easy to bypass, but still good to have String concatenated = getImplicit(message.replace(" ", "")); - - if (BLOCKED_MESSAGES.contains(concatenated)) { - return true; - } - - return false; + + return BLOCKED_MESSAGES.contains(concatenated); } private static final HashMap CHARACTER_MAP; diff --git a/src/main/java/com/diamondfire/helpbot/sys/multiselector/MultiSelector.java b/src/main/java/com/diamondfire/helpbot/sys/multiselector/MultiSelector.java index 52c74a72..4b6db69a 100644 --- a/src/main/java/com/diamondfire/helpbot/sys/multiselector/MultiSelector.java +++ b/src/main/java/com/diamondfire/helpbot/sys/multiselector/MultiSelector.java @@ -6,7 +6,6 @@ import net.dv8tion.jda.api.entities.Emoji; import net.dv8tion.jda.api.interactions.components.Button; - import java.util.*; public class MultiSelector { diff --git a/src/main/java/com/diamondfire/helpbot/sys/tag/TagHandler.java b/src/main/java/com/diamondfire/helpbot/sys/tag/TagHandler.java index ce84cec8..21a660ee 100644 --- a/src/main/java/com/diamondfire/helpbot/sys/tag/TagHandler.java +++ b/src/main/java/com/diamondfire/helpbot/sys/tag/TagHandler.java @@ -10,7 +10,7 @@ public class TagHandler { - private static List tags = new ArrayList<>(); + private static final List tags = new ArrayList<>(); private static final File FILE = ExternalFiles.TAGS; public static List getTags() throws IOException { @@ -46,7 +46,7 @@ public static void saveToJson() throws IOException { json.add(tag.getActivator(), obj); } - + FILE.delete(); FILE.createNewFile(); Files.write(FILE.toPath(), json.toString().getBytes(), StandardOpenOption.WRITE); diff --git a/src/main/java/com/diamondfire/helpbot/sys/tasks/MidnightTask.java b/src/main/java/com/diamondfire/helpbot/sys/tasks/MidnightTask.java index 2533e2fa..73017f03 100644 --- a/src/main/java/com/diamondfire/helpbot/sys/tasks/MidnightTask.java +++ b/src/main/java/com/diamondfire/helpbot/sys/tasks/MidnightTask.java @@ -1,7 +1,6 @@ package com.diamondfire.helpbot.sys.tasks; import java.time.*; -import java.time.chrono.ChronoLocalDateTime; import java.util.TimeZone; import java.util.concurrent.TimeUnit; diff --git a/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/GraphChannelTask.java b/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/GraphChannelTask.java index 62182dfd..b43d1a34 100644 --- a/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/GraphChannelTask.java +++ b/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/GraphChannelTask.java @@ -1,7 +1,6 @@ package com.diamondfire.helpbot.sys.tasks.impl; import com.diamondfire.helpbot.bot.HelpBotInstance; -import com.diamondfire.helpbot.bot.command.impl.stats.graph.*; import com.diamondfire.helpbot.sys.graph.generators.*; import com.diamondfire.helpbot.sys.graph.generators.context.TimeGraphContext; import com.diamondfire.helpbot.sys.tasks.MidnightTask; diff --git a/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/MuteExpireTask.java b/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/MuteExpireTask.java index 12214a9e..4ba55a70 100644 --- a/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/MuteExpireTask.java +++ b/src/main/java/com/diamondfire/helpbot/sys/tasks/impl/MuteExpireTask.java @@ -1,8 +1,7 @@ package com.diamondfire.helpbot.sys.tasks.impl; import com.diamondfire.helpbot.bot.HelpBotInstance; -import com.diamondfire.helpbot.bot.command.impl.other.mod.DiscussionMuteCommand; -import com.diamondfire.helpbot.bot.command.impl.other.mod.MuteCommand; +import com.diamondfire.helpbot.bot.command.impl.other.mod.*; import com.diamondfire.helpbot.sys.database.impl.DatabaseQuery; import com.diamondfire.helpbot.sys.database.impl.queries.BasicQuery; import com.diamondfire.helpbot.sys.tasks.OneTimeTask; diff --git a/src/main/java/com/diamondfire/helpbot/util/DateUtil.java b/src/main/java/com/diamondfire/helpbot/util/DateUtil.java index 58cadcee..1dabcae6 100644 --- a/src/main/java/com/diamondfire/helpbot/util/DateUtil.java +++ b/src/main/java/com/diamondfire/helpbot/util/DateUtil.java @@ -1,8 +1,7 @@ package com.diamondfire.helpbot.util; import java.sql.Timestamp; -import java.time.Instant; -import java.time.LocalDate; +import java.time.*; import java.util.*; @SuppressWarnings("deprecation") diff --git a/src/main/java/com/diamondfire/helpbot/util/IOUtil.java b/src/main/java/com/diamondfire/helpbot/util/IOUtil.java index 295066a7..16ef1cae 100644 --- a/src/main/java/com/diamondfire/helpbot/util/IOUtil.java +++ b/src/main/java/com/diamondfire/helpbot/util/IOUtil.java @@ -76,7 +76,7 @@ public static File zipFile(Path path, String fileName) throws IOException { public static File getFileFromSite(String url, String name) { - try (InputStream in = new URL(url).openStream();) { + try (InputStream in = new URL(url).openStream()) { File tempFile = ExternalFileUtil.generateFile(name); Files.write(tempFile.toPath(), in.readAllBytes(), StandardOpenOption.WRITE); diff --git a/src/main/java/com/diamondfire/helpbot/util/nbs/NBSDecoder.java b/src/main/java/com/diamondfire/helpbot/util/nbs/NBSDecoder.java index a38628cf..7031b3ae 100644 --- a/src/main/java/com/diamondfire/helpbot/util/nbs/NBSDecoder.java +++ b/src/main/java/com/diamondfire/helpbot/util/nbs/NBSDecoder.java @@ -52,7 +52,7 @@ private static SongData parse(InputStream inputStream, File songFile) throws IOE speed = actualSpeed / 100f; //speed dataInputStream.readBoolean(); //autosave dataInputStream.readByte(); //autosave duration - timeSignature = (short) dataInputStream.readByte(); //time signature + timeSignature = dataInputStream.readByte(); //time signature readInt(dataInputStream); //minutes spent readInt(dataInputStream); //left clicks readInt(dataInputStream); //right clicks @@ -222,7 +222,7 @@ private static SongData parse(InputStream inputStream, File songFile) throws IOE } } } - stringBuilder.append(columnStringBuilder.toString()); + stringBuilder.append(columnStringBuilder); } } diff --git a/src/main/java/com/diamondfire/helpbot/util/nbs/NBSToTemplate.java b/src/main/java/com/diamondfire/helpbot/util/nbs/NBSToTemplate.java index 6eee3ec0..c5bf54e7 100644 --- a/src/main/java/com/diamondfire/helpbot/util/nbs/NBSToTemplate.java +++ b/src/main/java/com/diamondfire/helpbot/util/nbs/NBSToTemplate.java @@ -91,7 +91,7 @@ public String convert() { if (currentNotes.length() > 1930) { currentNotes = new StringBuilder(revertString); - currentBlock.append(String.format(",{\"item\":{\"id\":\"txt\",\"data\":{\"name\":\"%s\"}},\"slot\":%d}", currentNotes.toString(), slot)); + currentBlock.append(String.format(",{\"item\":{\"id\":\"txt\",\"data\":{\"name\":\"%s\"}},\"slot\":%d}", currentNotes, slot)); currentNotes.setLength(0); noteCount = 0; finalNote = true; @@ -101,7 +101,7 @@ public String convert() { if (i >= songData.length - 1) { if (!finalNote) { - currentBlock.append(String.format(",{\"item\":{\"id\":\"txt\",\"data\":{\"name\":\"%s\"}},\"slot\":%d}", currentNotes.toString(), slot)); + currentBlock.append(String.format(",{\"item\":{\"id\":\"txt\",\"data\":{\"name\":\"%s\"}},\"slot\":%d}", currentNotes, slot)); currentNotes.setLength(0); } closeChest = true; @@ -117,7 +117,7 @@ public String convert() { } currentBlock.append(String.format("]},\"action\":\"%s\"},", varActionType)); - code.append(currentBlock.toString()); + code.append(currentBlock); currentBlock.setLength(0); currentNotes.setLength(0); @@ -148,7 +148,7 @@ public String convert() { currentSlot++; } instList.append("]},\"action\":\"CreateList\"},"); - code.append(instList.toString()); + code.append(instList); } //CreateList: songData diff --git a/src/main/java/com/diamondfire/helpbot/util/textgen/CacheData.java b/src/main/java/com/diamondfire/helpbot/util/textgen/CacheData.java index c016036e..5f372846 100644 --- a/src/main/java/com/diamondfire/helpbot/util/textgen/CacheData.java +++ b/src/main/java/com/diamondfire/helpbot/util/textgen/CacheData.java @@ -1,8 +1,7 @@ package com.diamondfire.helpbot.util.textgen; import java.io.*; -import java.util.ArrayList; -import java.util.Arrays; +import java.util.*; import static com.diamondfire.helpbot.util.textgen.MarkovManipulation.addWord; From 5fb61357cb26e610cf3e798e3bf1f2fb1f3420a2 Mon Sep 17 00:00:00 2001 From: RyanLandDev Date: Fri, 23 Jul 2021 20:40:02 +0200 Subject: [PATCH 8/8] fix the thing --- src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java b/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java index 348dcdfc..6a44cae5 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java +++ b/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java @@ -2,6 +2,7 @@ import com.diamondfire.helpbot.bot.command.CommandHandler; import com.diamondfire.helpbot.bot.command.impl.codeblock.*; +import com.diamondfire.helpbot.bot.command.impl.other.StoreCommand; import com.diamondfire.helpbot.bot.command.impl.other.dev.*; import com.diamondfire.helpbot.bot.command.impl.other.dumps.*; import com.diamondfire.helpbot.bot.command.impl.other.fun.*;