Skip to content
This repository has been archived by the owner on Feb 8, 2021. It is now read-only.

Commit

Permalink
[BREAKING] Package Refractor & ArchTasks
Browse files Browse the repository at this point in the history
Behaviors have now been deprecated with ArchTasks temporarily replacing them. ArchTasks are here to stay but the modularity of behaviors is not currently present. These changes haven't been tested yet & there's more to come before the next full release (Such as TriArch Beta, the SecurityManager, and a better Plugin Manager)
  • Loading branch information
squeeglii committed Jul 15, 2019
1 parent a551444 commit 7f0c8c8
Show file tree
Hide file tree
Showing 101 changed files with 1,087 additions and 1,185 deletions.

This file was deleted.

938 changes: 464 additions & 474 deletions .idea/workspace.xml

Large diffs are not rendered by default.

24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,27 @@ Supported types include:
- uint (Unsigned int)
- array (Value should have items seperated by ",")
- map (Value is like an array but each item should have a key and a value seperated by a ":")
- json (Not quite supported)

### TextDB
Unfinished. Will be documented fully on the plugin release. It's a "replacement" for regular databases, for example if a database goes offline and you need a backup. It's also useful for smaller Databases.
### ArchTasks

### TriArch (Scripting lang)
WIP

### And a few more which are generally self explanatory like:
- CommandManager (A simple command manager with help, management, and listing)
- Multichannel Event Loop (Events which can target channels which listeners can ignore)
- Logging (A fancy logging system cause why not.)
- Behaviors (Reprogrammable parts of the system which plugins can fully replace)
- Behaviors are slowly being added as bot components get finalized so there aren't many.
- We hope behaviors are adopted by plugins to make systems better.
- One of the current reprogrammable parts is the command dispatcher. It provides a raw command (Message For)

---

### A few things planned have also been dropped to like:
- Behaviors
- They're fully implemented and in the latest build but have been deprecated.
- The core has been seperated from this system so Behaviors only work between plugins.
- TextDB
- Never recieved a full implementation.
- There are tons of alternatives, some which do the same thing but better. More Database APIs will be added in the future with simpler interfaces.
- ConfigPlus json support
- Do I even have to explain how stupid of an idea that is? Just use json files.

The ideas above are not planned to be reimplemented as they were removed because they were either replaced by something better or were just stupid ideas.
2 changes: 1 addition & 1 deletion archt5.iml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<orderEntry type="library" name="Maven: com.neovisionaries:nv-websocket-client:2.2" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp:3.8.1" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okio:okio:1.13.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.7" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.9" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.11" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.11" level="project" />
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<configuration>
<archive>
<manifest>
<mainClass>net.cloudsbots.archseriest.archt5.Main</mainClass>
<mainClass>io.cloudsbots.arch.archt5.Main</mainClass>
</manifest>
</archive>
</configuration>
Expand All @@ -43,7 +43,7 @@
<configuration>
<archive>
<manifest>
<mainClass>net.cloudsbots.archseriest.archt5.Main</mainClass>
<mainClass>io.cloudsbots.arch.archt5.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package net.cloudsbots.archseriest.archt5;

import net.cloudsbots.archseriest.archt5.commands.CommandManager;
import net.cloudsbots.archseriest.archt5.behaviorchunks.BehaviorManager;
import net.cloudsbots.archseriest.archt5.components.Logger;
import net.cloudsbots.archseriest.archt5.components.Statistics;
import net.cloudsbots.archseriest.archt5.components.UtilityFunctions;
import net.cloudsbots.archseriest.archt5.events.EventManager;
import net.cloudsbots.archseriest.archt5.exceptions.PermissionDeniedException;
import net.cloudsbots.archseriest.archt5.plugin.DisableReason;
import net.cloudsbots.archseriest.archt5.plugin.PluginManager;
import net.cloudsbots.archseriest.archt5.plugin.PluginPackaging;
package io.cloudsbots.arch.archt5;

