Java Code Examples for org.bstats.bukkit.Metrics#addCustomChart()
The following examples show how to use
org.bstats.bukkit.Metrics#addCustomChart() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetricHandler.java From VoxelGamesLibv2 with MIT License | 6 votes |
@Override public void enable() { try (Timing timing = new Timing("MetricsEnable")) { 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."); } }
Example 2
Source File: ShopChest.java From ShopChest with MIT License | 6 votes |
private void loadMetrics() { debug("Initializing Metrics..."); Metrics metrics = new Metrics(this, 1726); metrics.addCustomChart(new Metrics.SimplePie("creative_setting", () -> Config.creativeSelectItem ? "Enabled" : "Disabled")); metrics.addCustomChart(new Metrics.SimplePie("database_type", () -> Config.databaseType.toString())); metrics.addCustomChart(new Metrics.AdvancedPie("shop_type", () -> { int normal = 0; int admin = 0; for (Shop shop : shopUtils.getShops()) { if (shop.getShopType() == ShopType.NORMAL) normal++; else if (shop.getShopType() == ShopType.ADMIN) admin++; } Map<String, Integer> result = new HashMap<>(); result.put("Admin", admin); result.put("Normal", normal); return result; })); }
Example 3
Source File: MetricsService.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
/** * This method intializes and starts the metrics collection. */ public void start() { Metrics metrics = new Metrics(plugin, 4574); if (SlimefunPlugin.getUpdater().getBranch().isOfficial()) { // We really do not need this data if it is an unofficially modified build... metrics.addCustomChart(new AutoUpdaterChart()); } metrics.addCustomChart(new ResourcePackChart()); metrics.addCustomChart(new SlimefunVersionChart()); metrics.addCustomChart(new ServerLanguageChart()); metrics.addCustomChart(new PlayerLanguageChart()); metrics.addCustomChart(new ResearchesEnabledChart()); metrics.addCustomChart(new GuideLayoutChart()); metrics.addCustomChart(new AddonsChart()); metrics.addCustomChart(new CommandChart()); metrics.addCustomChart(new ServerSizeChart()); metrics.addCustomChart(new CompatibilityModeChart()); }
Example 4
Source File: PlaceholderAPIPlugin.java From PlaceholderAPI with GNU General Public License v3.0 | 5 votes |
private void setupMetrics() { Metrics m = new Metrics(this); m.addCustomChart(new Metrics.SimplePie("using_expansion_cloud", () -> getExpansionCloud() != null ? "yes" : "no")); m.addCustomChart( new Metrics.SimplePie("using_spigot", () -> getServerVersion().isSpigot() ? "yes" : "no")); m.addCustomChart(new Metrics.AdvancedPie("expansions_used", () -> { Map<String, Integer> map = new HashMap<>(); Map<String, PlaceholderHook> p = PlaceholderAPI.getPlaceholders(); if (!p.isEmpty()) { for (PlaceholderHook hook : p.values()) { if (hook instanceof PlaceholderExpansion) { PlaceholderExpansion ex = (PlaceholderExpansion) hook; map.put(ex.getRequiredPlugin() == null ? ex.getIdentifier() : ex.getRequiredPlugin(), 1); } } } return map; })); }
Example 5
Source File: ExamplePlugin.java From bStats-Metrics with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onEnable() { // All you have to do is adding the following two lines in your onEnable method. // You can find the plugin ids of your plugins on the page https://bstats.org/what-is-my-plugin-id int pluginId = 1234; // <-- Replace with the id of your plugin! Metrics metrics = new Metrics(this, pluginId); // Optional: Add custom charts metrics.addCustomChart(new Metrics.SimplePie("chart_id", () -> "My value")); }
Example 6
Source File: WorldGuardExtraFlagsPlugin.java From WorldGuardExtraFlagsPlugin with MIT License | 5 votes |
private void setupMetrics() { final int bStatsPluginId = 7301; Metrics metrics = new Metrics(this, bStatsPluginId); metrics.addCustomChart(new Metrics.AdvancedPie("flags_count", new Callable<Map<String, Integer>>() { private final Set<Flag<?>> flags = WorldGuardExtraFlagsPlugin.this.getPluginFlags(); @Override public Map<String, Integer> call() throws Exception { Map<Flag<?>, Integer> valueMap = this.flags.stream().collect(Collectors.toMap((v) -> v, (v) -> 0)); WorldGuardExtraFlagsPlugin.this.getWorldGuardCommunicator().getRegionContainer().getLoaded().forEach((m) -> { m.getRegions().values().forEach((r) -> { r.getFlags().keySet().forEach((f) -> { valueMap.computeIfPresent(f, (k, v) -> v + 1); }); }); }); return valueMap.entrySet().stream().collect(Collectors.toMap((v) -> v.getKey().getName(), (v) -> v.getValue())); } })); }
Example 7
Source File: MetricsManager.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
private void setupMetrics(int pluginId) { Metrics bStats = new Metrics(plugin, pluginId); bStats.addCustomChart(new Metrics.SimplePie("language", () -> plugin.getConfig().getString("language", "en"))); bStats.addCustomChart(new Metrics.SimplePie("radius_and_distance", () -> String.format("(%d,%d)", Settings.island_radius, Settings.island_distance))); // Temp. chart to measure storage usage for (legacy) uuid.PlayerDB. bStats.addCustomChart(new Metrics.SimplePie("playerdb_type", () -> plugin.getConfig().getString("options.advanced.playerdb.storage", "yml"))); }
Example 8
Source File: OnStartupTasks.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
/** * 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 Metrics.SimplePie("messages_language", () -> settings.getProperty(PluginSettings.MESSAGES_LANGUAGE))); metrics.addCustomChart(new Metrics.SimplePie("database_backend", () -> settings.getProperty(DatabaseSettings.BACKEND).toString())); }
Example 9
Source File: MineTinker.java From MineTinker with GNU General Public License v3.0 | 4 votes |
@Override public void onEnable() { plugin = this; is16compatible = Bukkit.getVersion().split("MC: ")[1].startsWith("1.16"); ChatWriter.log(false, "Setting up internals..."); loadConfig(); //load Main config LanguageManager.reload(); //Load Language system ConfigurationManager.reload(); ModManager.instance(); addCoreMods(); BuildersWandListener.init(); ChatWriter.reload(); if (getConfig().getBoolean("PluginIncompatibility.Check")) { incompatibilityCheck(); } TabExecutor cmd = new CommandManager(); this.getCommand("minetinker").setExecutor(cmd); // must be after internals as it would throw a NullPointerException this.getCommand("minetinker").setTabCompleter(cmd); ChatWriter.logInfo(LanguageManager.getString("StartUp.Commands")); if (getConfig().getBoolean("AllowCrafting")) { Bukkit.getPluginManager().registerEvents(new CreateToolListener(), this); } if (getConfig().getBoolean("AllowConverting")) { Bukkit.getPluginManager().registerEvents(new ConvertToolListener(), this); } Bukkit.getPluginManager().registerEvents(new AnvilListener(), this); Bukkit.getPluginManager().registerEvents(new ArmorListener(), this); Bukkit.getPluginManager().registerEvents(new BlockListener(), this); Bukkit.getPluginManager().registerEvents(new CraftItemListener(), this); Bukkit.getPluginManager().registerEvents(new EntityListener(), this); Bukkit.getPluginManager().registerEvents(new ItemListener(), this); Bukkit.getPluginManager().registerEvents(new PlayerListener(), this); Bukkit.getPluginManager().registerEvents(new TinkerListener(), this); Bukkit.getPluginManager().registerEvents(new TridentListener(), this); Bukkit.getPluginManager().registerEvents(new PlayerInfo(), this); Bukkit.getPluginManager().registerEvents(new EnchantingListener(), this); Bukkit.getPluginManager().registerEvents(new GrindstoneListener(), this); FileConfiguration elytraConf = ConfigurationManager.getConfig("Elytra.yml"); elytraConf.options().copyDefaults(true); elytraConf.addDefault("ExpChanceWhileFlying", 10); ConfigurationManager.saveConfig(elytraConf); if (ConfigurationManager.getConfig("BuildersWand.yml").getBoolean("enabled")) { Bukkit.getPluginManager().registerEvents(new BuildersWandListener(), this); BuildersWandListener.reload(); ChatWriter.log(false, LanguageManager.getString("StartUp.BuildersWands")); } if (getConfig().getBoolean("EasyHarvest.enabled")) { Bukkit.getPluginManager().registerEvents(new EasyHarvestListener(), this); ChatWriter.log(false, LanguageManager.getString("StartUp.EasyHarvest")); } if (getConfig().getBoolean("actionbar-on-exp-gain", false)) { Bukkit.getPluginManager().registerEvents(new ActionBarListener(), this); } if (getConfig().getBoolean("ItemBehaviour.TrackStatistics", true)) { Bukkit.getPluginManager().registerEvents(new ItemStatisticsHandler(), this); } ChatWriter.log(false, LanguageManager.getString("StartUp.Events")); if (getConfig().getBoolean("logging.metrics", true)) { Metrics met = new Metrics(this, 2833); met.addCustomChart(new Metrics.SimplePie("used_language", () -> getConfig().getString("Language", "en_US"))); } ChatWriter.log(false, LanguageManager.getString("StartUp.GUIs")); GUIs.reload(); ChatWriter.log(false, LanguageManager.getString("StartUp.StdLogging")); ChatWriter.log(true, LanguageManager.getString("StartUp.DebugLogging")); for (Player current : Bukkit.getServer().getOnlinePlayers()) { Power.HAS_POWER.computeIfAbsent(current, player -> new AtomicBoolean(false)); Drilling.HAS_DRILLING.computeIfAbsent(current, player -> new AtomicBoolean(false)); Lists.BLOCKFACE.put(current, null); } if (getConfig().getBoolean("CheckForUpdates")) { Bukkit.getScheduler().runTaskLaterAsynchronously(this, (@NotNull Runnable) Updater::checkForUpdate, 20); } }
Example 10
Source File: GlobalWarming.java From GlobalWarming with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void onEnable() { instance = this; Lang.init(); this.random = new Random(); this.gson = new GsonBuilder().setPrettyPrinting().create(); this.conf = new GlobalWarmingConfig(); this.connectionManager = conf.makeConnectionManager(); this.tableManager = new TableManager(); try { //Connect to the database: // - Refer to setup.sh for setup information Connection connection = GlobalWarming.getInstance().getConnectionManager().openConnection(); //Create the database if it doesn't exist: // - Required for the first run AsyncDBQueue.getInstance().writeCreateTableQueue(connection); //Load any stored records back into memory: AsyncDBQueue.getInstance().writeSelectQueue(connection); //Confirm that each world has a record: // - Required for the first run WorldTable worldTable = tableManager.getWorldTable(); for (World world : Bukkit.getWorlds()) { GWorld gWorld = worldTable.getWorld(world.getUID()); if (gWorld == null) { worldTable.insertNewWorld(world.getUID()); } } } catch (SQLException | ClassNotFoundException e) { getLogger().severe("Database connection not found."); getLogger().severe("Data won't persist after restarts!"); getLogger().severe("Please update config.yml and restart the server."); } catch (Exception jex) { getLogger().severe("Server reloads are not supported when using H2 DB."); getLogger().severe("Disabling the plugin. Please full restart to fix."); Bukkit.getPluginManager().disablePlugin(this); return; // avoid proceeding with startup logic } ClimateEngine.getInstance().loadWorldClimateEngines(); EffectEngine.getInstance(); this.commandManager = new PaperCommandManager(this); this.scoreboard = new GScoreboard(conf.isScoreboardEnabled()); this.notifications = new CO2Notifications(); economy = null; registerCommands(); setupEconomy(); Bukkit.getPluginManager().registerEvents(new AttributionListener(this), this); Bukkit.getPluginManager().registerEvents(new CO2Listener(this), this); Bukkit.getPluginManager().registerEvents(new CH4Listener(this), this); Bukkit.getPluginManager().registerEvents(new PlayerListener(this), this); Bukkit.getPluginManager().registerEvents(new WorldListener(this), this); AsyncDBQueue.getInstance().scheduleAsyncTask(conf.getDatabaseInterval() * 20L); if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null && !conf.isScoreboardEnabled()) { new TemperatureExpansion().register(); } Metrics metrics = new Metrics(this); metrics.addCustomChart(new Metrics.SimplePie("databaseType", () -> String.valueOf(this.conf.getType()))); }