Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/discord4j/moduleloader
A simple module and classloading system forked from Discord4J
https://github.com/discord4j/moduleloader
addon loader mod modular module plugin
Last synced: 9 days ago
JSON representation
A simple module and classloading system forked from Discord4J
- Host: GitHub
- URL: https://github.com/discord4j/moduleloader
- Owner: Discord4J
- License: lgpl-3.0
- Created: 2018-05-27T12:40:52.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-05-27T15:07:46.000Z (over 6 years ago)
- Last Synced: 2024-04-14T01:09:57.809Z (9 months ago)
- Topics: addon, loader, mod, modular, module, plugin
- Language: Java
- Homepage: https://discord4j.com/
- Size: 14.6 KB
- Stars: 1
- Watchers: 7
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ModuleLoader
This is a fork/adaption of module loading system from v2.X of
[Discord4J](https://github.com/Discord4J/Discord4J/). It has been adapted
such that it can be used independently of Discord4J.## Notice
This is the culmination of ~3 years of development so the current codebase
should be stable enough to use in a production environment. However, it will
no longer receive regular updates as the focus of development is on v3 of
Discord4J. That being said, pull requests and issue reports are still encouraged.## Using the ModuleLoader
### Importing the project
Using maven:
```xml
jitpack.io
https://jitpack.io
com.github.Discord4J
ModuleLoader
1.0.0
```
Using gradle:
```groovy
repositories {
maven {
url "https://jitpack.io"
}
}dependencies {
compile "com.github.Discord4J:ModuleLoader:1.0.0"
}
```
### Dealing with modules
Module loading:
```java
ModuleLoader loader = new ModuleLoader("1.0.0", HashMap::new); //App version = 1.0.0 and we don't have extra properties
//That's it! All module jars in the ./modules dir are now loaded.//Manual loading works like this:
loader.enableModule(new MyModule()); //Where MyModule implements IModule
```
Creating modules:Create a class that implements IModule:
```java
public class MyModule implements IModule {
@Override
public boolean enable(Map options) {
return true; //Enabled!
}@Override
public void disable() {
//Disabled!
}@Override
public String getName() {
return "MyModule";
}@Override
public String getAuthor() {
return "Austin";
}@Override
public String getVersion() {
return "1.0.0-SNAPSHOT";
}@Override
public String getMinimumApplicationVersion() {
return "0.0.1";
}
}
```
Then compile it into its own jar and place it in the auto-generated `modules` directory.
To improve module loading perfomance, include a MANIFEST.MF file that looks something like this:
```manifest
Manifest-version: 1.0
Created-By: 1.0 (Austin)
Module-Class: my.package.MyModule```