当前位置: 首页>>代码示例>>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;未经允许,请勿转载。