gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-17 21:58:40 28 4
gpt4 key购买 nike

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

YamlConfiguration.load介绍

[英]Creates a new YamlConfiguration, loading from the given file.

Any errors loading the Configuration will be logged and then ignored. If the specified input is not a valid config, a blank config will be returned.

The encoding used may follow the system dependent default.
[中]创建新的YamlConfiguration,从给定文件加载。
加载配置时出现的任何错误都将被记录,然后被忽略。如果指定的输入不是有效的配置,将返回一个空配置。
使用的编码可能遵循依赖于系统的默认值。

代码示例

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

/**
   * Creates a new {@link YamlConfiguration}, loading from the given reader.
   * <p>
   * Any errors loading the Configuration will be logged and then ignored.
   * If the specified input is not a valid config, a blank config will be
   * returned.
   *
   * @param reader input
   * @return resulting configuration
   * @throws IllegalArgumentException Thrown if stream is null
   */
  public static YamlConfiguration loadConfiguration(Reader reader) {
    Validate.notNull(reader, "Stream cannot be null");

    YamlConfiguration config = new YamlConfiguration();

    try {
      config.load(reader);
    } catch (IOException ex) {
      Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex);
    } catch (InvalidConfigurationException ex) {
      Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex);
    }

    return config;
  }
}

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

/**
 * Creates a new {@link YamlConfiguration}, loading from the given stream.
 * <p>
 * Any errors loading the Configuration will be logged and then ignored.
 * If the specified input is not a valid config, a blank config will be
 * returned.
 *
 * @param stream Input stream
 * @return Resulting configuration
 * @throws IllegalArgumentException Thrown if stream is null
 * @deprecated does not properly consider encoding
 * @see #load(InputStream)
 * @see #loadConfiguration(Reader)
 */
@Deprecated
public static YamlConfiguration loadConfiguration(InputStream stream) {
  Validate.notNull(stream, "Stream cannot be null");
  YamlConfiguration config = new YamlConfiguration();
  try {
    config.load(stream);
  } catch (IOException ex) {
    Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex);
  } catch (InvalidConfigurationException ex) {
    Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex);
  }
  return config;
}

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

/**
 * Creates a new {@link YamlConfiguration}, loading from the given file.
 * <p>
 * Any errors loading the Configuration will be logged and then ignored.
 * If the specified input is not a valid config, a blank config will be
 * returned.
 * <p>
 * The encoding used may follow the system dependent default.
 *
 * @param file Input file
 * @return Resulting configuration
 * @throws IllegalArgumentException Thrown if file is null
 */
public static YamlConfiguration loadConfiguration(File file) {
  Validate.notNull(file, "File cannot be null");
  YamlConfiguration config = new YamlConfiguration();
  try {
    config.load(file);
  } catch (FileNotFoundException ex) {
  } catch (IOException ex) {
    Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
  } catch (InvalidConfigurationException ex) {
    Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file , ex);
  }
  return config;
}

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

