Search in sources :

Example 1 with Metrics

use of org.bstats.bukkit.Metrics in project dynmap-structures by KovuTheHusky.

the class DynmapStructuresPlugin method onEnable.

@Override
public void onEnable() {
    // Set up the metrics
    new Metrics(this);
    // Set up the configuration
    this.saveDefaultConfig();
    configuration = this.getConfig();
    configuration.options().copyDefaults(true);
    this.saveConfig();
    // Register for events
    this.getServer().getPluginManager().registerEvents(this, this);
    // Save the logger for convenience
    logger = this.getLogger();
    // Check if Dynmap is even enabled
    if (Bukkit.getPluginManager().isPluginEnabled("dynmap")) {
        // Set up our Dynmap layer
        api = ((DynmapCommonAPI) Bukkit.getPluginManager().getPlugin("dynmap")).getMarkerAPI();
        set = api.createMarkerSet(configuration.getString("layer.name").toLowerCase(Locale.ROOT), configuration.getString("layer.name"), null, false);
        set.setHideByDefault(configuration.getBoolean("layer.hidebydefault"));
        set.setLayerPriority(configuration.getInt("layer.layerprio"));
        noLabels = configuration.getBoolean("layer.nolabels");
        int minZoom = configuration.getInt("layer.minzoom");
        if (minZoom > 0)
            set.setMinZoom(minZoom);
        includeCoordinates = configuration.getBoolean("layer.inc-coord");
        // Create the marker icons
        for (String str : images) {
            InputStream in = this.getClass().getResourceAsStream("/" + str.toLowerCase(Locale.ROOT) + ".png");
            if (in != null)
                if (api.getMarkerIcon("structures." + str.toLowerCase(Locale.ROOT)) == null)
                    api.createMarkerIcon("structures." + str.toLowerCase(Locale.ROOT), str, in);
                else
                    api.getMarkerIcon("structures." + str.toLowerCase(Locale.ROOT)).setMarkerIconImage(in);
        }
        // Build an array of files to parse if changed
        List<String> enabled = new ArrayList<>();
        if (configuration.getBoolean("structures.endcity"))
            enabled.add("EndCity.dat");
        if (configuration.getBoolean("structures.fortress"))
            enabled.add("Fortress.dat");
        if (configuration.getBoolean("structures.mansion"))
            enabled.add("Mansion.dat");
        if (configuration.getBoolean("structures.mineshaft"))
            enabled.add("Mineshaft.dat");
        if (configuration.getBoolean("structures.monument"))
            enabled.add("Monument.dat");
        if (configuration.getBoolean("structures.stronghold"))
            enabled.add("Stronghold.dat");
        if (configuration.getBoolean("structures.igloo") || configuration.getBoolean("structures.temple") || configuration.getBoolean("structures.witch")) {
            enabled.add("BOPTemple.dat");
            enabled.add("Temple.dat");
        }
        if (configuration.getBoolean("structures.village")) {
            enabled.add("BOPVillage.dat");
            enabled.add("Village.dat");
        }
        this.enabled = enabled.toArray(new String[enabled.size()]);
        // Parse the worlds that have already been loaded
        for (World w : Bukkit.getWorlds()) this.addWorld(w);
    }
}
Also used : Metrics(org.bstats.bukkit.Metrics) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) NBTString(com.kovuthehusky.nbt.tags.NBTString) World(org.bukkit.World)

Example 2 with Metrics

use of org.bstats.bukkit.Metrics in project Minigames by AddstarMC.

the class Minigames method initMetrics.

private void initMetrics() {
    this.metrics = new Metrics(this, 1190);
    final Metrics.MultiLineChart chart = new Metrics.MultiLineChart("Players_in_Minigames", () -> {
        final Map<String, Integer> result = new HashMap<>();
        result.put("Total_Players", this.playerManager.getAllMinigamePlayers().size());
        for (final MinigamePlayer pl : this.playerManager.getAllMinigamePlayers()) {
            if (pl.isInMinigame()) {
                int count = result.getOrDefault(pl.getMinigame().getType().getName(), 0);
                result.put(pl.getMinigame().getType().getName(), count + 1);
            }
        }
        return result;
    });
    final Metrics.SimpleBarChart barChart = new Metrics.SimpleBarChart("Modules_v_Servers", () -> {
        final Map<String, Integer> result = new HashMap<>();
        for (final Class module : this.minigameManager.getModules()) {
            result.put(module.getCanonicalName(), 1);
        }
        return result;
    });
    this.metrics.addCustomChart(chart);
    this.metrics.addCustomChart(barChart);
}
Also used : Metrics(org.bstats.bukkit.Metrics) MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer)

