Credit & Comment + Version Bump (0.8.0-pre)
This commit is contained in:
parent
a513b914d4
commit
a0ba6fc27e
2
pom.xml
2
pom.xml
|
@ -7,7 +7,7 @@
|
|||
<groupId>moe.oko</groupId>
|
||||
<artifactId>Kiafumi</artifactId>
|
||||
<name>Kiafumi</name>
|
||||
<version>0.7.0-pre</version>
|
||||
<version>0.8.0-pre</version>
|
||||
<packaging>jar</packaging>
|
||||
<url>https://oko.moe/kiafumi.htm</url>
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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<Class> 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<CommandClass> 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<Class> classes = findAllClassesContaining("moe.oko.Kiafumi.command");
|
||||
List<CommandClass> commands = new ArrayList<>();
|
||||
info("Found " + classes.size() + " classes containing moe.oko.Kiafumi.command in package class.");
|
||||
|
|
|
@ -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<String> sides;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -21,6 +21,7 @@ import static moe.oko.Kiafumi.util.ResponseHandlers.STRING_RESPONSE_HANDLER;
|
|||
|
||||
/**
|
||||
* Mrow :3
|
||||
* @author Kay
|
||||
*/
|
||||
public class CatCommand extends CommandClass {
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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, <Server/Guild ID, Server Object>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
||||
/**
|
||||
|
|
|
@ -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> STRING_RESPONSE_HANDLER = response -> {
|
||||
int status = response.getStatusLine().getStatusCode();
|
||||
|
|
Loading…
Reference in a new issue