org.bstats.bukkit.Metrics Java Examples

The following examples show how to use org.bstats.bukkit.Metrics. 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 vote down vote up
@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: ServerTutorial.java    From ServerTutorial with MIT License 6 votes vote down vote up
@Override
public void onEnable() {
    instance = this;

    this.getServer().getPluginManager().registerEvents(new TutorialListener(), this);
    this.getCommand("tutorial").setExecutor(new TutorialMainCommand());
    this.saveDefaultConfig();

    if (this.getConfig().getBoolean("metrics", true)) {
        Metrics metrics = new Metrics(this);
    }
    DataLoading.getDataLoading().loadData();
    DataLoading.getDataLoading().loadPlayerData();
    DataLoading.getDataLoading().loadTempData();
    Caching.getCaching().casheAllData();
    Caching.getCaching().cacheConfigs();
    Caching.getCaching().cachePlayerData();
    Caching.getCaching().cacheTempData();

    this.checkUpdate();
}
 
Example #3
Source File: HubBasics.java    From HubBasics with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void onEnable() {
    instance = this;
    this.loggerManager = new HBLogger(null);
    HBLogger.setUnderlying(this.getLogger());
    this.taskManager = new TaskManager();
    this.configManager = new SpigotConfigManager(this);
    this.configHandler = new ConfigHandler(this);
    Bukkit.getPluginManager().registerEvents(this.configHandler, this);
    this.messenger = new Messenger();
    if (System.getenv("HubBasics.Spigot") == null) {
        this.metrics = new Metrics(this, 2353);
    } else {
        loggerManager.info("Running in Development mode, Metrics disabled.");
    }
    this.commandFramework = new CommandFramework();
    this.NMS = new NMSVersion();
    this.itemManager = new ItemManager(this.NMS.getRunningVersion());
    this.menuManager = new MenuManager();
    this.locationManager = new LocationManager();
    this.moduleManager = new ModuleManager(this.NMS.getRunningVersion());

    getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
    getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeListener());
}
 
Example #4
Source File: SurvivalGames.java    From Survival-Games with GNU General Public License v3.0 6 votes vote down vote up
public void onEnable() {
	logger = p.getLogger();
	setInstance(this);
	
	//check if server is pre 1.13
	if (Integer.parseInt(getServer().getVersion().replaceAll("[^\\d.]", "").split("\\.")[1]) < 13) {
		PRE1_13 = true;
	}else {
		PRE1_13 = false;
	}
	if(PRE1_13) {
		getServer().getConsoleSender().sendMessage("[SurvivalGames] Running pre 1.13");
	}else {
		getServer().getConsoleSender().sendMessage("[SurvivalGames] Running 1.13+");
	}
	
	
	// Ensure that all worlds are loaded. Fixes some issues with Multiverse loading after this plugin had started
	getServer().getScheduler().scheduleSyncDelayedTask(this, new Startup(), 10);

	
	@SuppressWarnings("unused")
	Metrics	metrics = new Metrics(this);

}
 
Example #5
Source File: MetricsService.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 #6
Source File: ShopChest.java    From ShopChest with MIT License 6 votes vote down vote up
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 #7
Source File: PlaceholderAPIPlugin.java    From PlaceholderAPI with GNU General Public License v3.0 5 votes vote down vote up
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 #8
Source File: OnStartupTasks.java    From AuthMeReloaded with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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: ExamplePlugin.java    From bStats-Metrics with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 #10
Source File: AstralEditPlugin.java    From AstralEdit with Apache License 2.0 5 votes vote down vote up
/**
 * Enables the plugin
 */
@Override
public void onEnable() {
    logger = this.getLogger();

    Bukkit.getServer().getConsoleSender().sendMessage(PREFIX_CONSOLE + ChatColor.GREEN + "Loading AstralEdit ...");

    final DependencyService dependencyService = new DependencyServiceImpl(this);
    final boolean requiredDependenciesInstalled = dependencyService.checkForInstalledDependencies();

    if (!VersionSupport.isServerVersionSupported(PLUGIN_NAME, PREFIX_CONSOLE) || !requiredDependenciesInstalled) {
        Bukkit.getPluginManager().disablePlugin(this);
    } else {
        try {
            this.saveDefaultConfig();
            if (this.getConfig().getBoolean("metrics")) {
                new Metrics(this);
            }

            final UpdateCheckService updateCheckService = new UpdateCheckServiceImpl(this, new ConcurrencyServiceImpl(this));
            updateCheckService.checkForUpdates();

            final Method method = AstralEditApi.class.getDeclaredMethod("initialize", Plugin.class, SelectionController.class);
            method.setAccessible(true);
            method.invoke(AstralEditApi.INSTANCE, this, new SelectionManager(new DependencyWorldEditServiceImpl(this), this));
            Bukkit.getServer().getConsoleSender().sendMessage(PREFIX_CONSOLE + ChatColor.GREEN + "Enabled AstralEdit " + this.getDescription().getVersion() + " by Shynixn");
        } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
            AstralEditPlugin.logger().log(Level.WARNING, "Failed to initialize plugin.", e);
        }
    }
}
 
