Package org.bukkit.configuration.file

Examples of org.bukkit.configuration.file.YamlConfiguration.loadFromString()


        }
       
        // Containers
        if (modify instanceof InventoryHolder) {
          YamlConfiguration config = new YamlConfiguration();
          config.loadFromString(query.getString("metadata"));
          ((InventoryHolder) modify).getInventory().clear();
          for (Object obj : config.getList("items")) {
            if (obj instanceof ItemStack) {
              ((InventoryHolder) modify).getInventory().addItem((ItemStack) obj);
            }
View Full Code Here


            YamlConfiguration toSerialize = new YamlConfiguration();
            toSerialize.set("color", base);
            String serialized = toSerialize.saveToString();

            YamlConfiguration deserialized = new YamlConfiguration();
            deserialized.loadFromString(serialized);

            assertThat(testColor.name + " on " + serialized, base, is(deserialized.getColor("color")));
        }
    }
View Full Code Here

            if (!text.equals(new String(contents, Charsets.UTF_8))) {
                getLogger().warning("Default system encoding may have misread config.yml from plugin jar");
            }

            try {
                defConfig.loadFromString(text);
            } catch (final InvalidConfigurationException e) {
                getLogger().log(Level.SEVERE, "Cannot load configuration from jar", e);
            }
        }
View Full Code Here

        return null;
    }

      YamlConfiguration defConfig = new YamlConfiguration();
      try {
      defConfig.loadFromString(config);
      return defConfig;
    } catch (InvalidConfigurationException e) {
      SimpleSpleef.log.severe("[SimpleSpleef] Could not convert resource file " + file + " to valid configuration! Reason: " + e.getMessage());
      return null;
    }
View Full Code Here

  @SuppressWarnings("unchecked")
  @Nullable
  public final static <T extends ConfigurationSerializable> T deserializeCS(final String s, final Class<T> c) {
    final YamlConfiguration y = new YamlConfiguration();
    try {
      y.loadFromString(s);
    } catch (final InvalidConfigurationException e) {
      return null;
    }
    final Object o = y.get("value");
    if (!c.isInstance(o))
View Full Code Here

  @Deprecated
  @Nullable
  public final static <T extends ConfigurationSerializable> T deserializeCSOld(final String s, final Class<T> c) {
    final YamlConfiguration y = new YamlConfiguration();
    try {
      y.loadFromString(s.replace("\uFEFF", "\n"));
    } catch (final InvalidConfigurationException e) {
      return null;
    }
    final Object o = y.get("value");
    if (!c.isInstance(o))
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.