Skip to content

Instantly share code, notes, and snippets.

@Bastian
Last active August 14, 2022 00:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bastian/090987ee9274d2366a2c615cc6cfe2b4 to your computer and use it in GitHub Desktop.
Save Bastian/090987ee9274d2366a2c615cc6cfe2b4 to your computer and use it in GitHub Desktop.
Velocity Example
@Plugin(id = "myfirstplugin", name = "My First Plugin", version = "0.1.0-SNAPSHOT",
url = "https://example.org", description = "I did it!", authors = {"Me"})
public class MyFirstPlugin {
private final ProxyServer server;
private final Logger logger;
private final Metrics.Factory metricsFactory;
@Inject
public MyFirstPlugin(ProxyServer server, Logger logger, Metrics.Factory metricsFactory) {
this.server = server;
this.logger = logger;
this.metricsFactory = metricsFactory;
}
@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {
// All you have to do is adding the following two lines in your onProxyInitialization method.
// You can find the plugin ids of your plugins on the page https://bstats.org/what-is-my-plugin-id
int pluginId = 1234; // <-- Replace with the id of your plugin!
Metrics metrics = metricsFactory.make(this, pluginId);
// You can also add custom charts:
metrics.addCustomChart(new SimplePie("chart_id", () -> "value"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment