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

My own API for a plugin

Comments in 'Plugin Development' started by SuperChipsLP, Jan 19, 2014.

  1. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    Hey there!

    I am currently working on a plugin with an API.
    Now, my problem is to get the /<pluginname> path
    in the plugins folder.
    How do i accomplish that? Here's what i have so far:

    Code:
    class **************API{
        private static $object;
        public static function set(*********** $plugin){
            if(*************API::$object instanceof **********){
                return false;
            }
            ***********API::$object = $plugin;
    }
    
    public static function has**********($username, $*********){
        $path_run = $this->api->plugin->configPath($this)."startup.txt";
    
            }
    
        }
    
    }
    
    }
    So, even though that doesn't wok (because it is just an example. My real code works fine.), how to i get the plugins subdirectory?

    When i use the api from within another plugin using
    Code:
    ***********API::has**********($issuer->username, $**********);
    my server crashes.

    And yes, i know that i haven't connected to the pocketmine api. :D

    Thanks.
    Last edited: Jan 19, 2014
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    what exactly do you want?
  3. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    If I was working with a plugin I would do:
    Code:
    FILE_PATH . "plugins/startup.txt"
    I'm not sure what you would do without the API, you could try something weird like, which looks three levels up so it should return the same as FILE_PATH.
    Code:
    realpath(dirname(dirname(__DIR__))) . "/ ";
    SuperChipsLP likes this.
  4. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    Thanks. I hope that helps. :=)
  5. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
  6. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    __DIR__ and __FILE__ didn't seem to work in plugins but they are used in the src, so I'm not sure how we'll it will work.

Share This Page

Advertisement