本文整理汇总了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 ());
}
示例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;
}
示例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.");
}
示例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);
}
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
}
}
示例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);
}
示例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);
}
示例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)));
}
示例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)));
}
示例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"));
}