mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-07 17:44:34 +00:00
moved commands into the core, because its a core functionality
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package dev.sheldan.abstracto.moderation.command;
|
||||
|
||||
import dev.sheldan.abstracto.command.AbstractFeatureFlaggedCommand;
|
||||
import dev.sheldan.abstracto.command.HelpInfo;
|
||||
import dev.sheldan.abstracto.command.execution.*;
|
||||
import dev.sheldan.abstracto.core.command.AbstractFeatureFlaggedCommand;
|
||||
import dev.sheldan.abstracto.core.command.HelpInfo;
|
||||
import dev.sheldan.abstracto.core.command.execution.*;
|
||||
import dev.sheldan.abstracto.moderation.Moderation;
|
||||
import dev.sheldan.abstracto.moderation.config.ModerationFeatures;
|
||||
import dev.sheldan.abstracto.moderation.models.template.BanLog;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package dev.sheldan.abstracto.moderation.command;
|
||||
|
||||
import dev.sheldan.abstracto.command.AbstractFeatureFlaggedCommand;
|
||||
import dev.sheldan.abstracto.command.HelpInfo;
|
||||
import dev.sheldan.abstracto.command.execution.*;
|
||||
import dev.sheldan.abstracto.core.command.AbstractFeatureFlaggedCommand;
|
||||
import dev.sheldan.abstracto.core.command.HelpInfo;
|
||||
import dev.sheldan.abstracto.core.command.execution.*;
|
||||
import dev.sheldan.abstracto.moderation.Moderation;
|
||||
import dev.sheldan.abstracto.moderation.config.ModerationFeatures;
|
||||
import dev.sheldan.abstracto.moderation.models.template.BanIdLog;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package dev.sheldan.abstracto.moderation.command;
|
||||
|
||||
import dev.sheldan.abstracto.command.AbstractFeatureFlaggedCommand;
|
||||
import dev.sheldan.abstracto.command.HelpInfo;
|
||||
import dev.sheldan.abstracto.command.execution.*;
|
||||
import dev.sheldan.abstracto.core.command.AbstractFeatureFlaggedCommand;
|
||||
import dev.sheldan.abstracto.core.command.HelpInfo;
|
||||
import dev.sheldan.abstracto.core.command.execution.*;
|
||||
import dev.sheldan.abstracto.moderation.Moderation;
|
||||
import dev.sheldan.abstracto.moderation.config.ModerationFeatures;
|
||||
import dev.sheldan.abstracto.moderation.models.template.KickLogModel;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package dev.sheldan.abstracto.moderation.command;
|
||||
|
||||
import dev.sheldan.abstracto.command.*;
|
||||
import dev.sheldan.abstracto.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.command.execution.Parameter;
|
||||
import dev.sheldan.abstracto.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.command.*;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.Parameter;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.service.Bot;
|
||||
import dev.sheldan.abstracto.moderation.Moderation;
|
||||
import dev.sheldan.abstracto.moderation.config.ModerationFeatures;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package dev.sheldan.abstracto.moderation.command;
|
||||
|
||||
import dev.sheldan.abstracto.command.AbstractFeatureFlaggedCommand;
|
||||
import dev.sheldan.abstracto.command.HelpInfo;
|
||||
import dev.sheldan.abstracto.command.execution.*;
|
||||
import dev.sheldan.abstracto.core.command.AbstractFeatureFlaggedCommand;
|
||||
import dev.sheldan.abstracto.core.command.HelpInfo;
|
||||
import dev.sheldan.abstracto.core.command.execution.*;
|
||||
import dev.sheldan.abstracto.core.service.management.UserManagementService;
|
||||
import dev.sheldan.abstracto.moderation.Moderation;
|
||||
import dev.sheldan.abstracto.moderation.config.ModerationFeatures;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package dev.sheldan.abstracto.moderation;
|
||||
|
||||
import dev.sheldan.abstracto.command.Module;
|
||||
import dev.sheldan.abstracto.command.module.ModuleInfo;
|
||||
import dev.sheldan.abstracto.core.command.ModuleInterface;
|
||||
import dev.sheldan.abstracto.core.command.module.ModuleInfo;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class Moderation implements Module {
|
||||
public class Moderation implements ModuleInterface {
|
||||
|
||||
public static final String MODERATION = "moderation";
|
||||
|
||||
|
||||
@@ -19,16 +19,16 @@
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.command</groupId>
|
||||
<artifactId>command-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core-interface</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.templating</groupId>
|
||||
<artifactId>templating-interface</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -19,11 +19,6 @@
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.command</groupId>
|
||||
<artifactId>command-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core-interface</artifactId>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.sheldan.abstracto.utility.command;
|
||||
|
||||
import dev.sheldan.abstracto.command.*;
|
||||
import dev.sheldan.abstracto.command.execution.*;
|
||||
import dev.sheldan.abstracto.core.command.*;
|
||||
import dev.sheldan.abstracto.core.command.execution.*;
|
||||
import dev.sheldan.abstracto.templating.TemplateService;
|
||||
import dev.sheldan.abstracto.utility.Utility;
|
||||
import dev.sheldan.abstracto.utility.config.UtilityFeatures;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package dev.sheldan.abstracto.utility.command;
|
||||
|
||||
import dev.sheldan.abstracto.command.AbstractFeatureFlaggedCommand;
|
||||
import dev.sheldan.abstracto.command.HelpInfo;
|
||||
import dev.sheldan.abstracto.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.command.execution.Parameter;
|
||||
import dev.sheldan.abstracto.core.command.AbstractFeatureFlaggedCommand;
|
||||
import dev.sheldan.abstracto.core.command.HelpInfo;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.command.execution.Parameter;
|
||||
import dev.sheldan.abstracto.core.models.embed.MessageToSend;
|
||||
import dev.sheldan.abstracto.templating.TemplateService;
|
||||
import dev.sheldan.abstracto.utility.Utility;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.sheldan.abstracto.utility.command.remind;
|
||||
|
||||
import dev.sheldan.abstracto.command.*;
|
||||
import dev.sheldan.abstracto.command.execution.*;
|
||||
import dev.sheldan.abstracto.core.command.*;
|
||||
import dev.sheldan.abstracto.core.command.execution.*;
|
||||
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||
import dev.sheldan.abstracto.utility.config.UtilityFeatures;
|
||||
import dev.sheldan.abstracto.utility.Utility;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package dev.sheldan.abstracto.utility.command.suggest;
|
||||
|
||||
import dev.sheldan.abstracto.command.AbstractFeatureFlaggedCommand;
|
||||
import dev.sheldan.abstracto.command.HelpInfo;
|
||||
import dev.sheldan.abstracto.command.execution.*;
|
||||
import dev.sheldan.abstracto.core.command.AbstractFeatureFlaggedCommand;
|
||||
import dev.sheldan.abstracto.core.command.HelpInfo;
|
||||
import dev.sheldan.abstracto.core.command.execution.*;
|
||||
import dev.sheldan.abstracto.utility.Utility;
|
||||
import dev.sheldan.abstracto.utility.config.UtilityFeatures;
|
||||
import dev.sheldan.abstracto.utility.models.template.SuggestionLog;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package dev.sheldan.abstracto.utility.command.suggest;
|
||||
|
||||
import dev.sheldan.abstracto.command.AbstractFeatureFlaggedCommand;
|
||||
import dev.sheldan.abstracto.command.HelpInfo;
|
||||
import dev.sheldan.abstracto.command.execution.*;
|
||||
import dev.sheldan.abstracto.core.command.AbstractFeatureFlaggedCommand;
|
||||
import dev.sheldan.abstracto.core.command.HelpInfo;
|
||||
import dev.sheldan.abstracto.core.command.execution.*;
|
||||
import dev.sheldan.abstracto.utility.Utility;
|
||||
import dev.sheldan.abstracto.utility.config.UtilityFeatures;
|
||||
import dev.sheldan.abstracto.utility.models.template.SuggestionLog;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package dev.sheldan.abstracto.utility.command.suggest;
|
||||
|
||||
import dev.sheldan.abstracto.command.AbstractFeatureFlaggedCommand;
|
||||
import dev.sheldan.abstracto.command.HelpInfo;
|
||||
import dev.sheldan.abstracto.command.execution.*;
|
||||
import dev.sheldan.abstracto.core.command.AbstractFeatureFlaggedCommand;
|
||||
import dev.sheldan.abstracto.core.command.HelpInfo;
|
||||
import dev.sheldan.abstracto.core.command.execution.*;
|
||||
import dev.sheldan.abstracto.utility.Utility;
|
||||
import dev.sheldan.abstracto.utility.config.UtilityFeatures;
|
||||
import dev.sheldan.abstracto.utility.models.template.SuggestionLog;
|
||||
|
||||
@@ -11,4 +11,12 @@
|
||||
|
||||
<artifactId>utility-int</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.templating</groupId>
|
||||
<artifactId>templating-interface</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -1,11 +1,11 @@
|
||||
package dev.sheldan.abstracto.utility;
|
||||
|
||||
import dev.sheldan.abstracto.command.Module;
|
||||
import dev.sheldan.abstracto.command.module.ModuleInfo;
|
||||
import dev.sheldan.abstracto.core.command.ModuleInterface;
|
||||
import dev.sheldan.abstracto.core.command.module.ModuleInfo;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class Utility implements Module {
|
||||
public class Utility implements ModuleInterface {
|
||||
|
||||
public static final String UTILITY = "utility";
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.command</groupId>
|
||||
<artifactId>command</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>command-impl</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.command</groupId>
|
||||
<artifactId>command-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core-interface</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -1 +0,0 @@
|
||||
abstracto.emoteNames.postReaction=warnReaction,successReaction
|
||||
@@ -1 +0,0 @@
|
||||
Command was not found.
|
||||
@@ -1 +0,0 @@
|
||||
The necessary parameters were not found. A '${class.simpleName}' was expected as '${parameterName}'. Consult help to see the correct syntax.
|
||||
@@ -1 +0,0 @@
|
||||
Insufficient parameters: ${parameterName} was not found.
|
||||
@@ -1 +0,0 @@
|
||||
The parameter ${parameterName} had a too large value: ${actualLength}. The maximum is: ${maximumLength}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.command</groupId>
|
||||
<artifactId>command</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<artifactId>command-int</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.dv8tion</groupId>
|
||||
<artifactId>JDA</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>club.minnced</groupId>
|
||||
<artifactId>opus-java</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.templating</groupId>
|
||||
<artifactId>templating-interface</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core-interface</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
</project>
|
||||
@@ -1,12 +0,0 @@
|
||||
package dev.sheldan.abstracto.command;
|
||||
|
||||
import dev.sheldan.abstracto.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.listener.FeatureAware;
|
||||
|
||||
public interface Command extends FeatureAware {
|
||||
|
||||
CommandResult execute(CommandContext commandContext);
|
||||
CommandConfiguration getConfiguration();
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package dev.sheldan.abstracto.command;
|
||||
|
||||
import dev.sheldan.abstracto.command.module.ModuleInfo;
|
||||
|
||||
public interface Module {
|
||||
ModuleInfo getInfo();
|
||||
String getParentModule();
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package dev.sheldan.abstracto.command.service;
|
||||
|
||||
|
||||
import dev.sheldan.abstracto.command.CommandHierarchy;
|
||||
import dev.sheldan.abstracto.command.Module;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ModuleRegistry {
|
||||
CommandHierarchy getDetailedModules();
|
||||
List<Module> getModules();
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package dev.sheldan.abstracto.command.service;
|
||||
|
||||
import dev.sheldan.abstracto.command.Command;
|
||||
import dev.sheldan.abstracto.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.command.execution.CommandResult;
|
||||
|
||||
public interface PostCommandExecution {
|
||||
void execute(CommandContext commandContext, CommandResult commandResult, Command command);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>dev.sheldan.abstracto.command</groupId>
|
||||
<artifactId>command</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>command-int</module>
|
||||
<module>command-impl</module>
|
||||
</modules>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -76,13 +76,6 @@
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.command</groupId>
|
||||
<artifactId>command-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.templating</groupId>
|
||||
<artifactId>templating-interface</artifactId>
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package dev.sheldan.abstracto.commands;
|
||||
package dev.sheldan.abstracto.core.command;
|
||||
|
||||
import dev.sheldan.abstracto.command.Command;
|
||||
import dev.sheldan.abstracto.command.Module;
|
||||
import dev.sheldan.abstracto.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.command.execution.Parameter;
|
||||
import dev.sheldan.abstracto.command.meta.CommandRegistry;
|
||||
import dev.sheldan.abstracto.command.meta.UnParsedCommandParameter;
|
||||
import dev.sheldan.abstracto.commands.exception.CommandNotFound;
|
||||
import dev.sheldan.abstracto.commands.exception.InsufficientParameters;
|
||||
import dev.sheldan.abstracto.core.command.exception.CommandNotFound;
|
||||
import dev.sheldan.abstracto.core.command.exception.InsufficientParameters;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.execution.Parameter;
|
||||
import dev.sheldan.abstracto.core.command.meta.CommandRegistry;
|
||||
import dev.sheldan.abstracto.core.command.meta.UnParsedCommandParameter;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -78,10 +76,10 @@ public class CommandManager implements CommandRegistry {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Command> getAllCommandsFromModule(Module module) {
|
||||
public List<Command> getAllCommandsFromModule(ModuleInterface moduleInterface) {
|
||||
List<Command> commands = new ArrayList<>();
|
||||
this.getAllCommands().forEach(command -> {
|
||||
if(command.getConfiguration().getModule().equals(module.getInfo().getName())){
|
||||
if(command.getConfiguration().getModule().equals(moduleInterface.getInfo().getName())){
|
||||
commands.add(command);
|
||||
}
|
||||
});
|
||||
@@ -1,13 +1,10 @@
|
||||
package dev.sheldan.abstracto.commands;
|
||||
package dev.sheldan.abstracto.core.command;
|
||||
|
||||
import dev.sheldan.abstracto.command.Command;
|
||||
import dev.sheldan.abstracto.command.CommandCondition;
|
||||
import dev.sheldan.abstracto.command.ConditionalCommand;
|
||||
import dev.sheldan.abstracto.command.service.PostCommandExecution;
|
||||
import dev.sheldan.abstracto.command.execution.*;
|
||||
import dev.sheldan.abstracto.command.meta.UnParsedCommandParameter;
|
||||
import dev.sheldan.abstracto.commands.exception.IncorrectParameter;
|
||||
import dev.sheldan.abstracto.commands.exception.ParameterTooLong;
|
||||
import dev.sheldan.abstracto.core.command.exception.IncorrectParameter;
|
||||
import dev.sheldan.abstracto.core.command.exception.ParameterTooLong;
|
||||
import dev.sheldan.abstracto.core.command.service.PostCommandExecution;
|
||||
import dev.sheldan.abstracto.core.command.execution.*;
|
||||
import dev.sheldan.abstracto.core.command.meta.UnParsedCommandParameter;
|
||||
import dev.sheldan.abstracto.core.Constants;
|
||||
import dev.sheldan.abstracto.core.exception.*;
|
||||
import dev.sheldan.abstracto.core.service.management.ChannelManagementService;
|
||||
@@ -1,9 +1,7 @@
|
||||
package dev.sheldan.abstracto.commands;
|
||||
package dev.sheldan.abstracto.core.command;
|
||||
|
||||
import dev.sheldan.abstracto.command.*;
|
||||
import dev.sheldan.abstracto.command.Module;
|
||||
import dev.sheldan.abstracto.command.meta.CommandRegistry;
|
||||
import dev.sheldan.abstracto.command.service.ModuleRegistry;
|
||||
import dev.sheldan.abstracto.core.command.meta.CommandRegistry;
|
||||
import dev.sheldan.abstracto.core.command.service.ModuleRegistry;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -14,7 +12,7 @@ import java.util.stream.Collectors;
|
||||
public class ModuleManager implements ModuleRegistry {
|
||||
|
||||
@Autowired
|
||||
private List<Module> modules;
|
||||
private List<ModuleInterface> moduleInterfaces;
|
||||
|
||||
@Autowired
|
||||
private CommandRegistry commandRegistry;
|
||||
@@ -22,28 +20,28 @@ public class ModuleManager implements ModuleRegistry {
|
||||
@Override
|
||||
public CommandHierarchy getDetailedModules() {
|
||||
List<PackedModule> modulesWithCommands = new ArrayList<>();
|
||||
List<Module> currentModules = getModules();
|
||||
currentModules.forEach(module -> {
|
||||
List<ModuleInterface> currentModuleInterfaces = getModuleInterfaces();
|
||||
currentModuleInterfaces.forEach(module -> {
|
||||
List<Command> commands = commandRegistry.getAllCommandsFromModule(module);
|
||||
PackedModule packed = PackedModule.builder().commands(commands).module(module).subModules(new ArrayList<>()).build();
|
||||
PackedModule packed = PackedModule.builder().commands(commands).moduleInterface(module).subModules(new ArrayList<>()).build();
|
||||
modulesWithCommands.add(packed);
|
||||
});
|
||||
return getHierarchicalPacks(modulesWithCommands, currentModules);
|
||||
return getHierarchicalPacks(modulesWithCommands, currentModuleInterfaces);
|
||||
}
|
||||
|
||||
private CommandHierarchy getHierarchicalPacks(List<PackedModule> modules, List<Module> currentModules){
|
||||
List<PackedModule> hierarchical = modules.stream().filter(packedModule -> packedModule.getModule().getParentModule() == null).collect(Collectors.toList());
|
||||
private CommandHierarchy getHierarchicalPacks(List<PackedModule> modules, List<ModuleInterface> currentModuleInterfaces){
|
||||
List<PackedModule> hierarchical = modules.stream().filter(packedModule -> packedModule.getModuleInterface().getParentModule() == null).collect(Collectors.toList());
|
||||
|
||||
List<PackedModule> subModules = modules.stream().filter(packedModule -> packedModule.getModule().getParentModule() != null).collect(Collectors.toList());
|
||||
List<PackedModule> subModules = modules.stream().filter(packedModule -> packedModule.getModuleInterface().getParentModule() != null).collect(Collectors.toList());
|
||||
subModules.forEach(module -> {
|
||||
List<Module> path = getModulePath(module, currentModules);
|
||||
List<ModuleInterface> path = getModulePath(module, currentModuleInterfaces);
|
||||
Collections.reverse(path);
|
||||
Module rootModule = path.get(0);
|
||||
Optional<PackedModule> any = hierarchical.stream().filter(moduleInList -> moduleInList.getModule().getInfo().getName().equals(rootModule.getInfo().getName())).findAny();
|
||||
ModuleInterface rootModuleInterface = path.get(0);
|
||||
Optional<PackedModule> any = hierarchical.stream().filter(moduleInList -> moduleInList.getModuleInterface().getInfo().getName().equals(rootModuleInterface.getInfo().getName())).findAny();
|
||||
if(any.isPresent()){
|
||||
PackedModule currentNodeInHierarchy = any.get();
|
||||
for (int i = 1; i < path.size(); i++) {
|
||||
Optional<PackedModule> nextInHierarchy = currentNodeInHierarchy.getSubModules().stream().filter(module1 -> module1.getModule().equals(module.getModule())).findAny();
|
||||
Optional<PackedModule> nextInHierarchy = currentNodeInHierarchy.getSubModules().stream().filter(module1 -> module1.getModuleInterface().equals(module.getModuleInterface())).findAny();
|
||||
if(nextInHierarchy.isPresent()){
|
||||
currentNodeInHierarchy = nextInHierarchy.get();
|
||||
} else {
|
||||
@@ -62,17 +60,17 @@ public class ModuleManager implements ModuleRegistry {
|
||||
|
||||
|
||||
|
||||
private List<Module> getModulePath(PackedModule moduleToPathFor, List<Module> currentModules){
|
||||
List<Module> modulesBetweenRootAndThis = new ArrayList<>();
|
||||
Module current = moduleToPathFor.getModule();
|
||||
private List<ModuleInterface> getModulePath(PackedModule moduleToPathFor, List<ModuleInterface> currentModuleInterfaces){
|
||||
List<ModuleInterface> modulesBetweenRootAndThis = new ArrayList<>();
|
||||
ModuleInterface current = moduleToPathFor.getModuleInterface();
|
||||
modulesBetweenRootAndThis.add(current);
|
||||
while(current.getParentModule() != null){
|
||||
String parentModule = current.getParentModule();
|
||||
Optional<Module> possibleModule = currentModules.stream().filter(module1 -> module1.getInfo().getName().equals(parentModule)).findFirst();
|
||||
Optional<ModuleInterface> possibleModule = currentModuleInterfaces.stream().filter(module1 -> module1.getInfo().getName().equals(parentModule)).findFirst();
|
||||
if(possibleModule.isPresent()){
|
||||
Module foundModule = possibleModule.get();
|
||||
modulesBetweenRootAndThis.add(foundModule);
|
||||
current = foundModule;
|
||||
ModuleInterface foundModuleInterface = possibleModule.get();
|
||||
modulesBetweenRootAndThis.add(foundModuleInterface);
|
||||
current = foundModuleInterface;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@@ -82,8 +80,8 @@ public class ModuleManager implements ModuleRegistry {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Module> getModules() {
|
||||
return modules;
|
||||
public List<ModuleInterface> getModuleInterfaces() {
|
||||
return moduleInterfaces;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.sheldan.abstracto.commands.config;
|
||||
package dev.sheldan.abstracto.core.command.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.sheldan.abstracto.commands.config;
|
||||
package dev.sheldan.abstracto.core.command.config;
|
||||
|
||||
import dev.sheldan.abstracto.command.Command;
|
||||
import dev.sheldan.abstracto.command.service.CommandService;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.service.CommandService;
|
||||
import dev.sheldan.abstracto.core.listener.ServerConfigListener;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.sheldan.abstracto.commands.exception;
|
||||
package dev.sheldan.abstracto.core.command.exception;
|
||||
|
||||
import dev.sheldan.abstracto.command.Templatable;
|
||||
import dev.sheldan.abstracto.core.command.Templatable;
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
|
||||
public class CommandNotFound extends AbstractoRunTimeException implements Templatable {
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.sheldan.abstracto.commands.exception;
|
||||
package dev.sheldan.abstracto.core.command.exception;
|
||||
|
||||
import dev.sheldan.abstracto.command.Command;
|
||||
import dev.sheldan.abstracto.command.Templatable;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.Templatable;
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.sheldan.abstracto.commands.exception;
|
||||
package dev.sheldan.abstracto.core.command.exception;
|
||||
|
||||
import dev.sheldan.abstracto.command.Templatable;
|
||||
import dev.sheldan.abstracto.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.Templatable;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.sheldan.abstracto.commands.exception;
|
||||
package dev.sheldan.abstracto.core.command.exception;
|
||||
|
||||
import dev.sheldan.abstracto.command.Command;
|
||||
import dev.sheldan.abstracto.command.Templatable;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.Templatable;
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -1,11 +1,11 @@
|
||||
package dev.sheldan.abstracto.commands.post;
|
||||
package dev.sheldan.abstracto.core.command.post;
|
||||
|
||||
import dev.sheldan.abstracto.command.Command;
|
||||
import dev.sheldan.abstracto.command.service.PostCommandExecution;
|
||||
import dev.sheldan.abstracto.command.Templatable;
|
||||
import dev.sheldan.abstracto.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.command.execution.ResultState;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.service.PostCommandExecution;
|
||||
import dev.sheldan.abstracto.core.command.Templatable;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.command.execution.ResultState;
|
||||
import dev.sheldan.abstracto.templating.TemplateService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -1,10 +1,10 @@
|
||||
package dev.sheldan.abstracto.commands.post;
|
||||
package dev.sheldan.abstracto.core.command.post;
|
||||
|
||||
import dev.sheldan.abstracto.command.Command;
|
||||
import dev.sheldan.abstracto.command.service.PostCommandExecution;
|
||||
import dev.sheldan.abstracto.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.command.execution.ResultState;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.service.PostCommandExecution;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.command.execution.ResultState;
|
||||
import dev.sheldan.abstracto.core.service.MessageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.sheldan.abstracto.commands.repository;
|
||||
package dev.sheldan.abstracto.core.command.repository;
|
||||
|
||||
import dev.sheldan.abstracto.command.models.ACommand;
|
||||
import dev.sheldan.abstracto.core.command.models.ACommand;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface CommandRepository extends JpaRepository<ACommand, Long> {
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.sheldan.abstracto.commands.repository;
|
||||
package dev.sheldan.abstracto.core.command.repository;
|
||||
|
||||
import dev.sheldan.abstracto.command.models.AModule;
|
||||
import dev.sheldan.abstracto.core.command.models.AModule;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface ModuleRepository extends JpaRepository<AModule, Long> {
|
||||
@@ -1,10 +1,10 @@
|
||||
package dev.sheldan.abstracto.commands.service;
|
||||
package dev.sheldan.abstracto.core.command.service;
|
||||
|
||||
import dev.sheldan.abstracto.command.models.ACommand;
|
||||
import dev.sheldan.abstracto.command.models.AModule;
|
||||
import dev.sheldan.abstracto.command.service.CommandService;
|
||||
import dev.sheldan.abstracto.command.service.management.CommandManagementService;
|
||||
import dev.sheldan.abstracto.command.service.management.ModuleManagementService;
|
||||
import dev.sheldan.abstracto.core.command.models.ACommand;
|
||||
import dev.sheldan.abstracto.core.command.models.AModule;
|
||||
import dev.sheldan.abstracto.core.command.service.CommandService;
|
||||
import dev.sheldan.abstracto.core.command.service.management.CommandManagementService;
|
||||
import dev.sheldan.abstracto.core.command.service.management.ModuleManagementService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package dev.sheldan.abstracto.commands.service.management;
|
||||
package dev.sheldan.abstracto.core.command.service.management;
|
||||
|
||||
import dev.sheldan.abstracto.command.models.ACommand;
|
||||
import dev.sheldan.abstracto.command.models.AModule;
|
||||
import dev.sheldan.abstracto.command.service.management.CommandManagementService;
|
||||
import dev.sheldan.abstracto.command.service.management.ModuleManagementService;
|
||||
import dev.sheldan.abstracto.commands.repository.CommandRepository;
|
||||
import dev.sheldan.abstracto.core.command.models.ACommand;
|
||||
import dev.sheldan.abstracto.core.command.models.AModule;
|
||||
import dev.sheldan.abstracto.core.command.repository.CommandRepository;
|
||||
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -1,8 +1,7 @@
|
||||
package dev.sheldan.abstracto.commands.service.management;
|
||||
package dev.sheldan.abstracto.core.command.service.management;
|
||||
|
||||
import dev.sheldan.abstracto.command.models.AModule;
|
||||
import dev.sheldan.abstracto.command.service.management.ModuleManagementService;
|
||||
import dev.sheldan.abstracto.commands.repository.ModuleRepository;
|
||||
import dev.sheldan.abstracto.core.command.models.AModule;
|
||||
import dev.sheldan.abstracto.core.command.repository.ModuleRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package dev.sheldan.abstracto.core.commands;
|
||||
|
||||
import dev.sheldan.abstracto.command.Command;
|
||||
import dev.sheldan.abstracto.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.command.execution.Parameter;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.command.execution.Parameter;
|
||||
import dev.sheldan.abstracto.config.AbstractoFeatures;
|
||||
import dev.sheldan.abstracto.core.commands.utility.UtilityModule;
|
||||
import dev.sheldan.abstracto.core.commands.utility.UtilityModuleInterface;
|
||||
import dev.sheldan.abstracto.core.service.management.FeatureFlagManagementService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -33,7 +33,7 @@ public class Disable implements Command {
|
||||
List<Parameter> parameters = Arrays.asList(featureName);
|
||||
return CommandConfiguration.builder()
|
||||
.name("disable")
|
||||
.module(UtilityModule.UTILITY)
|
||||
.module(UtilityModuleInterface.UTILITY)
|
||||
.parameters(parameters)
|
||||
.description("Disables features for this server.")
|
||||
.causesReaction(true)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package dev.sheldan.abstracto.core.commands;
|
||||
|
||||
import dev.sheldan.abstracto.command.Command;
|
||||
import dev.sheldan.abstracto.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.command.execution.Parameter;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.command.execution.Parameter;
|
||||
import dev.sheldan.abstracto.config.AbstractoFeatures;
|
||||
import dev.sheldan.abstracto.core.commands.utility.UtilityModule;
|
||||
import dev.sheldan.abstracto.core.commands.utility.UtilityModuleInterface;
|
||||
import dev.sheldan.abstracto.core.service.management.FeatureFlagManagementService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -33,7 +33,7 @@ public class Enable implements Command {
|
||||
List<Parameter> parameters = Arrays.asList(featureName);
|
||||
return CommandConfiguration.builder()
|
||||
.name("enable")
|
||||
.module(UtilityModule.UTILITY)
|
||||
.module(UtilityModuleInterface.UTILITY)
|
||||
.parameters(parameters)
|
||||
.description("Enables features for this server.")
|
||||
.causesReaction(true)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package dev.sheldan.abstracto.core.commands.channels;
|
||||
|
||||
import dev.sheldan.abstracto.command.Command;
|
||||
import dev.sheldan.abstracto.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.command.execution.Parameter;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.command.execution.Parameter;
|
||||
import dev.sheldan.abstracto.config.AbstractoFeatures;
|
||||
import dev.sheldan.abstracto.core.service.ChannelGroupService;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package dev.sheldan.abstracto.core.commands.channels;
|
||||
|
||||
import dev.sheldan.abstracto.command.Module;
|
||||
import dev.sheldan.abstracto.command.module.ModuleInfo;
|
||||
import dev.sheldan.abstracto.core.command.ModuleInterface;
|
||||
import dev.sheldan.abstracto.core.command.module.ModuleInfo;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ChannelsModule implements Module {
|
||||
public class ChannelsModuleInterface implements ModuleInterface {
|
||||
@Override
|
||||
public ModuleInfo getInfo() {
|
||||
return ModuleInfo.builder().name("channels").description("Includes utilities to configure the channel configuration stored in the database").build();
|
||||
@@ -1,10 +1,10 @@
|
||||
package dev.sheldan.abstracto.core.commands.channels;
|
||||
|
||||
import dev.sheldan.abstracto.command.Command;
|
||||
import dev.sheldan.abstracto.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.command.execution.Parameter;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.command.execution.Parameter;
|
||||
import dev.sheldan.abstracto.config.AbstractoFeatures;
|
||||
import dev.sheldan.abstracto.core.service.ChannelGroupService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.sheldan.abstracto.core.commands.channels;
|
||||
|
||||
import dev.sheldan.abstracto.command.Command;
|
||||
import dev.sheldan.abstracto.command.execution.*;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.execution.*;
|
||||
import dev.sheldan.abstracto.config.AbstractoFeatures;
|
||||
import dev.sheldan.abstracto.core.models.command.PostTargetErrorModel;
|
||||
import dev.sheldan.abstracto.core.service.PostTargetService;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package dev.sheldan.abstracto.core.commands.channels;
|
||||
|
||||
import dev.sheldan.abstracto.command.Command;
|
||||
import dev.sheldan.abstracto.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.command.execution.Parameter;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.command.execution.Parameter;
|
||||
import dev.sheldan.abstracto.config.AbstractoFeatures;
|
||||
import dev.sheldan.abstracto.core.service.ChannelGroupService;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package dev.sheldan.abstracto.core.commands.help;
|
||||
|
||||
import dev.sheldan.abstracto.command.*;
|
||||
import dev.sheldan.abstracto.command.execution.*;
|
||||
import dev.sheldan.abstracto.command.module.ModuleInfo;
|
||||
import dev.sheldan.abstracto.command.service.ModuleRegistry;
|
||||
import dev.sheldan.abstracto.core.command.*;
|
||||
import dev.sheldan.abstracto.core.command.execution.*;
|
||||
import dev.sheldan.abstracto.core.command.module.ModuleInfo;
|
||||
import dev.sheldan.abstracto.core.command.service.ModuleRegistry;
|
||||
import dev.sheldan.abstracto.config.AbstractoFeatures;
|
||||
import dev.sheldan.abstracto.templating.TemplateService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -104,7 +104,7 @@ public class Help implements Command {
|
||||
if(depth > 0){
|
||||
intentation = StringUtils.repeat("-", depth) + ">";
|
||||
}
|
||||
ModuleInfo info = module.getModule().getInfo();
|
||||
ModuleInfo info = module.getModuleInterface().getInfo();
|
||||
sb.append(String.format(intentation +"**%s** \n", info.getName()));
|
||||
sb.append(String.format(intentation + "%s \n", info.getDescription()));
|
||||
if(recursive) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package dev.sheldan.abstracto.core.commands.help;
|
||||
|
||||
import dev.sheldan.abstracto.command.Module;
|
||||
import dev.sheldan.abstracto.command.module.ModuleInfo;
|
||||
import dev.sheldan.abstracto.core.command.ModuleInterface;
|
||||
import dev.sheldan.abstracto.core.command.module.ModuleInfo;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class SupportModule implements Module {
|
||||
public class SupportModuleInterface implements ModuleInterface {
|
||||
|
||||
|
||||
@Override
|
||||
@@ -1,12 +1,12 @@
|
||||
package dev.sheldan.abstracto.core.commands.utility;
|
||||
|
||||
import dev.sheldan.abstracto.command.Command;
|
||||
import dev.sheldan.abstracto.command.CommandCondition;
|
||||
import dev.sheldan.abstracto.command.HelpInfo;
|
||||
import dev.sheldan.abstracto.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.command.execution.Parameter;
|
||||
import dev.sheldan.abstracto.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.CommandCondition;
|
||||
import dev.sheldan.abstracto.core.command.HelpInfo;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.Parameter;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.config.AbstractoFeatures;
|
||||
import dev.sheldan.abstracto.core.models.command.EchoModel;
|
||||
import dev.sheldan.abstracto.templating.TemplateService;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package dev.sheldan.abstracto.core.commands.utility;
|
||||
|
||||
import dev.sheldan.abstracto.command.Command;
|
||||
import dev.sheldan.abstracto.command.CommandCondition;
|
||||
import dev.sheldan.abstracto.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.CommandCondition;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.config.AbstractoFeatures;
|
||||
import dev.sheldan.abstracto.core.models.command.PingModel;
|
||||
import dev.sheldan.abstracto.templating.TemplateService;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package dev.sheldan.abstracto.core.commands.utility;
|
||||
|
||||
import dev.sheldan.abstracto.command.Command;
|
||||
import dev.sheldan.abstracto.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.command.execution.Parameter;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.command.execution.Parameter;
|
||||
import dev.sheldan.abstracto.config.AbstractoFeatures;
|
||||
import dev.sheldan.abstracto.core.service.EmoteService;
|
||||
import dev.sheldan.abstracto.core.service.management.EmoteManagementService;
|
||||
@@ -46,7 +46,7 @@ public class SetEmote implements Command {
|
||||
List<Parameter> parameters = Arrays.asList(emoteKey, emote);
|
||||
return CommandConfiguration.builder()
|
||||
.name("setEmote")
|
||||
.module(UtilityModule.UTILITY)
|
||||
.module(UtilityModuleInterface.UTILITY)
|
||||
.parameters(parameters)
|
||||
.description("Configures the emote key pointing towards a defined emote")
|
||||
.causesReaction(true)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package dev.sheldan.abstracto.core.commands.utility;
|
||||
|
||||
import dev.sheldan.abstracto.command.Module;
|
||||
import dev.sheldan.abstracto.command.module.ModuleInfo;
|
||||
import dev.sheldan.abstracto.core.command.ModuleInterface;
|
||||
import dev.sheldan.abstracto.core.command.module.ModuleInfo;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class UtilityModule implements Module {
|
||||
public class UtilityModuleInterface implements ModuleInterface {
|
||||
|
||||
public static final String UTILITY = "utility";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.sheldan.abstracto.command;
|
||||
package dev.sheldan.abstracto.core.command;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -0,0 +1,12 @@
|
||||
package dev.sheldan.abstracto.core.command;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.listener.FeatureAware;
|
||||
|
||||
public interface Command extends FeatureAware {
|
||||
|
||||
CommandResult execute(CommandContext commandContext);
|
||||
CommandConfiguration getConfiguration();
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package dev.sheldan.abstracto.command;
|
||||
package dev.sheldan.abstracto.core.command;
|
||||
|
||||
import dev.sheldan.abstracto.command.execution.CommandContext;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
|
||||
public interface CommandCondition {
|
||||
boolean shouldExecute(CommandContext commandContext, Command command);
|
||||
@@ -1,10 +1,9 @@
|
||||
package dev.sheldan.abstracto.command;
|
||||
package dev.sheldan.abstracto.core.command;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Getter @Builder
|
||||
public class CommandHierarchy {
|
||||
@@ -21,7 +20,7 @@ public class CommandHierarchy {
|
||||
}
|
||||
|
||||
private PackedModule getModuleWithName(String name, PackedModule module){
|
||||
if(module.getModule().getInfo().getName().equals(name)){
|
||||
if(module.getModuleInterface().getInfo().getName().equals(name)){
|
||||
return module;
|
||||
} else {
|
||||
for (PackedModule subModule: module.getSubModules()) {
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.sheldan.abstracto.command;
|
||||
package dev.sheldan.abstracto.core.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.sheldan.abstracto.command;
|
||||
package dev.sheldan.abstracto.core.command;
|
||||
|
||||
import dev.sheldan.abstracto.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.service.management.FeatureFlagManagementService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.sheldan.abstracto.command;
|
||||
package dev.sheldan.abstracto.core.command;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
@@ -0,0 +1,9 @@
|
||||
package dev.sheldan.abstracto.core.command;
|
||||
|
||||
|
||||
import dev.sheldan.abstracto.core.command.module.ModuleInfo;
|
||||
|
||||
public interface ModuleInterface {
|
||||
ModuleInfo getInfo();
|
||||
String getParentModule();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.sheldan.abstracto.command;
|
||||
package dev.sheldan.abstracto.core.command;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
@@ -8,7 +8,7 @@ import java.util.List;
|
||||
@Builder
|
||||
@Getter
|
||||
public class PackedModule {
|
||||
private Module module;
|
||||
private ModuleInterface moduleInterface;
|
||||
private PackedModule parentModule;
|
||||
private List<PackedModule> subModules;
|
||||
private List<Command> commands;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.sheldan.abstracto.command;
|
||||
package dev.sheldan.abstracto.core.command;
|
||||
|
||||
public interface Templatable {
|
||||
String getTemplateName();
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.sheldan.abstracto.command.execution;
|
||||
package dev.sheldan.abstracto.core.command.execution;
|
||||
|
||||
import dev.sheldan.abstracto.command.HelpInfo;
|
||||
import dev.sheldan.abstracto.core.command.HelpInfo;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package dev.sheldan.abstracto.command.execution;
|
||||
package dev.sheldan.abstracto.core.command.execution;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.UserInitiatedServerContext;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
|
||||
@Builder
|
||||
@Getter
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.sheldan.abstracto.command.execution;
|
||||
package dev.sheldan.abstracto.core.command.execution;
|
||||
|
||||
|
||||
import lombok.Builder;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.sheldan.abstracto.command.execution;
|
||||
package dev.sheldan.abstracto.core.command.execution;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.UserInitiatedServerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.sheldan.abstracto.command.execution;
|
||||
package dev.sheldan.abstracto.core.command.execution;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.sheldan.abstracto.command.execution;
|
||||
package dev.sheldan.abstracto.core.command.execution;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.sheldan.abstracto.command.execution;
|
||||
package dev.sheldan.abstracto.core.command.execution;
|
||||
|
||||
public enum ResultState {
|
||||
ERROR, SUCCESSFUL, IGNORED
|
||||
@@ -1,8 +1,9 @@
|
||||
package dev.sheldan.abstracto.command.meta;
|
||||
package dev.sheldan.abstracto.core.command.meta;
|
||||
|
||||
|
||||
import dev.sheldan.abstracto.command.Command;
|
||||
import dev.sheldan.abstracto.command.Module;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.ModuleInterface;
|
||||
import dev.sheldan.abstracto.core.command.module.ModuleInfo;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
|
||||
import java.util.List;
|
||||
@@ -11,6 +12,6 @@ public interface CommandRegistry {
|
||||
Command findCommandByParameters(String name, UnParsedCommandParameter context);
|
||||
Command findCommand(String message);
|
||||
List<Command> getAllCommands();
|
||||
List<Command> getAllCommandsFromModule(Module module);
|
||||
List<Command> getAllCommandsFromModule(ModuleInterface module);
|
||||
boolean isCommand(Message message);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.sheldan.abstracto.command.meta;
|
||||
package dev.sheldan.abstracto.core.command.meta;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package dev.sheldan.abstracto.core.command.models;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.database.AChannelGroup;
|
||||
import lombok.*;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "channel_group_command")
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public class AChannelGroupCommand {
|
||||
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "command_id", nullable = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@Column
|
||||
private ACommand command;
|
||||
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "group_id", nullable = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@Column
|
||||
private AChannelGroup group;
|
||||
|
||||
private Boolean enabled;
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.sheldan.abstracto.command.models;
|
||||
package dev.sheldan.abstracto.core.command.models;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.sheldan.abstracto.command.models;
|
||||
package dev.sheldan.abstracto.core.command.models;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@@ -1,10 +1,10 @@
|
||||
package dev.sheldan.abstracto.command.module;
|
||||
package dev.sheldan.abstracto.core.command.module;
|
||||
|
||||
import dev.sheldan.abstracto.command.Module;
|
||||
import dev.sheldan.abstracto.core.command.ModuleInterface;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AbstracatoModule implements Module {
|
||||
public class AbstracatoModuleInterface implements ModuleInterface {
|
||||
@Override
|
||||
public ModuleInfo getInfo() {
|
||||
return ModuleInfo.builder().name("default").description("Default module provided by abstracto").build();
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.sheldan.abstracto.command.module;
|
||||
package dev.sheldan.abstracto.core.command.module;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.sheldan.abstracto.command.service;
|
||||
package dev.sheldan.abstracto.core.command.service;
|
||||
|
||||
import dev.sheldan.abstracto.command.models.ACommand;
|
||||
import dev.sheldan.abstracto.core.command.models.ACommand;
|
||||
|
||||
public interface CommandService {
|
||||
ACommand createCommand(String name, String moduleName);
|
||||
@@ -0,0 +1,12 @@
|
||||
package dev.sheldan.abstracto.core.command.service;
|
||||
|
||||
|
||||
import dev.sheldan.abstracto.core.command.CommandHierarchy;
|
||||
import dev.sheldan.abstracto.core.command.ModuleInterface;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ModuleRegistry {
|
||||
CommandHierarchy getDetailedModules();
|
||||
List<ModuleInterface> getModuleInterfaces();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package dev.sheldan.abstracto.core.command.service;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
|
||||
public interface PostCommandExecution {
|
||||
void execute(CommandContext commandContext, CommandResult commandResult, Command command);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.sheldan.abstracto.command.service.management;
|
||||
package dev.sheldan.abstracto.core.command.service.management;
|
||||
|
||||
import dev.sheldan.abstracto.command.models.ACommand;
|
||||
import dev.sheldan.abstracto.command.models.AModule;
|
||||
import dev.sheldan.abstracto.core.command.models.ACommand;
|
||||
import dev.sheldan.abstracto.core.command.models.AModule;
|
||||
|
||||
public interface CommandManagementService {
|
||||
ACommand createCommand(String name, String moduleName);
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.sheldan.abstracto.command.service.management;
|
||||
package dev.sheldan.abstracto.core.command.service.management;
|
||||
|
||||
import dev.sheldan.abstracto.command.models.AModule;
|
||||
import dev.sheldan.abstracto.core.command.models.AModule;
|
||||
|
||||
public interface ModuleManagementService {
|
||||
AModule createModule(String name);
|
||||
@@ -0,0 +1,32 @@
|
||||
package dev.sheldan.abstracto.core.models.database;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.models.ACommand;
|
||||
import lombok.*;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "channel_group_command")
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public class AChannelGroupCommand {
|
||||
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "command_id", nullable = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@Column
|
||||
private ACommand command;
|
||||
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "group_id", nullable = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@Column
|
||||
private AChannelGroup group;
|
||||
|
||||
private Boolean enabled;
|
||||
|
||||
}
|
||||
@@ -49,13 +49,6 @@
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.command</groupId>
|
||||
<artifactId>command-impl</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- modules containing commands -->
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<modules>
|
||||
<module>command</module>
|
||||
<module>core</module>
|
||||
<module>executable</module>
|
||||
<module>templating</module>
|
||||
|
||||
Reference in New Issue
Block a user