Creating Extensions (Modules) - TheSourceCodeLLC/Source GitHub Wiki

Creating Extensions (Modules)

First and foremost, Extensions that have been deemed official are housed in the net.sourcebot.module package. If you are not interested in creating an official module, please do not use this package when creating your module. If you are not creating an official module, you should not be working in the Source git tree, so that you do not commit your module to the repository. Pull requests that introduce unofficial modules will not be merged.

Writing Official Extensions

  1. Fork the repository and clone it locally
  2. Introduce a new Gradle submodule in the Extensions parent module
  3. Create a module.json in your submodule's main/resources folder using the following template: Make sure you leave ${} variables alone; they are processed by Gradle!
{
  "main": "net.sourcebot.module.(module name).(main class name)",
  "name": "${project.name}",
  "version": "${project.version}",
  "description": "${project.description}",
  "author": "(your name or discord tag)"
}
  1. Create a class at the path net.sourcebot.module.(module name).(main class name)
  2. Make this new class extend SourceModule i.e:
package net.sourcebot.module.mymodule

class MyModule : SourceModule()
  1. From here on, you may override methods in the MyModule class (example) such as onEnable() or onDisable()
  2. Commit your changes to your repository, and open a Pull Request when you are ready.

Writing Unofficial Extensions

  1. Depend on net.sourcebot:API
  2. Create a class that extends SourceModule, this will be your main class:
class MyModule : SourceModule()
  1. Create a module.json in your main/resources folder using the following template:
{
  "main": "(path to main class)",
  "name": "(module name)",
  "version": "(module version)",
  "description": "(module description",
  "author": "(your name or discord tag)"
}
  1. Override methods in the MyModule class (example) such as onEnable() or onDisable()