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

Undefined property

Discussion in 'Development' started by armagadon159753, Feb 23, 2018.

  1. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    Here I'm trying to call init(); function but I get this error I have used others way but I get the same error
    PHP:
    [15:46:18] [Server thread/CRITICAL]: Unhandled exception executing command 'admin' in adminUndefined propertyHenoriaCore\Core::$AdminForms

    [15:46:18] [Server thread/CRITICAL]: ErrorException"Undefined property: HenoriaCore\Core::$AdminForms(EXCEPTIONin "HenoriaCore-master/src/Commands/Admin/Admin" at line 33
    Admin command function
    PHP:
    public function execute(CommandSender $senderstring $commandLabel, array $args):bool{
            if(!
    $sender instanceof Player){
                
    $sender->sendMessage(Core::USE_IN_GAME);
            }
            if(!
    $sender->hasPermission("Admin.command")){
                
    $sender->sendMessage(Core::NO_PERM);
            }
            if(
    $sender instanceof Player and $sender->hasPermission("admin.command")){
                
    $this->core->AdminForms->init($sender);//The error is here
            
    }
            return 
    true;
        }
    FormsAdmin function called
    PHP:
    public function init(Player $player){
            
    $pk = new ModalFormRequestPacket();
            
    $form = array();
            
    $form["title"] = "AdminMenu";
            
    $form["type"] = "form";
            
    $form["content"] = "";
            
    $form["buttons"][] = ["text" => "Ban"];
            
    $form["buttons"][] = ["text" => "Kick"];
            
    $pk->formId 200;
            
    $pk->formData json_encode($form);
            
    $player->dataPacket($pk);
        }
     
  2. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Property $AdminForms is not defined
     
    xXNiceAssassinlo YT likes this.
  3. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    PHP:
    private $plugin$player;

    public function 
    __construct(MainFile $pluginPlayer $player){
    $this->plugin $plugin;
    $this->player $player;
    self::init();
    }

    public static function 
    init(){
    $pk = new ModalFormRequestPacket();
    $form = array();
    $form["title"] = "AdminMenu";
    $form["type"] = "form";
    $form["content"] = "";
    $form["buttons"][] = ["text" => "Ban"];
    $form["buttons"][] = ["text" => "Kick"];
    $pk->formId 200;
    $pk->formData json_encode($form);
    $player->dataPacket($pk);
    }
    Command:
    PHP:
    public function execute(CommandSender $senderstring $commandLabel, array $args):bool{
            if(!
    $sender instanceof Player){
                
    $sender->sendMessage(Core::USE_IN_GAME);
            }
            if(!
    $sender->hasPermission("Admin.command")){
                
    $sender->sendMessage(Core::NO_PERM);
            }
            if(
    $sender instanceof Player and $sender->hasPermission("admin.command")){
                
    $this->adminforms = new AdminForms($this->core);
            }
            return 
    true;
        }
     
  4. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    When I execute the command nothing happen without any error
     
  5. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Dm me Plugin I’ll fix it
     
  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.