Search in sources :

Example 6 with Metrics

use of org.bstats.bukkit.Metrics in project WildernessTp by AcmeProject.

the class WildTP method wildMetrics.

public void wildMetrics() {
    try {
        new Metricsa(this).start();
    } catch (IOException e) {
    }
    try {
        Metrics metrics = new Metrics(this, 3316);
        metrics.addCustomChart(new Metrics.SimplePie("bukkit_impl", new Callable<String>() {

            @Override
            public String call() throws Exception {
                return getServer().getVersion().split("-")[1];
            }
        }));
        for (final String key : getConfig().getKeys(false)) {
            if (getConfig().isBoolean(key) && !getConfig().isInt(key) && !getConfig().isString(key))
                metrics.addCustomChart(new Metrics.SimplePie(key.toLowerCase(), new Callable<String>() {

                    @Override
                    public String call() throws Exception {
                        return getConfig().getString(key);
                    }
                }));
        }
    } catch (Throwable rock) {
    }
}
Also used : Metrics(org.bstats.bukkit.Metrics) IOException(java.io.IOException) Callable(java.util.concurrent.Callable) IOException(java.io.IOException)

Example 7 with Metrics

use of org.bstats.bukkit.Metrics in project VoxelGamesLibv2 by VoxelGamesLib.

the class MetricHandler method enable.

@Override
public void enable() {
    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.");
    }
}
Also used : Inject(javax.inject.Inject) GameHandler(com.voxelgameslib.voxelgameslib.game.GameHandler) VoxelGamesLib(com.voxelgameslib.voxelgameslib.VoxelGamesLib) Handler(com.voxelgameslib.voxelgameslib.handler.Handler) Map(java.util.Map) Metrics(org.bstats.bukkit.Metrics) HashMap(java.util.HashMap) Logger(java.util.logging.Logger) Singleton(javax.inject.Singleton) Metrics(org.bstats.bukkit.Metrics) Map(java.util.Map) HashMap(java.util.HashMap)

Example 8 with Metrics

use of org.bstats.bukkit.Metrics in project ServerSelectorX by ServerSelectorX.

the class Stats method initialize.

public static void initialize() {
    final Metrics metrics = new Metrics(Main.getPlugin());
    metrics.addCustomChart(new Metrics.SimplePie("placeholderapi", () -> {
        if (Main.PLACEHOLDER_API instanceof PlaceholdersEnabled) {
            return "yes";
        } else {
            return "no";
        }
    }));
    metrics.addCustomChart(new Metrics.SimplePie("number_of_selectors", () -> {
        return Main.getConfigurationManager().getAll().size() + "";
    }));
    metrics.addCustomChart(new Metrics.AdvancedPie("selector_item", () -> {
        final Map<String, Integer> map = new HashMap<>();
        for (final FileConfiguration config : Main.getConfigurationManager().getAll()) {
            final Material material = Material.getMaterial(config.getString("item"));
            // Do not count invalid items
            if (material == null)
                continue;
            if (map.containsKey(material.toString())) {
                map.put(material.toString(), map.get(material.toString() + 1));
            } else {
                map.put(material.toString(), 1);
            }
        }
        return map;
    }));
    metrics.addCustomChart(new Metrics.AdvancedPie("type", () -> {
        final Map<String, Integer> map = new HashMap<>();
        for (final FileConfiguration config : Main.getConfigurationManager().getAll()) {
            for (final String slot : config.getConfigurationSection("menu").getKeys(false)) {
                String action = config.getString("menu." + slot + ".action").split(":")[0].toLowerCase();
                if (map.containsKey(action)) {
                    map.put(action, map.get(action) + 1);
                } else {
                    map.put(action, 1);
                }
            }
        }
        return map;
    }));
    metrics.addCustomChart(new Metrics.SimplePie("ping_api", () -> {
        if (Main.getPlugin().getConfig().getBoolean("external-query", true)) {
            return "External";
        } else {
            return "Internal";
        }
    }));
    metrics.addCustomChart(new Metrics.SimplePie("updater", () -> {
        if (Main.getPlugin().getConfig().getBoolean("updater", true)) {
            return "Enabled";
        } else {
            return "Disabled";
        }
    }));
    metrics.addCustomChart(new Metrics.SimplePie("player_count_mode", () -> {
        return Main.getPlugin().getConfig().getString("item-count-mode", "absolute").toLowerCase();
    }));
    metrics.addCustomChart(new Metrics.SimplePie("background_pinging", () -> {
        if (Main.getPlugin().getConfig().getBoolean("background-pinging", true)) {
            return "Enabled";
        } else {
            return "Disabled";
        }
    }));
    metrics.addCustomChart(new Metrics.AdvancedPie("server_pinging", () -> {
        final Map<String, Integer> map = new HashMap<>();
        for (final FileConfiguration config : Main.getConfigurationManager().getAll()) {
            for (final String slot : config.getConfigurationSection("menu").getKeys(false)) {
                String action = config.getString("menu." + slot + ".action").split(":")[0].toLowerCase();
                if (action.equalsIgnoreCase("srv")) {
                    if (config.getBoolean("menu." + slot + ".ping-server", false)) {
                        if (map.containsKey("Enabled")) {
                            map.put("Enabled", map.get("Enabled") + 1);
                        } else {
                            map.put("Enabled", 1);
                        }
                    } else {
                        if (map.containsKey("Disabled")) {
                            map.put("Disabled", map.get("Disabled") + 1);
                        } else {
                            map.put("Disabled", 1);
                        }
                    }
                }
            }
        }
        return map;
    }));
    metrics.addCustomChart(new Metrics.SimplePie("permissions", () -> {
        if (Main.getPlugin().getConfig().getBoolean("permissions-enabled", false)) {
            return "Enabled";
        } else {
            return "Disabled";
        }
    }));
    metrics.addCustomChart(new Metrics.SimplePie("item_drop", () -> {
        if (Main.getPlugin().getConfig().getBoolean("cancel-item-drop", false)) {
            return "Cancel";
        } else {
            return "Allow";
        }
    }));
    metrics.addCustomChart(new Metrics.SimplePie("item_move", () -> {
        if (Main.getPlugin().getConfig().getBoolean("cancel-item-move", false)) {
            return "Cancel";
        } else {
            return "Allow";
        }
    }));
    metrics.addCustomChart(new Metrics.AdvancedPie("menu_item_slot", () -> {
        final Map<String, Integer> map = new HashMap<>();
        for (final FileConfiguration config : Main.getConfigurationManager().getAll()) {
            int slot = config.getInt("inv-slot", 0);
            if (slot < 0) {
                if (map.containsKey("Auto")) {
                    map.put("Auto", map.get("Auto") + 1);
                } else {
                    map.put("Auto", 1);
                }
            } else {
                if (map.containsKey(slot + "")) {
                    map.put(slot + "", map.get(slot + "") + 1);
                } else {
                    map.put(slot + "", 1);
                }
            }
        }
        return map;
    }));
    metrics.addCustomChart(new Metrics.AdvancedPie("rows", () -> {
        final Map<String, Integer> map = new HashMap<>();
        for (final FileConfiguration config : Main.getConfigurationManager().getAll()) {
            int rows = config.getInt("rows", 6);
            if (map.containsKey(rows + "")) {
                map.put(rows + "", map.get(rows + "") + 1);
            } else {
                map.put(rows + "", 1);
            }
        }
        return map;
    }));
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) Metrics(org.bstats.bukkit.Metrics) PlaceholdersEnabled(xyz.derkades.serverselectorx.placeholders.PlaceholdersEnabled) Material(org.bukkit.Material) Map(java.util.Map) HashMap(java.util.HashMap)

