added mostly complete support for dual commands

basically writing one command for both dms and a guild or having one
file and different functions based on where it was called

Signed-off-by: deepCurse <leverplays@gmail.com>
This commit is contained in:
lever1209 2021-12-06 14:01:02 -04:00
commit 168e45d745
No known key found for this signature in database
GPG key ID: EEBCBB60C9DFC782
18 changed files with 304 additions and 280 deletions

View file

@ -12,17 +12,17 @@ import java.util.concurrent.Executors;
import java.util.regex.Pattern;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import pkg.deepCurse.nopalmo.command.GuildCommand;
import pkg.deepCurse.nopalmo.command.guildCommand.info.Git;
import pkg.deepCurse.nopalmo.command.guildCommand.info.Help;
import pkg.deepCurse.nopalmo.command.guildCommand.info.Ping;
import pkg.deepCurse.nopalmo.command.CommandInterface.GuildCommandInterface;
import pkg.deepCurse.nopalmo.command.commands.Git;
import pkg.deepCurse.nopalmo.command.commands.Help;
import pkg.deepCurse.nopalmo.command.commands.Ping;
import pkg.deepCurse.nopalmo.core.Boot;
import pkg.deepCurse.nopalmo.database.DatabaseTools;
import pkg.deepCurse.nopalmo.global.Tools;
public class GuildCommandManager {
public class GuildCommandManager extends CommandManager {
private final Map<String, GuildCommand> guildCommandMap = new HashMap<>();
private final Map<String, GuildCommandInterface> guildCommandMap = new HashMap<>();
private static Executor executor = null;
public GuildCommandManager() {
@ -36,7 +36,7 @@ public class GuildCommandManager {
addCommand(new Git());
}
private void addCommand(GuildCommand c) {
private void addCommand(GuildCommandInterface c) {
if (!guildCommandMap.containsKey(c.getCommandName())) {
guildCommandMap.put(c.getCommandName(), c);
} else {
@ -45,11 +45,11 @@ public class GuildCommandManager {
}
}
public Collection<GuildCommand> getGuildCommands() {
public Collection<GuildCommandInterface> getGuildCommands() {
return guildCommandMap.values();
}
public GuildCommand getCommand(String commandName) {
public GuildCommandInterface getCommand(String commandName) {
if (commandName != null) {
return guildCommandMap.get(commandName);
}
@ -75,7 +75,7 @@ public class GuildCommandManager {
// ArrayList<String> commandFlags = new ArrayList<String>();
GuildCommandBlob commandBlob = new GuildCommandBlob(guildMessage);
GuildCommand guildCommand = guildCommandMap.get(command);
GuildCommandInterface guildCommand = guildCommandMap.get(command);
HashMap<String, Argument> argumentList = new HashMap<String, Argument>();
boolean printTime = false;
@ -144,7 +144,7 @@ public class GuildCommandManager {
commandBlob.setCommandManager(this);
if (remainsValid) {
guildCommand.runCommand(commandBlob, argumentList);
guildCommand.runGuildCommand(commandBlob, argumentList);
}
if (printTime) {