Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void registerYamlFile() {
- if (yamlConfiguration == null) {
- reloadYamlFile();
- }
- }
- public void reloadYamlFile() {
- File dir = new File(directory);
- if (!dir.exists()) dir.mkdirs();
- file = new File(directory, name + ".yml");
- if (!file.exists()) {
- try {
- if (file.createNewFile()) {
- if (javaPlugin != null) {
- String localDirectory = "";
- if (!directory.equals(javaPlugin.getDataFolder().getPath())) {
- localDirectory = StringUtils.remove(directory, javaPlugin.getDataFolder().getPath());
- localDirectory = StringUtils.replace(localDirectory, File.separator, "/");
- localDirectory = StringUtils.removeStart(localDirectory, "/");
- localDirectory = localDirectory + "/";
- }
- if (javaPlugin.getResource( localDirectory + name + ".yml") != null) javaPlugin.saveResource(localDirectory + name + ".yml", true);
- }
- }
- } catch (IOException | IllegalArgumentException e) {
- e.printStackTrace();
- }
- }
- yamlConfiguration = new YamlConfiguration();
- try{
- yamlConfiguration.load(file);
- }catch(Exception e){
- e.printStackTrace();
- }
- // load global replacements
- if (contains("replacements.global") && yamlConfiguration.isConfigurationSection("replacements.global")) {
- for (String key:getConfigurationSection("replacements.global").getKeys(false)) {
- SimpleYaml.globalReplacements.put(key, getString("replacements.global." + key));
- }
- }
- // load local replacements
- if (contains("replacements.local") && yamlConfiguration.isConfigurationSection("replacements.local")) {
- for (String key:getConfigurationSection("replacements.local").getKeys(false)) {
- replacements.put(key, getString("replacements.local." + key));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement