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

Unset error

Comments in 'Plugin Development' started by xBeastMode, Dec 13, 2015.

  1. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    This f***ing annoying error won't go away, I tried different methods and it's still happening...
    Code:
    PocketMine-MP Crash Dump Sat Dec 12 18:58:54 AKST 2015
    
    Error: Can't use method return value in write context
    File: /BeastHub/src/xbeastmode/beasthub/BeastHub
    Line: 75
    Type: E_COMPILE_ERROR
    
    THIS CRASH WAS CAUSED BY A PLUGIN
    
    Code:
    [66]             [$cfa[$world][$hub]["X"] => $player->getX(), $cfa[$world][$hub]["Y"] => $player->getY(), $cfa[$world][$hub]["Z"] => $player->getZ()]);
    [67]         $this->getConfig()->save();
    [68]     }
    [69]     /**
    [70]      * @param $world
    [71]      * @param $hub
    [72]      */
    [73]     public function deleteHub($world, $hub)
    [74]     {
    [75]         unset($this->getConfig()->getAll()[$world][$hub]);
    [76]         $this->getConfig()->save();
    [77]     }
    [78]     /**
    [79]      * @param CommandSender $issuer
    [80]      * @param Command $cmd
    [81]      * @param $alias
    [82]      * @param array $param
    [83]      * @return bool|void
    [84]      */
    [85]     public function onCommand(CommandSender $issuer, Command $cmd, $alias, array $param)
  2. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Are $world and $hub both supposed to be strings? And why not simply use Config->remove($key) instead of unset(Config->getAll()[$key])?
  3. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    Try this
    PHP:
    $config $this->getConfig()->getAll();
    unset(
    $config[$world][$hub]);
    $this->getConfig()->setAll($config);
    $this->getConfig()->save();
    xiaoq, PEMapModder and xBeastMode like this.
  4. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    It works, now I just have to fix bugs. Thanks. :)
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You cannot unset directly because getAll() doesn't return by reference. But you can unset directly for get(), which returns by reference.

Share This Page

Advertisement