Examples of YamlConfiguration


Examples of org.bukkit.configuration.file.YamlConfiguration

        if (!file.exists()) {
            plugin.saveResource("magicspells.yml", false);
            Messenger.info("magicspells.yml created.");
        }
        try {
            FileConfiguration config = new YamlConfiguration();
            config.load(file);
            setupSpells(config);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
View Full Code Here

Examples of org.bukkit.configuration.file.YamlConfiguration

    private final YamlConfiguration yamlConfiguration;
    private final Map<String, PPackage> cache = new HashMap<String, PPackage>();

    public FilePackageManager(File file) {
        this.file = file;
        yamlConfiguration = new YamlConfiguration();
        try {
            if(!file.exists()) {
                file.createNewFile();
            }
            yamlConfiguration.load(file);
View Full Code Here

Examples of org.bukkit.configuration.file.YamlConfiguration

    private final YamlConfiguration yamlConfiguration;

    public FileMetaData(File file, Database database) {
        super(database);
        this.file = file;
        yamlConfiguration = new YamlConfiguration();
        try {
            if(!file.getParentFile().exists()) {
                file.mkdirs();
            }
            if(!file.exists()) {
View Full Code Here

Examples of org.bukkit.configuration.file.YamlConfiguration

     *
     * loads from Jobs/generalConfig.yml
     */
    private synchronized void loadGeneralSettings(){
        File f = new File(plugin.getDataFolder(), "generalConfig.yml");
        YamlConfiguration config = YamlConfiguration.loadConfiguration(f);
       
        CommentedYamlConfiguration writer = new CommentedYamlConfiguration();
        StringBuilder header = new StringBuilder();
        header.append("General configuration.");
        header.append(System.getProperty("line.separator"));
        header.append("  The general configuration for the jobs plugin mostly includes how often the plugin");
        header.append(System.getProperty("line.separator"));
        header.append("saves user data (when the user is in the game), the storage method, whether");
        header.append(System.getProperty("line.separator"));
        header.append("to broadcast a message to the server when a user goes up a skill level.");
        header.append(System.getProperty("line.separator"));
        header.append("  It also allows admins to set the maximum number of jobs a player can have at");
        header.append(System.getProperty("line.separator"));
        header.append("any one time.");
        header.append(System.getProperty("line.separator"));
       
        config.options().copyDefaults(true);
       
        writer.options().header(header.toString());
       
        writer.addComment("locale-language", "Default language.  Use your languages two digit ISO 639-1 code, and optionally followed by the ISO-3166-1 country code.",
                "Example: en, en_US");
        config.addDefault("locale-language", Locale.getDefault().getLanguage());

        writer.addComment("storage-method", "storage method, can be MySQL, sqlite");
        config.addDefault("storage-method", "sqlite");
       
        writer.addComment("mysql-username", "Requires Mysql.");
        config.addDefault("mysql-username", "root");       
        config.addDefault("mysql-password", "");  
        config.addDefault("mysql-hostname", "localhost:3306");
        config.addDefault("mysql-database", "minecraft");
        config.addDefault("mysql-table-prefix", "jobs_");
       
        writer.addComment("save-period""How often in minutes you want it to save.  This must be a non-zero number");
        config.addDefault("save-period", 10);
       
        writer.addComment("save-on-disconnect",
                "Should player data be saved on disconnect?",
                "Player data is always periodically auto-saved and autosaved during a clean shutdown.",
                "Only enable this if you have a multi-server setup, or have a really good reason for enabling this.",
                "Turning this on will decrease database performance.");
        config.addDefault("save-on-disconnect", false);
       
        writer.addComment("broadcast-on-skill-up", "Do all players get a message when somone goes up a skill level?");
        config.addDefault("broadcast-on-skill-up", false);
       
        writer.addComment("broadcast-on-level-up", "Do all players get a message when somone goes up a level?");
        config.addDefault("broadcast-on-level-up", false);
       
        writer.addComment("max-jobs",
                "Maximum number of jobs a player can join.",
                "Use 0 for no maximum"
        );
        config.addDefault("max-jobs", 3);
       
        writer.addComment("hide-jobs-without-permission", "Hide jobs from player if they lack the permission to join the job");
        config.addDefault("hide-jobs-without-permission", false);
       
        writer.addComment("enable-pay-near-spawner", "option to allow payment to be made when killing mobs from a spawner");
        config.addDefault("enable-pay-near-spawner", false);
       
        writer.addComment("enable-pay-creative", "option to allow payment to be made in creative mode");
        config.addDefault("enable-pay-creative", false);
       
        writer.addComment("add-xp-player", "Adds the Jobs xp recieved to the player's Minecraft XP bar");
        config.addDefault("add-xp-player", false);
       
        writer.addComment("modify-chat", "Modifys chat to add chat titles.  If you're using a chat manager, you may add the tag {jobs} to your chat format and disable this.");
        config.addDefault("modify-chat", true);
       
        writer.addComment("economy-batch-delay", "Changes how often, in seconds, players are paid out.  Default is 5 seconds.",
                "Setting this too low may cause tick lag.  Increase this to improve economy performance (at the cost of delays in payment)");
        config.addDefault("economy-batch-delay", 5);
       
        writer.addComment("economy-async""Enable async economy calls.",
                "Only enable if your economy plugin is thread safe, use with EXTREME caution.");
        config.addDefault("economy-async", false);
       
        String storageMethod = config.getString("storage-method");
        if(storageMethod.equalsIgnoreCase("mysql")) {
            String legacyUrl = config.getString("mysql-url");
            if (legacyUrl != null) {
                String jdbcString = "jdbc:mysql://";
                if (legacyUrl.toLowerCase().startsWith(jdbcString)) {
                    legacyUrl = legacyUrl.substring(jdbcString.length());
                    String[] parts = legacyUrl.split("/");
                    if (parts.length >= 2) {
                        config.set("mysql-hostname", parts[0]);
                        config.set("mysql-database", parts[1]);
                    }
                }
            }
            String username = config.getString("mysql-username");
            if(username == null) {
                Jobs.getPluginLogger().severe("mysql-username property invalid or missing");
            }
            String password = config.getString("mysql-password");
            String hostname = config.getString("mysql-hostname");
            String database = config.getString("mysql-database");
            String prefix = config.getString("mysql-table-prefix");
            if (plugin.isEnabled())
                Jobs.setDAO(JobsDAOMySQL.initialize(hostname, database, username, password, prefix));
        } else if(storageMethod.equalsIgnoreCase("h2")) {
            File h2jar = new File(plugin.getDataFolder(), "h2.jar");
            Jobs.getPluginLogger().warning("H2 database no longer supported!  Converting to SQLite.");
            if (!h2jar.exists()) {
                Jobs.getPluginLogger().info("H2 library not found, downloading...");
                try {
                    FileDownloader.downloadFile(new URL("http://dev.bukkit.org/media/files/692/88/h2-1.3.171.jar"), h2jar);
                } catch (MalformedURLException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    Jobs.getPluginLogger().severe("Could not download database library!");
                }
            }
            if (plugin.isEnabled()) {
                try {
                    Jobs.getJobsClassloader().addFile(h2jar);
                } catch (IOException e) {
                    Jobs.getPluginLogger().severe("Could not load database library!");
                }
                if (plugin.isEnabled()) {
                    try {
                        JobsDAOH2.convertToSQLite();
                        Jobs.setDAO(JobsDAOSQLite.initialize());
                        config.set("storage-method", "sqlite");
                    } catch (SQLException e) {
                        Jobs.getPluginLogger().severe("Error when converting from H2 to SQLite!");
                        e.printStackTrace();
                    }
                }
            }
        } else if(storageMethod.equalsIgnoreCase("sqlite")) {
            Jobs.setDAO(JobsDAOSQLite.initialize());
        } else {
            Jobs.getPluginLogger().warning("Invalid storage method!  Changing method to sqlite!");
            config.set("storage-method", "sqlite");
            Jobs.setDAO(JobsDAOSQLite.initialize());
        }
       
        if (config.getInt("save-period") <= 0) {
            Jobs.getPluginLogger().severe("Save period must be greater than 0!  Defaulting to 10 minutes!");
            config.set("save-period", 10);
        }
       
        String localeString = config.getString("locale-language");
        try {
            int i = localeString.indexOf('_');
            if (i == -1) {
                locale = new Locale(localeString);
            } else {
                locale = new Locale(localeString.substring(0, i), localeString.substring(i+1));
            }
        } catch (IllegalArgumentException e) {
            locale = Locale.getDefault();
            Jobs.getPluginLogger().warning("Invalid locale \""+localeString+"\" defaulting to "+locale.getLanguage());
        }

        savePeriod = config.getInt("save-period");
        economyAsync = config.getBoolean("economy-async");
        isBroadcastingSkillups = config.getBoolean("broadcast-on-skill-up");
        isBroadcastingLevelups = config.getBoolean("broadcast-on-level-up");
        payInCreative = config.getBoolean("enable-pay-creative");
        addXpPlayer = config.getBoolean("add-xp-player");
        hideJobsWithoutPermission = config.getBoolean("hide-jobs-without-permission");
        maxJobs = config.getInt("max-jobs");
        payNearSpawner = config.getBoolean("enable-pay-near-spawner");
        modifyChat = config.getBoolean("modify-chat");
        economyBatchDelay = config.getInt("economy-batch-delay");
        saveOnDisconnect = config.getBoolean("save-on-disconnect");
       
        // Make sure we're only copying settings we care about
        copySetting(config, writer, "locale-language");
        copySetting(config, writer, "storage-method");
        copySetting(config, writer, "mysql-username");
View Full Code Here

Examples of org.bukkit.configuration.file.YamlConfiguration

     * loads from Jobs/titleConfig.yml
     */
    private synchronized void loadTitleSettings(){
        this.titles.clear();
        File f = new File(plugin.getDataFolder(), "titleConfig.yml");
        YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
        StringBuilder header = new StringBuilder()
            .append("Title configuration")
            .append(System.getProperty("line.separator"))
            .append(System.getProperty("line.separator"))
            .append("Stores the titles people gain at certain levels.")
            .append(System.getProperty("line.separator"))
            .append("Each title requres to have a name, short name (used when the player has more than")
            .append(System.getProperty("line.separator"))
            .append("1 job) the colour of the title and the level requrirement to attain the title.")
            .append(System.getProperty("line.separator"))
            .append(System.getProperty("line.separator"))
            .append("It is recommended but not required to have a title at level 0.")
            .append(System.getProperty("line.separator"))
            .append(System.getProperty("line.separator"))
            .append("Titles are completely optional.")
            .append(System.getProperty("line.separator"))
            .append(System.getProperty("line.separator"))
            .append("Titles:").append(System.getProperty("line.separator"))
            .append("  Apprentice:").append(System.getProperty("line.separator"))
            .append("    Name: Apprentice").append(System.getProperty("line.separator"))
            .append("    ShortName: A").append(System.getProperty("line.separator"))
            .append("    ChatColour: WHITE").append(System.getProperty("line.separator"))
            .append("    levelReq: 0").append(System.getProperty("line.separator"))
            .append("  Novice:").append(System.getProperty("line.separator"))
            .append("    Name: Novice").append(System.getProperty("line.separator"))
            .append("    ShortName: N").append(System.getProperty("line.separator"))
            .append("    ChatColour: GRAY").append(System.getProperty("line.separator"))
            .append("    levelReq: 30").append(System.getProperty("line.separator"))
            .append("  Journeyman:").append(System.getProperty("line.separator"))
            .append("    Name: Journeyman").append(System.getProperty("line.separator"))
            .append("    ShortName: J").append(System.getProperty("line.separator"))
            .append("    ChatColour: GOLD").append(System.getProperty("line.separator"))
            .append("    levelReq: 60").append(System.getProperty("line.separator"))
            .append("  Master:").append(System.getProperty("line.separator"))
            .append("    Name: Master").append(System.getProperty("line.separator"))
            .append("    ShortName: M").append(System.getProperty("line.separator"))
            .append("    ChatColour: BLACK").append(System.getProperty("line.separator"))
            .append("    levelReq: 90").append(System.getProperty("line.separator"))
            .append(System.getProperty("line.separator"));
        conf.options().header(header.toString());
        conf.options().copyDefaults(true);
        conf.options().indent(2);
       
        ConfigurationSection titleSection = conf.getConfigurationSection("Titles");
        if (titleSection == null) {
            titleSection = conf.createSection("Titles");
        }
        for (String titleKey : titleSection.getKeys(false)) {
            String titleName = conf.getString("Titles."+titleKey+".Name");
            String titleShortName = conf.getString("Titles."+titleKey+".ShortName");
            ChatColor titleColor = ChatColor.matchColor(conf.getString("Titles."+titleKey+".ChatColour", ""));
            int levelReq = conf.getInt("Titles."+titleKey+".levelReq", -1);
           
            if (titleName == null) {
                Jobs.getPluginLogger().severe("Title " + titleKey + " has an invalid Name property. Skipping!");
                continue;
            }
            if (titleShortName == null) {
                Jobs.getPluginLogger().severe("Title " + titleKey + " has an invalid ShortName property. Skipping!");
                continue;
            }
            if (titleColor == null) {
                Jobs.getPluginLogger().severe("Title " + titleKey + "has an invalid ChatColour property. Skipping!");
                continue;
            }
            if (levelReq <= -1) {
                Jobs.getPluginLogger().severe("Title " + titleKey + " has an invalid levelReq property. Skipping!");
                continue;
            }
           
            this.titles.add(new Title(titleName, titleShortName, titleColor, levelReq));
        }
       
        try {
            conf.save(f);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
View Full Code Here

Examples of org.bukkit.configuration.file.YamlConfiguration

     * loads from Jobs/restrictedAreas.yml
     */
    private synchronized void loadRestrictedAreaSettings(){
        this.restrictedAreas.clear();
        File f = new File(plugin.getDataFolder(), "restrictedAreas.yml");
        YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
        conf.options().indent(2);
        conf.options().copyDefaults(true);
        StringBuilder header = new StringBuilder();
       
        header.append("Restricted area configuration")
            .append(System.getProperty("line.separator"))
            .append(System.getProperty("line.separator"))
            .append("Configures restricted areas where you cannot get experience or money")
            .append(System.getProperty("line.separator"))
            .append("when performing a job.")
            .append(System.getProperty("line.separator"))
            .append(System.getProperty("line.separator"))
            .append("The multiplier changes the experience/money gains in an area.")
            .append(System.getProperty("line.separator"))
            .append("A multiplier of 0.0 means no money or xp, while 0.5 means you will get half the normal money/exp")
            .append(System.getProperty("line.separator"))
            .append(System.getProperty("line.separator"))
            .append("restrictedareas:")
            .append(System.getProperty("line.separator"))
            .append("  area1:")
            .append(System.getProperty("line.separator"))
            .append("    world: 'world'")
            .append(System.getProperty("line.separator"))
            .append("    multiplier: 0.0")
            .append(System.getProperty("line.separator"))
            .append("    point1:")
            .append(System.getProperty("line.separator"))
            .append("      x: 125")
            .append(System.getProperty("line.separator"))
            .append("      y: 0")
            .append(System.getProperty("line.separator"))
            .append("      z: 125")
            .append(System.getProperty("line.separator"))
            .append("    point2:")
            .append(System.getProperty("line.separator"))
            .append("      x: 150")
            .append(System.getProperty("line.separator"))
            .append("      y: 100")
            .append(System.getProperty("line.separator"))
            .append("      z: 150")
            .append(System.getProperty("line.separator"))
            .append("  area2:")
            .append(System.getProperty("line.separator"))
            .append("    world: 'world_nether'")
            .append(System.getProperty("line.separator"))
            .append("    multiplier: 0.0")
            .append(System.getProperty("line.separator"))
            .append("    point1:")
            .append(System.getProperty("line.separator"))
            .append("      x: -100")
            .append(System.getProperty("line.separator"))
            .append("      y: 0")
            .append(System.getProperty("line.separator"))
            .append("      z: -100")
            .append(System.getProperty("line.separator"))
            .append("    point2:")
            .append(System.getProperty("line.separator"))
            .append("      x: -150")
            .append(System.getProperty("line.separator"))
            .append("      y: 100")
            .append(System.getProperty("line.separator"))
            .append("      z: -150");
        conf.options().header(header.toString());
        ConfigurationSection areaSection = conf.getConfigurationSection("restrictedareas");
        if (areaSection != null) {
            for (String areaKey : areaSection.getKeys(false)) {
                String worldName = conf.getString("restrictedareas."+areaKey+".world");
                double multiplier = conf.getDouble("restrictedareas."+areaKey+".multiplier", 0.0);
                World world = Bukkit.getServer().getWorld(worldName);
                if (world == null)
                    continue;
                Location point1 = new Location(world,
                        conf.getDouble("restrictedareas."+areaKey+".point1.x", 0.0),
                        conf.getDouble("restrictedareas."+areaKey+".point1.y", 0.0),
                        conf.getDouble("restrictedareas."+areaKey+".point1.z", 0.0));
   
                Location point2 = new Location(world,
                        conf.getDouble("restrictedareas."+areaKey+".point2.x", 0.0),
                        conf.getDouble("restrictedareas."+areaKey+".point2.y", 0.0),
                        conf.getDouble("restrictedareas."+areaKey+".point2.z", 0.0));
                this.restrictedAreas.add(new RestrictedArea(point1, point2, multiplier));
            }
        }
        try {
            conf.save(f);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
View Full Code Here

Examples of org.bukkit.configuration.file.YamlConfiguration

            } catch (IOException e) {
                Jobs.getPluginLogger().severe("Unable to create jobConfig.yml!  No jobs were loaded!");
                return;
            }
        }
        YamlConfiguration conf = new YamlConfiguration();
        conf.options().pathSeparator('/');
        try {
            conf.load(f);
        } catch (Exception e) {
            Bukkit.getServer().getLogger().severe("==================== Jobs ====================");
            Bukkit.getServer().getLogger().severe("Unable to load jobConfig.yml!");
            Bukkit.getServer().getLogger().severe("Check your config for formatting issues!");
            Bukkit.getServer().getLogger().severe("No jobs were loaded!");
            Bukkit.getServer().getLogger().severe("Error: "+e.getMessage());
            Bukkit.getServer().getLogger().severe("==============================================");
            return;
        }
        conf.options().header(new StringBuilder()
            .append("Jobs configuration.").append(System.getProperty("line.separator"))
            .append(System.getProperty("line.separator"))
            .append("Stores information about each job.").append(System.getProperty("line.separator"))
            .append(System.getProperty("line.separator"))
            .append("For example configurations, visit http://dev.bukkit.org/server-mods/jobs/.").append(System.getProperty("line.separator"))
            .toString());
        ConfigurationSection jobsSection = conf.getConfigurationSection("Jobs");
        if (jobsSection == null) {
            jobsSection = conf.createSection("Jobs");
        }
        for (String jobKey : jobsSection.getKeys(false)) {
            ConfigurationSection jobSection = jobsSection.getConfigurationSection(jobKey);
            String jobName = jobSection.getString("fullname");
            if (jobName == null) {
                Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid fullname property. Skipping job!");
                continue;
            }
           
            int maxLevel = jobSection.getInt("max-level", 0);
            if (maxLevel < 0)
                maxLevel = 0;

            Integer maxSlots = jobSection.getInt("slots", 0);
            if (maxSlots.intValue() <= 0) {
                maxSlots = null;
            }

            String jobShortName = jobSection.getString("shortname");
            if (jobShortName == null) {
                Jobs.getPluginLogger().warning("Job " + jobKey + " is missing the shortname property.  Skipping job!");
                continue;
            }
           
            String description = jobSection.getString("description", "");
           
            ChatColor color = ChatColor.WHITE;
            if (jobSection.contains("ChatColour")) {
                color = ChatColor.matchColor(jobSection.getString("ChatColour", ""));
                if (color == null) {
                    color = ChatColor.WHITE;
                    Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid ChatColour property.  Defaulting to WHITE!");
                }
            }
            DisplayMethod displayMethod = DisplayMethod.matchMethod(jobSection.getString("chat-display", ""));
            if (displayMethod == null) {
                Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid chat-display property. Defaulting to None!");
                displayMethod = DisplayMethod.NONE;
            }
           
            Parser maxExpEquation;
            String maxExpEquationInput = jobSection.getString("leveling-progression-equation");
            try {
                maxExpEquation = new Parser(maxExpEquationInput);
                // test equation
                maxExpEquation.setVariable("numjobs", 1);
                maxExpEquation.setVariable("joblevel", 1);
                maxExpEquation.getValue();
            } catch(Exception e) {
                Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid leveling-progression-equation property. Skipping job!");
                continue;
            }
           
            Parser incomeEquation;
            String incomeEquationInput = jobSection.getString("income-progression-equation");
            try {
                incomeEquation = new Parser(incomeEquationInput);
                // test equation
                incomeEquation.setVariable("numjobs", 1);
                incomeEquation.setVariable("joblevel", 1);
                incomeEquation.setVariable("baseincome", 1);
                incomeEquation.getValue();
            } catch(Exception e) {
                Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid income-progression-equation property. Skipping job!");
                continue;
            }
           
            Parser expEquation;
            String expEquationInput = jobSection.getString("experience-progression-equation");
            try {
                expEquation = new Parser(expEquationInput);
                // test equation
                expEquation.setVariable("numjobs", 1);
                expEquation.setVariable("joblevel", 1);
                expEquation.setVariable("baseexperience", 1);
                expEquation.getValue();
            } catch(Exception e) {
                Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid experience-progression-equation property. Skipping job!");
                continue;
            }
           
            // Permissions
            ArrayList<JobPermission> jobPermissions = new ArrayList<JobPermission>();
            ConfigurationSection permissionsSection = jobSection.getConfigurationSection("permissions");
            if(permissionsSection != null) {
                for(String permissionKey : permissionsSection.getKeys(false)) {
                    ConfigurationSection permissionSection = permissionsSection.getConfigurationSection(permissionKey);
                   
                    String node = permissionKey.toLowerCase();
                    if (permissionSection == null) {
                        Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid permission key" + permissionKey + "!");
                        continue;
                    }
                    boolean value = permissionSection.getBoolean("value", true);
                    int levelRequirement = permissionSection.getInt("level", 0);
                    jobPermissions.add(new JobPermission(node, value, levelRequirement));
                }
            }
           
            Job job = new Job(jobName, jobShortName, description, color, maxExpEquation, displayMethod, maxLevel, maxSlots, jobPermissions);
           
            for (ActionType actionType : ActionType.values()) {
                ConfigurationSection typeSection = jobSection.getConfigurationSection(actionType.getName());
                ArrayList<JobInfo> jobInfo = new ArrayList<JobInfo>();
                if (typeSection != null) {
                    for (String key : typeSection.getKeys(false)) {
                        ConfigurationSection section = typeSection.getConfigurationSection(key);
                        String myKey = key.toUpperCase();
                        String type = null;
                        String subType = "";
                       
                        if (myKey.contains("-")) {
                            // uses subType
                            subType = ":" + myKey.split("-")[1];
                            myKey = myKey.split("-")[0];
                        }
                        Material material = Material.matchMaterial(myKey);
                        if (material == null) {
                            // try integer method
                            Integer matId = null;
                            try {
                                matId = Integer.decode(myKey);
                            } catch (NumberFormatException e) {}
                            if (matId != null) {
                                material = Material.getMaterial(matId);
                                if (material != null) {
                                    Jobs.getPluginLogger().warning("Job " + jobKey + " " + actionType.getName() + " is using a block by number ID: " + key + "!");
                                    Jobs.getPluginLogger().warning("Please switch to using the Material name instead: "+material.toString()+"!");
                                    Jobs.getPluginLogger().warning("Blocks by number IDs may break in a future release!");
                                }
                            }
                        }
                       
                        if (material != null) {
                            // Break and Place actions MUST be blocks
                            if (actionType == ActionType.BREAK || actionType == ActionType.PLACE) {
                                if (!material.isBlock()) {
                                    Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid " + actionType.getName() + " type property: " + key + "! Material must be a block!");
                                    continue;
                                }
                            }
                            // START HACK
                            /*
                             * Historically, GLOWING_REDSTONE_ORE would ONLY work as REDSTONE_ORE, and putting
                             * GLOWING_REDSTONE_ORE in the configuration would not work.  Unfortunately, this is
                             * completely backwards and wrong.
                             *
                             * To maintain backwards compatibility, all instances of REDSTONE_ORE should normalize
                             * to GLOWING_REDSTONE_ORE, and warn the user to change their configuration.  In the
                             * future this hack may be removed and anybody using REDSTONE_ORE will have their
                             * configurations broken.
                             */
                            if (material == Material.REDSTONE_ORE) {
                                Jobs.getPluginLogger().warning("Job "+jobKey+" is using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE.");
                                Jobs.getPluginLogger().warning("Automatically changing block to GLOWING_REDSTONE_ORE.  Please update your configuration.");
                                Jobs.getPluginLogger().warning("In vanilla minecraft, REDSTONE_ORE changes to GLOWING_REDSTONE_ORE when interacted with.");
                                Jobs.getPluginLogger().warning("In the future, Jobs using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE may fail to work correctly.");
                                material = Material.GLOWING_REDSTONE_ORE;
                            }
                            // END HACK
                           
                            type = material.toString();
                        } else if (actionType == ActionType.KILL) {
                            // check entities
                            EntityType entity = EntityType.fromName(key);
                            if (entity == null) {
                                try {
                                    entity = EntityType.valueOf(key.toUpperCase());
                                } catch (IllegalArgumentException e) {}
                            }
                           
                            if (entity != null && entity.isAlive())
                                type = entity.toString();
                        }
                       
                        if (type == null) {
                            Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid " + actionType.getName() + " type property: " + key + "!");
                            continue;
                        }
                       
                        double income = section.getDouble("income", 0.0);
                        double experience = section.getDouble("experience", 0.0);
                       
                        jobInfo.add(new JobInfo(type+subType, income, incomeEquation, experience, expEquation));
                    }
                }
                job.setJobInfo(actionType, jobInfo);
            }
           
            if (jobKey.equalsIgnoreCase("none")) {
                Jobs.setNoneJob(job);
            } else {
                jobs.add(job);
            }
        }
        try {
            conf.save(f);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
View Full Code Here

Examples of org.bukkit.configuration.file.YamlConfiguration

   throw new FileNotFoundException("\"" + directory.getPath() + "\" is not a directory");
  for (File file : directory.listFiles()) {
   String filename = file.getName();
   if (filename.endsWith(".yml")) {
    String sectionName = filename.replaceAll("\\.yml$", "");
    FileConfiguration sectionConfig = new YamlConfiguration();
    sectionConfig.options().pathSeparator(this.options().pathSeparator());
    sectionConfig.load(file);
    this.putSection(sectionName, sectionConfig);
   }
  }
}
View Full Code Here

Examples of org.bukkit.configuration.file.YamlConfiguration

   throw new FileNotFoundException("\"" + directory.getPath() + "\" is not a directory");
  for (String sectionName : this.getKeys(false)) {
   if (section != null && !sectionName.equals(section))
    continue;
   if (this.isConfigurationSection(sectionName)) {
    FileConfiguration sectionConfig = new YamlConfiguration();
    sectionConfig.addDefaults(this.getConfigurationSection(sectionName).getValues(true));
    sectionConfig.options().copyDefaults(true);
    sectionConfig.save(new File(directory, sectionName + ".yml"));
   }
  }
}
View Full Code Here

Examples of org.bukkit.configuration.file.YamlConfiguration

  private YamlConfiguration permBukkit;

  public ImportPermBukkit(SimplyPlugin plugin) {
    super(plugin);
    this.plugin = plugin;
    this.permBukkit = new YamlConfiguration();
    permBukkit.options().pathSeparator('/');
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.