Solved Logging to a YML?

Discussion in 'Plugin Development' started by Quidam, Jan 14, 2013.

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

    Quidam

    I've done this before, but I can't quite remember how.
    Basically, I need to log players into a YML file so I can associate each player with their own individual integer.
    ex: "KaiBB = 90"
    I will then check for the player's integer on a PlayerMoveEvent, and if the integer equals 100, a method will run.

    How do I load a custom YML into the script, and how do I log/check the player name and integer?
    Thanks in advance! :D
     
  2. Offline

    fireblast709

    int theirInteger = getConfig().getInt(player.getName);

    But you might want to cache it somewhere (like a HashMap<String, Integer>)
     
    Quidam likes this.
  3. Offline

    Quidam

    I suppose a HashMap would work, but if the server is shut off, the player needs to keep the same integer. So I need a file :3
    Do you know how to use a file other than the config? If not then it's fine, but if so please share :D
     
  4. Offline

    microgeek

    Thats what he said. Store it in in config, but cache, or load it into memory via a hashmap.
    If you don't know how to write to FileOutputStream, use Apache Commons.
     
  5. Offline

    Quidam

    Oh. But can't you load them directly?

    EDIT: Isn't there a config.contains(); ?
     
  6. Offline

    microgeek

    You can, but it would be faster to load it from a hashmap, opposed to getting it from the config each time.
    boolean contains(String path) {
    return config.getString("your.path") != null;
    }
     
  7. Offline

    Quidam

    Well I already check if the player exists, and so if the player is real but not in the config, the config will return null, so I can just log him there. I'll do that, and if it doesn't work well I'll use a HashMap. Thanks!
     
  8. Offline

    fireblast709

    when you want to get a player, just get it. When he is not in the config it will return 0 (not null, as int cannot be null)
     
Thread Status:
Not open for further replies.

Share This Page