exceptions spectator actions
This commit is contained in:
parent
671c934f2b
commit
e71b763075
@ -11,6 +11,8 @@ use ManiaControl\Admin\AuthenticationManager;
|
||||
use ManiaControl\Formatter;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Manialinks\ManialinkManager;
|
||||
use Maniaplanet\DedicatedServer\InvalidArgumentException;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
/**
|
||||
* PlayerActions Class
|
||||
@ -82,15 +84,20 @@ class PlayerActions {
|
||||
return;
|
||||
}
|
||||
|
||||
$success = $this->maniaControl->client->forceSpectator($target->login, self::SPECTATOR_PLAYER);
|
||||
if(!$success) {
|
||||
try {
|
||||
$this->maniaControl->client->forceSpectator($target->login, self::SPECTATOR_PLAYER);
|
||||
|
||||
} catch(Exception $e) {
|
||||
//TODO $e error text
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
|
||||
return;
|
||||
}
|
||||
|
||||
if($userIsAbleToSelect) {
|
||||
$success = $this->maniaControl->client->forceSpectator($target->login, self::SPECTATOR_USER_SELECTABLE);
|
||||
if(!$success) {
|
||||
try {
|
||||
$this->maniaControl->client->forceSpectator($target->login, self::SPECTATOR_USER_SELECTABLE);
|
||||
} catch(Exception $e) {
|
||||
//TODO $e error text
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
|
||||
return;
|
||||
}
|
||||
@ -161,8 +168,10 @@ class PlayerActions {
|
||||
}
|
||||
$target = $this->maniaControl->playerManager->getPlayer($targetLogin);
|
||||
|
||||
$success = $this->maniaControl->client->forceSpectator($target->login, $spectatorState);
|
||||
if(!$success) {
|
||||
try {
|
||||
$this->maniaControl->client->forceSpectator($target->login, $spectatorState);
|
||||
} catch(Exception $e) {
|
||||
//TODO error message from $e
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
|
||||
return;
|
||||
}
|
||||
@ -174,7 +183,12 @@ class PlayerActions {
|
||||
|
||||
if($releaseSlot) {
|
||||
// Free player slot
|
||||
//$this->maniaControl->client->spectatorReleasePlayerSlot($target->login); //TODO not in spec exception mp crash
|
||||
try {
|
||||
$this->maniaControl->client->spectatorReleasePlayerSlot($target->login);
|
||||
} catch(InvalidArgumentException $e) {
|
||||
//TODO error message from $e
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,8 @@ use ManiaControl\Formatter;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Manialinks\ManialinkManager;
|
||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||
use Maniaplanet\DedicatedServer\InvalidArgumentException;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
/**
|
||||
* PlayerList Widget Class
|
||||
@ -593,7 +595,11 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
switch($action) {
|
||||
case self::ACTION_SPECTATE_PLAYER:
|
||||
$this->maniaControl->client->forceSpectator($adminLogin, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
|
||||
//$this->maniaControl->client->forceSpectatorTarget($adminLogin, $targetLogin, 1); //TODO mc crash player is not a spectator
|
||||
try {
|
||||
$this->maniaControl->client->forceSpectatorTarget($adminLogin, $targetLogin, 1); //TODO mc crash player is not a spectator
|
||||
} catch(Exception $e) {
|
||||
//TODO error message from $e
|
||||
}
|
||||
break;
|
||||
case self::ACTION_OPEN_PLAYER_DETAILED:
|
||||
$player = $this->maniaControl->playerManager->getPlayer($adminLogin);
|
||||
|
Loading…
Reference in New Issue
Block a user