Example #11
Source File: WorldGuardExtraFlagsPlugin.java    From WorldGuardExtraFlagsPlugin with MIT License 5 votes vote down vote up
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 #12
Source File: WesvMetrics.java    From WorldEditSelectionVisualizer with MIT License 5 votes vote down vote up
private WesvMetrics(WorldEditSelectionVisualizer plugin) {
    metrics = new Metrics(plugin);

    CompatibilityHelper compatHelper = plugin.getCompatibilityHelper();

    addObjectChart("selection_update_interval", () -> plugin.getConfig().getInt("selection-update-interval"));
    addBooleanChart("top_bottom_cuboid", () -> plugin.getConfig().getBoolean("cuboid-top-bottom"));
    addCustomChart("worldedit_version", () -> "WorldEdit " + compatHelper.getWorldEditVersion());
    addBooleanChart("use_fawe", compatHelper::isUsingFawe);
    addBooleanChart("check_for_axe", () -> plugin.getConfig().getBoolean("need-we-wand"));
}
 
Example #13
Source File: MetricsManager.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
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 #14
Source File: LunaChatBukkit.java    From LunaChat with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * プラグインが有効化されたときに呼び出されるメソッド
 * @see org.bukkit.plugin.java.JavaPlugin#onEnable()
 */
@Override
public void onEnable() {

    LunaChat.setPlugin(this);
    LunaChat.setMode(LunaChatMode.BUKKIT);

    // Metrics
    new Metrics(this, 7936);

    // 変数などの初期化
    config = new LunaChatConfig(getDataFolder(), getFile());
    uuidCacheData = new UUIDCacheData(getDataFolder());
    Messages.initialize(new File(getDataFolder(), "messages"), getFile(), config.getLang());
    manager = new ChannelManager();
    normalChatLogger = new LunaChatLogger("==normalchat");

    // チャンネルチャット無効なら、デフォルト発言先をクリアする(see issue #59)
    if ( !config.isEnableChannelChat() ) {
        manager.removeAllDefaultChannels();
    }

    // Vault のロード
    Plugin temp = getServer().getPluginManager().getPlugin("Vault");
    if ( temp != null ) {
        vaultchat = VaultChatBridge.load(temp);
    }

    // Dynmap のロード
    temp = getServer().getPluginManager().getPlugin("dynmap");
    if ( temp != null ) {
        dynmap = DynmapBridge.load(temp);
        if ( dynmap != null ) {
            getServer().getPluginManager().registerEvents(dynmap, this);
        }
    }

    // MultiverseCore のロード
    temp = getServer().getPluginManager().getPlugin("Multiverse-Core");
    if ( temp != null ) {
        multiverse = MultiverseCoreBridge.load(temp);
    }

    // mcMMOのロード
    if ( getServer().getPluginManager().isPluginEnabled("mcMMO") ) {
        getServer().getPluginManager().registerEvents(new McMMOBridge(), this);
    }

    // リスナーの登録
    getServer().getPluginManager().registerEvents(new BukkitEventListener(), this);

    // コマンドの登録
    lunachatCommand = new LunaChatCommand();
    messageCommand = new LunaChatMessageCommand();
    replyCommand = new LunaChatReplyCommand();
    lcjapanizeCommand = new LunaChatJapanizeCommand();

    // 期限チェッカータスクの起動
    expireCheckerTask = Bukkit.getScheduler().runTaskTimerAsynchronously(
            this, new ExpireCheckTask(), 100, 600);

    // イベント実行クラスの登録
    LunaChat.setEventSender(new BukkitEventSender());
}
 
Example #15
Source File: MetricsHandler.java    From TrMenu with MIT License 4 votes vote down vote up
public static Metrics getMetrics() {
    return metrics;
}
 
