diff --git a/.idea/encodings.xml b/.idea/encodings.xml index 0218f4cb..75dc5175 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -1,7 +1,7 @@ + - - + \ No newline at end of file diff --git a/changelog.txt b/changelog.txt index b3d4ebd2..9c12c3a6 100644 --- a/changelog.txt +++ b/changelog.txt @@ -17,6 +17,7 @@ - added some missing PHP Docs - added some depency libraries as they are used by the Socket Handler - added additional Callback which gets triggered on ManiaControl Restart +- added class name to the BillData object - updated some depency libraries #Bug Fixes diff --git a/core/Bills/BillData.php b/core/Bills/BillData.php index 3e3d145c..25b0c94a 100644 --- a/core/Bills/BillData.php +++ b/core/Bills/BillData.php @@ -22,10 +22,12 @@ class BillData { public $amount = 0; public $creationTime = -1; public $message = ""; + public $class = ""; /** * Construct new Bill Data Model * + * @param string $class * @param callable $function * @param Player|string $player * @param int $amount @@ -33,7 +35,8 @@ class BillData { * @param string $receiverLogin * @param string $message */ - public function __construct(callable $function, $player, $amount, $pay = false, $receiverLogin = null, $message = '') { + public function __construct($class, callable $function, $player, $amount, $pay = false, $receiverLogin = null, $message = '') { + $this->class = $class; $this->function = $function; $this->player = $player; $this->amount = $amount; diff --git a/core/Bills/BillManager.php b/core/Bills/BillManager.php index 49c8a131..c06b0704 100644 --- a/core/Bills/BillManager.php +++ b/core/Bills/BillManager.php @@ -58,16 +58,21 @@ class BillManager implements CallbackListener { * @return bool */ public function sendBill(callable $function, Player $player, $amount, $message, $receiver = '') { + //Get the Caller Class + $backTrace = debug_backtrace(); + $class = $backTrace[1]['class']; + 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($class, $function, $player, $amount, false, $receiver, $message); return true; } + /** * Send planets from the server to a player * @@ -78,12 +83,17 @@ class BillManager implements CallbackListener { * @return bool */ public function sendPlanets(callable $function, $receiverLogin, $amount, $message) { + //Get the Caller Class + $backTrace = debug_backtrace(); + $class = $backTrace[1]['class']; + 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($class, $function, $receiverLogin, $amount, true, $receiverLogin, $message); return true; }