Skip to content

Commit

Permalink
Add bStats
Browse files Browse the repository at this point in the history
  • Loading branch information
CoPokBl committed May 2, 2024
1 parent 922a18f commit 30deb83
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/.idea/
/EsTools.iml
/out
dependency-reduced-pom.xml
16 changes: 15 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,19 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<configuration>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>net.serble.estools</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
<goal>shade</goal>
</goals>
</execution>
</executions>
Expand Down Expand Up @@ -77,5 +85,11 @@
<version>1.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.0.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
13 changes: 13 additions & 0 deletions src/main/java/net/serble/estools/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import net.serble.estools.Commands.Teleport.*;
import net.serble.estools.Commands.Warps.*;
import net.serble.estools.Signs.SignMain;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie;
import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;
Expand All @@ -22,6 +24,8 @@ public class Main extends JavaPlugin {
public static int majorVersion;
public static int minorVersion;
public static boolean tabCompleteEnabled = true;

private static final int bStatsId = 21760;

@Override
public void onEnable() {
Expand All @@ -39,6 +43,15 @@ public void onEnable() {
saveDefaultConfig();
}

// Metrics
if (getConfig().getBoolean("metrics", true)) {
Metrics metrics = new Metrics(this, bStatsId);
metrics.addCustomChart(new SimplePie("vault_enabled", () -> String.valueOf(Vault.economy != null)));
Bukkit.getLogger().info("Started bStat metrics");
} else {
Bukkit.getLogger().info("Metrics are disabled");
}

if (majorVersion <= 2) {
Bukkit.getLogger().info("Tab completion is not supported for versions 1.2 and below.");
tabCompleteEnabled = false;
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Stops players taking fall damage when they teleport
safetp: true

# Toggle bStats metrics
metrics: true

0 comments on commit 30deb83

Please sign in to comment.