本文整理汇总了Java中org.bstats.bukkit.Metrics类的典型用法代码示例。如果您正苦于以下问题:Java Metrics类的具体用法?Java Metrics怎么用?Java Metrics使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Metrics类属于org.bstats.bukkit包,在下文中一共展示了Metrics类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.bstats.bukkit.Metrics; //导入依赖的package包/类
@Override
public void start() {
try {
metrics = new Metrics(voxelGamesLib);
//TODO add custom charts, like user/gamemode, installed gamesmodes, user/lang, installed langs etc
// gamemodes multiline TODO enable this on the bstats page once its implemented....
metrics.addCustomChart(new Metrics.MultiLineChart("gamemodes", () -> {
Map<String, Integer> valueMap = new HashMap<>();
gameHandler.getGameModes().forEach((gm) -> valueMap.put(gm.getName(), 1));
return valueMap;
}));
} catch (Throwable ex) {
log.warning("Metrics failed to enabled. This is not a critical problem. You can ignore it.");
}
}
示例2: onEnable
import org.bstats.bukkit.Metrics; //导入依赖的package包/类
@Override
public void onEnable() {
// All you have to do is adding this line in your onEnable method:
Metrics metrics = new Metrics(this);
// Optional: Add custom charts
metrics.addCustomChart(new Metrics.SimplePie("chart_id", new Callable<String>() {
@Override
public String call() throws Exception {
return "My value";
}
}));
// If you use Java 8 you can use Lambdas:
// metrics.addCustomChart(new Metrics.SimplePie("chart_id", () -> "My value"));
}
示例3: onEnable
import org.bstats.bukkit.Metrics; //导入依赖的package包/类
@Override
public void onEnable() {
//Metrics powered by bstats.org
Metrics metrics = new Metrics(this);
this.saveDefaultConfig();
int bufferSize = getConfig().getInt("bufferSize");
if (bufferSize <= 0) {
logger.info(this.getName() + ": Invalid bufferSize " + bufferSize + "! Must be greater 0");
}
chatBuffer = new ChatBuffer(
bufferSize,
getConfig().getString("replayHeader"),
getConfig().getString("replayFooter"),
getConfig().getString("replayMsgFormat"),
getConfig().getString("replayMsgHover"));
getServer().getPluginManager().registerEvents(this, this);
}
示例4: init
import org.bstats.bukkit.Metrics; //导入依赖的package包/类
@Override
public void init(JavaPlugin plugin) {
// Main
File configFile = new File(new File(plugin.getDataFolder().getParentFile(), "bStats"), "config.yml");
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
if (!config.getBoolean("enabled", true)) {
config.set("enabled", true);
try {
config.save(configFile);
} catch (IOException e) {
throw new IllegalStateException(e);
}
Static.log(ChatColor.RED + "bStats 가 비활성화되어있어 활성화했습니다.");
}
Metrics metrics = new Metrics(plugin);
metrics.addCustomChart(new Metrics.AdvancedPie("players_by_server", () -> {
Map<String, Integer> map = new HashMap<>();
map.put(Static.getAddress(), Static.getOnlinePlayers().size());
return map;
}));
}
示例5: onEnable
import org.bstats.bukkit.Metrics; //导入依赖的package包/类
@Override
public void onEnable() {
if (!isAboveMC18()) {
getLogger().info("[TradeShop] Minecraft versions before 1.9 are not supported beyond TradeShop version 1.5.2!");
getServer().getPluginManager().disablePlugin(this);
return;
}
createConfigs();
reloadConfig();
PluginManager pm = getServer().getPluginManager();
pm.registerEvents(new TradeEventListener(this), this);
pm.registerEvents(new ShopCreateEventListener(this), this);
pm.registerEvents(new BiTradeEventListener(this), this);
pm.registerEvents(new BiShopCreateEventListener(this), this);
pm.registerEvents(new ShopProtectionHandler(this), this);
pm.registerEvents(new ITradeEventListener(this), this);
pm.registerEvents(new IShopCreateEventListener(this), this);
getCommand("tradeshop").setExecutor(new Executor(this));
boolean checkUpdates = getSettings().getBoolean("check-updates");
if (checkUpdates) {
new Thread(() -> new Updater(getDescription()).checkCurrentVersion()).start();
}
if (getSettings().getBoolean("allow-metrics")) {
metrics = new Metrics(this);
getLogger().info("Metrics successfully initialized!");
} else {
getLogger().warning("Metrics are disabled! Please consider enabling them to support the authors!");
}
}
示例6: onEnable
import org.bstats.bukkit.Metrics; //导入依赖的package包/类
@Override
public void onEnable() {
instance = this;
//根據不同版本選擇Handler
String version = getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
switch (version) {
case "v1_8_R1":
case "v1_8_R2":
case "v1_8_R3":
versionHandler = new VersionHandler_1_8();
break;
default:
versionHandler = new VersionHandler();
break;
}
//Commands
registerCommands();
//CustomGUI
CustomGUI.enable();
//Config
List<String> configList = Arrays.asList("config", "price");
for (String config : configList) {
KConfigManager.load(config);
}
//Reload
reload();
//bStats
Metrics metrics = new Metrics(this);
}
示例7: sendMetrics
import org.bstats.bukkit.Metrics; //导入依赖的package包/类
/**
* Sends bstats metrics.
*
* @param plugin the plugin instance
* @param settings the settings
*/
public static void sendMetrics(AuthMe plugin, Settings settings) {
final Metrics metrics = new Metrics(plugin);
metrics.addCustomChart(new Metrics.SimplePie("messages_language",
() -> settings.getProperty(PluginSettings.MESSAGES_LANGUAGE)));
metrics.addCustomChart(new Metrics.SimplePie("database_backend",
() -> settings.getProperty(DatabaseSettings.BACKEND).toString()));
}
示例8: setupMetrics
import org.bstats.bukkit.Metrics; //导入依赖的package包/类
@Override
public void setupMetrics() {
Metrics metrics = new Metrics((JavaPlugin) getPlugin());
metrics.addCustomChart(new Metrics.SimplePie("MySQL", () -> DatabaseManager.get().isUseMySQL() ? "yes" : "no"));
}