Add bStats

actually 2.0.5
This commit is contained in:
Minecon724 2024-09-22 11:26:20 +02:00
parent dcdf9a880e
commit eb39a22d81
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8
2 changed files with 45 additions and 2 deletions

33
pom.xml
View file

@ -42,6 +42,12 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.0.2</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
@ -55,11 +61,36 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId> <artifactId>maven-release-plugin</artifactId>
<version>3.0.1</version> <version>3.1.1</version>
<configuration> <configuration>
<allowTimestampedSnapshots>true</allowTimestampedSnapshots> <allowTimestampedSnapshots>true</allowTimestampedSnapshots>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>full</shadedClassifierName>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<!-- Replace this with your package! -->
<shadedPattern>eu.m724.giants</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>

View file

@ -1,5 +1,6 @@
package eu.m724.giants; package eu.m724.giants;
import org.bstats.bukkit.Metrics;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.entity.Giant; import org.bukkit.entity.Giant;
@ -7,6 +8,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import java.io.File; import java.io.File;
import java.lang.reflect.Constructor;
public class GiantsPlugin extends JavaPlugin implements CommandExecutor { public class GiantsPlugin extends JavaPlugin implements CommandExecutor {
private final File configFile = new File(getDataFolder(), "config.yml"); private final File configFile = new File(getDataFolder(), "config.yml");
@ -25,7 +27,17 @@ public class GiantsPlugin extends JavaPlugin implements CommandExecutor {
getCommand("giants").setExecutor(new GiantsCommand(this, configuration)); getCommand("giants").setExecutor(new GiantsCommand(this, configuration));
giantProcessor.start(); giantProcessor.start();
}
// bStats is optional
try {
Class<?> clazz = Class.forName("eu.m724.giants.bukkit.Metrics");
Constructor<?> constructor = clazz.getDeclaredConstructor(JavaPlugin.class, int.class);
constructor.newInstance(this, 14131);
getLogger().info("Enabled bStats");
} catch (Exception e) {
getLogger().info("Not using bStats (" + e.getClass().getName() + ")");
}
}
// TODO api, untested // TODO api, untested