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


Java FileConfiguration.save方法代码示例

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


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

示例1: save

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
void save(Arena item) {
    if (item != null && item.getName() != null) {
        try {
            final FileConfiguration configuration = new YamlConfiguration();
            final File file = new File(this.getFolder(), "arena_" + item.getName() + ".yml");
            if (file.exists()) {
                if (!file.delete())
                    throw new IllegalStateException("Cannot delete file!");
            }
            if (!file.createNewFile())
                throw new IllegalStateException("Cannot create file!");
            configuration.load(file);
            final Map<String, Object> data = item.serialize();
            for (final String key : data.keySet()) {
                configuration.set("arena." + key, data.get(key));
            }
            configuration.save(file);
        } catch (IOException | InvalidConfigurationException ex) {
            Bukkit.getLogger().log(Level.WARNING,"Cannot save arena." ,ex.getMessage());
        }
    }
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:23,代码来源:ArenaFileManager.java

示例2: sync

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
/**
 * Write in-memory changes of config to its file
 *
 * @param clazz The configuration class to sync.
 */
public static void sync(Class clazz) {
    Object config = configurations.get(clazz);

    if (config == null)
        return;

    String name = config.getClass().getDeclaredAnnotation(Configuration.class).value();
    File file = new File(JavaPlugin.getProvidingPlugin(clazz).getDataFolder(), String.format("%s.yml", name));
    FileConfiguration configFile = new YamlConfiguration();

    buildToConfig(config, configFile);

    try {
        configFile.save(file);
    } catch (IOException e) {
        Logger.err("Couldn't sync config " + name + " to its file!");
    }
}
 
开发者ID:CyR1en,项目名称:Minecordbot,代码行数:24,代码来源:ConfigurationBuilder.java

示例3: restoreNodes

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public static void restoreNodes(Coord<File, FileConfiguration> coord, Class<? extends Configurable> clazz) throws IllegalArgumentException, IllegalAccessException, IOException {
	FileConfiguration config = coord.getValue();

    for (Field field : clazz.getDeclaredFields()) {
        Node node = field.getAnnotation(Node.class);
        if (node == null) continue;
        field.setAccessible(true);

        Object def = field.get(null);
        int mod = field.getModifiers();
        if (Modifier.isStatic(mod) && !Modifier.isFinal(mod)) {
            String path = node.path();
            Object value = config.get(path);
            if (value == null) {
                config.set(path, def);
                field.set(null, AzureAPI.colorzine(def)); // for colorzine
            } else {
                field.set(null, AzureAPI.colorzine(value));
            }
        }
    }

    config.save(coord.getKey());
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:25,代码来源:Configurable.java

示例4: removeCraft

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public void removeCraft(int nb) {
try {
	//replacing in the file
   	File craftfile = new File(plugin.getDataFolder(), "crafts.yml");
	craftfile.createNewFile();
	FileConfiguration craftconfig = YamlConfiguration.loadConfiguration(craftfile);
	int count = 0;
	for(String craftuuid : craftconfig.getConfigurationSection("Crafts").getKeys(false)) {
		if(nb == count) {
			craftconfig.set("Crafts." + craftuuid, null);
		}
		count++;
	}
	craftconfig.save(craftfile);
  	} catch (Exception e) {
  		//
  	}
  }
 
开发者ID:Slaymd,项目名称:CaulCrafting,代码行数:19,代码来源:CraftStorage.java

示例5: save

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
private void save(FileConfiguration fc) {
	try {
		fc.save(getRecordFile());
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:8,代码来源:LearnData.java

示例6: save

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public void save() {
    try {
    	 File dataDirectory = SkyWarsReloaded.get().getDataFolder();

         File playerInventories = new File(dataDirectory, "inventories.yml");

         if (!playerInventories.exists() && !playerInventories.createNewFile()) {
         	System.out.println("Could not get Inventories File");
             return;
         }

         if (playerInventories.exists()) {
             FileConfiguration storage = YamlConfiguration.loadConfiguration(playerInventories);
             
             storage.set("inventories", null);
            
             for (String uuid: inventories.keySet()) {
            	 storage.set("inventories." + uuid + ".contents", inventories.get(uuid).getContent());
            	 storage.set("inventories." + uuid + ".armor", inventories.get(uuid).getArmor());
            	 storage.set("inventories." + uuid + ".level", inventories.get(uuid).getLevel());
            	 storage.set("inventories." + uuid + ".exp", inventories.get(uuid).getExp());
            	 storage.set("inventories." + uuid + ".gameMode", inventories.get(uuid).getGameMode().toString());
             }
             storage.save(playerInventories);
         }
    } catch (IOException ioException) {
        System.out.println("Failed to load inventories file: " + ioException.getMessage());
    }
   
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:31,代码来源:InventoryController.java

示例7: addKill

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public static void addKill(String p) {
	File pFile = new File(Main.getInstance().getDataFolder(), "Players/" + p.toLowerCase() + ".yml");
	FileConfiguration pConfig = YamlConfiguration.loadConfiguration(pFile);
	pConfig.set("Kills", Integer.valueOf(pConfig.getInt("Kills") + 1));
	try {
		pConfig.save(pFile);
	} catch (Exception e) {
	}
}
 
开发者ID:MohibMirza,项目名称:RPGPlus,代码行数:10,代码来源:Datafiles.java

示例8: addDeath

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public static void addDeath(String p) {
	File pFile = new File(Main.getInstance().getDataFolder(), "Players/" + p.toLowerCase() + ".yml");
	FileConfiguration pConfig = YamlConfiguration.loadConfiguration(pFile);
	pConfig.set("Deaths", Integer.valueOf(pConfig.getInt("Deaths") + 1));
	try {
		pConfig.save(pFile);
	} catch (Exception e) {
	}
}
 
开发者ID:MohibMirza,项目名称:RPGPlus,代码行数:10,代码来源:Datafiles.java

示例9: setPoints

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public void setPoints(String p, int newAmount) {
	File pFile = new File(Main.getInstance().getDataFolder(), "Players/" + p.toLowerCase() + ".yml");
	FileConfiguration pConfig = YamlConfiguration.loadConfiguration(pFile);
	pConfig.set("Points", Integer.valueOf(newAmount));
	try {
		pConfig.save(pFile);
	} catch (Exception e) {
	}
}
 
开发者ID:MohibMirza,项目名称:RPGPlus,代码行数:10,代码来源:Datafiles.java

示例10: addPoints

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public void addPoints(String p, int amountAdded) {
	File pFile = new File(Main.getInstance().getDataFolder(), "Players/" + p.toLowerCase() + ".yml");
	FileConfiguration pConfig = YamlConfiguration.loadConfiguration(pFile);
	pConfig.set("Points", Integer.valueOf(pConfig.getInt("Points") + amountAdded));
	try {
		pConfig.save(pFile);
	} catch (Exception e) {
	}
}
 
开发者ID:MohibMirza,项目名称:RPGPlus,代码行数:10,代码来源:Datafiles.java

示例11: takePoints

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public void takePoints(String p, int amountTaken) {
	File pFile = new File(Main.getInstance().getDataFolder(), "Players/" + p.toLowerCase() + ".yml");
	FileConfiguration pConfig = YamlConfiguration.loadConfiguration(pFile);
	int PointsCurrent = pConfig.getInt("Points");
	if (PointsCurrent - amountTaken >= 0) {
		int newAmount = PointsCurrent - amountTaken;
		pConfig.set("Points", Integer.valueOf(newAmount));
	}
	try {
		pConfig.save(pFile);
	} catch (Exception e) {
	}
}
 
开发者ID:MohibMirza,项目名称:RPGPlus,代码行数:14,代码来源:Datafiles.java

示例12: addSignJoinGame

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public boolean addSignJoinGame(Location loc, String mapName) {
	if (SkyWarsReloaded.getMC().mapRegistered(mapName)) {
		String world = loc.getWorld().getName().toString();
		int x = loc.getBlockX();
		int y = loc.getBlockY();
		int z = loc.getBlockZ();
		GameSign gs = new GameSign(x, y, z, world, mapName);
		gameNumber = -1;
		File signJoinFile = new File(SkyWarsReloaded.get().getDataFolder(), "signJoinGames.yml");
		if (!signJoinFile.exists()) {
			SkyWarsReloaded.get().saveResource("signJoinGames.yml", false);
		}
		if (signJoinFile.exists()) {
			FileConfiguration storage = YamlConfiguration.loadConfiguration(signJoinFile);
			for (int i = 1; i < 1000; i++) {
				if (storage.getString("games." + i + ".map") == null) {
					gameNumber = i;
					break;
				}
			}
			storage.set("games." + gameNumber + ".x", x);
			storage.set("games." + gameNumber + ".y", y);
			storage.set("games." + gameNumber + ".z", z);
			storage.set("games." + gameNumber + ".world", world);
			storage.set("games." + gameNumber + ".map", mapName);
			try {
				storage.save(signJoinFile);
			} catch (IOException e) {
				e.printStackTrace();
			}
			signJoinGames.put(gameNumber, gs);
			createGame(gameNumber, gs);
			return true;
		} else {
			return false;
		}
		}
	return false;
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:40,代码来源:GameController.java

示例13: incrementCounter

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public static void incrementCounter(String p) {
	File pFile = new File(Main.getInstance().getDataFolder(), "Players/" + p.toLowerCase() + ".yml");
	FileConfiguration pConfig = YamlConfiguration.loadConfiguration(pFile);
	pConfig.set("counter", Integer.valueOf(pConfig.getInt("counter") + 1));
	try {
		pConfig.save(pFile);
	} catch (Exception e) {
	}
}
 
开发者ID:MohibMirza,项目名称:RPGPlus,代码行数:10,代码来源:Datafiles.java

示例14: setCombos

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public static void setCombos(String p, int index, String click) {
	File pFile = new File(Main.getInstance().getDataFolder(), "Players/" + p.toLowerCase() + ".yml");
	FileConfiguration pConfig = YamlConfiguration.loadConfiguration(pFile);
	List<String> combos = pConfig.getStringList("Combo");
	combos.remove(index);
	combos.add(index, click);
	pConfig.set("Combo", combos);
	try {
		pConfig.save(pFile);
	} catch (Exception e) {
	}
}
 
开发者ID:MohibMirza,项目名称:RPGPlus,代码行数:13,代码来源:Datafiles.java

示例15: resetCounter

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public static void resetCounter(String p) {
	File pFile = new File(Main.getInstance().getDataFolder(), "Players/" + p.toLowerCase() + ".yml");
	FileConfiguration pConfig = YamlConfiguration.loadConfiguration(pFile);
	pConfig.set("counter", Integer.valueOf(1));
	try {
		pConfig.save(pFile);
	} catch (Exception e) {
	}
}
 
开发者ID:MohibMirza,项目名称:RPGPlus,代码行数:10,代码来源:Datafiles.java


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