playerlist advanced clone und bufix
This commit is contained in:
parent
449719aa99
commit
18fd95dcd4
@ -11,7 +11,6 @@ use FML\Controls\Quad;
|
|||||||
use FML\Controls\Quads\Quad_BgRaceScore2;
|
use FML\Controls\Quads\Quad_BgRaceScore2;
|
||||||
use FML\Controls\Quads\Quad_BgsPlayerCard;
|
use FML\Controls\Quads\Quad_BgsPlayerCard;
|
||||||
use FML\Controls\Quads\Quad_Emblems;
|
use FML\Controls\Quads\Quad_Emblems;
|
||||||
use FML\Controls\Quads\Quad_Icons128x128_1;
|
|
||||||
use FML\Controls\Quads\Quad_Icons64x64_1;
|
use FML\Controls\Quads\Quad_Icons64x64_1;
|
||||||
use FML\Controls\Quads\Quad_UIConstruction_Buttons;
|
use FML\Controls\Quads\Quad_UIConstruction_Buttons;
|
||||||
use FML\ManiaLink;
|
use FML\ManiaLink;
|
||||||
@ -57,6 +56,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
private $quadStyle;
|
private $quadStyle;
|
||||||
private $quadSubstyle;
|
private $quadSubstyle;
|
||||||
private $playersListShown = array();
|
private $playersListShown = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new server commands instance
|
* Create a new server commands instance
|
||||||
*
|
*
|
||||||
@ -65,18 +65,15 @@ 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(self::ACTION_CLOSE_PLAYER_ADV, $this,
|
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CLOSE_PLAYER_ADV, $this, 'closePlayerAdvancedWidget');
|
||||||
'closePlayerAdvancedWidget');
|
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
|
$this->maniaControl->callbackManager->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||||
'handleManialinkPageAnswer');
|
|
||||||
|
|
||||||
// Update Widget Events
|
// Update Widget Events
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'updateWidget');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'updateWidget');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'updateWidget');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'updateWidget');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'updateWidget');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'updateWidget');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this,
|
$this->maniaControl->callbackManager->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'updateWidget');
|
||||||
'updateWidget');
|
|
||||||
|
|
||||||
// settings
|
// settings
|
||||||
$this->width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
$this->width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||||
@ -138,8 +135,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
// $array = array("Id" => $x + 5, "Nickname" => $x + 10, "Login" => $x + 40, "Ladder" => $x + 60,"Zone" => $x + 85);
|
// $array = array("Id" => $x + 5, "Nickname" => $x + 10, "Login" => $x + 40, "Ladder" => $x + 60,"Zone" => $x + 85);
|
||||||
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||||
$array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 60, "Location" => $x + 91, "Actions" => $x + 135);
|
$array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 60, "Location" => $x + 91, "Actions" => $x + 135);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 60, "Location" => $x + 91);
|
$array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 60, "Location" => $x + 91);
|
||||||
}
|
}
|
||||||
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
|
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
|
||||||
@ -191,8 +187,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$teamQuad->setSubStyle($teamQuad::SUBSTYLE_2);
|
$teamQuad->setSubStyle($teamQuad::SUBSTYLE_2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if($listPlayer->isSpectator) {
|
||||||
else if ($listPlayer->isSpectator) {
|
|
||||||
// Player is in Spectator Mode
|
// Player is in Spectator Mode
|
||||||
$specQuad = new Quad_BgRaceScore2();
|
$specQuad = new Quad_BgRaceScore2();
|
||||||
$playerFrame->add($specQuad);
|
$playerFrame->add($specQuad);
|
||||||
@ -350,7 +345,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
* @param $login
|
* @param $login
|
||||||
*/
|
*/
|
||||||
public function advancedPlayerWidget(Player $caller, $login) {
|
public function advancedPlayerWidget(Player $caller, $login) {
|
||||||
if (!$caller) return;
|
if(!$caller) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$this->playersListShown[$caller->login] = $login; // Show a certain player
|
$this->playersListShown[$caller->login] = $login; // Show a certain player
|
||||||
$this->showPlayerList($caller); // reopen playerlist
|
$this->showPlayerList($caller); // reopen playerlist
|
||||||
}
|
}
|
||||||
@ -438,62 +435,42 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$label->setTextColor($textColor);
|
$label->setTextColor($textColor);
|
||||||
|
|
||||||
$y -= 5;
|
$y -= 5;
|
||||||
|
|
||||||
// Show Kick
|
// Show Kick
|
||||||
$quad = new Quad_BgsPlayerCard();
|
$quad = clone $quad;
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setX(0);
|
|
||||||
$quad->setY($y);
|
$quad->setY($y);
|
||||||
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
|
||||||
$quad->setSize($quadWidth, 5);
|
|
||||||
$quad->setAction(self::ACTION_KICK_PLAYER . "." . $login);
|
$quad->setAction(self::ACTION_KICK_PLAYER . "." . $login);
|
||||||
|
|
||||||
$label = new Label_Button();
|
$label = clone $label;
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setAlign(Control::CENTER, Control::CENTER);
|
|
||||||
$label->setX(0);
|
|
||||||
$label->setY($y);
|
$label->setY($y);
|
||||||
$label->setStyle($style);
|
|
||||||
$label->setTextSize($textSize);
|
|
||||||
$label->setText("Kick");
|
$label->setText("Kick");
|
||||||
$label->setTextColor("F90");
|
$label->setTextColor("F90");
|
||||||
|
|
||||||
$y -= 5;
|
$y -= 5;
|
||||||
// Show Ban
|
// Show Ban
|
||||||
$quad = new Quad_BgsPlayerCard();
|
$quad = clone $quad;
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setX(0);
|
|
||||||
$quad->setY($y);
|
$quad->setY($y);
|
||||||
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
|
||||||
$quad->setSize($quadWidth, 5);
|
|
||||||
$quad->setAction(self::ACTION_BAN_PLAYER . "." . $login);
|
$quad->setAction(self::ACTION_BAN_PLAYER . "." . $login);
|
||||||
|
|
||||||
$label = new Label_Button();
|
$label = clone $label;
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setAlign(Control::CENTER, Control::CENTER);
|
|
||||||
$label->setX(0);
|
|
||||||
$label->setY($y);
|
$label->setY($y);
|
||||||
$label->setStyle($style);
|
|
||||||
$label->setTextSize($textSize);
|
|
||||||
$label->setText("Ban");
|
$label->setText("Ban");
|
||||||
$label->setTextColor("700");
|
$label->setTextColor("700");
|
||||||
|
|
||||||
$y -= 10;
|
$y -= 10;
|
||||||
// Show Add as Master-Admin
|
// Show Add as Master-Admin
|
||||||
$quad = new Quad_BgsPlayerCard();
|
$quad = clone $quad;
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setX(0);
|
|
||||||
$quad->setY($y);
|
$quad->setY($y);
|
||||||
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
|
||||||
$quad->setSize($quadWidth, 5);
|
|
||||||
$quad->setAction(self::ACTION_ADD_AS_MASTER . "." . $login);
|
$quad->setAction(self::ACTION_ADD_AS_MASTER . "." . $login);
|
||||||
|
|
||||||
$label = new Label_Button();
|
$label = clone $label;
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setAlign(Control::CENTER, Control::CENTER);
|
|
||||||
$label->setX(0);
|
|
||||||
$label->setY($y);
|
$label->setY($y);
|
||||||
$label->setStyle($style);
|
|
||||||
$label->setTextSize($textSize);
|
|
||||||
|
|
||||||
$label->setText("Set SuperAdmin");
|
$label->setText("Set SuperAdmin");
|
||||||
|
|
||||||
@ -501,62 +478,41 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
|
|
||||||
$y -= 5;
|
$y -= 5;
|
||||||
// Show Add as Admin
|
// Show Add as Admin
|
||||||
$quad = new Quad_BgsPlayerCard();
|
$quad = clone $quad;
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setX(0);
|
|
||||||
$quad->setY($y);
|
$quad->setY($y);
|
||||||
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
|
||||||
$quad->setSize($quadWidth, 5);
|
|
||||||
$quad->setAction(self::ACTION_ADD_AS_ADMIN . "." . $login);
|
$quad->setAction(self::ACTION_ADD_AS_ADMIN . "." . $login);
|
||||||
|
|
||||||
$label = new Label_Button();
|
$label = clone $label;
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setAlign(Control::CENTER, Control::CENTER);
|
|
||||||
$label->setX(0);
|
|
||||||
$label->setY($y);
|
$label->setY($y);
|
||||||
$label->setStyle($style);
|
|
||||||
$label->setTextSize($textSize);
|
|
||||||
$label->setText("Set Admin");
|
$label->setText("Set Admin");
|
||||||
$label->setTextColor($textColor);
|
$label->setTextColor($textColor);
|
||||||
|
|
||||||
$y -= 5;
|
$y -= 5;
|
||||||
// Show Add as Moderator
|
// Show Add as Moderator
|
||||||
$quad = new Quad_BgsPlayerCard();
|
$quad = clone $quad;
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setX(0);
|
|
||||||
$quad->setY($y);
|
$quad->setY($y);
|
||||||
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
|
||||||
$quad->setSize($quadWidth, 5);
|
|
||||||
$quad->setAction(self::ACTION_ADD_AS_MOD . "." . $login);
|
$quad->setAction(self::ACTION_ADD_AS_MOD . "." . $login);
|
||||||
|
|
||||||
$label = new Label_Button();
|
$label = clone $label;
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setAlign(Control::CENTER, Control::CENTER);
|
|
||||||
$label->setX(0);
|
|
||||||
$label->setY($y);
|
$label->setY($y);
|
||||||
$label->setStyle($style);
|
|
||||||
$label->setTextSize($textSize);
|
|
||||||
$label->setText("Set Moderator");
|
$label->setText("Set Moderator");
|
||||||
$label->setTextColor($textColor);
|
$label->setTextColor($textColor);
|
||||||
|
|
||||||
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||||
$y -= 5;
|
$y -= 5;
|
||||||
// Revoke Rights
|
// Revoke Rights
|
||||||
$quad = new Quad_BgsPlayerCard();
|
$quad = clone $quad;
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setX(0);
|
|
||||||
$quad->setY($y);
|
$quad->setY($y);
|
||||||
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
|
||||||
$quad->setSize($quadWidth, 5);
|
|
||||||
$quad->setAction(self::ACTION_REVOKE_RIGHTS . "." . $login);
|
$quad->setAction(self::ACTION_REVOKE_RIGHTS . "." . $login);
|
||||||
|
|
||||||
$label = new Label_Button();
|
$label = clone $label;
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setAlign(Control::CENTER, Control::CENTER);
|
|
||||||
$label->setX(0);
|
|
||||||
$label->setY($y);
|
$label->setY($y);
|
||||||
$label->setStyle($style);
|
|
||||||
$label->setTextSize($textSize);
|
|
||||||
$label->setText("Revoke Rights");
|
$label->setText("Revoke Rights");
|
||||||
$label->setTextColor("700");
|
$label->setTextColor("700");
|
||||||
}
|
}
|
||||||
@ -602,16 +558,13 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
|
|
||||||
switch($action) {
|
switch($action) {
|
||||||
case self::ACTION_FORCE_BLUE:
|
case self::ACTION_FORCE_BLUE:
|
||||||
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($adminLogin, $targetLogin,
|
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::BLUE_TEAM);
|
||||||
PlayerActions::BLUE_TEAM);
|
|
||||||
break;
|
break;
|
||||||
case self::ACTION_FORCE_RED:
|
case self::ACTION_FORCE_RED:
|
||||||
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($adminLogin, $targetLogin,
|
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::RED_TEAM);
|
||||||
PlayerActions::RED_TEAM);
|
|
||||||
break;
|
break;
|
||||||
case self::ACTION_FORCE_SPEC:
|
case self::ACTION_FORCE_SPEC:
|
||||||
$this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($adminLogin, $targetLogin,
|
$this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($adminLogin, $targetLogin, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
|
||||||
PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
|
|
||||||
break;
|
break;
|
||||||
case self::ACTION_WARN_PLAYER:
|
case self::ACTION_WARN_PLAYER:
|
||||||
$this->maniaControl->playerManager->playerActions->warnPlayer($adminLogin, $targetLogin);
|
$this->maniaControl->playerManager->playerActions->warnPlayer($adminLogin, $targetLogin);
|
||||||
@ -627,16 +580,13 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$this->advancedPlayerWidget($admin, $targetLogin);
|
$this->advancedPlayerWidget($admin, $targetLogin);
|
||||||
break;
|
break;
|
||||||
case self::ACTION_ADD_AS_MASTER:
|
case self::ACTION_ADD_AS_MASTER:
|
||||||
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin,
|
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||||
AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
|
||||||
break;
|
break;
|
||||||
case self::ACTION_ADD_AS_ADMIN:
|
case self::ACTION_ADD_AS_ADMIN:
|
||||||
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin,
|
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||||
AuthenticationManager::AUTH_LEVEL_ADMIN);
|
|
||||||
break;
|
break;
|
||||||
case self::ACTION_ADD_AS_MOD:
|
case self::ACTION_ADD_AS_MOD:
|
||||||
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin,
|
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||||
AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
|
||||||
break;
|
break;
|
||||||
case self::ACTION_REVOKE_RIGHTS:
|
case self::ACTION_REVOKE_RIGHTS:
|
||||||
$this->maniaControl->playerManager->playerActions->revokeAuthLevel($adminLogin, $targetLogin);
|
$this->maniaControl->playerManager->playerActions->revokeAuthLevel($adminLogin, $targetLogin);
|
||||||
@ -659,8 +609,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$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
|
// if player with the open widget disconnected remove him from the shownlist
|
||||||
unset($this->playersListShown[$login]);
|
unset($this->playersListShown[$login]);
|
||||||
}
|
}
|
||||||
|
@ -58,10 +58,8 @@ class PlayerManager implements CallbackListener {
|
|||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'onInit');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'onInit');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCONNECT, $this, 'playerConnect');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCONNECT, $this, 'playerConnect');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERDISCONNECT, $this,
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERDISCONNECT, $this, 'playerDisconnect');
|
||||||
'playerDisconnect');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERINFOCHANGED, $this, 'playerInfoChanged');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERINFOCHANGED, $this,
|
|
||||||
'playerInfoChanged');
|
|
||||||
|
|
||||||
// Define player stats
|
// Define player stats
|
||||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_JOIN_COUNT);
|
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_JOIN_COUNT);
|
||||||
@ -137,14 +135,12 @@ class PlayerManager implements CallbackListener {
|
|||||||
|
|
||||||
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer()) {
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer()) {
|
||||||
$string = array(0 => '$0f0Player', 1 => '$0f0Moderator', 2 => '$0f0Admin', 3 => '$0f0MasterAdmin', 4 => '$0f0MasterAdmin');
|
$string = array(0 => '$0f0Player', 1 => '$0f0Moderator', 2 => '$0f0Admin', 3 => '$0f0MasterAdmin', 4 => '$0f0MasterAdmin');
|
||||||
$chatMessage = '$s$0f0' . $string[$player->authLevel] . ' $fff' . $player->nickname . '$z$s$0f0 Nation:$fff ' .
|
$chatMessage = '$s$0f0' . $string[$player->authLevel] . ' $fff' . $player->nickname . '$z$s$0f0 Nation:$fff ' . $player->getCountry() . ' $z$s$0f0joined!';
|
||||||
$player->getCountry() . ' $z$s$0f0joined!';
|
|
||||||
$this->maniaControl->chat->sendChat($chatMessage);
|
$this->maniaControl->chat->sendChat($chatMessage);
|
||||||
$this->maniaControl->chat->sendInformation('This server uses ManiaControl v' . ManiaControl::VERSION . '!', $player->login);
|
$this->maniaControl->chat->sendInformation('This server uses ManiaControl v' . ManiaControl::VERSION . '!', $player->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
$logMessage = "Player joined: {$player->login} / " . Formatter::stripCodes($player->nickname) . " Nation: " .
|
$logMessage = "Player joined: {$player->login} / " . Formatter::stripCodes($player->nickname) . " Nation: " . $player->getCountry() . " IP: {$player->ipAddress}";
|
||||||
$player->getCountry() . " IP: {$player->ipAddress}";
|
|
||||||
$this->maniaControl->log($logMessage);
|
$this->maniaControl->log($logMessage);
|
||||||
|
|
||||||
// Trigger own PlayerJoined callback
|
// Trigger own PlayerJoined callback
|
||||||
@ -183,7 +179,9 @@ class PlayerManager implements CallbackListener {
|
|||||||
*/
|
*/
|
||||||
public function playerInfoChanged(array $callback) {
|
public function playerInfoChanged(array $callback) {
|
||||||
$player = $this->getPlayer($callback[1][0]['Login']);
|
$player = $this->getPlayer($callback[1][0]['Login']);
|
||||||
if ($player == null) return;
|
if($player == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$player->teamId = $callback[1][0]["TeamId"];
|
$player->teamId = $callback[1][0]["TeamId"];
|
||||||
$player->isSpectator = $callback[1][0]["SpectatorStatus"];
|
$player->isSpectator = $callback[1][0]["SpectatorStatus"];
|
||||||
@ -306,8 +304,7 @@ class PlayerManager implements CallbackListener {
|
|||||||
$playerStatement->close();
|
$playerStatement->close();
|
||||||
|
|
||||||
// Increment the Player Join Count
|
// Increment the Player Join Count
|
||||||
$success = $this->maniaControl->statisticManager->incrementStat(self::STAT_JOIN_COUNT, $player,
|
$success = $this->maniaControl->statisticManager->incrementStat(self::STAT_JOIN_COUNT, $player, $this->maniaControl->server->getLogin());
|
||||||
$this->maniaControl->server->getLogin());
|
|
||||||
|
|
||||||
if(!$success) {
|
if(!$success) {
|
||||||
trigger_error("Error while setting the JoinCount");
|
trigger_error("Error while setting the JoinCount");
|
||||||
@ -328,7 +325,6 @@ class PlayerManager implements CallbackListener {
|
|||||||
}
|
}
|
||||||
$playedTime = time() - $player->joinTime;
|
$playedTime = time() - $player->joinTime;
|
||||||
|
|
||||||
return $this->maniaControl->statisticManager->insertStat(self::STAT_PLAYTIME, $player, $this->maniaControl->server->getLogin(),
|
return $this->maniaControl->statisticManager->insertStat(self::STAT_PLAYTIME, $player, $this->maniaControl->server->getLogin(), $playedTime);
|
||||||
$playedTime);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ namespace ManiaControl\Statistics;
|
|||||||
use ManiaControl\Callbacks\CallbackListener;
|
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\PlayerManager;
|
use ManiaControl\Players\PlayerManager;
|
||||||
|
|
||||||
class StatisticCollector implements CallbackListener {
|
class StatisticCollector implements CallbackListener {
|
||||||
@ -36,6 +35,7 @@ class StatisticCollector implements CallbackListener {
|
|||||||
*/
|
*/
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
private $onShootArray = array();
|
private $onShootArray = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct player manager
|
* Construct player manager
|
||||||
*
|
*
|
||||||
@ -75,6 +75,7 @@ class StatisticCollector implements CallbackListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle Player Shoots
|
* Handle Player Shoots
|
||||||
|
*
|
||||||
* @param $login
|
* @param $login
|
||||||
*/
|
*/
|
||||||
private function handleOnShoot($login) {
|
private function handleOnShoot($login) {
|
||||||
@ -96,10 +97,12 @@ class StatisticCollector implements CallbackListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert OnShoot Statistic when a player leaves
|
* Insert OnShoot Statistic when a player leaves
|
||||||
|
*
|
||||||
* @param array $callback
|
* @param array $callback
|
||||||
* @param Player $player
|
|
||||||
*/
|
*/
|
||||||
public function onPlayerDisconnect(array $callback, Player $player) {
|
public function onPlayerDisconnect(array $callback) {
|
||||||
|
$player = $callback[1];
|
||||||
|
|
||||||
//Check if Stat Collecting is enabled
|
//Check if Stat Collecting is enabled
|
||||||
if(!$this->maniaControl->settingManager->getSetting($this, self::SETTING_COLLECT_STATS_ENABLED)) {
|
if(!$this->maniaControl->settingManager->getSetting($this, self::SETTING_COLLECT_STATS_ENABLED)) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user