From a0ba6fc27e7e57175725a17fad0fd51756358344 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 1 Apr 2022 10:59:40 -0700 Subject: [PATCH] Credit & Comment + Version Bump (0.8.0-pre) --- pom.xml | 2 +- src/main/java/moe/oko/Kiafumi/Kiafumi.java | 9 +++++++++ .../moe/oko/Kiafumi/command/CommandClass.java | 4 ++++ .../oko/Kiafumi/command/CommandRegistrar.java | 16 ++++++++++++++++ .../oko/Kiafumi/command/fun/DreidelCommand.java | 4 ++++ .../oko/Kiafumi/command/fun/FightCommand.java | 5 +++++ .../command/fun/SeptemberDateCommand.java | 4 ++++ .../oko/Kiafumi/command/image/AvatarCommand.java | 4 ++++ .../oko/Kiafumi/command/image/CatCommand.java | 1 + .../Kiafumi/command/moderation/ModCommand.java | 5 +++++ .../oko/Kiafumi/command/music/MusicCommand.java | 5 +++++ .../oko/Kiafumi/command/utility/DuckCommand.java | 4 ++++ .../oko/Kiafumi/command/utility/InfoCommand.java | 4 ++++ .../Kiafumi/command/utility/InviteCommand.java | 4 ++++ .../oko/Kiafumi/command/utility/PingCommand.java | 4 ++++ .../Kiafumi/command/utility/SettingCommand.java | 4 ++++ .../moe/oko/Kiafumi/listener/MainListener.java | 1 + .../java/moe/oko/Kiafumi/model/KiafumiDB.java | 2 ++ src/main/java/moe/oko/Kiafumi/model/Server.java | 2 ++ .../moe/oko/Kiafumi/model/ServerManager.java | 1 + .../java/moe/oko/Kiafumi/util/CommandInfo.java | 3 +-- .../java/moe/oko/Kiafumi/util/CommandType.java | 4 ++++ .../moe/oko/Kiafumi/util/ResponseHandlers.java | 5 +++++ 23 files changed, 94 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 675bb6a..fcef064 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ moe.oko Kiafumi Kiafumi - 0.7.0-pre + 0.8.0-pre jar https://oko.moe/kiafumi.htm diff --git a/src/main/java/moe/oko/Kiafumi/Kiafumi.java b/src/main/java/moe/oko/Kiafumi/Kiafumi.java index 3a7a657..6287dd3 100644 --- a/src/main/java/moe/oko/Kiafumi/Kiafumi.java +++ b/src/main/java/moe/oko/Kiafumi/Kiafumi.java @@ -31,6 +31,15 @@ import java.util.List; /** * Kiafumi Main Class + * @author Kay, oko, Tiddy + * @version 0.8.0-pre + * @apiNote Thanks to: + * | Maxopoly, Orinnari, ProgrammerDan, and more, for helping teach Kay how to code Java from scratch. + * | Favna, and the HC Development community for encouraging the development core of HC. + * | HC as a whole, for being a wonderful community and encouraging the creation of this bot + * | Civ, for encouraging us all to sort out how the hell programming works + * | Discord, for offering a platform to learn these skills on + * | The Java Development Team, for making a Language I personally love and adore - Kay */ public class Kiafumi { diff --git a/src/main/java/moe/oko/Kiafumi/command/CommandClass.java b/src/main/java/moe/oko/Kiafumi/command/CommandClass.java index 7cfff12..b5bd34f 100644 --- a/src/main/java/moe/oko/Kiafumi/command/CommandClass.java +++ b/src/main/java/moe/oko/Kiafumi/command/CommandClass.java @@ -6,6 +6,10 @@ import net.dv8tion.jda.api.hooks.ListenerAdapter; import java.util.List; +/** + * CommandClass Abstract Class + * Use this for any commands you make, and ensure they go under the .command class. + */ public abstract class CommandClass extends ListenerAdapter { //Is the command enabled? diff --git a/src/main/java/moe/oko/Kiafumi/command/CommandRegistrar.java b/src/main/java/moe/oko/Kiafumi/command/CommandRegistrar.java index fc8a031..47c2e7a 100644 --- a/src/main/java/moe/oko/Kiafumi/command/CommandRegistrar.java +++ b/src/main/java/moe/oko/Kiafumi/command/CommandRegistrar.java @@ -12,8 +12,18 @@ import java.util.stream.Collectors; import static moe.oko.Kiafumi.Kiafumi.error; import static moe.oko.Kiafumi.Kiafumi.info; +/** + * CommandRegistrar Class + * Used for easy command package loading, we use this to avoid having 20 lines of list.add() methods. + * @author Kay + */ public class CommandRegistrar { + /** + * Locates all classes that contain the package name provided. Use CAREFULLY. + * @param packageName - the name of the package to look for + * @return - A set of classes that contain that package name. + */ public Set findAllClassesContaining(String packageName) { try { return ClassPath.from(ClassLoader.getSystemClassLoader()) @@ -30,8 +40,14 @@ public class CommandRegistrar { } } + /** + * Utilizes findAllClassesContaining() to find all command classes and return them in a simple manner. + * @return - The CommandClass's located. + */ public List getCommandClasses() { try { + //todo have this check the classpath that we're under and have it scan *that* instead of hard-coding it to only be + //moe.oko.Kiafumi path. Set classes = findAllClassesContaining("moe.oko.Kiafumi.command"); List commands = new ArrayList<>(); info("Found " + classes.size() + " classes containing moe.oko.Kiafumi.command in package class."); diff --git a/src/main/java/moe/oko/Kiafumi/command/fun/DreidelCommand.java b/src/main/java/moe/oko/Kiafumi/command/fun/DreidelCommand.java index 1e96e9c..0ce4b44 100644 --- a/src/main/java/moe/oko/Kiafumi/command/fun/DreidelCommand.java +++ b/src/main/java/moe/oko/Kiafumi/command/fun/DreidelCommand.java @@ -13,6 +13,10 @@ import java.util.List; import java.util.Random; import java.util.concurrent.TimeUnit; +/** + * Dreidel Dreidel... + * @author Tiddy + */ public class DreidelCommand extends CommandClass { private boolean enabled = true; private List sides; diff --git a/src/main/java/moe/oko/Kiafumi/command/fun/FightCommand.java b/src/main/java/moe/oko/Kiafumi/command/fun/FightCommand.java index 5e3ea9b..1bf53fc 100644 --- a/src/main/java/moe/oko/Kiafumi/command/fun/FightCommand.java +++ b/src/main/java/moe/oko/Kiafumi/command/fun/FightCommand.java @@ -16,6 +16,11 @@ import java.util.List; import java.util.Random; import java.util.concurrent.TimeUnit; +/** + * Random User Choice Command + * Intended for when you want to roll the dice on who gets to join the LIMITED EDITION(tm) call + * @author Kay + */ public class FightCommand extends CommandClass { private boolean enabled = false; @Override diff --git a/src/main/java/moe/oko/Kiafumi/command/fun/SeptemberDateCommand.java b/src/main/java/moe/oko/Kiafumi/command/fun/SeptemberDateCommand.java index ff726f4..eb0a96c 100644 --- a/src/main/java/moe/oko/Kiafumi/command/fun/SeptemberDateCommand.java +++ b/src/main/java/moe/oko/Kiafumi/command/fun/SeptemberDateCommand.java @@ -14,6 +14,10 @@ import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.List; +/** + * Fetches the REAL date + * @author oko + */ public class SeptemberDateCommand extends CommandClass { @Override diff --git a/src/main/java/moe/oko/Kiafumi/command/image/AvatarCommand.java b/src/main/java/moe/oko/Kiafumi/command/image/AvatarCommand.java index 98da3e4..c127e46 100644 --- a/src/main/java/moe/oko/Kiafumi/command/image/AvatarCommand.java +++ b/src/main/java/moe/oko/Kiafumi/command/image/AvatarCommand.java @@ -12,6 +12,10 @@ import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.List; +/** + * Helpful Avatar grabber command + * @author oko + */ public class AvatarCommand extends CommandClass { @Override public boolean isEnabled() { return true; } diff --git a/src/main/java/moe/oko/Kiafumi/command/image/CatCommand.java b/src/main/java/moe/oko/Kiafumi/command/image/CatCommand.java index dcf9b4a..e546e23 100644 --- a/src/main/java/moe/oko/Kiafumi/command/image/CatCommand.java +++ b/src/main/java/moe/oko/Kiafumi/command/image/CatCommand.java @@ -21,6 +21,7 @@ import static moe.oko.Kiafumi.util.ResponseHandlers.STRING_RESPONSE_HANDLER; /** * Mrow :3 + * @author Kay */ public class CatCommand extends CommandClass { diff --git a/src/main/java/moe/oko/Kiafumi/command/moderation/ModCommand.java b/src/main/java/moe/oko/Kiafumi/command/moderation/ModCommand.java index 8daadad..043712f 100644 --- a/src/main/java/moe/oko/Kiafumi/command/moderation/ModCommand.java +++ b/src/main/java/moe/oko/Kiafumi/command/moderation/ModCommand.java @@ -13,6 +13,11 @@ import java.awt.*; import java.util.ArrayList; import java.util.List; +/** + * For use on Guilds that tend to get TOS'd with ease. Also just basic server protection + * @author Kay + * (Requires Permission.ADMINISTRATOR to function properly) + */ public class ModCommand extends CommandClass { @Override public boolean isEnabled() { diff --git a/src/main/java/moe/oko/Kiafumi/command/music/MusicCommand.java b/src/main/java/moe/oko/Kiafumi/command/music/MusicCommand.java index 0850d99..4e028cf 100644 --- a/src/main/java/moe/oko/Kiafumi/command/music/MusicCommand.java +++ b/src/main/java/moe/oko/Kiafumi/command/music/MusicCommand.java @@ -30,6 +30,11 @@ import java.io.IOException; import java.util.*; import java.util.List; +/** + * Music Command + * Most code taken from SHIRO Project (ISC License still applies) + * @author Kay + */ public class MusicCommand extends CommandClass { private static final int PLAYLIST_LIMIT = 200; diff --git a/src/main/java/moe/oko/Kiafumi/command/utility/DuckCommand.java b/src/main/java/moe/oko/Kiafumi/command/utility/DuckCommand.java index 553a2e5..f06bbda 100644 --- a/src/main/java/moe/oko/Kiafumi/command/utility/DuckCommand.java +++ b/src/main/java/moe/oko/Kiafumi/command/utility/DuckCommand.java @@ -14,6 +14,10 @@ import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.List; +/** + * Helpful Search Command (Uses DDG API) + * @author Kay + */ public class DuckCommand extends CommandClass { private boolean enabled = true; diff --git a/src/main/java/moe/oko/Kiafumi/command/utility/InfoCommand.java b/src/main/java/moe/oko/Kiafumi/command/utility/InfoCommand.java index 938a82a..f126f24 100644 --- a/src/main/java/moe/oko/Kiafumi/command/utility/InfoCommand.java +++ b/src/main/java/moe/oko/Kiafumi/command/utility/InfoCommand.java @@ -14,6 +14,10 @@ import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; +/** + * Helpful User Information Command + * @author oko + */ public class InfoCommand extends CommandClass { @Override public boolean isEnabled() { return true; } diff --git a/src/main/java/moe/oko/Kiafumi/command/utility/InviteCommand.java b/src/main/java/moe/oko/Kiafumi/command/utility/InviteCommand.java index 49a273a..dff87d5 100644 --- a/src/main/java/moe/oko/Kiafumi/command/utility/InviteCommand.java +++ b/src/main/java/moe/oko/Kiafumi/command/utility/InviteCommand.java @@ -12,6 +12,10 @@ import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.List; +/** + * Helpful Invite Command + * @author Kay, oko + */ public class InviteCommand extends CommandClass { @Override public boolean isEnabled() { diff --git a/src/main/java/moe/oko/Kiafumi/command/utility/PingCommand.java b/src/main/java/moe/oko/Kiafumi/command/utility/PingCommand.java index 494417e..a9d17aa 100644 --- a/src/main/java/moe/oko/Kiafumi/command/utility/PingCommand.java +++ b/src/main/java/moe/oko/Kiafumi/command/utility/PingCommand.java @@ -14,6 +14,10 @@ import java.util.List; import java.util.Locale; import java.util.Random; +/** + * Helpful Ping Command + * @author Kay + */ public class PingCommand extends CommandClass { //Always true, ping cmd is EXISTENTIAL @Override diff --git a/src/main/java/moe/oko/Kiafumi/command/utility/SettingCommand.java b/src/main/java/moe/oko/Kiafumi/command/utility/SettingCommand.java index e350be4..9980027 100644 --- a/src/main/java/moe/oko/Kiafumi/command/utility/SettingCommand.java +++ b/src/main/java/moe/oko/Kiafumi/command/utility/SettingCommand.java @@ -15,6 +15,10 @@ import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.List; +/** + * Permits modification of server settings, critical class to functionality. + * @author Kay + */ public class SettingCommand extends CommandClass { @Override public boolean isEnabled() { diff --git a/src/main/java/moe/oko/Kiafumi/listener/MainListener.java b/src/main/java/moe/oko/Kiafumi/listener/MainListener.java index c54fadc..beca513 100644 --- a/src/main/java/moe/oko/Kiafumi/listener/MainListener.java +++ b/src/main/java/moe/oko/Kiafumi/listener/MainListener.java @@ -28,6 +28,7 @@ import static moe.oko.Kiafumi.Kiafumi.info; /** * Main Listener * Used for all utility garbage like guild handling and persistence. (Also LOL prevention). + * @author Kay, oko, Tiddy */ public class MainListener extends ListenerAdapter { diff --git a/src/main/java/moe/oko/Kiafumi/model/KiafumiDB.java b/src/main/java/moe/oko/Kiafumi/model/KiafumiDB.java index c353daf..28006b7 100644 --- a/src/main/java/moe/oko/Kiafumi/model/KiafumiDB.java +++ b/src/main/java/moe/oko/Kiafumi/model/KiafumiDB.java @@ -14,6 +14,8 @@ import static moe.oko.Kiafumi.Kiafumi.info; /** * Kiafumi DB Class * Basically our helpful MySQL functions that pertain to data persistence. + * @author Kay, with moral support from Yodabird + * @apiNote I HATE SQL I HATE SQL AAAAAAAAAAAAAA */ public class KiafumiDB { //Our actual MySQL Connection, this is created on class construction. diff --git a/src/main/java/moe/oko/Kiafumi/model/Server.java b/src/main/java/moe/oko/Kiafumi/model/Server.java index e75e722..e3076df 100644 --- a/src/main/java/moe/oko/Kiafumi/model/Server.java +++ b/src/main/java/moe/oko/Kiafumi/model/Server.java @@ -7,6 +7,8 @@ import javax.annotation.Nullable; /** * Server Class * Used for in-memory data storage. Loaded from Database later. + * @author Kay + * @implNote This class is where all server info is stored per-server, so be liberal with additions. */ public class Server { //Guild ID diff --git a/src/main/java/moe/oko/Kiafumi/model/ServerManager.java b/src/main/java/moe/oko/Kiafumi/model/ServerManager.java index 686623c..f6a50a6 100644 --- a/src/main/java/moe/oko/Kiafumi/model/ServerManager.java +++ b/src/main/java/moe/oko/Kiafumi/model/ServerManager.java @@ -13,6 +13,7 @@ import static moe.oko.Kiafumi.Kiafumi.info; /** * ServerManager Class * Permits the access of servers easily + * @author Kay */ public class ServerManager { //Server Memory Storage Hashmap, diff --git a/src/main/java/moe/oko/Kiafumi/util/CommandInfo.java b/src/main/java/moe/oko/Kiafumi/util/CommandInfo.java index f97f957..2f9ba95 100644 --- a/src/main/java/moe/oko/Kiafumi/util/CommandInfo.java +++ b/src/main/java/moe/oko/Kiafumi/util/CommandInfo.java @@ -4,10 +4,9 @@ import net.dv8tion.jda.api.interactions.commands.OptionType; import java.util.HashMap; -import static moe.oko.Kiafumi.Kiafumi.error; - /** * Helpful CommandInfo class to easily make slash commands. + * @author Kay */ public class CommandInfo { private String name; diff --git a/src/main/java/moe/oko/Kiafumi/util/CommandType.java b/src/main/java/moe/oko/Kiafumi/util/CommandType.java index a60085f..85e84fa 100644 --- a/src/main/java/moe/oko/Kiafumi/util/CommandType.java +++ b/src/main/java/moe/oko/Kiafumi/util/CommandType.java @@ -1,5 +1,9 @@ package moe.oko.Kiafumi.util; +/** + * Used to identify what type of Command is being used. + * This is intended to prevent JDA errors. Which is does. + */ public enum CommandType { /** diff --git a/src/main/java/moe/oko/Kiafumi/util/ResponseHandlers.java b/src/main/java/moe/oko/Kiafumi/util/ResponseHandlers.java index 7f6f814..3874e83 100644 --- a/src/main/java/moe/oko/Kiafumi/util/ResponseHandlers.java +++ b/src/main/java/moe/oko/Kiafumi/util/ResponseHandlers.java @@ -5,6 +5,11 @@ import org.apache.http.client.ClientProtocolException; import org.apache.http.client.ResponseHandler; import org.apache.http.util.EntityUtils; +/** + * Basic ResponseHandler Class + * Intended for GET requests from online API's + * Such as, Steam, DDG, ProtonDB, CatApi, etc. + */ public class ResponseHandlers { public static final ResponseHandler STRING_RESPONSE_HANDLER = response -> { int status = response.getStatusLine().getStatusCode();