Example #16
Source File: Core.java    From skRayFall with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onEnable() {
    getLogger().info("Yay! You are running skRayFall " + this.getDescription().getVersion() + "!");
    getLogger().info("Nathan and Lewis <3 you.");

    getServer().getPluginManager().registerEvents(this, this);
    Skript.registerAddon(this);
    saveDefaultConfig();

    this.getCommand("skrayfall").setExecutor(new GeneralCommands(this));
    if (plugin == null) {
        plugin = this;
    }

    getLogger().info("Cooking Bacon...");

    Metrics metrics = new Metrics(this);

    // Register all types
    TypeManager typeManager = new TypeManager(this);
    typeManager.registerSyntax();

    CitizensSyntaxManager citizensSyntaxManager = new CitizensSyntaxManager(this);
    citizensSyntaxManager.registerSyntax();

    EffectLibSyntaxManager effectLibSyntaxManager = new EffectLibSyntaxManager(this);
    effectLibSyntaxManager.registerSyntax();
    effectManager = effectLibSyntaxManager.getEffectManager();
    rayfallEffectManager = effectLibSyntaxManager.getRayfallEffectManager();

    VotifierSyntaxManager votifierSyntaxManager = new VotifierSyntaxManager(this);
    votifierSyntaxManager.registerSyntax();

    HologramSyntaxManager hologramSyntaxManager = new HologramSyntaxManager(this);
    hologramSyntaxManager.registerSyntax();

    CrackshotSyntaxManager crackshotSyntaxManager = new CrackshotSyntaxManager(this);
    crackshotSyntaxManager.registerSyntax();

    BossBarApiSyntaxManager bossBarApiSyntaxManager = new BossBarApiSyntaxManager(this);
    bossBarApiSyntaxManager.registerSyntax();

    CapesSyntaxManager capesSyntaxManager = new CapesSyntaxManager(this);
    capesSyntaxManager.registerSyntax();

    CoreProtectSyntaxManager coreProtectSyntaxManager = new CoreProtectSyntaxManager(this);
    coreProtectSyntaxManager.registerSyntax();
    skCoreProtect = coreProtectSyntaxManager.getSkCoreProtect();

    ScoreboardSyntaxManager scoreboardSyntaxManager = new ScoreboardSyntaxManager(this);
    scoreboardSyntaxManager.registerSyntax();
    sbManager = scoreboardSyntaxManager.getIdScoreBoardManager();

    GeneralSyntaxManager generalSyntaxManager = new GeneralSyntaxManager(this);
    generalSyntaxManager.registerSyntax();

    VersionedGeneralSyntaxManager versionedGeneralSyntaxManager = new VersionedGeneralSyntaxManager(this);
    versionedGeneralSyntaxManager.registerSyntax();
    bossbarManager = versionedGeneralSyntaxManager.getBossbarManager();

    enableFastScoreboards = this.getConfig().getBoolean("enableFastScoreBoards");
    if (getConfig().getBoolean("UpdateAlerts", false)) {
        Updater updater =
                new Updater(this, 88677, this.getFile(), Updater.UpdateType.NO_DOWNLOAD, true);
        if (updater.getResult() == UpdateResult.UPDATE_AVAILABLE) {
            getServer().getConsoleSender().sendMessage("[" + ChatColor.DARK_AQUA + "skRayFall"
                    + ChatColor.RESET + "] " + ChatColor.RED + "An update for skRayFall is available!");
        }
    }
    getLogger().info("Bacon is ready!");
}
 
Example #17
Source File: WesvMetrics.java    From WorldEditSelectionVisualizer with MIT License 4 votes vote down vote up
private void addCustomChart(String name, Supplier<String> value) {
    metrics.addCustomChart(new Metrics.SimplePie(name, value::get));
}
 
Example #18
Source File: BStatsBukkit.java    From Plan with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected void addStringSettingPie(String id, String setting) {
    metrics.addCustomChart(new Metrics.SimplePie(id, () -> setting));
}
 
