當前位置: 首頁>>代碼示例>>Java>>正文


Java YamlConfiguration.set方法代碼示例

本文整理匯總了Java中org.bukkit.configuration.file.YamlConfiguration.set方法的典型用法代碼示例。如果您正苦於以下問題:Java YamlConfiguration.set方法的具體用法?Java YamlConfiguration.set怎麽用?Java YamlConfiguration.set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.configuration.file.YamlConfiguration的用法示例。


在下文中一共展示了YamlConfiguration.set方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeTable

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
/** CURRENTLY UNTESTED! NEED TO REPLICATE THIS IN THE READING OF THE FILE AS WELL
 * This method will write the table specified by the internal parents
 * protected mTableName field.
 *
 * @param controller The configuration controller in order to gain
 *                   access to a specified resource file.
 */
@Override
public void writeTable (ConfigController controller)
{
    YamlConfiguration wageTable = controller.getSpecialConfig (mTableName.getFileName ());

    for (Map.Entry<String, ConcurrentHashMap<String, BigDecimal>> tableEntry : mBlockMap.entrySet ())
    {
        ConcurrentHashMap<String, BigDecimal> tableMap = tableEntry.getValue ();
        ConcurrentHashMap<String, BigDecimal> blockMapSection = mBlockMap.get (tableEntry.getKey ());

        for (Map.Entry<String, BigDecimal> entry : tableMap.entrySet ())
        {
            wageTable.set (tableEntry.getKey () + "." + entry.getKey (), blockMapSection.get (entry.getKey ()));
        }
    }

    controller.saveConfig (wageTable, mTableName.getFileName ());
}
 
開發者ID:MagnaRisa,項目名稱:CraftyProfessions,代碼行數:26,代碼來源:BlockTable.java

示例2: mockPlugin

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
private static Plugin mockPlugin() {
    final YamlConfiguration configuration = new YamlConfiguration();
    configuration.set("sql.enabled", false);
    configuration.set("sql.host", "localhost");
    configuration.set("sql.port", 3306);
    configuration.set("sql.database", "db");
    configuration.set("sql.username", "root");
    configuration.set("sql.password", "");
    final Plugin plugin = mock(Plugin.class);
    final Server server = mock(Server.class);
    when(server.getLogger()).thenReturn(Logger.getGlobal());
    if (Bukkit.getServer() == null)
        Bukkit.setServer(server);
    new File("BlockBall/BlockBall.db").delete();
    when(plugin.getDataFolder()).thenReturn(new File("BlockBall"));
    when(plugin.getConfig()).thenReturn(configuration);
    when(plugin.getResource(any(String.class))).thenAnswer(invocationOnMock -> {
        final String file = invocationOnMock.getArgument(0);
        return Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
    });
    return plugin;
}
 
開發者ID:Shynixn,項目名稱:BlockBall,代碼行數:23,代碼來源:StatsMySQLControllerTest.java

示例3: checkDefaults

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
/**
 * Checks if any configuration sections is null and sets a default
 * to avoid a NPE.
 */
private void checkDefaults() {
	YamlConfiguration config = file.returnYaml();
	main.getLogger().info("Checking for defaults inside data.yml");
	
	if (config.getStringList("supply-drops.enabled-worlds") == null || config.getStringList("supply-drops.enabled-worlds").isEmpty()) {
		config.set("supply-drops.enabled-worlds", Arrays.asList("world"));
	}
	
	if (config.get("radiation.default-damage") == null)
		config.set("radiation.default-damage", 1D);
	
	if (config.get("radiation.storm-damage") == null)
		config.set("radiation.storm-damage", 1D);
	
	if (config.get("radiation.water-damage") == null)
		config.set("radiation.water-damage", 2D);
	
	if (config.get("radiation.seconds-delay") == null)
		config.set("radiation.seconds-delay", 3);
	
	file.save(config);
	main.getLogger().info("Saved defaults.");
}
 
開發者ID:kadeska,項目名稱:MT_Core,代碼行數:28,代碼來源:DataManager.java

