New config system?

Discussion in 'Plugin Development' started by Niels15, Jun 1, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Niels15

    Hi,

    I'm updating a old broken plugin with the old config system to the new config system. But I don't understand the new config system after reading different guides. I've a few questions:
    How do I update this code in the new config system?
    Code:
    plugin.conf.removeProperty((new StringBuilder("test.")).append(key).toString());
    Error that I get: The method removeProperty(string) is undefined for the type Configuration
    Code:
    plugin.conf.saveConfig();
    Error that I get: The method saveConfig() is undefined for the type Configuration
    Code:
    plugin.conf.setProperty((new StringBuilder("test.")).append(key).append(".test1").toString(), test1);
    Error that I get: The method setProperty(string, string) is undefined for the type Configuration
    Code:
    return plugin.conf.getProperty((new StringBuilder("test.")).append(x).append("_").append(y).append("_").append(z).toString()) != null;
    Error that I get: The method getProperty(string) is undefined for the type Configuration

    Can somebody help me?

    Thanks :)
     
  2. Offline

    LucasEmanuel

    Well the new system doesnt use the Configuration class it uses FileConfiguration.

    Get the FileConfiguration for your plugin by calling the following method: "plugin.getConfig();"

    Then "plugin.getConfig().getString("path.to.string);" to get a string from your config file :)
     
  3. Offline

    theguynextdoor

    For removing a 'property' from the config, want you want to do is to set it to null. An example:

    Code:java
    1. plugin.getConfig().set("path.path", null);
    2. plugin.saveConfig();


    Which also answers the saving question (use plugin.saveConfig()) and also the setting property (replace null with the value you want to set it to).

    To get a value it would be

    For a String:
    plugin.getConfig().getString("path.path");

    For an Int:
    plugin.getConfig().getInt("path.path");

    For a boolean:
    plugin.getConfig().getBoolean("path.path");

    and so on
     
  4. Offline

    Niels15

    Ok, thanks it works :)
    I've again a few questions how do I fix this:
    Code:
    if(plugin.conf.getKeys("fabrics") != null)
    The method getKeys(boolean) in the type ConfigurationSection is not applicable for the arguments (String)
    Code:
    for(Iterator iterator = plugin.conf.getKeys("test").iterator(); iterator.hasNext();)
    Iterator is a raw type. References to generic type Iterator<E> should be parameterized
    The method getKeys(boolean) in the type ConfigurationSection is not applicable for the arguments (String)
    Code:
    test = Collections.synchronizedMap(new HashMap());
    HashMap is a raw type. References to generic type HashMap<K,V> should be parameterized
    Type safety: The expression of type HashMap needs unchecked conversion to conform to Map<Object,Object>
    Type safety: Unchecked invocation synchronizedMap(HashMap) of the generic method synchronizedMap(Map<K,V>) of type Collections
    Code:
    static Map fabrics;
    Map is a raw type. References to generic type Map<K,V> should be parameterized

    Thanks :)
     
  5. Offline

    Niels15

  6. Offline

    Niels15

    bump?
     
  7. just do the java basics?
     
  8. Offline

    Niels15

    Yes, I know. But I've said to a friend that I'll update this plugin for him and this are the last error where I can't come out.
     
  9. learn java generics
     
Thread Status:
Not open for further replies.

Share This Page