1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved count broken blocks

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

  1. THXC

    THXC Spider

    Messages:
    10
    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:
    92
    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:
    749
    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.
     
  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.