import io.cloudsbots.arch.archt5.commands.CommandManager;
import io.cloudsbots.arch.archt5.components.Logger;
import io.cloudsbots.arch.archt5.components.Statistics;
import io.cloudsbots.arch.archt5.components.UtilityFunctions;
import io.cloudsbots.arch.archt5.events.EventManager;
import io.cloudsbots.arch.archt5.exceptions.PermissionDeniedException;
import io.cloudsbots.arch.archt5.plugin.DisableReason;
import io.cloudsbots.arch.archt5.plugin.PluginManager;
import io.cloudsbots.arch.archt5.plugin.PluginPackaging;
import io.cloudsbots.arch.archt5.tasks.TaskManager;
import io.cloudsbots.arch.archt5.behaviorchunks.BehaviorManager;
import net.dv8tion.jda.core.JDA;

import java.util.HashMap;
Expand All @@ -22,7 +23,7 @@ public class Bot {

static {
log = new Logger();
//Thread.setDefaultUncaughtExceptionHandler(log);
Thread.setDefaultUncaughtExceptionHandler(log);
}

private String pass;
Expand All @@ -32,18 +33,19 @@ public Bot(String syspass){
logger = log;
statistics = new Statistics();
eventManager = new EventManager();
behaviorManager = new BehaviorManager(pass);
taskManager = new TaskManager();
behaviorManager = new BehaviorManager(pass); //TODO: Move behaviors to a plugin. Remove them from core codebase.
commandManager = new CommandManager(pass);
}

public static final String BRANCH_NAME = "DEV5";
public static final String MILESTONE_VERSION = "0.1.0";
public static final String BUILD_VERSION = "ADP191201"; //Example - Alpha Version, Development Build, Private Beta, 2018, Week 52, Build 01 of that week = ADP185201
public static final int BUILD_STRUCTURE = 1; // If there's a major code change which is breaking of old features, increment this.
public static final int BUILD_STRUCTURE = 2; // If there's a major code change which is breaking of old features, increment this.
public static final String BUILD_DATE = "27/12/18"; // dd/mm/yy

public static final String AUTHOR = "CloudG360";
public static final String WEBSITE = "https://discordapp.com/";
public static final String WEBSITE = "https://discordapp.com/"; //TODO: Point to a wiki
public static final String PREFIX = "Hey Arch! ";

private EventManager eventManager;
Expand All @@ -52,6 +54,7 @@ public Bot(String syspass){
private CommandManager commandManager;
private Statistics statistics;
private PluginManager pluginManager;
private TaskManager taskManager;

private boolean pluginManagerSet = false;

Expand All @@ -69,10 +72,12 @@ public Bot(String syspass){
public Logger getLogger() { return getBot().logger; }
public HashMap<String, Object> getSessionConfig() { return getBot().session_config; }
public boolean isDiscordActive() { return discord_active; }
@Deprecated
public BehaviorManager getBehaviorManager() { return behaviorManager; }
public CommandManager getCommandManager() { return commandManager; }
public Statistics getStatisticsHub() { return statistics; }
public PluginManager getPluginManager() { return pluginManager; }
public TaskManager getTaskManager() { return taskManager; }

public void setPluginManager(PluginManager pluginManager){
if(!pluginManagerSet){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package net.cloudsbots.archseriest.archt5;

package io.cloudsbots.arch.archt5;

import io.cloudsbots.arch.archt5.components.BotEventsProcessor;
import io.cloudsbots.arch.archt5.components.CoreEventProcessor;
import io.cloudsbots.arch.archt5.components.Logger;
import io.cloudsbots.arch.archt5.config.ConfigurationFile;
import io.cloudsbots.arch.archt5.events.CallableEvent;
import io.cloudsbots.arch.archt5.events.EventChannel;
import io.cloudsbots.arch.archt5.exceptions.PermissionDeniedException;
import io.cloudsbots.arch.archt5.exceptions.RethrownException;
import io.cloudsbots.arch.archt5.plugin.Plugin;
import io.cloudsbots.arch.archt5.plugin.PluginManager;
import io.cloudsbots.arch.archt5.plugin.PluginPackaging;
import io.cloudsbots.arch.archt5.plugin.SystemPlugin;
import javafx.util.Pair;
import net.cloudsbots.archseriest.archt5.commands.CommandManager;
import net.cloudsbots.archseriest.archt5.commands.Core.CommandBotStats;
import net.cloudsbots.archseriest.archt5.commands.Core.CommandHelp;
import net.cloudsbots.archseriest.archt5.behaviorchunks.BehaviorManager;
import net.cloudsbots.archseriest.archt5.behaviorchunks.CoreBehaviors.BehaviorCommandProcess;
import net.cloudsbots.archseriest.archt5.components.BotEventsProcessor;
import net.cloudsbots.archseriest.archt5.components.CoreEventProcessor;
import net.cloudsbots.archseriest.archt5.components.Logger;
import net.cloudsbots.archseriest.archt5.config.ConfigurationFile;
import net.cloudsbots.archseriest.archt5.events.CallableEvent;
import net.cloudsbots.archseriest.archt5.events.EventChannel;
import net.cloudsbots.archseriest.archt5.exceptions.PermissionDeniedException;
import net.cloudsbots.archseriest.archt5.exceptions.RethrownException;
import net.cloudsbots.archseriest.archt5.plugin.*;
import io.cloudsbots.arch.archt5.plugin.*;
import net.dv8tion.jda.core.AccountType;
import net.dv8tion.jda.core.JDABuilder;
import net.dv8tion.jda.core.OnlineStatus;
Expand Down Expand Up @@ -97,6 +96,7 @@ public static void main(String[] args){

}

//TODO: Just make it package private ffs.
public static PluginPackaging getSysPlugin(String password) {
if(password.toLowerCase().equals(pass.toLowerCase())) {
return plugin;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package net.cloudsbots.archseriest.archt5.behaviorchunks;
package io.cloudsbots.arch.archt5.behaviorchunks;

import net.cloudsbots.archseriest.archt5.components.Statistics;
import net.cloudsbots.archseriest.archt5.exceptions.RethrownException;

import java.util.concurrent.TimeUnit;
import io.cloudsbots.arch.archt5.components.Statistics;

@Deprecated
public abstract class Behavior extends Bh {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package net.cloudsbots.archseriest.archt5.behaviorchunks;
package io.cloudsbots.arch.archt5.behaviorchunks;

import io.cloudsbots.arch.archt5.Bot;
import io.cloudsbots.arch.archt5.Main;
import io.cloudsbots.arch.archt5.behaviorchunks.CoreBehaviors.BehaviorNotFound;
import io.cloudsbots.arch.archt5.components.Validator;
import io.cloudsbots.arch.archt5.events.CallableEvent;
import io.cloudsbots.arch.archt5.events.EventChannel;
import io.cloudsbots.arch.archt5.exceptions.PermissionDeniedException;
import io.cloudsbots.arch.archt5.plugin.Plugin;
import io.cloudsbots.arch.archt5.plugin.PluginPackaging;
import io.cloudsbots.arch.archt5.plugin.PluginState;
import io.cloudsbots.arch.archt5.plugin.SystemPlugin;
import javafx.util.Pair;
import net.cloudsbots.archseriest.archt5.Bot;
import net.cloudsbots.archseriest.archt5.Main;
import net.cloudsbots.archseriest.archt5.behaviorchunks.CoreBehaviors.BehaviorCommandProcess;
import net.cloudsbots.archseriest.archt5.behaviorchunks.CoreBehaviors.BehaviorNotFound;
import net.cloudsbots.archseriest.archt5.components.Validator;
import net.cloudsbots.archseriest.archt5.events.CallableEvent;
import net.cloudsbots.archseriest.archt5.events.EventChannel;
import net.cloudsbots.archseriest.archt5.exceptions.BehaviorNotFoundException;
import net.cloudsbots.archseriest.archt5.exceptions.PermissionDeniedException;
import net.cloudsbots.archseriest.archt5.plugin.Plugin;
import net.cloudsbots.archseriest.archt5.plugin.PluginPackaging;
import net.cloudsbots.archseriest.archt5.plugin.PluginState;
import net.cloudsbots.archseriest.archt5.plugin.SystemPlugin;

import java.util.ArrayList;
import java.util.HashMap;
Expand All @@ -31,7 +29,7 @@ public final class BehaviorManager {

public void defaultBehavior(Plugin plugin, String name, String pass){
if(name.toLowerCase().equals("cmd_pcs")){
behaviors.put(name.toLowerCase(), new BehaviorCommandProcess());
behaviors.put(name.toLowerCase(), new BehaviorNotFound());
} else {
if(behaviors.containsKey(name.toLowerCase())){
Behavior b = behaviors.get(name.toLowerCase());
Expand All @@ -54,11 +52,25 @@ public void defaultBehavior(Plugin plugin, String name, String pass){
}
}

/**
* Registers a modular behavior without any password protection.
*
* Deprecation - Replaced by ArchTasks and TriArch (Scripting) as
* they are designed better and can tie into the security manager better.
*/
@Deprecated
public void registerBehavior(String name, Behavior behavior, PluginPackaging plugin){ registerBehavior(name, behavior, plugin, ""); }

/**
* Registers a modular behavior which is password protected. Behaviors can
* be ran with the run Behavior function.
*
* Deprecation - Replaced by ArchTasks and TriArch (Scripting) as
* they are designed better and can tie into the security manager better.
*/
@Deprecated
public boolean registerBehavior(String name, Behavior behavior, PluginPackaging plugin, String password){
if(Bot.getBot().getPluginManager().getPluginState(plugin) != PluginState.ENABLED){
//TODO: #BanSpot
throw new PermissionDeniedException("Plugin State Error: Disabled/Banned/Unloaded plugins cannot register behaviors");
}
if(behaviors.containsKey(name.toLowerCase())){
Expand All @@ -85,6 +97,13 @@ public boolean registerBehavior(String name, Behavior behavior, PluginPackaging
}
}

/**
* Runs a registered behavior.
*
* Deprecation - Replaced by ArchTasks and TriArch (Scripting) as
* they are designed better and can tie into the security manager better.
*/
@Deprecated
public Behavior runBehavior(String name, Object... params){
Validator.notNull(name, "Running Behavior");
new CallableEvent(Main.getSysPlugin(pass), "behaviors.run."+name, new Pair<>("VERIF", Bot.getBot().getSession().toString())).call(EventChannel.SYSTEM, true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.cloudsbots.archseriest.archt5.behaviorchunks;
package io.cloudsbots.arch.archt5.behaviorchunks;

public abstract class Bh {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.cloudsbots.archseriest.archt5.behaviorchunks.CoreBehaviors;
package io.cloudsbots.arch.archt5.behaviorchunks.CoreBehaviors;

import net.cloudsbots.archseriest.archt5.Bot;
import net.cloudsbots.archseriest.archt5.behaviorchunks.Behavior;
import io.cloudsbots.arch.archt5.Bot;
import io.cloudsbots.arch.archt5.behaviorchunks.Behavior;

public class BehaviorNotFound extends Behavior {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.cloudsbots.archseriest.archt5.commands;
package io.cloudsbots.arch.archt5.commands;

import net.cloudsbots.archseriest.archt5.components.Statistics;
import io.cloudsbots.arch.archt5.components.Statistics;
import net.dv8tion.jda.core.entities.Message;

public abstract class Command {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package net.cloudsbots.archseriest.archt5.commands;
package io.cloudsbots.arch.archt5.commands;

import javafx.util.Pair;
import net.cloudsbots.archseriest.archt5.Bot;
import net.cloudsbots.archseriest.archt5.Main;
import net.cloudsbots.archseriest.archt5.behaviorchunks.BehaviorManager;
import net.cloudsbots.archseriest.archt5.events.CallableEvent;
import net.cloudsbots.archseriest.archt5.events.EventChannel;
import net.cloudsbots.archseriest.archt5.exceptions.CommandClashException;
import net.cloudsbots.archseriest.archt5.plugin.Plugin;
import net.cloudsbots.archseriest.archt5.plugin.PluginPackaging;
import net.dv8tion.jda.core.entities.Message;
import io.cloudsbots.arch.archt5.Bot;
import io.cloudsbots.arch.archt5.Main;
import io.cloudsbots.arch.archt5.events.CallableEvent;
import io.cloudsbots.arch.archt5.events.EventChannel;
import io.cloudsbots.arch.archt5.exceptions.CommandClashException;
import io.cloudsbots.arch.archt5.plugin.Plugin;
import io.cloudsbots.arch.archt5.plugin.PluginPackaging;

import java.util.*;

Expand Down

0 comments on commit 7f0c8c8

Please sign in to comment.