Example 3 with Metrics

use of org.bstats.bukkit.Metrics in project EliteMobs by MagmaGuy.

the class EliteMobs method onEnable.

@Override
public void onEnable() {
    Bukkit.getLogger().info(" _____ _     _____ _____ ________  ______________  _____");
    Bukkit.getLogger().info("|  ___| |   |_   _|_   _|  ___|  \\/  |  _  | ___ \\/  ___|");
    Bukkit.getLogger().info("| |__ | |     | |   | | | |__ | .  . | | | | |_/ /\\ `--.");
    Bukkit.getLogger().info("|  __|| |     | |   | | |  __|| |\\/| | | | | ___ \\ `--. \\");
    Bukkit.getLogger().info("| |___| |_____| |_  | | | |___| |  | \\ \\_/ / |_/ //\\__/ /");
    Bukkit.getLogger().info("\\____/\\_____/\\___/  \\_/ \\____/\\_|  |_/\\___/\\____/ \\____/");
    MetadataHandler.PLUGIN = this;
    Bukkit.getLogger().info("By MagmaGuy - v. " + MetadataHandler.PLUGIN.getDescription().getVersion());
    ServerTime.startTickCounter();
    if (Bukkit.getServer().spigot().getConfig().getDouble("settings.attribute.maxHealth.max") < 100000000) {
        Bukkit.getServer().spigot().getConfig().set("settings.attribute.maxHealth.max", 100000000);
        try {
            File spigotConfigContainer = new File(Paths.get(MetadataHandler.PLUGIN.getDataFolder().getParentFile().getCanonicalFile().getParentFile().toString() + "/spigot.yml").toString());
            Bukkit.getServer().spigot().getConfig().save(spigotConfigContainer);
            new InfoMessage("New default max health set correctly!");
        } catch (IOException e) {
            new WarningMessage("Failed to save max health value! For the plugin to work correctly, you should increase your max health on the spigot.yml config file to " + 100000000);
        }
    }
    // Remove entities that should not exist
    CrashFix.startupCheck();
    /*
        New config loading
         */
    initializeConfigs();
    if (Bukkit.getPluginManager().isPluginEnabled("LibsDisguises"))
        DisguiseEntity.initialize();
    if (worldGuardIsEnabled)
        Bukkit.getLogger().info("[EliteMobs] WorldGuard compatibility is enabled!");
    else
        Bukkit.getLogger().warning("[EliteMobs] WorldGuard compatibility is not enabled!");
    // Enable Vault
    try {
        VaultCompatibility.vaultSetup();
    } catch (Exception e) {
        Bukkit.getLogger().warning("[EliteMobs] Something went wrong with the vault configuration - your Vault " + "version is probably not compatible with this EliteMobs version. Please contact the dev about this error.");
        VaultCompatibility.VAULT_ENABLED = false;
    }
    // Hook up all listeners, some depend on config
    EventsRegistrer.registerEvents();
    // Launch the local data cache
    PlayerData.initializeDatabaseConnection();
    ElitePlayerInventory.initialize();
    // Get world list
    worldScanner();
    // Start the repeating tasks such as scanners
    launchRunnables();
    // launch events
    ActionEvent.initializeBlueprintEvents();
    TimedEvent.initializeBlueprintEvents();
    // launch internal clock for attack cooldown
    EliteMobDamagedByPlayerEvent.EliteMobDamagedByPlayerEventFilter.launchInternalClock();
    /*
        Initialize mob values
         */
    PluginMobProperties.initializePluginMobValues();
    /*
        Cache animation vectors
         */
    MinorPowerStanceMath.initializeVectorCache();
    MajorPowerStanceMath.initializeVectorCache();
    /*
        Scan for loaded SuperMobs
         */
    PassiveEliteMobDeathHandler.SuperMobScanner.scanSuperMobs();
    // Small check to make sure that PlaceholderAPI is installed
    if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
        Placeholders placeholders = new Placeholders();
        placeholders.register();
        this.placeholders = placeholders;
    }
    // Enable stats
    metrics = new Metrics(this, 1081);
    // Initialize custom charts
    new CustomCharts();
    // Imports custom configurations and mindungeons from the import folder
    ConfigurationImporter.initializeConfigs();
    ConfigurationExporter.initializeConfigs();
    // Import custom items after potentially importing new items
    new CustomItemsConfig();
    CustomItem.initializeCustomItems();
    LootTables.initialize();
    // Load minidungeons, most of all load the worlds of minidungeons
    new DungeonPackagerConfig();
    // Load Adventurer's Guild
    if (AdventurersGuildConfig.isGuildWorldIsEnabled()) {
        try {
            CustomWorldLoading.startupWorldInitialization();
            AdventurersGuildCommand.defineTeleportLocation();
            if (AdventurersGuildConfig.getGuildWorldLocation() == null)
                AdventurersGuildConfig.toggleGuildInstall();
        } catch (Exception e) {
            AdventurersGuildConfig.toggleGuildInstall();
            new WarningMessage("Failed to initialize the Adventurer's Guild Hub! It is now disabled. You can try to" + "reenable it in /em setup");
        }
    }
    // Load all regional bosses
    new CustomBossesConfig();
    new CustomTreasureChestsConfig();
    // Find the stats of bosses in minidungeons
    for (Minidungeon minidungeon : Minidungeon.getMinidungeons().values()) {
        if (minidungeon.getDungeonPackagerConfigFields().getDungeonLocationType() != null)
            if (minidungeon.getDungeonPackagerConfigFields().getDungeonLocationType().equals(DungeonPackagerConfigFields.DungeonLocationType.WORLD))
                minidungeon.quantifyWorldBosses();
            else if (minidungeon.getDungeonPackagerConfigFields().getDungeonLocationType().equals(DungeonPackagerConfigFields.DungeonLocationType.SCHEMATIC))
                minidungeon.quantifySchematicBosses(false);
    }
    // Initialize npcs
    new NPCsConfig();
    // Initialize custom spawn methods, this runs late because it compares loaded worlds against worlds listed in the config
    try {
        new CustomSpawnConfig();
    } catch (Exception ex) {
        new WarningMessage("You are using a version of Spigot or a branch thereof (Paper, Purpur, so on) that is (probably) HORRIBLY outdated!" + " This issue will probably be fixed if you update your server version to the latest patch of the version you are running.");
        new WarningMessage(" This does not mean that you have to update your Minecraft version, but it does mean you must update your server version to the latest patch" + " available for that Minecraft version. Download from trustworthy sources, as if you download Spigot from some random website other than Spigot," + " you are probably not getting the latest version (and also there's a high chance you'll get a virus).");
    }
    new CustomQuestsConfig();
    new WormholeConfig();
    // Commands
    new CommandHandler();
    /*
        Check for new plugin version or for dungeon updates
         */
    VersionChecker.check();
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) CustomItemsConfig(com.magmaguy.elitemobs.config.customitems.CustomItemsConfig) Minidungeon(com.magmaguy.elitemobs.dungeons.Minidungeon) CustomQuestsConfig(com.magmaguy.elitemobs.config.customquests.CustomQuestsConfig) CustomTreasureChestsConfig(com.magmaguy.elitemobs.config.customtreasurechests.CustomTreasureChestsConfig) IOException(java.io.IOException) CommandHandler(com.magmaguy.elitemobs.commands.CommandHandler) IOException(java.io.IOException) CustomCharts(com.magmaguy.elitemobs.thirdparty.bstats.CustomCharts) DungeonPackagerConfig(com.magmaguy.elitemobs.config.dungeonpackager.DungeonPackagerConfig) WormholeConfig(com.magmaguy.elitemobs.config.wormholes.WormholeConfig) Metrics(org.bstats.bukkit.Metrics) Placeholders(com.magmaguy.elitemobs.thirdparty.placeholderapi.Placeholders) InfoMessage(com.magmaguy.elitemobs.utils.InfoMessage) NPCsConfig(com.magmaguy.elitemobs.config.npcs.NPCsConfig) CustomSpawnConfig(com.magmaguy.elitemobs.config.customspawns.CustomSpawnConfig) File(java.io.File) CustomBossesConfig(com.magmaguy.elitemobs.config.custombosses.CustomBossesConfig)

