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

Subclass a Config

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

  1. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    How would this work? I don't have two devices so I can't test it properly. But can someone test it for me?
    PHP:
    class PlayerConfig extends Config{
        
    /**
        * @param Player/CNRGuestAsst $p The player/player assistant to create config with
        */
        
    public function __construct($p) {
            
    parent::__construct(CNRIO::getPlayersDir()."$p/maindb.yml",CONFIG_YAML,array(
                
    "lang"=>"default",
                
    "register timestamp"=>time()
            ));
            
    $this->setLastLoginTime(time());
        }
        public function 
    setLastLoginTime($t){
            
    $this->set("last login timestamp",$t);
        }
        public function 
    getLastLoginTime() {
            return 
    $this->get("last login timestamp");
        }
        public function 
    setLang($lang) {
            if (!isset(
    CNRRStr::getAll()[$lang]))
                return 
    false;
            
    $this->set("lang",$lang);
        }
        public function 
    getLang() {
            return 
    $this->get("lang");
        }
        public function 
    getRegisterTime() {
            return 
    $this->get("register timestamp");
        }
        public function 
    getPoints(){
            return 
    $this->get("personal points");
        }
        public function 
    addPoints($pts=1){
            
    $this->set("personal points",$this->getPoints()+$pts);
        }
        public function 
    takePoints($pts=1){
            
    $this->addPoints(-$pts);
        }
        public final function 
    getPath(){
            return 
    $this->file;
        }
    }

  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Can this work?

Share This Page

Advertisement