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

CallbackTask help?

Comments in 'Plugin Development' started by Legoboy0215, Jun 5, 2015.

  1. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    I have a plugin that uses CallbackTask that is deprecated, so I placed the same file in my plugin and uses it. But, there is an error that happens everytime. Here you go:
    Code:
    2015-06-05 05:18:12 [NOTICE] ArrayOutOfBoundsException: "Undefined offset: 0" (E_NOTICE) in "/src/pocketmine/utils/Binary" at line 87 2015-06-05 05:18:24 [CRITICAL] Could not execute task legoboy\CallbackTask: Undefined offset: 0
    The CallbackTask.php is here:
    PHP:
    <?php

    /*
     *
     *  ____            _        _   __  __ _                  __  __ ____
     * |  _ \ ___   ___| | _____| |_|  \/  (_)_ __   ___      |  \/  |  _ \
     * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
     * |  __/ (_) | (__|   <  __/ |_| |  | | | | | |  __/_____| |  | |  __/
     * |_|   \___/ \___|_|\_\___|\__|_|  |_|_|_| |_|\___|     |_|  |_|_|
     *
     * This program is free software: you can redistribute it and/or modify
     * it under the terms of the GNU Lesser General Public License as published by
     * the Free Software Foundation, either version 3 of the License, or
     * (at your option) any later version.
     *
     * @author PocketMine Team
     * @link http://www.pocketmine.net/
     *
     *
    */

    namespace legoboy;

    use 
    pocketmine\scheduler\Task;

    /**
     * Allows the creation of simple callbacks with extra data
     * The last parameter in the callback will be this object
     *
     * If you want to do a task in a Plugin, consider extending PluginTask to your needs
     *
     * @deprecated
     *
     */
    class CallbackTask extends Task{

        
    /** @var callable */
        
    protected $callable;

        
    /** @var array */
        
    protected $args;

        
    /**
        * @param callable $callable
        * @param array    $args
        */
        
    public function __construct(callable $callable, array $args = []){
            
    $this->callable $callable;
            
    $this->args $args;
            
    $this->args[] = $this;
        }

        
    /**
        * @return callable
        */
        
    public function getCallable(){
            return 
    $this->callable;
        }

        public function 
    onRun($currentTicks){
            
    call_user_func_array($this->callable$this->args);
        }

    }

    Any help what is happening?
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    The Error isn't in that Class
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What is $this->callable?
    Also, plugin tasks must always extend PluginTask.
  4. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17

Share This Page

Advertisement