diff --git a/discord/build.gradle b/discord/build.gradle deleted file mode 100644 index cf123f0..0000000 --- a/discord/build.gradle +++ /dev/null @@ -1,28 +0,0 @@ -plugins { - id 'java-library' - id 'application' - id 'com.google.cloud.tools.jib' version '3.1.4' -} - -tasks.withType(AbstractArchiveTask) { - preserveFileTimestamps = false - reproducibleFileOrder = true -} - -mainClassName = "com.clubobsidian.obbylang.discord.Bootstrap" - -shadowJar { - archiveBaseName.set('ObbyLangDiscord') -} - -tasks.shadowJar.dependsOn ':core:shadowJar' - -dependencies { - implementation project(path: ':core') - implementation('com.github.DV8FromTheWorld:JDA:v4.4.0') { - exclude module: 'opus-java' - } - implementation 'org.slf4j:slf4j-log4j12:1.7.32' - implementation 'org.jline:jline:3.21.0' - implementation 'org.mariadb.jdbc:mariadb-java-client:3.0.4' -} diff --git a/discord/src/main/java/com/clubobsidian/obbylang/discord/Bootstrap.java b/discord/src/main/java/com/clubobsidian/obbylang/discord/Bootstrap.java deleted file mode 100644 index 7a2dc88..0000000 --- a/discord/src/main/java/com/clubobsidian/obbylang/discord/Bootstrap.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * ObbyLang - * Copyright (C) 2021 virustotalop - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.clubobsidian.obbylang.discord; - -import com.clubobsidian.obbylang.discord.plugin.DiscordObbyLangPlugin; - -public class Bootstrap { - - private static DiscordObbyLangPlugin plugin; - - public static void main(String[] args) { - //System.setProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager"); - //BasicConfigurator.configure(); - plugin = new DiscordObbyLangPlugin(); - plugin.onEnable(); - } - - public static DiscordObbyLangPlugin getPlugin() { - return plugin; - } -} \ No newline at end of file diff --git a/discord/src/main/java/com/clubobsidian/obbylang/discord/command/Command.java b/discord/src/main/java/com/clubobsidian/obbylang/discord/command/Command.java deleted file mode 100644 index bae6874..0000000 --- a/discord/src/main/java/com/clubobsidian/obbylang/discord/command/Command.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * ObbyLang - * Copyright (C) 2021 virustotalop - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.clubobsidian.obbylang.discord.command; - -import com.clubobsidian.obbylang.pipe.Pipe; - -public abstract class Command { - - private String name; - - public Command(String name) { - this.name = name; - } - - public String getName() { - return this.name; - } - - public abstract boolean onCommand(Pipe pipe, String[] args); - -} \ No newline at end of file diff --git a/discord/src/main/java/com/clubobsidian/obbylang/discord/command/DiscordConsoleCommandManager.java b/discord/src/main/java/com/clubobsidian/obbylang/discord/command/DiscordConsoleCommandManager.java deleted file mode 100644 index e2a308a..0000000 --- a/discord/src/main/java/com/clubobsidian/obbylang/discord/command/DiscordConsoleCommandManager.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * ObbyLang - * Copyright (C) 2021 virustotalop - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.clubobsidian.obbylang.discord.command; - -import com.clubobsidian.obbylang.discord.pipe.LoggerPipe; -import com.clubobsidian.obbylang.discord.plugin.DiscordObbyLangPlugin; -import com.clubobsidian.obbylang.pipe.Pipe; - -import java.util.Arrays; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.logging.Logger; - -public class DiscordConsoleCommandManager { - - private final Map commands; - private final Pipe consolePipe; - - public DiscordConsoleCommandManager() { - this.commands = new ConcurrentHashMap<>(); - this.consolePipe = new LoggerPipe(); - } - - public boolean register(Command command, String... aliases) { - return this.register(command, aliases, false); - } - - public boolean register(Command command, String[] aliases, boolean force) { - if(force) { - this.commands.put(command.getName(), command); - for(String alias : aliases) { - this.commands.put(alias, command); - } - return true; - } - - if(this.commandExists(command.getName())) { - return false; - } - - this.commands.put(command.getName(), command); - return true; - } - - public boolean commandExists(String command) { - return this.commands.keySet().contains(command); - } - - public boolean dispatchCommand(String command) { - Logger logger = DiscordObbyLangPlugin.get().getLogger(); - logger.info(this.commands.toString()); - if(command.length() <= 0) { - logger.info("Invalid command length for command, length is: " + command.length()); - return false; - } - - String[] args = command.split(" "); - if(args.length > 0) { - String name = args[0]; - if(this.commandExists(name)) { - if(args.length > 1) { - args = Arrays.copyOfRange(args, 1, args.length); - } else { - args = new String[0]; - } - - Command cmd = this.commands.get(name); - cmd.onCommand(this.consolePipe, args); - return true; - } else { - logger.info("Unknown command " + name + " please try again"); - } - } - return false; - } -} \ No newline at end of file diff --git a/discord/src/main/java/com/clubobsidian/obbylang/discord/command/DiscordObbyLangCommand.java b/discord/src/main/java/com/clubobsidian/obbylang/discord/command/DiscordObbyLangCommand.java deleted file mode 100644 index 4c1fb94..0000000 --- a/discord/src/main/java/com/clubobsidian/obbylang/discord/command/DiscordObbyLangCommand.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * ObbyLang - * Copyright (C) 2021 virustotalop - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.clubobsidian.obbylang.discord.command; - -import com.clubobsidian.obbylang.manager.script.ScriptManager; -import com.clubobsidian.obbylang.pipe.Pipe; - -import javax.inject.Inject; -import java.util.List; - -public class DiscordObbyLangCommand extends Command { - - private final ScriptManager scriptManager; - - @Inject - private DiscordObbyLangCommand(ScriptManager scriptManager) { - super("obbylang"); - this.scriptManager = scriptManager; - } - - @Override - public boolean onCommand(Pipe pipe, String[] args) { - if(args.length == 2) { - if(args[0].equalsIgnoreCase("load")) { - boolean loaded = this.scriptManager.loadScript(args[1], pipe); - if(loaded) { - pipe.out("Script has been loaded"); - } else { - pipe.out("Script could not be loaded"); - } - } else if(args[0].equalsIgnoreCase("unload")) { - boolean unloaded = this.scriptManager.unloadScript(args[1], pipe); - if(unloaded) { - pipe.out("Script has been unloaded"); - } else { - pipe.out("Script could not be unloaded"); - } - } else if(args[0].equalsIgnoreCase("reload")) { - boolean reload = this.scriptManager.reloadScript(args[1], pipe); - if(reload) { - pipe.out("Script has been reloaded"); - } else { - pipe.out("Script could not be reloaded"); - pipe.out("Attemping to load the script"); - boolean load = this.scriptManager.loadScript(args[1], pipe); - if(load) { - pipe.out("Script has been loaded"); - } else { - pipe.out("Script could not be loaded"); - } - } - } else if(args[0].equalsIgnoreCase("enable")) { - boolean enable = this.scriptManager.enableScript(args[1], pipe); - if(enable) { - pipe.out("Script has been enabled"); - } else { - pipe.out("Script can not be enabled"); - } - } else if(args[0].equalsIgnoreCase("disable")) { - boolean disable = this.scriptManager.disableScript(args[1], pipe); - if(disable) { - pipe.out("Script has been disabled"); - } else { - pipe.out("Script can not be disabled"); - } - } else { - this.sendCommandList(this.getName(), pipe); - } - return true; - } else if(args.length == 1) { - if(args[0].equalsIgnoreCase("list")) { - StringBuilder sb = new StringBuilder(); - List scriptNames = this.scriptManager.getScriptNamesRaw(); - for(int i = 0; i < scriptNames.size(); i++) { - sb.append(scriptNames.get(i).replace(".js", "")); - if(i != scriptNames.size() - 1) { - sb.append(","); - } - } - - String scriptStr = sb.toString(); - pipe.out(scriptStr); - return true; - } - } - - this.sendCommandList(this.getName(), pipe); - return true; - - - } - - private void sendCommandList(String label, Pipe pipe) { - pipe.out(label + " load