Skip to content

Commit

Permalink
Merge branch 'dev' into docs
Browse files Browse the repository at this point in the history
# Conflicts:
#	docs/api/plugins.md
  • Loading branch information
topi314 committed Oct 12, 2023
2 parents edb9524 + 76ef7c7 commit f362f94
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 7 deletions.
11 changes: 8 additions & 3 deletions LavalinkServer/application.yml.example
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
server: # REST and WS server
port: 2333
address: 0.0.0.0
http2:
enabled: false # Whether to enable HTTP/2 support
plugins:
# name: # Name of the plugin
# some_key: some_value # Some key-value pair for the plugin
# another_key: another_value
lavalink:
plugins:
# - dependency: "group:artifact:version"
# repository: "repository"
pluginsDir: "./plugins"
# - dependency: "com.github.example:example-plugin:1.0.0" # required, the coordinates of your plugin
# repository: "https://maven.example.com/releases" # optional, defaults to the Lavalink releases repository by default
# snapshot: false # optional, defaults to false, used to tell Lavalink to use the snapshot repository instead of the release repository
# pluginsDir: "./plugins" # optional, defaults to "./plugins"
# defaultPluginRepository: "https://maven.lavalink.dev/releases" # optional, defaults to the Lavalink release repository
# defaultPluginSnapshotRepository: "https://maven.lavalink.dev/snapshots" # optional, defaults to the Lavalink snapshot repository
server:
password: "youshallnotpass"
sources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ class PluginManager(val config: PluginsConfig) {
data class Declaration(val group: String, val name: String, val version: String, val repository: String)

val declarations = config.plugins.map { declaration ->
if (declaration.dependency == null || declaration.repository == null) throw RuntimeException("Illegal declaration $declaration")
if (declaration.dependency == null) throw RuntimeException("Illegal dependency declaration: null")
val fragments = declaration.dependency!!.split(":")
if (fragments.size != 3) throw RuntimeException("Invalid dependency \"${declaration.dependency}\"")
val repository =

var repository = declaration.repository
?: if (declaration.snapshot) config.defaultPluginSnapshotRepository else config.defaultPluginRepository
repository =
if (declaration.repository!!.endsWith("/")) declaration.repository!! else declaration.repository!! + "/"
Declaration(fragments[0], fragments[1], fragments[2], repository)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import org.springframework.stereotype.Component
class PluginsConfig {
var plugins: List<PluginDeclaration> = emptyList()
var pluginsDir: String = "./plugins"
var defaultPluginRepository: String = "https://maven.lavalink.dev/releases"
var defaultPluginSnapshotRepository: String = "https://maven.lavalink.dev/snapshots"
}

data class PluginDeclaration(
var dependency: String? = null,
var repository: String? = null
var repository: String? = null,
var snapshot: Boolean = false
)
32 changes: 31 additions & 1 deletion docs/api/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: Make your own plugin for Lavalink.
> **Note:**
> If your plugin is developed in Kotlin make sure you are using **Kotlin v1.8.22**
Follow [these steps](https://github.com/lavalink-devs/lavalink-plugin-template#how-to-use-this-template) to setup a new Lavalink plugin
Follow [these steps](https://github.com/lavalink-devs/lavalink-plugin-template#how-to-use-this-template) to set up a new Lavalink plugin

Now you can start writing your plugin. You can test your plugin against Lavalink by running Gradle with the
`:runLavalink` Gradle task. The [Gradle plugin documentation](https://github.com/lavalink-devs/lavalink-gradle-plugin#running-the-plugin) might be helpful.
Expand Down Expand Up @@ -67,4 +67,34 @@ import dev.arbjerg.lavalink.api.AudioPluginInfoModifier;
class TestAudioPluginInfoModifier implements AudioPluginInfoModifier {
// ...
}
```

# Distributing your plugin

The official plugin repository is hosted on https://maven.lavalink.dev. If you want to publish your plugin there, please reach out to us via [Discord](https://discord.gg/ZW4s47Ppw4) for credentials.
The Lavalink team has release (https://maven.lavalink.dev/releases) and snapshot (https://maven.lavalink.dev/snapshots) repositories which you can use to publish your plugin.
By default, Lavalink will look for the plugin in the Lavalink repository, but you can also specify a custom repository for each plugin in your `application.yml` file.

```yaml

lavalink:
plugins:
- dependency: "com.github.example:example-plugin:x.y.z" # required, the dependency to your plugin
repository: "https://maven.example.com/releases" # optional, defaults to https://maven.lavalink.dev/releases for releases
snapshot: false # optional, defaults to false, used to tell Lavalink to use the snapshot repository instead of the release repository
```
The default repositories can also be overridden in your `application.yml` file.

```yaml
lavalink:
defaultPluginRepository: "https://maven.example.com/releases" # optional, defaults to https://maven.lavalink.dev/releases
defaultPluginSnapshotRepository: "https://maven.example.com/snapshots" # optional, defaults to https://maven.lavalink.dev/snapshots
```

Additionally, you can override the default plugin path where Lavalink saves and loads the downloaded plugins.

```yaml
lavalink:
pluginsDir: "./lavalink-plugins" # optional, defaults to "./plugins"
```
3 changes: 3 additions & 0 deletions docs/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ For arrays, the index is appended to the key, starting at 0. For example, `LAVAL
```env title="enviroment variables"
SERVER_PORT
SERVER_ADDRESS
SERVER_HTTP2_ENABLED
LAVALINK_PLUGINS_0_DEPENDENCY
LAVALINK_PLUGINS_0_REPOSITORY
Expand All @@ -36,6 +37,8 @@ LAVALINK_PLUGINS_1_DEPENDENCY
LAVALINK_PLUGINS_1_REPOSITORY
LAVALINK_PLUGINS_DIR
LAVALINK_DEFAULT_PLUGIN_REPOSITORY
LAVALINK_DEFAULT_PLUGIN_SNAPSHOT_REPOSITORY
LAVALINK_SERVER_PASSWORD
LAVALINK_SERVER_SOURCES_YOUTUBE
Expand Down

0 comments on commit f362f94

Please sign in to comment.