Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Create new player file

Comments in 'Plugin Development' started by Artide, Sep 6, 2015.

  1. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    I'm getting an error when trying to create a file, check below.
    PHP:
    $health = new Config($this->getDataFolder() . "/players" strtolower($player->getName()) . ".yml"Config::YAML,
                                        [
                                        
    "Value" => $args[1],
                                        
    "Admin" => $sender->getName(),
                                        ]
                                    );
    [10:09:26] [Server thread/WARNING]: RuntimeException: "mkdir(): File exists" (E_WARNING) in "/HealthManager/src/HealthManager/Main" at line 25
  2. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Are you sure error is in that code?
  3. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    Can you show us the code around line 25?
  4. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    @mkdir($this->getDataFolder() . "/players");
  5. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    Change that to
    PHP:
    if(!file_exists($this->getDataFolder() . "/players")){
    @
    mkdir($this->getDataFolder() . "/players");
    }
    PocketKiller and Artide like this.
  6. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    Yeah it worked, thanks. I had 2 mkdir's. xD
    DunxandMinecraft likes this.
  7. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    Ok :)

Share This Page

Advertisement