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

Anyone can help me with getting a plugin internal resource pls?

Discussion in 'Development' started by EndermannbugZJFC, May 15, 2020.

  1. EndermannbugZJFC

    EndermannbugZJFC Slime

    Messages:
    84
    GitHub:
    endermanbugzjfc
    My code:
    PHP:
            if (!file_exists(dirname($this->getDataFolder(), 2)) . "/start.sh") {
                @
    copy($this->getResource("start.sh"), dirname($this->getDataFolder() . "/start.sh"2));
            }
    Error log:
    Code:
    TypeError: "copy() expects parameter 1 to be a valid path, resource given" (EXCEPTION) in "plugins/LabRestarter/src/Endermanbugzjfc/LabRestarter/LabRestarter" at line 74
     
  2. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
  3. Diduhless

    Diduhless Baby Zombie

    Messages:
    199
    GitHub:
    Diduhless
    Just get any plugin's class by calling them on your plugin
     
  4. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    getResource returns a file handle. You should use the stream family of functions (e.g. fread, fseek, stream_get_contents, etc.), not the filesystem family of functions.
     
  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.