示例4: onPlayerExpChange

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
@EventHandler
public void onPlayerExpChange(PlayerExpChangeEvent event){
	Player player = event.getPlayer();
	YamlConfiguration PlayerData = onLoadData(player.getName());
	if(PlayerData ==null)return;
	PlayerData.set("attribute.level", player.getLevel());
	onSaveData(player.getName(), PlayerData);
	if(Config.getConfig("extraExp.enabled").equals("true")){
		int playerWantedPoints = PlayerData.getInt("wanted.points");
		if(playerWantedPoints > 0){
			int exp = event.getAmount();
			int value = Integer.valueOf(Config.getConfig("extraExp.pointsValue").replaceAll("%", ""));
			PlayerData.set("attribute.level", player.getLevel());
			int addExp = Integer.valueOf(String.valueOf(exp*playerWantedPoints*value/100));
			event.setAmount(addExp + exp);
			if(getConfig().getBoolean("extraExp.message") == true)
			player.sendMessage(Message.getMsg("player.expMessage", String.valueOf(addExp), String.valueOf(exp), String.valueOf(exp+addExp)));
			onSaveData(player.getName(), PlayerData);
		}
	}
}
 
開發者ID:Saukiya,項目名稱:PVPAsWantedManager,代碼行數:22,代碼來源:PVPAsWantedManager.java

示例5: 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

示例6: mockPlugin

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
private static Plugin mockPlugin() {
    final YamlConfiguration configuration = new YamlConfiguration();
    configuration.set("sql.enabled", false);
    configuration.set("sql.host", "localhost");
    configuration.set("sql.port", 3306);
    configuration.set("sql.database", "db");
    configuration.set("sql.username", "root");
    configuration.set("sql.password", "");
    final Plugin plugin = mock(Plugin.class);
    if (Bukkit.getServer() == null) {
        final Server server = mock(Server.class);
        when(server.getLogger()).thenReturn(Logger.getGlobal());
        Bukkit.setServer(server);
    }
    new File("PetBlocks.db").delete();
    when(plugin.getDataFolder()).thenReturn(new File("PetBlocks"));
    when(plugin.getConfig()).thenReturn(configuration);
    when(plugin.getResource(any(String.class))).thenAnswer(invocationOnMock -> {
        final String file = invocationOnMock.getArgument(0);
        return Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
    });
    return plugin;
}
 
開發者ID:Shynixn,項目名稱:PetBlocks,代碼行數:24,代碼來源:PlayerMetaSQLiteControllerIT.java

示例7: mockPlugin

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
private static Plugin mockPlugin() {
    final YamlConfiguration configuration = new YamlConfiguration();
    configuration.set("sql.enabled", false);
    configuration.set("sql.host", "localhost");
    configuration.set("sql.port", 3306);
    configuration.set("sql.database", "db");
    configuration.set("sql.username", "root");
    configuration.set("sql.password", "");
    final Plugin plugin = mock(Plugin.class);
    new File("PetBlocks.db").delete();
    when(plugin.getDataFolder()).thenReturn(new File("PetBlocks"));
    when(plugin.getConfig()).thenReturn(configuration);
    when(plugin.getResource(any(String.class))).thenAnswer(invocationOnMock -> {
        final String file = invocationOnMock.getArgument(0);
        return Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
    });
    return plugin;
}
 
開發者ID:Shynixn,項目名稱:PetBlocks,代碼行數:19,代碼來源:ParticleEffectMetaMySQLControllerIT.java

示例8: mockPlugin

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
private static Plugin mockPlugin() {
    final YamlConfiguration configuration = new YamlConfiguration();
    configuration.set("sql.enabled", false);
    configuration.set("sql.host", "localhost");
    configuration.set("sql.port", 3306);
    configuration.set("sql.database", "db");
    configuration.set("sql.username", "root");
    configuration.set("sql.password", "");
    final Plugin plugin = mock(Plugin.class);
    final Server server = mock(Server.class);
    when(server.getLogger()).thenReturn(Logger.getGlobal());
    if(Bukkit.getServer() == null)
        Bukkit.setServer(server);
    Factory.disable();
    new File("BlockBall/BlockBall.db").delete();
    when(plugin.getDataFolder()).thenReturn(new File("BlockBall"));
    when(plugin.getConfig()).thenReturn(configuration);
    when(plugin.getResource(any(String.class))).thenAnswer(invocationOnMock -> {
        final String file = invocationOnMock.getArgument(0);
        return Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
    });
    return plugin;
}
 
