8000 Initial version of uuid idea · DuncteBot/lavalink-track-uuid@4ae6f21 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4ae6f21

Browse files
committed
Initial version of uuid idea
1 parent 2714483 commit 4ae6f21

File tree

8 files changed

+69
-77
lines changed

8 files changed

+69
-77
lines changed

README.md

+2-44
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,3 @@
1-
# lavalink-plugin-template
1+
# uuid-plugin
22

3-
This is a template for creating a plugin for [Lavalink](https://github.com/lavalink-devs/Lavalink). It is written in
4-
java, but you can also use kotlin (version `1.8.22`) if you want.
5-
6-
## How to use this template
7-
8-
1. Clone this repository
9-
2. Rename the package `com.example.plugin` to your package name
10-
3. Rename the class `ExamplePlugin` to your plugin name
11-
4. Rename the file `ExamplePlugin.java` to your plugin name
12-
5. fill in the `lavalinkPlugin` in [build.gradle.kts](build.gradle.kts)
13-
6. Write your plugin
14-
15-
## How to test your plugin
16-
17-
1. Place a `application.yml` file in the root directory
18-
2. Run `./gradlew runLavalink` (for windows: `./gradlew.bat runLavalink`) in the root directory
19-
3. The plugin will be loaded
20-
4. You can now test your plugin
21-
5. If you change something in the plugin, you can just run `./gradlew runLavalink` again
22-
23-
## How to build your plugin
24-
25-
1. Run `./gradlew build` (for windows: `./gradlew.bat build`) in the root directory
26-
2. The jar file will be in `build/libs/`
27-
28-
## How to publish your plugin
29-
30-
This template uses [jitpack](https://jitpack.io/) to publish the plugin. You just need to push your changes to github
31-
and jitpack will build the plugin for you.
32-
33-
## How to use your plugin
34-
35-
```yml
36-
lavalink:
37-
plugins:
38-
- dependency: com.github.lavalink:lavalink-plugin-template:{VERSION} # replace {VERSION} with the version you want to use
39-
repository: https://jitpack.io
40-
```
41-
42-
## How to get help
43-
44-
If you need help, you can join the [Lavalink Discord Server](https://discord.gg/jttmwHTAad) and ask in
45-
the `#plugin-development` channel.
3+
Concept for adding unique ids to lavalink tracks

build.gradle.kts

+15-6
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@ plugins {
44
alias(libs.plugins.lavalink)
55
}
66

7-
group = "org.example"
7+
group = "com.dunctebot"
88
version = "0.1.0"
99

1010
lavalinkPlugin {
11-
name = "plugin-template"
11+
name = "track-uuid"
12+
path = "$group.track-uuid"
1213
apiVersion = libs.versions.lavalink.api
1314
serverVersion = libs.versions.lavalink.server
1415
}
1516

1617
java {
1718
toolchain {
18-
languageVersion = JavaLanguageVersion.of(17)
19+
languageVersion.set(JavaLanguageVersion.of(17))
1920
}
2021
}
2122

@@ -30,9 +31,17 @@ dependencies {
3031
}
3132

3233
publishing {
33-
publications {
34-
create<MavenPublication>("maven") {
35-
from(components["java"])
34+
repositories {
35+
maven {
36+
name = "lavalink"
37+
url = uri("https://maven.lavalink.dev/releases")
38+
credentials {
39+
username = System.getenv("USERNAME")
40+
password = System.getenv("PASSWORD")
41+
}
42+
authentication {
43+
create<BasicAuthentication>("basic")
44+
}
3645
}
3746
}
3847
}

gradle/libs.versions.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[versions]
2-
lavalink-api = "4.0.0-beta.3"
3-
lavalink-server = "4.0.0-beta.3"
2+
lavalink-api = "4.0.0-beta.5"
3+
lavalink-server = "4.0.0-beta.5"
44

55
[plugins]
6-
lavalink = { id = "dev.arbjerg.lavalink.gradle-plugin", version = "1.0.10" }
6+
lavalink = { id = "dev.arbjerg.lavalink.gradle-plugin", version = "1.0.15" }

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://servi F438 ces.gradle.org/distributions/gradle-8.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

settings.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rootProject.name = "lavalink-plugin-template"
1+
rootProject.name = "track-uuid"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.dunctebot.trackUuid;
2+
3+
import kotlinx.serialization.json.JsonElementKt;
4+
import kotlinx.serialization.json.JsonObject;
5+
6+
import java.util.Map;
7+
8+
public record PluginJSONData(String uuid) {
9+
public JsonObject toJson() {
10+
return new JsonObject(Map.of(
11+
"id", JsonElementKt.JsonPrimitive(uuid))
12+
);
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.dunctebot.trackUuid;
2+
3+
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
4+
import dev.arbjerg.lavalink.api.AudioPluginInfoModifier;
5+
import kotlinx.serialization.json.JsonObject;
6+
import org.jetbrains.annotations.NotNull;
7+
import org.jetbrains.annotations.Nullable;
8+
import org.springframework.stereotype.Service;
9+
10+
import java.util.UUID;
11+
12+
@Service
13+
public class UUIDPluginInfoModifier implements AudioPluginInfoModifier {
14+
@Nullable
15+
@Override
16+
public JsonObject modifyAudioTrackPluginInfo(@NotNull AudioTrack track) {
17+
if (track.getUserData() == null) {
18+
final var pluginData = createPluginData();
19+
20+
track.setUserData(pluginData);
21+
}
22+
23+
return track.getUserData(PluginJSONData.class).toJson();
24+
}
25+
26+
private PluginJSONData createPluginData() {
27+
return new PluginJSONData(getUniqueId());
28+
}
29+
30+
private String getUniqueId() {
31+
return UUID.randomUUID().toString();
32+
}
33+
}

src/main/java/org/example/plugin/SampleEventHandler.java

-22
This file was deleted.

0 commit comments

Comments
 (0)
0