Solved Yet another Yaml issue [sic]

Discussion in 'Plugin Development' started by Webster56, Sep 11, 2014.

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

    Webster56

    Hello people,

    I'm on another plugin and for some reason, the only problems I encounter while developing are Yaml parsing issues.

    Here's the config.yml file :

    Code:
    #
    # Cost = cout en PO d'une pub (fixe)
    # Delay = temps entre deux pub pour un joueur donne :
    # (valeur+unite, ex : 5m pour 5 minutes, 3h pour 3 heures ou 10s pour 10 secondes)
    # Prefix : ce qui sera affiche avant le pseudo + le message (et le format et couleur de ces trucs !)
    #
    pub:
      - cost: 10
      - delay: "5m"
      - prefix: '&b[&c&oPub&r&b]&3&o'
    debug: true
    
    I've tested this on two Yaml parsers, this one for instance gives me a correct output, no error, no nothing.

    However the console tells me this :

    http://pastebin.com/EJFL92v1


    Line 75 being this code :

    Code:
    pubCost = getConfig().getDouble("pub.cost");
    Got any idea to solve this ? There are two spaces, no tabs and an empty line at the end of it. I've also tried this with a space after the comment block.

    Thanks :)
     
  2. Offline

    RRServer

    A double would be a number value such as (10.34235432566434564 - to a very large number of decimals both negatively and positively). If you are going to using a whole number value (10 in this case) for pubCost, do :

    int pubCost = getConfig().getInt("pub.cost");

    OR

    double pubCost = getConfig().getDouble("pub.cost");

    Also. Do:

    pub:
    (Two spaces)cost:
    (Two spaces)delay:
    (Two spaces)prefix:
    debug:
     
  3. Switching software for support is also not allowed. Please seek support where you acquired your server mod.
     
  4. Offline

    nlthijs48

    Webster56 The section you created under 'pub' is a mix of a list and mapping, that is your problem. You have placed the minus symbols before the 3 lines below pub, this indicates to the YAML parser that a list follows. But then you have key-value pairs below this, so that is why it does not work.

    In this case you just need to remove the minus symbols that are in front of the cost, delay and prefix lines.
    Code:
    #
    # Cost = cout en PO d'une pub (fixe)
    # Delay = temps entre deux pub pour un joueur donne :
    # (valeur+unite, ex : 5m pour 5 minutes, 3h pour 3 heures ou 10s pour 10 secondes)
    # Prefix : ce qui sera affiche avant le pseudo + le message (et le format et couleur de ces trucs !)
    #
    pub:
      cost: 10
      delay: "5m"
      prefix: '&b[&c&oPub&r&b]&3&o'
    debug: true
     
  5. Offline

    Webster56

    nlthijs48 I've changed to this (which is what I had before the error occured, before I added the debug thing that is), yet the same error happens :/
     
  6. Offline

    nlthijs48

    Webster56 Are you sure it is exactly the same? Can you post it again? Also be sure that your plugin is actually using the new config (delete the old config.yml that is in the plugin folder and restart the server).
     
  7. Offline

    Webster56

  8. Offline

    nlthijs48

    Webster56 That is indeed exactly the same, please post the contents of the config file at this place: 'plugins\PubChat\config.yml'
     
  9. Offline

    fireblast709

    Webster56 nlthijs48
     
  10. Offline

    Webster56

    fireblast709 I've been looking for this fact the past 10 minutes, but can't find it, is it in the rules or a sticky thread ?
     
  11. Offline

    nlthijs48

    fireblast709 I'm allowed to decide for myself if I want to help him or not right? Because personally I don't care about what he uses.
     
  12. Offline

    Webster56

    nlthijs48 There's the file

    Code:
    #
    # Cost = cout en PO d'une pub (fixe)
    # Delay = temps entre deux pub pour un joueur donne :
    # (valeur+unite, ex : 5m pour 5 minutes, 3h pour 3 heures ou 10s pour 10 secondes)
    # Prefix : ce qui sera affiche avant le pseudo + le message (et le format et couleur de ces trucs !)
    #
    pub:
      cost: 10
      delay: "5m"
      prefix: '&b[&c&oPub&r&b]&3&o'
    debug: true
     
    
    It's the same in the workspace file, so the server can't load anything than this (of course i've removed the one from the plugin folder several times)
     
  13. Offline

    fireblast709

    Webster56 Have a look at the dupe thread you made, which got locked by an administrator for unsupported builds. Quick switching is just a cheap shot to avoid the rules. Then again, we both know you will be using a third party build regardless, so why ask here?
    nlthijs48 Forum rules are forum rules.
     
  14. Offline

    Webster56

    fireblast709 I'm talking about the rule where it says I can't switch build; as I was saying I forgot to remove the other build, if I knew I was using it I'd have removed it before posting, I just want help for my plugin nothing else.

    I seriously am not using the said build on a local server, used solely for development purposes. If the build really mattered in plugin development I might proceed so, but as far as I know it's not the case.

    Anyways I've solved this, in case somebody has the same problem and pops here :

    What I did is I generated the file using YamlConfiguration methods : used a buch of set(path, value) methods, saved the File and voilĂ .

    Code:java
    1. public void onEnable() {
    2.  
    3. File file = new File(this.getDataFolder(), "config.yml");
    4. FileConfiguration conf = new YamlConfiguration();
    5. if (!file.exists())
    6. {
    7.  
    8. initConfig(conf, file);
    9. }


    and the initConfig method :

    Code:java
    1. private void initConfig(FileConfiguration fc, File f) {
    2. // TODO Auto-generated method stub
    3. System.out.println("Initialisation config.");
    4. fc.set("debug", true);
    5. fc.set("pub.cost", 10);
    6. fc.set("pub.delay", "5m");
    7. fc.set("pub.prefix", "&b[&c&oPub&r&b]&3&o");
    8. try {
    9. fc.save(f);
    10. } catch (IOException e) {
    11. // TODO Auto-generated catch block
    12. e.printStackTrace();
    13. }
    14. }


    Which outputs the following Yaml file :

    Code:
    debug: true
    pub:
      cost: 10
      delay: 5m
      prefix: '&b[&c&oPub&r&b]&3&o'
     
    
    This file has the great advantage of being perfectly parsed by the Yaml parser.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
Thread Status:
Not open for further replies.

Share This Page