mirror of
https://github.com/taoneill/war.git
synced 2025-02-21 13:51:19 +01:00
Collect metrics statistics from servers
War now collects statistics from servers running the plugin. The statistics are minimal. The goal is so the developers of the plugin can tell what areas they need to do more work in. In addition to the default statistics collected by PluginMetrics, War sends the number of warzones and if certain plugins that War interfaces with are enabled. To prevent your server from sending statistical data, set "opt-out" to "true" in plugins/PluginMetrics/config.yml. Closes #716.
This commit is contained in:
parent
ca03c96173
commit
0805a04cad
2
.gitignore
vendored
2
.gitignore
vendored
@ -12,3 +12,5 @@
|
||||
bin
|
||||
*/lib/*
|
||||
*/target/*
|
||||
dependency-reduced-pom.xml
|
||||
|
||||
|
157
war/pom.xml
157
war/pom.xml
@ -1,67 +1,96 @@
|
||||
<?xml version="1.0"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.tommytony</groupId>
|
||||
<artifactId>war</artifactId>
|
||||
<version>1.8-PREVIEW</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>War</name>
|
||||
<url>http://war.tommytony.com</url>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>bukkit-repo</id>
|
||||
<url>http://repo.bukkit.org/content/groups/public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>cma-repo</id>
|
||||
<url>http://maven.cmastudios.me/archiva/repository/internal</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>tagapi-repo</id>
|
||||
<url>http://repo.kitteh.org/content/repositories/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>http://maven.sk89q.com/repo/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<repository>
|
||||
<id>bukkit-repo</id>
|
||||
<url>http://repo.bukkit.org/content/groups/public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>cma-repo</id>
|
||||
<url>http://maven.cmastudios.me/archiva/repository/internal</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>tagapi-repo</id>
|
||||
<url>http://repo.kitteh.org/content/repositories/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>http://maven.sk89q.com/repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>mcstats.releases</id>
|
||||
<url>http://repo.mcstats.org/content/repositories/releases/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<issueManagement>
|
||||
<system>Github issues</system>
|
||||
<url>https://github.com/taoneill/war/issues</url>
|
||||
<system>Github issues</system>
|
||||
<url>https://github.com/taoneill/war/issues</url>
|
||||
</issueManagement>
|
||||
<ciManagement>
|
||||
<system>Jenkins</system>
|
||||
<url>http://ci.tommytony.com</url>
|
||||
<system>Jenkins</system>
|
||||
<url>http://ci.tommytony.com</url>
|
||||
</ciManagement>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/taoneill/war.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:taoneill/war.git</developerConnection>
|
||||
<tag>HEAD</tag>
|
||||
<url>https://github.com/taoneill/war</url>
|
||||
<connection>scm:git:git://github.com/taoneill/war.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:taoneill/war.git</developerConnection>
|
||||
<tag>HEAD</tag>
|
||||
<url>https://github.com/taoneill/war</url>
|
||||
</scm>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.0.2</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/main/resources/</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.0.2</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>org.mcstats.bukkit:metrics</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<minimizeJar>false</minimizeJar>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.mcstats</pattern>
|
||||
<shadedPattern>com.tommytony.war.metrics</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/main/resources/</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@ -72,28 +101,28 @@
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.8.1</version>
|
||||
<scope>test</scope>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.6.2-R1.0</version>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.6.2-R1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.kitteh</groupId>
|
||||
<artifactId>tagapi</artifactId>
|
||||
<version>2.0</version>
|
||||
<scope>compile</scope>
|
||||
<groupId>org.kitteh</groupId>
|
||||
<artifactId>tagapi</artifactId>
|
||||
<version>2.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<version>1.8.5</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<version>1.8.5</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
@ -101,5 +130,11 @@
|
||||
<version>5.5.6</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mcstats.bukkit</groupId>
|
||||
<artifactId>metrics</artifactId>
|
||||
<version>R7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -1280,4 +1280,8 @@ public class War extends JavaPlugin {
|
||||
public String getString(String key) {
|
||||
return messages.getString(key);
|
||||
}
|
||||
|
||||
public Locale getLoadedLocale() {
|
||||
return messages.getLocale();
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,21 @@
|
||||
package com.tommytony.war.job;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.tommytony.war.War;
|
||||
import com.tommytony.war.Warzone;
|
||||
import com.tommytony.war.config.WarzoneConfig;
|
||||
import com.tommytony.war.mapper.WarzoneYmlMapper;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import org.mcstats.Metrics;
|
||||
import org.mcstats.Metrics.Graph;
|
||||
|
||||
public class RestoreYmlWarzonesJob implements Runnable {
|
||||
|
||||
private final List<String> warzones;
|
||||
@ -44,8 +51,55 @@ public class RestoreYmlWarzonesJob implements Runnable {
|
||||
}
|
||||
if (War.war.getWarzones().size() > 0) {
|
||||
War.war.log("Warzones ready.", Level.INFO);
|
||||
final int zones = War.war.getWarzones().size();
|
||||
try {
|
||||
Metrics metrics = new Metrics(War.war);
|
||||
Graph warzoneCount = metrics.createGraph("Warzones");
|
||||
warzoneCount.addPlotter(new FixedPlotter("Count", zones));
|
||||
Graph language = metrics.createGraph("Language");
|
||||
language.addPlotter(new PlotterEnabled(War.war.getLoadedLocale().getDisplayLanguage(Locale.ENGLISH)));
|
||||
Graph plugins = metrics.createGraph("Extensions");
|
||||
if (War.war.isSpoutServer()) {
|
||||
plugins.addPlotter(new PlotterEnabled("Spout"));
|
||||
}
|
||||
if (War.war.isTagServer()) {
|
||||
plugins.addPlotter(new PlotterEnabled("TagAPI"));
|
||||
}
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("WorldEdit")) {
|
||||
plugins.addPlotter(new PlotterEnabled("WorldEdit"));
|
||||
}
|
||||
plugins.addPlotter(new PlotterEnabled("War")); // of course
|
||||
metrics.start();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class FixedPlotter extends Metrics.Plotter {
|
||||
|
||||
private final int value;
|
||||
|
||||
public FixedPlotter(final String name, final int value) {
|
||||
super(name);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
private static class PlotterEnabled extends Metrics.Plotter {
|
||||
|
||||
public PlotterEnabled(final String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user