Examples of YAMLProcessor


Examples of com.sk89q.util.yaml.YAMLProcessor

                try {
                    f.createNewFile();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            YAMLProcessor lang = new YAMLProcessor(f, true, YAMLFormat.EXTENDED);

            try {
                lang.load();
            } catch (Throwable e) {
                CraftBookPlugin.inst().getLogger().severe("An error occured loading the languages file for: " + language + "! This language WILL NOT WORK UNTIL FIXED!");
                e.printStackTrace();
                continue;
            }

            lang.setWriteDefaults(true);

            for(Entry<String, String> s : defaultMessages.entrySet())
                lang.getString(s.getKey(), s.getValue());

            lang.save();

            languageMap.put(language, lang);
        }
    }
View Full Code Here

Examples of com.sk89q.util.yaml.YAMLProcessor

    public String getString(String message, String language) {

        //message = ChatColor.stripColor(message);
        if(language == null || !languageMap.containsKey(language))
            language = CraftBookPlugin.inst().getConfiguration().language;
        YAMLProcessor languageData = languageMap.get(language);
        String def = defaultMessages.get(message);
        if(languageData == null) {
            if(!CraftBookPlugin.inst().getConfiguration().languageScanText || def != null) {
                return def == null ? message : def;
            } else {
                String trans = message;
                for(Entry<String, String> tran : defaultMessages.entrySet()) {
                    trans = StringUtils.replace(trans, tran.getKey(), tran.getValue());
                }
                return trans;
            }
        } else {
            String translated = null;
            if(def == null || languageData.getString(message) != null)
                translated = languageData.getString(message);
            else {
                translated = languageData.getString(message, def);
            }

            if(!CraftBookPlugin.inst().getConfiguration().languageScanText || translated != null) {
                if(translated != null)
                    return translated;
                else
                    return def == null ? message : def;
            } else {
                String trans = message;
                for(String tran : languageData.getMap().keySet()) {
                    String trand = defaultMessages.get(tran) != null ? languageData.getString(tran, defaultMessages.get(tran)) : languageData.getString(tran);
                    if(tran == null || trand == null) continue;
                    trans = StringUtils.replace(trans, tran, trand);
                }
                return trans;
            }
View Full Code Here

Examples of com.sk89q.util.yaml.YAMLProcessor

        return INSTANCE;
    }

    public void enable() {
        CraftBookPlugin.inst().createDefaultConfiguration(new File(CraftBookPlugin.inst().getDataFolder(), "ic-config.yml"), "ic-config.yml");
        icConfiguration = new ICConfiguration(new YAMLProcessor(new File(CraftBookPlugin.inst().getDataFolder(), "ic-config.yml"), true, YAMLFormat.EXTENDED), CraftBookPlugin.logger());

        midiFolder = new File(CraftBookPlugin.inst().getDataFolder(), "midi/");
        new File(midiFolder, "playlists").mkdirs();

        romFolder = new File(CraftBookPlugin.inst().getDataFolder(), "rom/");
View Full Code Here

Examples of com.sk89q.util.yaml.YAMLProcessor

    public boolean enable() {

        definitions = new HashSet<CustomDropDefinition>();

        CraftBookPlugin.inst().createDefaultConfiguration(new File(CraftBookPlugin.inst().getDataFolder(), "custom-drops.yml"), "custom-drops.yml");
        config = new YAMLProcessor(new File(CraftBookPlugin.inst().getDataFolder(), "custom-drops.yml"), false, YAMLFormat.EXTENDED);

        load();

        return true;
    }
View Full Code Here

Examples of com.sk89q.util.yaml.YAMLProcessor

            BlockState oldState = Bukkit.getWorlds().get(0).getBlockAt(0, 255, 0).getState();
            Bukkit.getWorlds().get(0).getBlockAt(0, 255, 0).setType(Material.WALL_SIGN);

            CraftBookPlugin.inst().createDefaultConfiguration(new File(getGenerationFolder(), "ic-config.yml"), "ic-config.yml");
            ICConfiguration icConfiguration = new ICConfiguration(new YAMLProcessor(new File(getGenerationFolder(), "ic-config.yml"), true, YAMLFormat.EXTENDED), CraftBookPlugin.logger());

            icConfiguration.load();

            int missingComments = 0;
View Full Code Here

Examples of com.sk89q.util.yaml.YAMLProcessor

                language.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        YAMLProcessor proc = new YAMLProcessor(language, true, YAMLFormat.EXTENDED);
        try {
            proc.load();
        } catch (IOException e) {
            e.printStackTrace();
        }

        proc.setWriteDefaults(true);

        new LanguageManager();

        for(Entry<String, String> map : LanguageManager.defaultMessages.entrySet()) {
            proc.getString(map.getKey(), map.getValue());
        }

        proc.save();
    }
View Full Code Here

Examples of com.sk89q.util.yaml.YAMLProcessor

                file.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        BukkitConfiguration config = new BukkitConfiguration(new YAMLProcessor(file, true, YAMLFormat.EXTENDED), Bukkit.getLogger());
        config.load();

        file = new File(getGenerationFolder(), "mechanisms.yml");
        if(!file.exists()) {
            try {
                file.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            file.delete();
            try {
                file.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        YAMLProcessor proc = new YAMLProcessor(file, true, YAMLFormat.EXTENDED);

        try {
            proc.load();
        } catch (IOException e) {
            e.printStackTrace();
        }

        List<String> mechs = new ArrayList<String>();

        mechs.addAll(CraftBookPlugin.availableMechanics.keySet());

        Collections.sort(mechs);

        for(String enabled : mechs) {

            Class<? extends CraftBookMechanic> mechClass = CraftBookPlugin.availableMechanics.get(enabled);
            try {
                if(mechClass != null) {

                    CraftBookMechanic mech = mechClass.newInstance();
                    mech.loadConfiguration(proc, "mechanics." + enabled + ".");
                }
            } catch (Throwable t) {
                Bukkit.getLogger().log(Level.WARNING, "Failed to load mechanic: " + enabled, t);
            }
        }

        Bukkit.getLogger().info("Created config files!");

        proc.save();
    }
View Full Code Here

Examples of com.sk89q.util.yaml.YAMLProcessor

        // -- Component loaders
        final File configDir = new File(getDataFolder(), "config/");
        componentManager.addComponentLoader(new StaticComponentLoader(getLogger(), configDir, new SessionComponent()) {
            @Override
            public ConfigurationFile createConfigurationNode(File file) {
                return new YAMLProcessorConfigurationFile(new YAMLProcessor(file, true, YAMLFormat.EXTENDED));
            }
        });
        final YAMLProcessor jarComponentAliases = new DefaultsFileYAMLProcessor("components.yml", false);
        try {
            jarComponentAliases.load();
        } catch (IOException e) {
            getLogger().severe("Error loading component aliases!");
            e.printStackTrace();
        } catch (YAMLException e) {
            getLogger().severe("Error loading component aliases!");
            e.printStackTrace();
        }
        componentManager.addComponentLoader(new ConfigListedComponentLoader(getLogger(),
                new YAMLNodeConfigurationNode(config),
                new YAMLNodeConfigurationNode(jarComponentAliases), configDir));

        for (String dir : config.getStringList("component-class-dirs", Arrays.asList("component-classes"))) {
            final File classesDir = new File(getDataFolder(), dir);
            if (!classesDir.exists() || !classesDir.isDirectory()) {
                classesDir.mkdirs();
            }
            componentManager.addComponentLoader(new ClassLoaderComponentLoader(getLogger(), classesDir, configDir) {
                @Override
                public ConfigurationFile createConfigurationNode(File file) {
                    return new YAMLProcessorConfigurationFile(new YAMLProcessor(file, true, YAMLFormat.EXTENDED));
                }
            });
        }

        for (String dir : config.getStringList("component-jar-dirs", Arrays.asList("component-jars"))) {
            final File classesDir = new File(getDataFolder(), dir);
            if (!classesDir.exists() || !classesDir.isDirectory()) {
                classesDir.mkdirs();
            }
            componentManager.addComponentLoader(new JarFilesComponentLoader(getLogger(), classesDir, configDir) {
                @Override
                public ConfigurationFile createConfigurationNode(File file) {
                    return new YAMLProcessorConfigurationFile(new YAMLProcessor(file, true, YAMLFormat.EXTENDED));
                }
            });
        }

        // -- Annotation handlers
View Full Code Here

Examples of com.sk89q.util.yaml.YAMLProcessor

     * Loads the configuration.
     */
    @Override
    public YAMLProcessor createConfiguration() {
        final File configFile = new File(getDataFolder(), "config.yml");
        YAMLProcessor config = new YAMLProcessor(configFile, true, YAMLFormat.EXTENDED);
        YAMLProcessor comments = new DefaultsFileYAMLProcessor("config-comments.yml", false);
        try {
            if (!configFile.exists()) {
                configFile.getParentFile().mkdirs();
                configFile.createNewFile();
            }
            config.load();
            comments.load();
        } catch (Exception e) {
            getLogger().log(Level.WARNING, "Error loading configuration: ", e);
        }

        for (Map.Entry<String, Object> e : comments.getMap().entrySet()) {
            if (e.getValue() != null) {
                config.setComment(e.getKey(), e.getValue().toString());
            }
        }

View Full Code Here

Examples of com.sk89q.util.yaml.YAMLProcessor

            try {
                configFile.createNewFile();
            } catch (IOException e) {
                CommandBook.logger().log(Level.SEVERE, "CommandBook: Spawn storage file creation error: {0}", e.getMessage());
            }
        config = new YAMLProcessor(configFile, true, YAMLFormat.COMPACT);
        load();
    }
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.