開發者ID:Shynixn,項目名稱:BlockBall,代碼行數:24,代碼來源:PlayerMetaSQLiteControllerTest.java

示例9: mockPlugin

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
private static Plugin mockPlugin() {
    final YamlConfiguration configuration = new YamlConfiguration();
    configuration.set("sql.enabled", false);
    configuration.set("sql.host", "localhost");
    configuration.set("sql.port", 3306);
    configuration.set("sql.database", "db");
    configuration.set("sql.username", "root");
    configuration.set("sql.password", "");
    try {
        final Field field = PetBlocksPlugin.class.getDeclaredField("logger");
        field.setAccessible(true);
        field.set(null, Logger.getGlobal());
    } catch (IllegalAccessException | NoSuchFieldException e) {
       Assert.fail();
    }
    final Plugin plugin = mock(Plugin.class);
    new File("PetBlocks.db").delete();
    when(plugin.getDataFolder()).thenReturn(new File("PetBlocks"));
    when(plugin.getConfig()).thenReturn(configuration);
    when(plugin.getResource(any(String.class))).thenAnswer(invocationOnMock -> {
        final String file = invocationOnMock.getArgument(0);
        return Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
    });
    return plugin;
}
 
開發者ID:Shynixn,項目名稱:PetBlocks,代碼行數:26,代碼來源:PetMetaMySQLControllerIT.java

示例10: mergeInDefaultConfig

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
private void mergeInDefaultConfig(YamlConfiguration c) {
     for (Map.Entry<String, Object> defaultConfigItem : defaults.entrySet()) {
        if (!c.contains(defaultConfigItem.getKey())) {
            c.set(defaultConfigItem.getKey(), defaultConfigItem.getValue());
        }
    }
}
 
開發者ID:Deltik,項目名稱:SignEdit,代碼行數:8,代碼來源:Configuration.java

示例11: saveMessagessToDisk

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
public void saveMessagessToDisk() {
	YamlConfiguration config = file.returnYaml();
	List<String> messageStrings = new ArrayList<>();
	
	for (TextMessage m : textMessages) {
		messageStrings.add(m.getConfigFormat());
	}
	
	config.set("messages", messageStrings);
	
	file.save(config);
}
 
開發者ID:kadeska,項目名稱:MT_Communication,代碼行數:13,代碼來源:TextMessageManager.java

示例12: savePlayersToDisk

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
public void savePlayersToDisk() {
		YamlConfiguration config = file.returnYaml();

		for (PlayerObject p : players.values()) {
			String uuid = p.getUuid().toString();
			config.set(uuid + ".current-cellphone-recipient", p.getCurrentCellPhoneRecipient());
//			config.set(uuid + ".walkie-talkie.current-channel", p.getCurrentWalkieTalkieFrequency().getChannel());
//			config.set(uuid + ".walkie-talkie.current-frequency", p.getCurrentWalkieTalkieFrequency().getFrequency());
			config.set(uuid + ".notification-sound", p.receiveNotificationSound());
			config.set(uuid + ".contacts", p.getContacts());
		}

		players.clear();
		file.save(config);
	}
 
開發者ID:kadeska,項目名稱:MT_Communication,代碼行數:16,代碼來源:PlayerManager.java

