Skip to content

Commit 65ada98

Browse files
committed
Add ExamplePlugin with custom metrics and plugin.yml
1 parent 29d2495 commit 65ada98

4 files changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
plugins {
2+
id("com.gradleup.shadow") version ("9.3.0")
3+
}
4+
5+
repositories {
6+
maven("https://repo.papermc.io/repository/maven-public/")
7+
}
8+
9+
dependencies {
10+
compileOnly("io.papermc.paper:paper-api:1.21.11-R0.1-SNAPSHOT")
11+
implementation(project(":bukkit"))
12+
}
13+
14+
tasks.shadowJar {
15+
relocate("dev.faststats", "com.example.utils") // optionally relocate faststats
16+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.example;
2+
3+
import dev.faststats.bukkit.BukkitMetrics;
4+
import dev.faststats.core.Metrics;
5+
import dev.faststats.core.chart.Chart;
6+
import org.bukkit.plugin.java.JavaPlugin;
7+
8+
import java.net.URI;
9+
10+
public class ExamplePlugin extends JavaPlugin {
11+
private final Metrics metrics = BukkitMetrics.factory()
12+
.url(URI.create("https://metrics.example.com/v1/collect")) // For self-hosted metrics servers only
13+
14+
// Custom example charts
15+
// For this to work you have to create a corresponding data source in your project settings first
16+
.addChart(Chart.number("example_chart", () -> 42))
17+
.addChart(Chart.string("example_string", () -> "Hello, World!"))
18+
.addChart(Chart.bool("example_boolean", () -> true))
19+
.addChart(Chart.stringArray("example_string_array", () -> new String[]{"Option 1", "Option 2"}))
20+
.addChart(Chart.numberArray("example_number_array", () -> new Number[]{1, 2, 3}))
21+
.addChart(Chart.booleanArray("example_boolean_array", () -> new Boolean[]{true, false}))
22+
23+
.debug(true) // Enable debug mode for development and testing
24+
25+
.token("YOUR_TOKEN_HERE") // required -> token can be found in the settings of your project
26+
.create(this);
27+
28+
@Override
29+
public void onDisable() {
30+
metrics.shutdown();
31+
}
32+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: ExamplePlugin
2+
version: 1.0.0
3+
main: com.example.ExamplePlugin

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ plugins {
44

55
rootProject.name = "dev-kits"
66
include("bukkit")
7+
include("bukkit:example-plugin")
78
include("bungeecord")
89
include("core")
910
include("minestom")

0 commit comments

Comments
 (0)