当前位置: 首页>>代码示例>>Java>>正文


Java YamlConfiguration.save方法代码示例

本文整理汇总了Java中org.bukkit.configuration.file.YamlConfiguration.save方法的典型用法代码示例。如果您正苦于以下问题:Java YamlConfiguration.save方法的具体用法?Java YamlConfiguration.save怎么用?Java YamlConfiguration.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.configuration.file.YamlConfiguration的用法示例。


在下文中一共展示了YamlConfiguration.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initFile

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
/**
 * 初始化配置文件
 *
 * @param config
 *            配置文件
 * @throws IOException
 */
private static void initFile(final YamlConfiguration config) throws IOException {
    if (config.getString("guid") == null) {
        config.options().header("YUMC数据中心 http://www.yumc.pw 收集的数据仅用于统计插件使用情况").copyDefaults(true);
        config.set("guid", UUID.randomUUID().toString());
        config.set("debug", false);
        config.save(configfile);
    }
    if (!config.contains("YumAccount")) {
        config.set("YumAccount.username", "Username Not Set");
        config.set("YumAccount.password", "Password NotSet");
        config.save(configfile);
    }
    if (!config.contains("TellrawManualHandle")) {
        config.set("TellrawManualHandle", false);
        config.save(configfile);
    }
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:25,代码来源:YUMCStatistics.java

示例2: saveYamlFile

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
/**
 * Saves a YAML file
 * 
 * @param yamlFile
 * @param fileName
 */
@Override
public void saveYamlFile(YamlConfiguration yamlFile, String tableName, String fileName) {
    if (!fileName.endsWith(".yml")) {
        fileName = fileName + ".yml";
    }
    File tableFolder = new File(dataFolder, tableName);
    File file = new File(tableFolder, fileName);
    if (!tableFolder.exists()) {
        tableFolder.mkdirs();
    }
    try {
        yamlFile.save(file);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:23,代码来源:FlatFileDatabaseConnecter.java

示例3: save

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public boolean save(){
	YamlConfiguration recipe;
	 File f=new File(rs.getDataFolder()+File.separator+"SyntheticFormula"+File.separator+"FireCraftTable"+File.separator+name+".yml");
	if(!f.exists())try {f.createNewFile();} catch (IOException e1) {return false;}
	
	recipe=YamlConfiguration.loadConfiguration(f);
	recipe.set(name+".name", name);
	recipe.set(name+".time", time);
	recipe.set(name+".temperature", temperature);
	recipe.set(name+".maxTime", maxTime);
	recipe.set(name+".shape", shape);
	for(Character c:materials.keySet())
		recipe.set(name+".material."+c,materials.get(c) );
	for(int i=0;i<3;i++)
		recipe.set(name+".product."+i, product[i]);
	try {recipe.save(f);} catch (IOException e) {return false;}
	return true;
}
 
开发者ID:SchoolUniform,项目名称:RealSurvival,代码行数:19,代码来源:FireCraftTableRecipe.java

示例4: copyDefaultNode

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public static void copyDefaultNode(YamlConfiguration configFile, Plugin plugin, String path, String nodPath){
	configFile.createSection(nodPath);
	path = fixPath(path);
	InputStream file = plugin.getResource(path.replace(File.separatorChar, '/'));
	if(file!=null){
		YamlConfiguration defaultFile = YamlConfiguration.loadConfiguration(new InputStreamReader(file));
		if(defaultFile.contains(nodPath))
			configFile.set(nodPath, defaultFile.get(path));
		else
			configFile.set(nodPath, Error.MISSING_NODE.getMessage());
	}
	File temp = new File(plugin.getDataFolder(), path);
	try {
		configFile.save(temp);
	} catch (IOException e) {
		e.printStackTrace();
		ErrorLogger.addError("I/O Exception for file : " + temp.getAbsolutePath());
	}
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:20,代码来源:ConfigUtils.java

示例5: save

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
/**
 * Save Method (Only for YAML)
 *
 */

public void save(YamlConfiguration yamlConfiguration) {
    try {
        yamlConfiguration.save(file);
        main.getServer().getConsoleSender().sendMessage(MortuusTerraChat.MTC_PREFIX + ChatColor.GREEN + "Successfully saved file " + name + "!");
    } catch (IOException e) {
        e.printStackTrace();
        main.getServer().getConsoleSender().sendMessage(MortuusTerraChat.MTC_PREFIX + ChatColor.RED + "Failed to save file " + name + "!");
    }
}
 
开发者ID:kadeska,项目名称:MT_Communication,代码行数:15,代码来源:PluginFile.java

示例6: saveConfig

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
/**
 * This method will allow the saving of a single config file based on the file name
 *
 * @param resource The file to find and save
 */
public void saveConfig (String resource) throws IOException, ConfigNotFoundException
{
    YamlConfiguration configuration = getSpecialConfig (resource);
    File file = mWageFiles.get (resource);

    if (file == null)
    {
        throw new ConfigNotFoundException ("Could not find config labeled " + resource);
    }

    configuration.save (file);
}
 
开发者ID:MagnaRisa,项目名称:CraftyProfessions,代码行数:18,代码来源:ConfigController.java

示例7: BMetrics

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
/**
 * Class constructor.
 *
 * @param plugin The plugin which stats should be submitted.
 */
public BMetrics() {
    // Get the config file
    File bStatsFolder = new File(getConfigFile(), "bStats");
    File configFile = new File(bStatsFolder, "config.yml");
    YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);

    // Check if the config file exists
    if (!config.isSet("serverUuid")) {

        // Add default values
        config.addDefault("enabled", true);
        // Every server gets it's unique random id.
        config.addDefault("serverUuid", UUID.randomUUID().toString());
        // Should failed request be logged?
        config.addDefault("logFailedRequests", false);

        // Inform the server owners about bStats
        config.options().header(
                "bStats collects some data for plugin authors like how many servers are using their plugins.\n" +
                        "To honor their work, you should not disable it.\n" +
                        "This has nearly no effect on the server performance!\n" +
                        "Check out https://bStats.org/ to learn more :)"
        ).copyDefaults(true);
        try {
            config.save(configFile);
        } catch (IOException ignored) { }
    }

    // Load the data
    serverUUID = config.getString("serverUuid");
    logFailedRequests = config.getBoolean("logFailedRequests", false);
    if (config.getBoolean("enabled", true)) {
        startSubmitting();
    }
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:41,代码来源:BMetrics.java

示例8: load

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
private static YamlConfiguration load(String FileLocation)
   {
       File f = new File(FileLocation);
	YamlConfiguration cfg;
	cfg = setDefaults(); 
	if ( ! f.exists())
       {
		try 
           {
               if(f.getParentFile().mkdir() && f.createNewFile())
               {
                   Bukkit.getServer().getLogger().log(Level.INFO, "[PrisonPicks] New Config Created at: " + FileLocation);
                   cfg.save(new File(FileLocation));
               } else
               {
                   Bukkit.getServer().getLogger().log(Level.SEVERE, "[PrisonPicks] Failed to create Config file");
               }
		}catch (IOException e1)
           {
			e1.printStackTrace(); 
		}
	}else 
       {
		try 
           {
			cfg.load(f); 
		}catch (IOException | InvalidConfigurationException e)
           {
			e.printStackTrace(); 
		}
	}
	return cfg; 
}
 
开发者ID:ThePhilderbeast,项目名称:prisonPicks,代码行数:34,代码来源:Config.java

示例9: load

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
/**
 * Reset then load per-plugin language map
 * Based on {@link this#getPlugin()} and {@link this#getLanguage()}
 */
public void load() {
    String codeName = getLanguage();
    JavaPlugin plugin = getPlugin();
    if (codeName == null) codeName = DEFAULT_LANGUAGE;
    map.clear();
    // load languages
    loadResourceMap(corePlugin, DEFAULT_LANGUAGE, map, true, false);
    loadLocalMap(corePlugin, DEFAULT_LANGUAGE, map, true, false);
    loadResourceMap(corePlugin, codeName, map, true, false);
    loadLocalMap(corePlugin, codeName, map, true, false);

    loadResourceMap(getPlugin(), DEFAULT_LANGUAGE, map, false, false);
    loadLocalMap(getPlugin(), DEFAULT_LANGUAGE, map, false, false);
    loadResourceMap(getPlugin(), codeName, map, false, false);
    loadLocalMap(getPlugin(), codeName, map, false, false);

    // save (probably) modified language file back to disk
    File localLangFile = new File(plugin.getDataFolder(), codeName + ".yml");
    try {
        YamlConfiguration yaml = new YamlConfiguration();
        for (String key : map.keySet()) {
            yaml.set(key, map.get(key));
        }
        yaml.save(localLangFile);
    } catch (IOException ex) {
        plugin.getLogger().warning("Cannot save language file: " + codeName + ".yml");
    }

    plugin.getLogger().info(getFormatted("internal.info.using_language", codeName));
}
 
开发者ID:NyaaCat,项目名称:NyaaCore,代码行数:35,代码来源:LanguageRepository.java

示例10: save

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public void save() {
    ensureConfigIntegrity();
    YamlConfiguration cfg = new YamlConfiguration();
    serialize(cfg);
    try {
        cfg.save(ensureFile());
    } catch (IOException ex) {
        getPlugin().getLogger().severe("Cannot save " + getFileName() + ". Emergency dump:");
        getPlugin().getLogger().severe("\n" + cfg.saveToString());
        getPlugin().getLogger().severe("Cannot save " + getFileName() + ". Emergency dump End.");
        throw new RuntimeException(ex);
    }
}
 
开发者ID:NyaaCat,项目名称:NyaaCore,代码行数:14,代码来源:FileConfigure.java

示例11: save

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
/**
 * Save Method (Only for YAML)
 *
 */

public void save(YamlConfiguration yamlConfiguration) {
    try {
        yamlConfiguration.save(file);
        main.getServer().getConsoleSender().sendMessage(MortuusTerraCore.MTC_PREFIX + ChatColor.GREEN + "Successfully saved file " + name + "!");
    } catch (IOException e) {
        e.printStackTrace();
        main.getServer().getConsoleSender().sendMessage(MortuusTerraCore.MTC_PREFIX + ChatColor.RED + "Failed to save file " + name + "!");
    }
}
 
开发者ID:kadeska,项目名称:MT_Core,代码行数:15,代码来源:PluginFile.java

示例12: saveResource

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
/**
 * {@code synchronized} to prevent the overwriting of a file
 * that is already saving.
 *
 * @param name   the name of the resource.
 * @param config the YamlConfiguration to be saved.
 */
public synchronized void saveResource(String name, YamlConfiguration config) {
    try {
        config.save(new File(plugin.getDataFolder() + "/" + name + ".yml"));
    } catch (IOException e) {
        ConsoleLog.error("An IOException occurred when saving the resource '" + name + ".yml:");
        e.printStackTrace();
    }
}
 
开发者ID:ImABradley,项目名称:Peach,代码行数:16,代码来源:ResourceProvider.java

示例13: setRating

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public static void setRating(UUID uuid, Ladder ladder, Integer rating, GenericCallback callback) {
    if (Bukkit.getPlayer(uuid) != null) {
        ManagerHandler.getPlayerManager().getPlayerProfile(uuid).setRating(ladder, 1000);
        ManagerHandler.getPlayerManager().getPlayerProfile(uuid).save(null);
        callback.call(true);
        return;
    }

    try {
        File file = new File(PracticePlugin.getInstance().getDataFolder() + "/playerdata/" + uuid.toString() + ".yml");

        if (!file.exists()) {
            callback.call(false);
            return;
        }

        YamlConfiguration yml = YamlConfiguration.loadConfiguration(file);

        yml.set("ratings." + ladder.getName(), rating);
        yml.save(file);

        callback.call(true);
    }
    catch (Exception e) {
        callback.call(false);
        System.out.println("DataAccessor -> Failed method setRating");
        System.out.println(" * " + uuid.toString());
        System.out.println(" * " + ladder.getName());
        System.out.println(" * " + rating);
    }
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:32,代码来源:DataAccessor.java

示例14: writeFullConfig

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public boolean writeFullConfig(YamlConfiguration c) {
    mergeInDefaultConfig(c);
    sanitizeConfig(c);
    try {
        c.save(configFile);
        return true;
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }
}
 
开发者ID:Deltik,项目名称:SignEdit,代码行数:12,代码来源:Configuration.java

示例15: onSaveData

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
static public void onSaveData(String name, YamlConfiguration PlayerData){
	File DataFile = new File("plugins" + File.separator + "PVPAsWantedManager" + File.separator + "PlayerData" + File.separator + name + ".yml");
	try {PlayerData.save(DataFile);} catch (IOException e) {e.printStackTrace();}
}
 
开发者ID:Saukiya,项目名称:PVPAsWantedManager,代码行数:5,代码来源:PVPAsWantedManager.java


注:本文中的org.bukkit.configuration.file.YamlConfiguration.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。