Example #19
Source File: AdditionsAPI.java    From AdditionsAPI with MIT License 4 votes vote down vote up
public void onEnable() {

		instance = this;

		// Initializing Config
		ConfigFile config = ConfigFile.getInstance();
		config.setup();
		if (config.getConfig().getBoolean("resource-pack.force-on-join"))
			ResourcePackManager.setForceResourcePack();

		// Initializing Data File
		DataFile.getInstance().setup();

		// Initializing Lang File and adding all entries
		LangFile lang = LangFile.getInstance();
		lang.setup();

		String pluginName = "more_minecraft";
		lang.addEntry(pluginName, "sword", "Sword");
		lang.addEntry(pluginName, "axe", "Axe");
		lang.addEntry(pluginName, "picakaxe", "Pickaxe");
		lang.addEntry(pluginName, "spade", "Shovel");
		lang.addEntry(pluginName, "hoe", "Hoe");
		lang.addEntry(pluginName, "helmet", "Helmet");
		lang.addEntry(pluginName, "chestplate", "Chestplate");
		lang.addEntry(pluginName, "leggings", "Leggings");
		lang.addEntry(pluginName, "boots", "Boots");
		lang.addEntry(pluginName, "leather_helmet", "Cap");
		lang.addEntry(pluginName, "leather_chestplate", "Tunic");
		lang.addEntry(pluginName, "leather_leggings", "Pants");
		lang.addEntry(pluginName, "leather_boots", "Boots");
		lang.addEntry(pluginName, "when_in_head", "When in head:");
		lang.addEntry(pluginName, "when_in_body", "When in body:");
		lang.addEntry(pluginName, "when_in_legs", "When in legs:");
		lang.addEntry(pluginName, "when_in_feet", "When in feet:");
		lang.addEntry(pluginName, "when_in_main_hand", "When in main hand:");
		lang.addEntry(pluginName, "when_in_off_hand", "When in off hand:");
		lang.addEntry(pluginName, "attribute_generic_attack_speed", "Attack Speed");
		lang.addEntry(pluginName, "attribute_generic_attack_damage", "Attack Damage");
		lang.addEntry(pluginName, "attribute_armor", "Armor");
		lang.addEntry(pluginName, "attribute_armor_toughness", "Armor Toughness");
		lang.addEntry(pluginName, "attribute_generic_follow_range", "Follow Range");
		lang.addEntry(pluginName, "attribute_generic_knockback_resistance", "Knockback Resistance");
		lang.addEntry(pluginName, "attribute_generic_luck", "Luck");
		lang.addEntry(pluginName, "attribute_generic_max_health", "Max Health");
		lang.addEntry(pluginName, "attribute_generic_movement_speed", "Speed");
		lang.addEntry(pluginName, "attribute_horse_jump_strength", "Horse Jump Strength");
		lang.addEntry(pluginName, "attribute_zombie_spawn_reinforcements", "Zombie Spawn Reinforcements");
		lang.addEntry(pluginName, "durability", "Durability:");
		lang.addEntry(pluginName, "death_message", " using [CustomItem]");
		lang.addEntry(pluginName, "resource_pack_kick",
				"You must accept the resource pack in order to join the server! Click on the server once, then click edit and change Server Resource pack to True.");
		lang.addEntry(pluginName, "item_durability_main_hand", "Item Durability in Main Hand: ");
		lang.addEntry(pluginName, "item_durability_off_hand", "Item Durability in Off Hand: ");

		lang.saveLang();

		// Initialize Metrics
		new Metrics(this);

		// Registering listeners
		for (Listener listener : Arrays.asList(new EnchantItem(), new Anvil(), new CraftingTable(), new BlockBreak(),
				new CustomItemBlockBreak(), new EntityDamage(), new EntityDamageByPlayerUsingCustomItem(),
				new PlayerCustomItemDamage(), new PlayerInteract(), new CustomItemPlayerInteract(),
				new PlayerShearEntity(), new CustomItemShearEntity(), new PlayerFish(), new CustomItemFish(),
				new BlockIgnite(), new CustomItemBlockIgnite(), new EntityShootBow(), new EntityShootCustomBow(),
				new CustomShieldEntityDamageByEntity(), new EntityToggleGlide(), new CustomElytraPlayerToggleGlide(),
				this, new ArrowFromCustomBowHit(), new PlayerDeath(), new DurabilityBar(), new FurnaceBurn(),
				new CustomItemFurnaceBurn(), new ResourcePackListener(), new Experience(), new ArmorListener(),
				new ArmorEquip(), new PlayerDropItem(), new PlayerDropCustomItem(), new PlayerPickupItem(),
				new PlayerPickupCustomItem())) {
			getServer().getPluginManager().registerEvents(listener, this);
		}

		// Commands
		PluginCommand additions = getCommand("additions");
		additions.setExecutor(new AdditionsCmd());
		additions.setTabCompleter(new AdditionsTab());
		
		// Check if the server has the methods I added to Spigot (anything newer than around the 6th of August 2018 should be good)
		try {
			Material.DIAMOND_BLOCK.isInteractable();
			Material.DIAMOND_BLOCK.getHardness();
			Material.DIAMOND_BLOCK.getBlastResistance();
		} catch (NoSuchMethodError e) {
			MaterialUtils.useNewMethods = false;
		}

		// Commented out - these are not ready yet. Works on Linux but still fighting
		// for the rest of the OSes.
		// Tools.loadAgentLibrary();
		// new RuntimeTransformer(ItemStackTransformer.class,
		// CraftItemStack_1_12_Transformer.class);

		// After all plugins have been enabled
		getServer().getScheduler().scheduleSyncDelayedTask(this, () -> load());
	}
 
Example #20
Source File: GlobalWarming.java    From GlobalWarming with GNU Lesser General Public License v3.0 4 votes vote down vote up
@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())));
}
 
Example #21
Source File: MineTinker.java    From MineTinker with GNU General Public License v3.0 4 votes vote down vote up
@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 #22
Source File: PluginUtils.java    From CS-CoreLib with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Returns the previously setup Metrics
 * which can be used to setup custom charts
 *
 * @return      Metrics of this Plugin
 */
public Metrics getMetrics() {
	return metrics;
}