Skip to content

Commit

Permalink
Add bStats
Browse files Browse the repository at this point in the history
  • Loading branch information
NEZNAMY committed Jun 28, 2024
1 parent 20d6f72 commit 0172edb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dependencies {
implementation project(':proxy')
compileOnly project(':api')

implementation 'org.bstats:bstats-velocity:3.0.1'
compileOnly 'com.velocitypowered:velocity-api:3.3.0-SNAPSHOT'
compileOnly 'com.velocitypowered:velocity-proxy:3.3.0-SNAPSHOT'
compileOnly 'io.netty:netty-codec-http:4.1.111.Final'
Expand All @@ -16,6 +17,7 @@ shadowJar {
dependencies {
exclude dependency(':slf4j-api')
}
relocate("org.bstats", "com.velocitypowered.scoreboardapi.libs.org.bstats")
}

tasks {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.velocitypowered.proxy.data.LoggerManager;
import com.velocitypowered.proxy.scoreboard.VelocityScoreboard;
import com.velocitypowered.proxy.scoreboard.VelocityScoreboardManager;
import org.bstats.velocity.Metrics;
import org.jetbrains.annotations.NotNull;
import org.slf4j.event.Level;

Expand All @@ -40,17 +41,22 @@
public class VelocityScoreboardAPI {

private final ProxyServer server;
private final Metrics.Factory metricsFactory;
private boolean enabled;

/**
* Constructs new instance with given parameter
* Constructs new instance with given parameters.
*
* @param server
* Proxy server
* @param metricsFactory
* Metrics for bStats
*/
@Inject
public VelocityScoreboardAPI(@NotNull ProxyServer server) {
public VelocityScoreboardAPI(@NotNull ProxyServer server, @NotNull Metrics.Factory metricsFactory) {
this.server = server;
this.metricsFactory = metricsFactory;

}

/**
Expand Down Expand Up @@ -88,6 +94,7 @@ public void onProxyInitialization(ProxyInitializeEvent event) {
ScoreboardManager.setInstance(new VelocityScoreboardManager(server, this));
LoggerManager.log(Level.INFO,"<green>Successfully injected Scoreboard API.");
enabled = true;
metricsFactory.make(this, 22437);
}

/**
Expand Down

0 comments on commit 0172edb

Please sign in to comment.