示例13: surrendPlayer

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
public static void surrendPlayer(Player player){
       YamlConfiguration PlayerData = PVPAsWantedManager.onLoadData(player.getName());
       int value = PlayerData.getInt("jail.times");
	int times = PlayerData.getInt("wanted.points")*Integer.valueOf(Config.getConfig("timeTick.jailPlayerTimes").replace("min", "").replace("m", ""));
	if(value > 0){
		player.sendMessage(Message.getMsg("player.isAlreadyInJailMessage"));
		return;
	}
	if(times <1){
		player.sendMessage(Message.getMsg("player.notSurrendMessage"));
		return;
	}
	Location location = player.getLocation();
       int playerX = location.getBlockX();
       int playerY = location.getBlockY();
       int playerZ = location.getBlockZ();
       String playerWorld = location.getWorld().getName();
       PlayerData.set("attribute.X", playerX);
       PlayerData.set("attribute.Y", playerY);
       PlayerData.set("attribute.Z", playerZ);
       PlayerData.set("attribute.World", playerWorld);
       PlayerData.set("wanted.points", Integer.valueOf(0));
       PlayerData.set("jail.times", times);
       PVPAsWantedManager.onDeleteList(player.getName(), "WantedList");
       PVPAsWantedManager.onCreateList(player.getName(), "JailedList");
       PVPAsWantedManager.onSaveData(player.getName(), PlayerData);
	JailManager.playerJoinJail(player,location);
	player.sendMessage(Message.getMsg("player.surrendMessage",String.valueOf(times)));
}
 
開發者ID:Saukiya,項目名稱:PVPAsWantedManager,代碼行數:30,代碼來源:JailManager.java

示例14: onSetJailTimes

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
@PlayerCommand(cmd="setTime",arg = " <player> <times>")
public void onSetJailTimes(CommandSender sender,String args[]){
	if(sender instanceof Player){
		if(!sender.hasPermission("pvpaswantedmanager." + args[0])) {
			sender.sendMessage(Message.getMsg("player.noPermissionMessage"));
			return;
		}
	}
	if(args.length <= 2 ){
		sender.sendMessage(Message.getMsg("admin.setTimeCorrectionsMessage"));
		return;
	}
	if(!Pattern.compile("[-0-9]*").matcher(args[2]).matches()){
		sender.sendMessage(Message.getMsg("admin.wrongFormatMessage"));
		return;
	}
	String playerName = args[1];
       YamlConfiguration PlayerData = PVPAsWantedManager.onLoadData(playerName);
       if(PlayerData == null){
       	sender.sendMessage(Message.getMsg("admin.playerNullMessage"));
       	return;
       }
	int times = PlayerData.getInt("jail.times");
	int value = times + Integer.valueOf(args[2]);
	PlayerData.set("jail.times", value);
	onSaveData(playerName, PlayerData);
	sender.sendMessage(Message.getMsg("admin.EditPlayerJailTimesMessage", playerName,String.valueOf(value)));
	
}
 
開發者ID:Saukiya,項目名稱:PVPAsWantedManager,代碼行數:30,代碼來源:PVPAsWantedManager.java

示例15: onSetPoint

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
@PlayerCommand(cmd="setPoint",arg = " <player> <value>")
public void onSetPoint(CommandSender sender,String args[]){
	if(sender instanceof Player){
		if(!sender.hasPermission("pvpaswantedmanager." + args[0])) {
			sender.sendMessage(Message.getMsg("player.noPermissionMessage"));
			return;
		}
	}
	if(args.length <3){
		sender.sendMessage(Message.getMsg("admin.wrongFormatMessage"));
		return;
	}
	
	YamlConfiguration PlayerData = onLoadData(args[1]);
	if(PlayerData == null){
		sender.sendMessage(Message.getMsg("admin.playerNullMessage"));
		return;
	}
	if(!Pattern.compile("[0-9]*").matcher(args[2]).matches()){
		sender.sendMessage(Message.getMsg("admin.wrongFormatMessage"));
		return;
	}
	int value = Integer.valueOf(args[2]);
	if(PlayerData.getInt("wanted.points")==0&& value > 0){
		PVPAsWantedManager.onCreateList(args[1], "WantedList");
	}else if(PlayerData.getInt("wanted.points")>0 && value ==0){
		PVPAsWantedManager.onDeleteList(args[1], "WantedList");
	}
	PlayerData.set("wanted.points", value);
	PVPAsWantedManager.onSaveData(args[1], PlayerData);
	sender.sendMessage(Message.getMsg("admin.EditPlayerDataMessage"));
	
}
 
開發者ID:Saukiya,項目名稱:PVPAsWantedManager,代碼行數:34,代碼來源:PVPAsWantedManager.java


注:本文中的org.bukkit.configuration.file.YamlConfiguration.set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。