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

Solved Change files with pocketmine

Discussion in 'Development' started by Subbitx, Aug 27, 2019.

  1. Subbitx

    Subbitx Silverfish

    Messages:
    18
    Is it possible that I can move , read or delete files with pocketmine ? I want to navigate to the plugins folder and look what plugins are installed.
     
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    you should be able to get all the plugins using getplugins(see /plugins command)
     
  3. Subbitx

    Subbitx Silverfish

    Messages:
    18
    Ok thanks for that. Anyways can you answer if it is possible to read the files...
     
  4. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    This will give you the path to a plugin's data folder (where the config is stored).
    PHP:
    $this->getServer()->getPluginManager()->getPlugin("plugin name")->getDataFolder();
     
  5. Subbitx

    Subbitx Silverfish

    Messages:
    18
    To answer my own question:

    $path = $this->getServer()->getDataPath() . "plugins/";
    $allFiles = scandir($path);

    for ($i = 0; $i < sizeof($allFiles); $i++) {
    if($this->endsWith($allFiles[$i], ".phar")) {
    $player->sendMessage($allFiles[$i]);
    }
    }
     
    HimbeersaftLP likes this.
  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.