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

Classes problems

Comments in 'Plugin Development' started by PEMapModder, Jan 14, 2014.

  1. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I have a few problems about classes.
    1. Are there any functions equivalent to getClass().getName() in Java?
    2. In the src I saw something like
      PHP:
      new $varA($varB)
      . Is this constructing a new instance of a class with the name $varA?
  2. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    218
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    get_class()

    getName dont exist on php or so I do believe.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
  4. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    218
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    Yes, Sorry
  5. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    218
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    Your Question: In the src I saw something like
    PHP:
    new $varA($varB)

    //the variable A contain the name of the class and variable B contain the parameter of the class
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Thanks a lot
  7. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    Java is awesome!
    :)
    PEMapModder likes this.
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Love classes!
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    So then how will this work?
    PHP:
    class Saveable {
        private 
    $saveableConfig;
        private 
    $saveableFilePath;
        public function 
    save() {
            
    $this->saveableConfig->setAll($this->getMemory());
        }
        public function 
    __construct($dir,$classname=false) {
            if(
    substr($dir,-1)!='\\' and substr($dir,-1)!='/')
                
    $dir.="/";
            @
    mkdir($dir);
            
    $this->saveableFilePath=$dir;
            
    $this->saveableConfig=new Config($dir.get_class().".yml",CONFIG_YAML,array());
            if (
    $classname!==false) {
                foreach (
    $this->saveableConfig->getAll() as $name => $value) {
                    
    $this->$name=$value;
                }
            }
        }
        public abstract function 
    getMemory();
    }

Share This Page

Advertisement