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