onebone / EconomyS

The economy plugin for PocketMine-MP
GNU General Public License v3.0
144 stars 188 forks source link

Some bugs for EconomyCasino_v2.0.1 #54

Closed PrinceMCPE closed 9 years ago

PrinceMCPE commented 9 years ago

Hi, onebone. I am from China. Thank you for your Economic Plugins. It is very useful for me. Also It is popular in China. Now, I will tell you some bugs for EconomyCasino_v2.0.1 and my trial to fix these bugs. I hope it'll help you

  1. An unrecoverable error occurred and the server crashed when run "/jackpot " or "/casino gamble " in-game Error message:

    Fatal error: Call to undefined method onebone\economyapi\EconomyAPI::monetaryUnit() in phar://C:/Users/Sky/Desktop/PocketMine-MP/plugins/EconomyCasino_v2.0.1.phar/src/onebone/economycasino/EconomyCasino.php on line 274 Fatal error: Call to undefined method onebone\economyapi\EconomyAPI::monetaryUnit() in phar://C:/Users/Sky/Desktop/PocketMine-MP/plugins/EconomyCasino_v2.0.1.phar/src/onebone/economycasino/EconomyCasino.php on line 233

    My trial to fix the bug: "$this->api->monetaryUnit()" on line 215, 231, 233, 249, 251, 272, 274 in the EconomyCasino.php Changed to "$this->api->getMonetaryUnit()" defined on line 580 in the EconomyAPI.php

  2. An error occurred when run "/jackpot " in the console Error message:

    [CRITICAL] Unhandled exception executing command 'jackpot 1000' in jackpot: strtolower() expects parameter 1 to be string, object given [WARNING] InvalidArgumentException: "strtolower() expects parameter 1 to be string, object given" (E_WARNING) in "/EconomyAPI_v2.0.5.phar/src/onebone/economyapi/EconomyAPI" at line 800

    My trial to fix the bug: Added "if(!$sender instanceof Player)" in case "jackpot": case "jackpot": if(!$sender instanceof Player){ $sender->sendMessage("Please run this command in-game."); break; } ...

  3. not getting proper array key on line 225 My trial to fix the bug: "$got = array_rand($this->casino[$sender->getName()]);" Changed to "$got = array_rand($this->casino[$sender->getName()]["players"]);"
  4. mymoney is only $1000.But when I run "/jackpot 1000000" and win jackpot, mymoney will be $1000000 My trial to fix the bug: Added "if($this->api->myMoney($sender) < $money)" in case "jackpot": case "jackpot": if(!$sender instanceof Player){ $sender->sendMessage("Please run this command in-game."); break; } $money = array_shift($params); if(!is_numeric($money)){ $sender->sendMessage("Usage: ".$command->getUsage()); break; } $money = (int)$money; if($this->api->myMoney($sender) < $money){ $sender->sendMessage("You don't have money to jackpot ".$this->api->getMonetaryUnit()."$money"); break; }

5 money not added when win jackpot My trial to fix the bug: case "jackpot": ... $this->api->reduceMoney($sender, $money); $rand = rand(0, $this->config->get("jackpot-winning")); if($rand === 0){ $this->api->addMoney($sender, $money); $sender->sendMessage("You've wined jackpot! You've got ".$this->api->monetaryUnit()."$money"); }else{ $sender->sendMessage("You've failed your jackpot! You've lost ".$this->api->monetaryUnit()."$money"); } break;

changed to:

case "jackpot": ... $rand = rand(0, $this->config->get("jackpot-winning")); if($rand === 0){ $this->api->addMoney($sender, $money); $sender->sendMessage("You've wined jackpot! You've got ".$this->api->getMonetaryUnit()."$money"); }else{ $this->api->reduceMoney($sender, $money); $sender->sendMessage("You've failed your jackpot! You've lost ".$this->api->getMonetaryUnit()."$money"); } break;

That's all.I hope it'll help you

onebone commented 9 years ago

Thank you for reporting, I think that the bugs that you've reported are all my mistakes. I will fix the bugs as soon as possible.

onebone commented 9 years ago