/search (player) command HELP

Discussion in 'Plugin Development' started by Jumbapablo, Sep 15, 2014.

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

    Jumbapablo

    Alright so I am making an ore tracking plugin that tracks how many ore have been mined on the server by each person and so far I have it to where when a player mines any ore, it will generate their name in a config and it'll then track how many ores they mine from there under there name... It looks like this:
    EXAMPLE:
    # Jumba's Ore Plugin Config:
    jumbapablo:
    d: 7
    g: 5
    l: 789
    e: 365
    i: 47
    c:13
    r:67476
    q:96
    Now I want to make it so that they can type in a command like /ottrack (player) and when they type in /ottrack and then the players name it will search the config for that name and return the list of ores mined.

    So like if I typed in /ottrack Jumbapablo it would go through the config and find my name, then display all my info like:
    Jumbapablo's ore list:
    diamonds mined: 7
    gold mined: 5
    lapis mined: 789
    emerald mined: 365
    iron mined: 47
    coal mined: 13
    redstone mined:67476
    quartz mined: 96
    And if I did /ottrack spike228 (another player) then it would search for his name in the config and display me his info.
    How would I do such a thing?
     
  2. Offline

    Skionz

    Code:java
    1. config.get(player.getName() + ".diamonds mined");
    2. //however you should use uuids

    configs are awful for storing data, use a database with SQL
     
  3. Offline

    Unica

    Skionz

    Depends entirely on your server.
    Small servers don't need SQL
     
  4. Offline

    fireblast709

    Stop spreading false information...
     
    mine-care, AdamQpzm and Garris0n like this.
  5. Offline

    Halginzz

    Jumbapablo
    You want to use yml files? Well, in my opinion it would be better to create per-player files (.yml) on PlayerJoinEvent with some default values. Then you can use BlockBreakEvent for increasing the number of destroyed ores. On command check if their file exists. If yes, send those values to sender. If no, send something like "This player doesn't exist."

    http://wiki.bukkit.org/Configuration_API_Reference
    http://jd.bukkit.org/rb/apidocs/org/bukkit/command/CommandSender.html
    http://jd.bukkit.org/rb/apidocs/org/bukkit/event/block/BlockBreakEvent.html
    http://jd.bukkit.org/rb/doxygen/d3/db6/classorg_1_1bukkit_1_1event_1_1player_1_1PlayerJoinEvent.html
     
  6. Offline

    Garris0n

    If there are enough players that one file is a problem, OP should be using a database anyway.
     
    AdamQpzm likes this.
Thread Status:
Not open for further replies.

Share This Page