added bot kick, playerdisconenct own callback
This commit is contained in:
parent
a2c423e7e8
commit
b56ad5682c
@ -192,7 +192,10 @@ class PlayerActions {
|
|||||||
$target = $this->maniaControl->playerManager->getPlayer($targetLogin);
|
$target = $this->maniaControl->playerManager->getPlayer($targetLogin);
|
||||||
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
|
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
|
||||||
|
|
||||||
$success = $this->maniaControl->client->query('Kick', $target->login, $message); //TODO bestätigung
|
if($target->isFakePlayer())
|
||||||
|
$success = $this->maniaControl->client->query('DisconnectFakePlayer', $target->login);
|
||||||
|
else
|
||||||
|
$success = $this->maniaControl->client->query('Kick', $target->login, $message); //TODO bestätigung
|
||||||
if (!$success) {
|
if (!$success) {
|
||||||
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
|
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
|
||||||
return;
|
return;
|
||||||
|
@ -66,15 +66,14 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
public function __construct(ManiaControl $maniaControl) {
|
public function __construct(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this,
|
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
|
||||||
'closeWidget');
|
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CLOSE_PLAYER_ADV , $this, 'closePlayerAdvancedWidget');
|
||||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CLOSE_PLAYER_ADV , $this,
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||||
'closePlayerAdvancedWidget');
|
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
|
//Update Widget Events
|
||||||
'handleManialinkPageAnswer');
|
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'updateWidget');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'updateWidget');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCONNECT, $this, 'updateWidget');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'updateWidget');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERDISCONNECT, $this, 'updateWidget');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'updateWidget');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'updateWidget');
|
$this->maniaControl->callbackManager->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'updateWidget');
|
||||||
|
|
||||||
//settings
|
//settings
|
||||||
@ -142,8 +141,6 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$y -= 10;
|
$y -= 10;
|
||||||
foreach($players as $listPlayer){
|
foreach($players as $listPlayer){
|
||||||
|
|
||||||
//$path = substr($listPlayer->path, 6);
|
|
||||||
//$path = $listPlayer->getCountry() . " - " . $listPlayer->getProvince();
|
|
||||||
$path = $listPlayer->getProvince();
|
$path = $listPlayer->getProvince();
|
||||||
$playerFrame = new Frame();
|
$playerFrame = new Frame();
|
||||||
$frame->add($playerFrame);
|
$frame->add($playerFrame);
|
||||||
@ -316,7 +313,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//show advanced window
|
//show advanced window
|
||||||
if($this->playersListShown[$player->login] != self::SHOWN_MAIN_WINDOW){
|
if($this->playersListShown[$player->login] != false && $this->playersListShown[$player->login] != self::SHOWN_MAIN_WINDOW){
|
||||||
$frame = $this->showAdvancedPlayerWidget($this->playersListShown[$player->login]);
|
$frame = $this->showAdvancedPlayerWidget($this->playersListShown[$player->login]);
|
||||||
$maniaLink->add($frame);
|
$maniaLink->add($frame);
|
||||||
}
|
}
|
||||||
@ -342,6 +339,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
* @return Frame
|
* @return Frame
|
||||||
*/
|
*/
|
||||||
public function showAdvancedPlayerWidget($login){
|
public function showAdvancedPlayerWidget($login){
|
||||||
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||||
|
|
||||||
//todo all configurable or as constants
|
//todo all configurable or as constants
|
||||||
$x = $this->width / 2 + 2.5;
|
$x = $this->width / 2 + 2.5;
|
||||||
$width = 35;
|
$width = 35;
|
||||||
@ -383,8 +382,6 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$label->setText("Advanced Actions");
|
$label->setText("Advanced Actions");
|
||||||
$label->setTextColor($textColor);
|
$label->setTextColor($textColor);
|
||||||
|
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
|
||||||
|
|
||||||
//Show Nickname
|
//Show Nickname
|
||||||
$label = new Label_Text();
|
$label = new Label_Text();
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
@ -619,11 +616,17 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
public function updateWidget(array $callback){
|
public function updateWidget(array $callback){
|
||||||
foreach($this->playersListShown as $login => $shown){
|
foreach($this->playersListShown as $login => $shown){
|
||||||
if($shown){
|
if($shown){
|
||||||
|
//Check if Shown player still exists
|
||||||
|
if($this->maniaControl->playerManager->getPlayer($shown) == null){
|
||||||
|
$this->playersListShown[$login] = false;
|
||||||
|
}
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||||
if($player != null)
|
if($player != null){
|
||||||
$this->showPlayerList($player);
|
$this->showPlayerList($player);
|
||||||
else
|
}else{
|
||||||
|
//if player with the open widget disconnected remove him from the shownlist
|
||||||
unset($this->playersListShown[$login]);
|
unset($this->playersListShown[$login]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ class PlayerManager implements CallbackListener {
|
|||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const CB_PLAYERJOINED = 'PlayerManagerCallback.PlayerJoined';
|
const CB_PLAYERJOINED = 'PlayerManagerCallback.PlayerJoined';
|
||||||
|
const CB_PLAYERDISCONNECTED = 'PlayerManagerCallback.PlayerDisconnected';
|
||||||
const CB_ONINIT = 'PlayerManagerCallback.OnInit';
|
const CB_ONINIT = 'PlayerManagerCallback.OnInit';
|
||||||
const CB_PLAYERINFOCHANGED = 'PlayerManagerCallback.PlayerInfoChanged';
|
const CB_PLAYERINFOCHANGED = 'PlayerManagerCallback.PlayerInfoChanged';
|
||||||
const TABLE_PLAYERS = 'mc_players';
|
const TABLE_PLAYERS = 'mc_players';
|
||||||
@ -156,6 +157,9 @@ class PlayerManager implements CallbackListener {
|
|||||||
$login = $callback[1][0];
|
$login = $callback[1][0];
|
||||||
$player = $this->removePlayer($login);
|
$player = $this->removePlayer($login);
|
||||||
|
|
||||||
|
// Trigger own callback
|
||||||
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_PLAYERDISCONNECTED, array(self::CB_PLAYERDISCONNECTED, $player));
|
||||||
|
|
||||||
if($player->isFakePlayer())
|
if($player->isFakePlayer())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user