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

Solved [ECONOMY API] Can't type /topmoney

Discussion in 'Plugin Help' started by Groin, Feb 24, 2017.

  1. Groin

    Groin Baby Zombie

    Messages:
    159
    Who can fix it? I NEED HELP!

    Code:
    Code:
    >topmoney
    [Server] [05:40:31] [Asynchronous Worker #1 thread/CRITICAL]: RuntimeException: "Threaded members previously set to Threaded objects are immutable, cannot overwrite topList" (EXCEPTION) in "/EconomyAPI_v2.0.9.phar/src/onebone/economyapi/task/SortTask" at line 36
    [Server] [05:40:31] [Server thread/CRITICAL]: Could not execute asynchronous task SortTask: Task crashed
    
    Or
    topmoney
    [Server] [05:40:31] [Asynchronous Worker #1 thread/CRITICAL]: RuntimeException: "Threaded members previously set to Threaded objects are immutable, cannot overwrite topList" (EXCEPTION) in "/EconomyAPI_v2.0.9.phar/src/onebone/economyapi/task/SortTask" at line 36
    [Server] [05:40:31] [Server thread/CRITICAL]: Could not execute asynchronous task SortTask: Task crashed
     
  2. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    Fix the code yourself by forking EconomyAPI, if you know. If you don't, share us the full code. You can also add a new issue on the original EconomyAPI Repo by onebone..
     
  3. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    this is a plugin help section, not plugin dev
     
  4. Groin

    Groin Baby Zombie

    Messages:
    159
    Do you use EconomyAPi?
     
  5. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Are you using the latest version of EconomyAPI from Poggit?
     
  6. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    Yes
     
  7. Groin

    Groin Baby Zombie

    Messages:
    159
    Umm I downloaded from creator's github
     
  8. Groin

    Groin Baby Zombie

    Messages:
    159
    Would you mind if give me a download link?
     
  9. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    I have exactly the same problem too, but I don't know how to fix it.

    This is what my whole SortTask.php looks like:

    PHP:
    <?php

    namespace onebone\economyapi\task;

    use 
    pocketmine\scheduler\AsyncTask;
    use 
    pocketmine\Server;
    use 
    pocketmine\Player;

    use 
    onebone\economyapi\EconomyAPI;

    class 
    SortTask extends AsyncTask{
        private 
    $player$moneyData$addOp$page$ops$banList;

        private 
    $max 0;

        private 
    $topList = [];

        
    /**
         * @param string    $player
         * @param array        $moneyData
         * @param bool        $addOp
         * @param int        $page
         * @param array        $ops
         * @param array        $banList
         */
        
    public function __construct($player$moneyData$addOp$page$ops$banList){
            
    $this->player $player;
            
    $this->moneyData $moneyData;
            
    $this->addOp $addOp;
            
    $this->page $page;
            
    $this->ops $ops;
            
    $this->banList $banList;
        }

        public function 
    onRun(){
            
    $this->topList $this->getTopList();
        }

        private function 
    getTopList(){
            
    $money $this->moneyData["money"];

            
    arsort($money);

            
    $ret = [];

            
    $n 1;
            
    $this->max ceil((count($money) - count($this->banList) - ($this->addOp count($this->ops))) / 5);
            
    $this->page = (int)min($this->maxmax(1$this->page));

            foreach(
    $money as $p => $money){
                
    $p strtolower($p);

                if(isset(
    $this->banList[$p])) continue;
                if(isset(
    $this->ops[$p]) and $this->addOp === false) continue;

                
    $current = (int) ceil($n 5);

                if(
    $current === $this->page){
                    
    $ret[$n] = [$p$money];
                }elseif(
    $current $this->page){
                    break;
                }
                ++
    $n;
            }
            return 
    $ret;
        }

        public function 
    onCompletion(Server $server){
            if(((
    $player $this->player) === "CONSOLE") or ($player $server->getPlayerExact($this->player)) instanceof Player){
                
    $plugin EconomyAPI::getInstance();

                
    $output "- Showing top money list ({$this->page} of {$this->max}) - \n";
                
    $message = ($plugin->getMessage("topmoney-format"$this->player, ["%1""%2""%3""%4"])."\n");

                foreach(
    $this->topList as $n => $list){
                    
    $output .= str_replace(["%1""%2""%3"], [$n$list[0], $list[1]], $message);
                }

                if(
    $player instanceof Player){
                    
    $player->sendMessage($output);
                }else{
                    
    $plugin->getLogger()->info($output);
                }
            }
        }
    }
     
  10. Groin

    Groin Baby Zombie

    Messages:
    159
  11. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    How did you fix it? Maybe you can give me the working code or tell me what to change?
     
    Last edited: Jun 11, 2017
    InspectorGadget likes this.
  12. Groin

    Groin Baby Zombie

    Messages:
    159
    My friend has sent me a EconomyAPI phar has fixed
     
  13. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    Can I have it?
     
  14. Groin

    Groin Baby Zombie

    Messages:
    159
  15. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
  16. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    I already fixed the problem myself.
     
  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.