Example 9 with Metrics

use of org.bstats.bukkit.Metrics in project Prism-Bukkit by prism.

the class Prism method checkPluginDependencies.

private void checkPluginDependencies() {
    // DripReporter
    ApiHandler.configureMonitor();
    // WorldEdit
    ApiHandler.hookWorldEdit();
    // bstats
    if (getConfig().getBoolean("prism.allow-metrics")) {
        Prism.log("Prism bStats metrics are enabled - thank you!");
        // assigned by bstats.org
        int pluginId = 4365;
        Metrics metrics = new Metrics(this, pluginId);
        if (!metrics.isEnabled()) {
            Prism.warn("bStats failed to initialise! Please check Prism/bStats configs.");
        }
        Metrics.MultiLineChart blockBreaksHour = new Metrics.MultiLineChart("//TODO", ActionMeter::getMetricMeter);
        metrics.addCustomChart(blockBreaksHour);
    }
}
Also used : Metrics(org.bstats.bukkit.Metrics) ActionMeter(me.botsko.prism.actions.ActionMeter)

Example 10 with Metrics

use of org.bstats.bukkit.Metrics in project AuthMeReloaded by AuthMe.

the class OnStartupTasks method sendMetrics.

/**
 * 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, 164);
    metrics.addCustomChart(new SimplePie("messages_language", () -> settings.getProperty(PluginSettings.MESSAGES_LANGUAGE)));
    metrics.addCustomChart(new SimplePie("database_backend", () -> settings.getProperty(DatabaseSettings.BACKEND).toString()));
}
Also used : Metrics(org.bstats.bukkit.Metrics) SimplePie(org.bstats.charts.SimplePie)

Aggregations

Metrics (org.bstats.bukkit.Metrics)10 HashMap (java.util.HashMap)3 Map (java.util.Map)3 File (java.io.File)2 IOException (java.io.IOException)2 MinigamePlayer (au.com.mineauz.minigames.objects.MinigamePlayer)1 NBTString (com.kovuthehusky.nbt.tags.NBTString)1 CommandHandler (com.magmaguy.elitemobs.commands.CommandHandler)1 CustomBossesConfig (com.magmaguy.elitemobs.config.custombosses.CustomBossesConfig)1 CustomItemsConfig (com.magmaguy.elitemobs.config.customitems.CustomItemsConfig)1 CustomQuestsConfig (com.magmaguy.elitemobs.config.customquests.CustomQuestsConfig)1 CustomSpawnConfig (com.magmaguy.elitemobs.config.customspawns.CustomSpawnConfig)1 CustomTreasureChestsConfig (com.magmaguy.elitemobs.config.customtreasurechests.CustomTreasureChestsConfig)1 DungeonPackagerConfig (com.magmaguy.elitemobs.config.dungeonpackager.DungeonPackagerConfig)1 NPCsConfig (com.magmaguy.elitemobs.config.npcs.NPCsConfig)1 WormholeConfig (com.magmaguy.elitemobs.config.wormholes.WormholeConfig)1 Minidungeon (com.magmaguy.elitemobs.dungeons.Minidungeon)1 CustomCharts (com.magmaguy.elitemobs.thirdparty.bstats.CustomCharts)1 Placeholders (com.magmaguy.elitemobs.thirdparty.placeholderapi.Placeholders)1 InfoMessage (com.magmaguy.elitemobs.utils.InfoMessage)1