conf.load(file);
} catch (IOException e) {
  GlowServer.logger.log(Level.SEVERE, "Failed to read config: " + file, e);

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

config.load(configFile);
} catch (IOException e) {
  GlowServer.logger.log(Level.SEVERE, "Failed to read config: " + configFile, e);

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

config.load(configFile);
} catch (IOException e) {
  GlowServer.logger.log(Level.SEVERE, "Failed to read config: " + configFile, e);

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

YamlConfiguration bukkit = new YamlConfiguration();
try {
  bukkit.load(bukkitYml);
} catch (InvalidConfigurationException e) {
  report(bukkitYml, e);

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

public YamlWrapper(File file) {
  super();
  
  try {
    if (!file.exists()) {
      file.getParentFile().mkdirs();
      file.createNewFile();
    }
    super.load(file);
  } catch (Exception e) {
    e.printStackTrace();
  }
  this.file = file;
}

代码示例来源:origin: elBukkit/MagicPlugin

public static ConfigurationSection loadConfiguration(File file) throws IOException, InvalidConfigurationException
{
  YamlConfiguration configuration = new YamlConfiguration();
  try {
    configuration.load(file);
  } catch (FileNotFoundException fileNotFound) {
  }
  return configuration;
}

代码示例来源:origin: elBukkit/MagicPlugin

public static YamlConfiguration loadConfiguration(InputStream stream) throws IOException, InvalidConfigurationException
{
  YamlConfiguration configuration = new YamlConfiguration();
  try {
    configuration.load(new InputStreamReader(stream, "UTF-8"));
  } catch (FileNotFoundException fileNotFound) {
  }
  return configuration;
}

代码示例来源:origin: elBukkit/MagicPlugin

public static ConfigurationSection loadConfiguration(String fileName) throws IOException, InvalidConfigurationException
{
  YamlConfiguration configuration = new YamlConfiguration();
  try {
    configuration.load(fileName);
  } catch (FileNotFoundException fileNotFound) {
  }
  return configuration;
}

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

public YamlStorage(LukkitPlugin plugin, String path) {
  super(plugin, path, Storage.YAML);
  this.yamlConfiguration = new YamlConfiguration();
  try {
    this.yamlConfiguration.load(new FileReader(this.getStorageFile()));
  } catch (IOException | InvalidConfigurationException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: BentoBoxWorld/BentoBox

@NonNull
private YamlConfiguration addonDescription(@NonNull JarFile jar) throws InvalidAddonFormatException, IOException, InvalidConfigurationException {
  // Obtain the addon.yml file
  JarEntry entry = jar.getJarEntry("addon.yml");
  if (entry == null) {
    throw new InvalidAddonFormatException("Addon '" + jar.getName() + "' doesn't contains addon.yml file");
  }
  // Open a reader to the jar
  BufferedReader reader = new BufferedReader(new InputStreamReader(jar.getInputStream(entry)));
  // Grab the description in the addon.yml file
  YamlConfiguration data = new YamlConfiguration();
  data.load(reader);
  return data;
}

代码示例来源:origin: stackoverflow.com

YamlConfiguration config = new YamlConfiguration();
File[] files = this.getDataFolder().listFiles();
for(File file : files){
  try {
    config.load(file);
    if(config.contains("Path")){
      //What you need to do.
    }
  } catch (FileNotFoundException e) {
    e.printStackTrace();
  } catch (IOException e) {
    e.printStackTrace();
  } catch (InvalidConfigurationException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: aikar/commands

/**
 * Loads the given file
 * @param file
 * @param locale
 * @return If any language keys were added
 * @throws IOException
 * @throws InvalidConfigurationException
 */
public boolean loadYamlLanguageFile(File file, Locale locale) throws IOException, InvalidConfigurationException {
  YamlConfiguration yamlConfiguration = new YamlConfiguration();
  yamlConfiguration.load(file);
  return loadLanguage(yamlConfiguration, locale);
}

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

private FileConfiguration loadConfiguration() throws IOException, InvalidConfigurationException {
  File folder = createDataFolder();
  File file = new File(folder, "config.yml");
  if (!file.exists()) {
    plugin.getLogger().info("No config-file found. Creating default...");
    plugin.saveDefaultConfig();
  }
  YamlConfiguration yaml = new YamlConfiguration();
  yaml.load(file);
  return yaml;
}

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

public boolean isOptOut() {
  synchronized (optOutLock) {
    try {
      // Reload the metrics file
      configuration.load(getConfigFile());
    } catch (IOException | InvalidConfigurationException ex) {
      if (debug) {
        Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
      }
      return true;
    }
    return configuration.getBoolean("opt-out", false);
  }
}

代码示例来源:origin: aikar/commands

/**
 * Loads a file out of the plugins data folder by the given name
 * @param file
 * @param locale
 * @return If any language keys were added
 * @throws IOException
 * @throws InvalidConfigurationException
 */
public boolean loadYamlLanguageFile(String file, Locale locale) throws IOException, InvalidConfigurationException {
  YamlConfiguration yamlConfiguration = new YamlConfiguration();
  yamlConfiguration.load(new File(this.manager.plugin.getDataFolder(), file));
  return loadLanguage(yamlConfiguration, locale);
}

代码示例来源:origin: TotalFreedom/TotalFreedomMod

private ConfigDefaults(InputStream defaultConfig)
{
  try
  {
    defaults = new YamlConfiguration();
    final InputStreamReader isr = new InputStreamReader(defaultConfig);
    defaults.load(isr);
    isr.close();
  }
  catch (IOException ex)
  {
    FLog.severe(ex);
  }
  catch (InvalidConfigurationException ex)
  {
    FLog.severe(ex);
  }
}

代码示例来源:origin: eccentricdevotion/TARDIS

TARDISGeneralInstanceKeeper(TARDIS plugin) {
  this.plugin = plugin;
  roomArgs = buildRoomArgs();
  transparent = buildTransparent();
  doorListener = new TARDISDoorListener(plugin);
  sign_lookup = buildSignLookup();
  setRechargers();
  InputStream is = plugin.getResource("plugin.yml");
  InputStreamReader reader = new InputStreamReader(is);
  pluginYAML = new YamlConfiguration();
  try {
    pluginYAML.load(reader);
  } catch (IOException | InvalidConfigurationException ex) {
    Logger.getLogger(TARDISCommandHelper.class.getName()).log(Level.SEVERE, null, ex);
  }
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com