當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。