billmanager exception handling + mc version increase for new beta release

这个提交包含在:
kremsy
2015-06-05 10:07:34 +02:00
父节点 9f809ec9d3
当前提交 d887488f04
共有 2 个文件被更改,包括 13 次插入3 次删除

查看文件

@@ -6,6 +6,7 @@ use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
use Maniaplanet\DedicatedServer\InvalidArgumentException;
use Maniaplanet\DedicatedServer\Structures\Bill;
/**
@@ -57,7 +58,12 @@ class BillManager implements CallbackListener {
* @return bool
*/
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);
return true;
}
@@ -72,7 +78,11 @@ class BillManager implements CallbackListener {
* @return bool
*/
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);
return true;
}

查看文件

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