Example 4 with Metrics

use of org.bstats.bukkit.Metrics in project MyPet by xXKeyleXx.

the class MyPetPlugin method onEnable.

public void onEnable() {
    this.isReady = false;
    Updater updater = new Updater("MyPet");
    updater.update();
    if (compatUtil.getInternalVersion() == null || !MyPetVersion.isValidBukkitPacket(compatUtil.getInternalVersion())) {
        getLogger().warning("This version of MyPet is not compatible with \"" + compatUtil.getInternalVersion() + "\". Is MyPet up to date?");
        updater.waitForDownload();
        setEnabled(false);
        return;
    }
    serviceManager.activate(Load.State.OnEnable);
    entityRegistry.registerEntityTypes();
    if (getLogger() instanceof MyPetLogger) {
        ((MyPetLogger) getLogger()).updateDebugLoggerLogLevel();
    }
    compatManager.enable();
    getLogger().info("Compat mode for " + compatUtil.getInternalVersion() + " loaded.");
    ConfigurationLoader.loadCompatConfiguration();
    // register leash flags
    registerLeashFlags();
    // register skilltree requirementSettings
    registerSkilltreeRequirements();
    // register exp calculators
    if (!new File(getDataFolder(), "exp.js").exists()) {
        platformHelper.copyResource(this, "exp.js", new File(getDataFolder(), "exp.js"));
    }
    serviceManager.getService(ExperienceCalculatorManager.class).ifPresent(calculatorManager -> {
        calculatorManager.registerCalculator("JS", JavaScriptExperienceCalculator.class);
        calculatorManager.registerCalculator("JavaScript", JavaScriptExperienceCalculator.class);
        calculatorManager.switchCalculator(Configuration.LevelSystem.CALCULATION_MODE.toLowerCase());
    });
    // register event listener
    PlayerListener playerListener = new PlayerListener();
    getServer().getPluginManager().registerEvents(playerListener, this);
    VehicleListener vehicleListener = new VehicleListener();
    getServer().getPluginManager().registerEvents(vehicleListener, this);
    EntityListener entityListener = new EntityListener();
    getServer().getPluginManager().registerEvents(entityListener, this);
    MyPetEntityListener myPetEntityListener = new MyPetEntityListener();
    getServer().getPluginManager().registerEvents(myPetEntityListener, this);
    LevelListener levelupListener = new LevelListener();
    getServer().getPluginManager().registerEvents(levelupListener, this);
    WorldListener worldListener = new WorldListener();
    getServer().getPluginManager().registerEvents(worldListener, this);
    // register commands
    getCommand("petname").setExecutor(new CommandName());
    getCommand("petcall").setExecutor(new CommandCall());
    getCommand("petsendaway").setExecutor(new CommandSendAway());
    getCommand("petstop").setExecutor(new CommandStop());
    getCommand("petrelease").setExecutor(new CommandRelease());
    getCommand("mypet").setExecutor(new CommandHelp());
    getCommand("petinventory").setExecutor(new CommandInventory());
    getCommand("petpickup").setExecutor(new CommandPickup());
    getCommand("petbehavior").setExecutor(new CommandBehavior());
    getCommand("petinfo").setExecutor(new CommandInfo());
    getCommand("mypetadmin").setExecutor(new CommandAdmin());
    getCommand("petskill").setExecutor(new CommandSkill());
    getCommand("petchooseskilltree").setExecutor(new CommandChooseSkilltree());
    getCommand("petbeacon").setExecutor(new CommandBeacon());
    getCommand("petrespawn").setExecutor(new CommandRespawn());
    getCommand("petsettings").setExecutor(new CommandSettings());
    getCommand("petswitch").setExecutor(new CommandSwitch());
    getCommand("petstore").setExecutor(new CommandStore());
    getCommand("petlist").setExecutor(new CommandList());
    getCommand("petcapturehelper").setExecutor(new CommandCaptureHelper());
    getCommand("pettrade").setExecutor(new CommandTrade());
    getCommand("petshop").setExecutor(new CommandShop());
    // load worldgroups
    WorldGroup.loadGroups(new File(getDataFolder().getPath(), "worldgroups.yml"));
    // register skills
    registerSkills();
    // create folders
    File skilltreeFolder = new File(getDataFolder().getPath(), "skilltrees");
    getDataFolder().mkdirs();
    boolean createDefaultSkilltree = skilltreeFolder.mkdirs();
    boolean createLocaleReadme = new File(getDataFolder(), "locale").mkdirs();
    new File(getDataFolder(), "logs").mkdirs();
    if (!createDefaultSkilltree) {
        File legacyDefaultSkilltree = new File(skilltreeFolder, "default.st");
        if (legacyDefaultSkilltree.exists()) {
            if (Util.getSha256FromFile(legacyDefaultSkilltree) == -4323392001800132707L) {
                createDefaultSkilltree = true;
                legacyDefaultSkilltree.delete();
            }
        }
    }
    if (createDefaultSkilltree) {
        File skilltreeFile = new File(skilltreeFolder, "Combat.st.json");
        if (!skilltreeFile.exists()) {
            platformHelper.copyResource(this, "skilltrees/Combat.st.json", new File(skilltreeFolder, "Combat.st.json"));
        }
        skilltreeFile = new File(skilltreeFolder, "Farm.st.json");
        if (!skilltreeFile.exists()) {
            platformHelper.copyResource(this, "skilltrees/Farm.st.json", new File(skilltreeFolder, "Farm.st.json"));
        }
        skilltreeFile = new File(skilltreeFolder, "PvP.st.json");
        if (!skilltreeFile.exists()) {
            platformHelper.copyResource(this, "skilltrees/PvP.st.json", new File(skilltreeFolder, "PvP.st.json"));
        }
        skilltreeFile = new File(skilltreeFolder, "Ride.st.json");
        if (!skilltreeFile.exists()) {
            platformHelper.copyResource(this, "skilltrees/Ride.st.json", new File(skilltreeFolder, "Ride.st.json"));
        }
        skilltreeFile = new File(skilltreeFolder, "Utility.st.json");
        if (!skilltreeFile.exists()) {
            platformHelper.copyResource(this, "skilltrees/Utility.st.json", new File(skilltreeFolder, "Utility.st.json"));
        }
        MyPetApi.getLogger().info("Default skilltree files created.");
    }
    // load skilltrees
    MyPetApi.getSkilltreeManager().clearSkilltrees();
    SkillTreeLoaderJSON.loadSkilltrees(new File(getDataFolder(), "skilltrees"));
    for (int i = 0; i <= Configuration.Misc.MAX_STORED_PET_COUNT; i++) {
        try {
            Bukkit.getPluginManager().addPermission(new Permission("MyPet.petstorage.limit." + i));
        } catch (Exception ignored) {
        }
    }
    if (createLocaleReadme) {
        platformHelper.copyResource(this, "locale-readme.txt", new File(getDataFolder(), "locale" + File.separator + "readme.txt"));
    }
    Translation.init();
    for (Team team : Bukkit.getScoreboardManager().getMainScoreboard().getTeams()) {
        if (team.getName().startsWith("MyPet-")) {
            team.unregister();
        }
    }
    // init repository
    if (Configuration.Repository.REPOSITORY_TYPE.equalsIgnoreCase("NBT")) {
        Configuration.Repository.REPOSITORY_TYPE = "SQLite";
        Configuration.Repository.CONVERT_FROM = "NBT";
        repo = new SqLiteRepository();
        try {
            repo.init();
        } catch (RepositoryInitException e) {
            e.printStackTrace();
            repo = null;
        }
    } else if (Configuration.Repository.REPOSITORY_TYPE.equalsIgnoreCase("MySQL")) {
        MyPetApi.getLogger().info("Connect to MySQL database...");
        repo = new MySqlRepository();
        try {
            repo.init();
            MyPetApi.getLogger().info("MySQL connection successful.");
        } catch (RepositoryInitException e) {
            MyPetApi.getLogger().warning("MySQL connection failed!");
            e.printStackTrace();
            repo = null;
        }
    } else if (Configuration.Repository.REPOSITORY_TYPE.equalsIgnoreCase("MongoDB")) {
        MyPetApi.getLogger().info("Connect to MongoDB database...");
        repo = new MongoDbRepository();
        try {
            repo.init();
            MyPetApi.getLogger().info("MongoDB connection successful.");
        } catch (RepositoryInitException e) {
            MyPetApi.getLogger().warning("MongoDB connection failed!");
            e.printStackTrace();
            repo = null;
        }
    }
    if (repo == null) {
        MyPetApi.getLogger().info("Connect to SQLite database...");
        repo = new SqLiteRepository();
        try {
            repo.init();
            MyPetApi.getLogger().info("SQLite connection successful.");
        } catch (RepositoryInitException ignored) {
            MyPetApi.getLogger().warning("SQLite connection failed!");
            setEnabled(false);
            return;
        }
    }
    Converter.convert();
    if (repo instanceof Scheduler) {
        Timer.addTask((Scheduler) repo);
    }
    File shopConfig = new File(getDataFolder(), "pet-shops.yml");
    if (!shopConfig.exists()) {
        platformHelper.copyResource(this, "pet-shops.yml", shopConfig);
    }
    new ShopManager();
    Timer.startTimer();
    updater.waitForDownload();
    pluginHookManager.enableHooks();
    serviceManager.activate(Load.State.AfterHooks);
    // init Metrics
    try {
        Metrics metrics = new Metrics(this, 778);
        if (metrics.isEnabled()) {
            metrics.addCustomChart(new Metrics.SingleLineChart("active_pets", () -> myPetManager.countActiveMyPets()));
            metrics.addCustomChart(new Metrics.SimplePie("build", MyPetVersion::getBuild));
            metrics.addCustomChart(new Metrics.SimplePie("update_mode", () -> {
                String mode = "Disabled";
                if (Configuration.Update.CHECK) {
                    mode = "Check";
                    if (Configuration.Update.DOWNLOAD) {
                        mode += " & Download";
                    }
                }
                return mode;
            }));
            metrics.addCustomChart(new Metrics.AdvancedPie("hooks", () -> {
                Map<String, Integer> activatedHooks = new HashMap<>();
                for (PluginHook hook : MyPetApi.getPluginHookManager().getHooks()) {
                    activatedHooks.put(hook.getPluginName(), 1);
                }
                return activatedHooks;
            }));
        }
    } catch (Throwable e) {
        errorReporter.sendError(e, "Init Metrics failed");
    }
    getLogger().info("Version " + MyPetVersion.getVersion() + "-b" + MyPetVersion.getBuild() + ChatColor.GREEN + " ENABLED");
    this.isReady = true;
    serviceManager.activate(Load.State.OnReady);
    // load pets for online players
    new BukkitRunnable() {

        @Override
        public void run() {
            for (final Player player : getServer().getOnlinePlayers()) {
                repo.getMyPetPlayer(player, new RepositoryCallback<MyPetPlayer>() {

                    @Override
                    public void callback(final MyPetPlayer p) {
                        if (p != null) {
                            final MyPetPlayerImpl onlinePlayer = (MyPetPlayerImpl) p;
                            onlinePlayer.setLastKnownName(player.getName());
                            if (!player.getUniqueId().equals(onlinePlayer.getOfflineUUID())) {
                                if (onlinePlayer.getMojangUUID() == null) {
                                    onlinePlayer.setMojangUUID(player.getUniqueId());
                                }
                                onlinePlayer.setOnlineMode(true);
                            }
                            playerManager.setOnline(onlinePlayer);
                            final WorldGroup joinGroup = WorldGroup.getGroupByWorld(player.getWorld().getName());
                            if (joinGroup.isDisabled()) {
                                return;
                            }
                            if (onlinePlayer.hasMyPet()) {
                                MyPet myPet = onlinePlayer.getMyPet();
                                if (!myPet.getWorldGroup().equals(joinGroup.getName())) {
                                    myPetManager.deactivateMyPet(onlinePlayer, true);
                                }
                            }
                            if (!onlinePlayer.hasMyPet() && onlinePlayer.hasMyPetInWorldGroup(joinGroup.getName())) {
                                final UUID petUUID = onlinePlayer.getMyPetForWorldGroup(joinGroup.getName());
                                MyPetApi.getRepository().getMyPet(petUUID, new RepositoryCallback<StoredMyPet>() {

                                    @Override
                                    public void callback(StoredMyPet storedMyPet) {
                                        myPetManager.activateMyPet(storedMyPet);
                                        if (onlinePlayer.hasMyPet()) {
                                            final MyPet myPet = onlinePlayer.getMyPet();
                                            final MyPetPlayer myPetPlayer = myPet.getOwner();
                                            if (myPet.wantsToRespawn()) {
                                                if (myPetPlayer.hasMyPet()) {
                                                    MyPet runMyPet = myPetPlayer.getMyPet();
                                                    switch(runMyPet.createEntity()) {
                                                        case Canceled:
                                                            runMyPet.getOwner().sendMessage(Util.formatText(Translation.getString("Message.Spawn.Prevent", myPet.getOwner()), runMyPet.getPetName()));
                                                            break;
                                                        case NoSpace:
                                                            runMyPet.getOwner().sendMessage(Util.formatText(Translation.getString("Message.Spawn.NoSpace", myPet.getOwner()), runMyPet.getPetName()));
                                                            break;
                                                        case NotAllowed:
                                                            runMyPet.getOwner().sendMessage(Util.formatText(Translation.getString("Message.No.AllowedHere", myPet.getOwner()), myPet.getPetName()));
                                                            break;
                                                        case Dead:
                                                            if (Configuration.Respawn.DISABLE_AUTO_RESPAWN) {
                                                                runMyPet.getOwner().sendMessage(Util.formatText(Translation.getString("Message.Call.Dead", myPet.getOwner()), myPet.getPetName()));
                                                            } else {
                                                                runMyPet.getOwner().sendMessage(Util.formatText(Translation.getString("Message.Spawn.Respawn.In", myPet.getOwner()), myPet.getPetName(), myPet.getRespawnTime()));
                                                            }
                                                            break;
                                                        case Flying:
                                                            runMyPet.getOwner().sendMessage(Util.formatText(Translation.getString("Message.Spawn.Flying", myPet.getOwner()), myPet.getPetName()));
                                                            break;
                                                        case Success:
                                                            runMyPet.getOwner().sendMessage(Util.formatText(Translation.getString("Message.Command.Call.Success", myPet.getOwner()), runMyPet.getPetName()));
                                                            break;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                });
                            }
                            onlinePlayer.checkForDonation();
                        }
                    }
                });
            }
        }
    }.runTaskLater(this, 0);
}
Also used : MySqlRepository(de.Keyle.MyPet.repository.types.MySqlRepository) MyPetPlayerImpl(de.Keyle.MyPet.util.player.MyPetPlayerImpl) Metrics(org.bstats.bukkit.Metrics) Updater(de.Keyle.MyPet.util.Updater) Permission(org.bukkit.permissions.Permission) ShopManager(de.Keyle.MyPet.util.shop.ShopManager) UUID(java.util.UUID) StoredMyPet(de.Keyle.MyPet.api.entity.StoredMyPet) Player(org.bukkit.entity.Player) MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) MongoDbRepository(de.Keyle.MyPet.repository.types.MongoDbRepository) MyPetLogger(de.Keyle.MyPet.api.util.logger.MyPetLogger) PluginHook(de.Keyle.MyPet.api.util.hooks.PluginHook) SqLiteRepository(de.Keyle.MyPet.repository.types.SqLiteRepository) File(java.io.File) Map(java.util.Map) HashMap(java.util.HashMap) MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) MyPet(de.Keyle.MyPet.api.entity.MyPet) StoredMyPet(de.Keyle.MyPet.api.entity.StoredMyPet) Team(org.bukkit.scoreboard.Team) ExperienceCalculatorManager(de.Keyle.MyPet.api.skill.experience.ExperienceCalculatorManager) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable)

Example 5 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)

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