count broken blocks

Discussion in 'Development' started by THXC, Sep 3, 2020.

  1. THXC

    THXC Creeper

    Messages:
    5
    GitHub:
    codsxblastin
    How would you go about counting how many blocks a certain player has broken. Like if player "x" broke 18 stone and wanted to check it then they could do /collection stone. How would i got about making the function to count player broken blocks.
     
  2. iCirgio

    iCirgio Slime

    Messages:
    93
    GitHub:
    lolnova
    You can make it so that the data saves in a config when they leave and loads then adds in an array when they join.

    and in the BlockBreakEvent, check if block is stone for example, then add one to their data every time they mine a block
     
    Diduhless likes this.
  3. Primus

    Primus Zombie Pigman

    Messages:
    434
    It's discouraged to use a Config utility as a database.

    PHP:
    $data = (new Config($this->getDataFolder()."data.yml"Config::YAML))->getAll();
    // or
    $data yaml_parse_file($this->getDataFolder()."data.yml");
    It is not just about the length of the code, but using things as intended and avoiding unnecessary stuff.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.