billmanager exception handling + mc version increase for new beta release

This commit is contained in:
kremsy 2015-06-05 10:07:34 +02:00
parent 9f809ec9d3
commit d887488f04
2 changed files with 13 additions and 3 deletions

View File

@ -6,6 +6,7 @@ use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
use Maniaplanet\DedicatedServer\InvalidArgumentException;
use Maniaplanet\DedicatedServer\Structures\Bill; use Maniaplanet\DedicatedServer\Structures\Bill;
/** /**
@ -57,7 +58,12 @@ class BillManager implements CallbackListener {
* @return bool * @return bool
*/ */
public function sendBill(callable $function, Player $player, $amount, $message, $receiver = '') { public function sendBill(callable $function, Player $player, $amount, $message, $receiver = '') {
$billId = $this->maniaControl->getClient()->sendBill($player->login, $amount, $message, $receiver); try {
$billId = $this->maniaControl->getClient()->sendBill($player->login, intval($amount), $message, $receiver);
} catch (InvalidArgumentException $e) {
//TODO better error handling, maybe call the user func with ERROR_WHILE_TRANSACTION
return false;
}
$this->openBills[$billId] = new BillData($function, $player, $amount, false, $receiver, $message); $this->openBills[$billId] = new BillData($function, $player, $amount, false, $receiver, $message);
return true; return true;
} }
@ -72,7 +78,11 @@ class BillManager implements CallbackListener {
* @return bool * @return bool
*/ */
public function sendPlanets(callable $function, $receiverLogin, $amount, $message) { public function sendPlanets(callable $function, $receiverLogin, $amount, $message) {
$billId = $this->maniaControl->getClient()->pay($receiverLogin, $amount, $message); try {
$billId = $this->maniaControl->getClient()->pay($receiverLogin, intval($amount), $message);
} catch (InvalidArgumentException $e) {
return false;
}
$this->openBills[$billId] = new BillData($function, $receiverLogin, $amount, true, $receiverLogin, $message); $this->openBills[$billId] = new BillData($function, $receiverLogin, $amount, true, $receiverLogin, $message);
return true; return true;
} }

View File

@ -42,7 +42,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
/* /*
* Constants * Constants
*/ */
const VERSION = '0.156'; const VERSION = '0.157';
const API_VERSION = '2013-04-16'; const API_VERSION = '2013-04-16';
const MIN_DEDIVERSION = '2014-04-02_18_00'; const MIN_DEDIVERSION = '2014-04-02_18_00';
const SCRIPT_TIMEOUT = 10; const SCRIPT_TIMEOUT = 10;