org.bukkit.configuration.file.YamlConfiguration.save()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(177)

本文整理了Java中org.bukkit.configuration.file.YamlConfiguration.save()方法的一些代码示例,展示了YamlConfiguration.save()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlConfiguration.save()方法的具体详情如下:
包路径:org.bukkit.configuration.file.YamlConfiguration
类名称:YamlConfiguration
方法名:save

YamlConfiguration.save介绍

暂无

代码示例

代码示例来源:origin: GlowstoneMC/Glowstone

/**
 * Save the configuration back to file.
 */
public void save() {
  try {
    config.save(configFile);
  } catch (IOException e) {
    GlowServer.logger.log(Level.SEVERE, "Failed to write config: " + configFile, e);
  }
}

代码示例来源:origin: GlowstoneMC/Glowstone

/**
 * Save the configuration back to file.
 */
public void save() {
  try {
    config.save(configFile);
  } catch (IOException e) {
    GlowServer.logger.log(Level.SEVERE, "Failed to write config: " + configFile, e);
  }
}

代码示例来源:origin: sgtcaze/NametagEdit

private void save(YamlConfiguration config, File file) {
  try {
    config.save(file);
  } catch (IOException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: FunnyGuilds/FunnyGuilds

@Override
public void save(File file) {
  try {
    if (!file.exists()) {
      file.getParentFile().mkdirs();
      file.createNewFile();
    }
    super.save(file);
  } catch (IOException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: FunnyGuilds/FunnyGuilds

public void save() {
  try {
    if (!file.exists()) {
      file.getParentFile().mkdirs();
      file.createNewFile();
    }
    super.save(this.file);
  } catch (IOException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: com.greatmancode/tools

@Override
public void setValue(String path, Object value) {
  configFile.set(path, value);
  try {
    configFile.save(file);
  } catch (IOException e) {
    serverCaller.getLogger().severe("Error while saving + " + file.getName() + ". Error: " + e.getMessage());
  }
}

代码示例来源:origin: artex-development/Lukkit

@Override
  public void save() {
    this.preSaveCheck();
    try {
      this.yamlConfiguration.save(this.getStorageFile());
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}

代码示例来源:origin: SkyWars/SkyWars

public void save(String header) throws IOException {
  config.options().header(header).indent(2);
  try {
    config.save(configFile.toFile());
  } catch (IOException ex) {
    throw new IOException("Failed to save to " + configFile.toAbsolutePath(), ex);
  }
}

代码示例来源:origin: drtshock/PlayerVaults

private void saveSignsFile() {
  if (!getConfig().getBoolean("signs-enabled", true)) {
    return;
  }
  saveQueued = false;
  try {
    signs.save(this.signsFile);
  } catch (IOException e) {
    getLogger().severe("PlayerVaults has encountered an error trying to save the signs file.");
    getLogger().severe("Please report this error to drtshock.");
    e.printStackTrace();
  }
}

代码示例来源:origin: garbagemule/MobArena

void save(SignStore signStore) {
  YamlConfiguration yaml = new YamlConfiguration();
  List<ArenaSign> values = new ArrayList<>(signStore.findAll());
  yaml.set("signs", values);
  try {
    File data = new File(plugin.getDataFolder(), "data");
    yaml.options().header("MobArena Sign Store\n\nPlease DON'T edit this file by hand!\n");
    yaml.save(new File(data, SignStore.FILENAME));
  } catch (IOException e) {
    throw new IllegalStateException(e);
  }
}

代码示例来源:origin: sgtcaze/NametagEdit

private void handleFile(Plugin plugin, CommandSender sender, String fileType) throws IOException {
  final boolean GROUP = fileType.equals("groups");
  File nametagConfigFile = new File(plugin.getDataFolder(), fileType + ".yml");
  YamlConfiguration nametagConfig = Utils.getConfig(nametagConfigFile);
  for (String line : getLines(sender, plugin, fileType + ".txt")) {
    if (!line.contains("=")) continue; // If the special token is missing, skip. Malformed line.
    if (GROUP) {
      handleGroup(nametagConfig, line);
    } else {
      handlePlayer(nametagConfig, line);
    }
  }
  nametagConfig.save(nametagConfigFile);
}

代码示例来源:origin: SkyWars/SkyWars

@Override
public void save() throws IOException {
  Path kitFile = plugin.getDataFolder().toPath().resolve("kits.yml");
  if (!Files.exists(kitFile)) {
    plugin.saveResource("kits.yml", true);
  }
  YamlConfiguration config = YamlConfiguration.loadConfiguration(kitFile.toFile());
  for (SkyKit kit : kits.values()) {
    SkyKitEnconder.encodeKit(kit, config);
  }
  for (SkyKit kit : disabledKits) {
    SkyKitEnconder.encodeKit(kit, config);
  }
  config.options().header(String.format(KIT_HEADER)).indent(2);
  config.save(kitFile.toFile());
}

代码示例来源:origin: garbagemule/MobArena

private void createBackup() {
  YamlConfiguration yaml = new YamlConfiguration();
  yaml.set("contents", contents);
  backup = new File(inventories, player.getUniqueId().toString());
  try {
    yaml.save(backup);
  } catch (IOException e) {
    throw new RuntimeException("Failed to store inventory for " + player.getName(), e);
  }
  arena.getInventoryManager().put(player, contents);
}

代码示例来源:origin: SkyWars/SkyWars

public void saveArena(Path path, SkyArenaConfig arenaConfig, String header) {
  YamlConfiguration newConfig = new YamlConfiguration();
  newConfig.options().header(header).indent(2);
  arenaConfig.serialize(newConfig);
  try {
    newConfig.save(path.toFile());
  } catch (IOException ex) {
    plugin.getLogger().log(Level.SEVERE, "Failed to save arena config to file " + path.toAbsolutePath(), ex);
  }
}

代码示例来源:origin: mcMMO-Dev/mcMMO

/**
   * Save formula file.
   */
  public void saveFormula() {
    mcMMO.p.debug("Saving previous XP formula type...");
    YamlConfiguration formulasFile = new YamlConfiguration();
    formulasFile.set("Previous_Formula", previousFormula.toString());

    try {
      formulasFile.save(formulaFile);
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
}

代码示例来源:origin: FunnyGuilds/FunnyGuilds

public void enable() throws IOException {
  // This has to be synchronized or it can collide with the check in the task.
  synchronized (optOutLock) {
    // Check if the server owner has already set opt-out, if not, set it.
    if (isOptOut()) {
      configuration.set("opt-out", false);
      configuration.save(configurationFile);
    }
    // Enable Task, if it is not running
    if (task == null) {
      start();
    }
  }
}

代码示例来源:origin: dzikoysk/WildSkript

public void enable() throws IOException {
  // This has to be synchronized or it can collide with the check in the task.
  synchronized (optOutLock) {
    // Check if the server owner has already set opt-out, if not, set it.
    if (isOptOut()) {
      configuration.set("opt-out", false);
      configuration.save(configurationFile);
    }
    // Enable Task, if it is not running
    if (task == null) {
      start();
    }
  }
}

代码示例来源:origin: dzikoysk/WildSkript

public void disable() throws IOException {
  // This has to be synchronized or it can collide with the check in the task.
  synchronized (optOutLock) {
    // Check if the server owner has already set opt-out, if not, set it.
    if (!isOptOut()) {
      configuration.set("opt-out", true);
      configuration.save(configurationFile);
    }
    // Disable Task, if it is running
    if (task != null) {
      task.cancel();
      task = null;
    }
  }
}

代码示例来源:origin: DevLeoko/AdvancedBan

@Override
public void createMySQLFile(File f) {
  mysql.set("MySQL.IP", "localhost");
  mysql.set("MySQL.DB-Name", "YourDatabase");
  mysql.set("MySQL.Username", "root");
  mysql.set("MySQL.Password", "pw123");
  mysql.set("MySQL.Port", 3306);
  try {
    mysql.save(f);
  } catch (IOException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: ChestShop-authors/ChestShop-3

public DiscountModule() {
  config = YamlConfiguration.loadConfiguration(ChestShop.loadFile("discounts.yml"));
  config.options().header("This file is for discount management. You are able to do that:\n" +
      "group1: 75\n" +
      "That means that the person with ChestShop.discount.group1 permission will pay only 75% of the price. \n" +
      "For example, if the price is 100 dollars, the player pays only 75 dollars.\n" +
      "(Only works in buy-only Admin Shops!)");
  try {
    config.save(ChestShop.loadFile("discounts.yml"));
  } catch (IOException e) {
    e.printStackTrace();
  }
  groupList = config.getKeys(false);
}

相关文章