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

Solved Fatal Error: Can't use '$this'?!

Comments in 'Plugin Development' started by Survingo, May 14, 2016.

  1. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    Code:
    Error: Using $this when not in object context
    PHP:
    class CustomCommands{
       
       public static function 
    checkCommands(){
         if(
    $this->getConfig()->getNested("help-cmd.custom") === true){
          
    $this->getServer()->getCommandMap()->getCommand("help")->unregister($this->getServer()->getCommandMap());
    Already tryed nearly everything... __construct(), extends and so on, but it won't let me use $this.

    Anyone can help me?
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Learn OOP.
    Ritch and Vaivez66 like this.
  3. Mat
    Offline

    Mat Active Member Plugin Developer

    Joined:
    Jun 15, 2014
    Posts:
    179
    Plugins:
    1
    Minecraft User:
    matcracker
    You are using a static method. Remove static and should work.
    korado531m7 and Survingo like this.
  4. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Why is has he even added static?
    Legoboy0215 likes this.
  5. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    'Search' - 'Replace all' ops
  6. Mat
    Offline

    Mat Active Member Plugin Developer

    Joined:
    Jun 15, 2014
    Posts:
    179
    Plugins:
    1
    Minecraft User:
    matcracker
    No sense but, ok xD

Share This Page

Advertisement