Added MCStats Metrics. Can be disabled together with Piwik,
or like descriped at http://mcstats.org/learn-more/
This commit is contained in:
parent
e7a794add7
commit
86eeceb450
1 changed files with 28 additions and 0 deletions
|
@ -6,18 +6,46 @@ import org.bukkit.event.Listener;
|
||||||
|
|
||||||
import de.jaschastarke.bukkit.lib.CoreModule;
|
import de.jaschastarke.bukkit.lib.CoreModule;
|
||||||
import de.jaschastarke.bukkit.tools.stats.IStatistics;
|
import de.jaschastarke.bukkit.tools.stats.IStatistics;
|
||||||
|
import de.jaschastarke.bukkit.tools.stats.MCStatsMetrics;
|
||||||
|
import de.jaschastarke.bukkit.tools.stats.MCStatsMetrics.Graph;
|
||||||
import de.jaschastarke.bukkit.tools.stats.PiwikStatistics;
|
import de.jaschastarke.bukkit.tools.stats.PiwikStatistics;
|
||||||
|
import de.jaschastarke.modularize.IModule;
|
||||||
|
import de.jaschastarke.modularize.ModuleEntry;
|
||||||
|
import de.jaschastarke.modularize.ModuleEntry.ModuleState;
|
||||||
|
|
||||||
public class FeatureMetrics extends CoreModule<LimitedCreative> implements Listener {
|
public class FeatureMetrics extends CoreModule<LimitedCreative> implements Listener {
|
||||||
public FeatureMetrics(LimitedCreative plugin) {
|
public FeatureMetrics(LimitedCreative plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
}
|
}
|
||||||
private IStatistics metric;
|
private IStatistics metric;
|
||||||
|
private MCStatsMetrics mcstats = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
super.onEnable();
|
super.onEnable();
|
||||||
metric = new PiwikStatistics(plugin);
|
metric = new PiwikStatistics(plugin);
|
||||||
|
if (mcstats == null) {
|
||||||
|
try {
|
||||||
|
mcstats = new MCStatsMetrics(plugin);
|
||||||
|
|
||||||
|
Graph moduleGraph = mcstats.createGraph("Module Usage");
|
||||||
|
for (final ModuleEntry<IModule> mod : plugin.getModules()) {
|
||||||
|
if (mod.getModule() instanceof CoreModule<?>) {
|
||||||
|
moduleGraph.addPlotter(new MCStatsMetrics.Plotter(((CoreModule<?>) mod.getModule()).getName()) {
|
||||||
|
@Override
|
||||||
|
public int getValue() {
|
||||||
|
return mod.getState() == ModuleState.ENABLED ? 1 : 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mcstats.start();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// Failed to submit the stats :-(
|
||||||
|
getLog().warn("MCStats-Error: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue