-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13c2ccc
commit b8eaaa6
Showing
6 changed files
with
174 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
bedwars-plugin/src/main/java/com/andrei1058/bedwars/metrics/MetricsManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.andrei1058.bedwars.metrics; | ||
|
||
import com.andrei1058.bedwars.BedWars; | ||
import com.andrei1058.bedwars.api.language.Language; | ||
import com.andrei1058.bedwars.support.citizens.JoinNPC; | ||
import org.bstats.bukkit.Metrics; | ||
import org.bstats.charts.SimplePie; | ||
|
||
import java.util.concurrent.Callable; | ||
|
||
public class MetricsManager { | ||
|
||
private static MetricsManager instance; | ||
|
||
private final Metrics metrics; | ||
|
||
private MetricsManager(BedWars plugin) { | ||
metrics = new Metrics(plugin, 97320); | ||
|
||
// base metrics | ||
metrics.addCustomChart(new SimplePie("server_type", () -> BedWars.getServerType().toString())); | ||
metrics.addCustomChart(new SimplePie("default_language", () -> Language.getDefaultLanguage().getIso())); | ||
metrics.addCustomChart(new SimplePie("auto_scale", () -> String.valueOf(BedWars.autoscale))); | ||
metrics.addCustomChart(new SimplePie("party_adapter", () -> BedWars.getParty().getClass().getName())); | ||
metrics.addCustomChart(new SimplePie("chat_adapter", () -> BedWars.getChatSupport().getClass().getName())); | ||
metrics.addCustomChart(new SimplePie("level_adapter", () -> BedWars.getLevelSupport().getClass().getName())); | ||
metrics.addCustomChart(new SimplePie("db_adapter", () -> BedWars.getRemoteDatabase().getClass().getName())); | ||
metrics.addCustomChart(new SimplePie("map_adapter", () -> BedWars.getAPI().getRestoreAdapter().getClass().getName())); | ||
metrics.addCustomChart(new SimplePie("citizens_support", () -> String.valueOf(JoinNPC.isCitizensSupport()))); | ||
} | ||
|
||
public Metrics getMetrics() { | ||
return metrics; | ||
} | ||
|
||
public static void appendPie(String id, Callable<String> callable) { | ||
if (null == instance) { | ||
throw new RuntimeException("Metrics manager is not initialized!"); | ||
} | ||
instance.getMetrics().addCustomChart(new SimplePie(id, callable)); | ||
} | ||
|
||
public static void initService(BedWars plugin) { | ||
if (null != instance) { | ||
return; | ||
} | ||
instance = new MetricsManager(plugin); | ||
} | ||
} |
Oops, something went wrong.