added method to playermanager
This commit is contained in:
parent
02a60ac875
commit
d8d52251c9
@ -143,14 +143,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 ' . $player->getCountry() .
|
$chatMessage = '$s$0f0' . $string[$player->authLevel] . ' $fff' . $player->nickname . '$z$s$0f0 Nation:$fff ' . $player->getCountry() . ' $z$s$0f0joined!';
|
||||||
' $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: " . $player->getCountry() .
|
$logMessage = "Player joined: {$player->login} / " . Formatter::stripCodes($player->nickname) . " Nation: " . $player->getCountry() . " IP: {$player->ipAddress}";
|
||||||
" IP: {$player->ipAddress}";
|
|
||||||
$this->maniaControl->log($logMessage);
|
$this->maniaControl->log($logMessage);
|
||||||
|
|
||||||
// Trigger own PlayerJoined callback
|
// Trigger own PlayerJoined callback
|
||||||
@ -210,6 +208,24 @@ class PlayerManager implements CallbackListener {
|
|||||||
return $this->players;
|
return $this->players;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a Player by his index
|
||||||
|
*
|
||||||
|
* @param $index
|
||||||
|
* @return Player|null
|
||||||
|
*/
|
||||||
|
public function getPlayerByIndex($index) {
|
||||||
|
foreach($this->players as $player) {
|
||||||
|
/** @var Player $player */
|
||||||
|
if($player->index == $index) {
|
||||||
|
|
||||||
|
return $player;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a Player by Login
|
* Get a Player by Login
|
||||||
*
|
*
|
||||||
@ -243,7 +259,9 @@ class PlayerManager implements CallbackListener {
|
|||||||
* @return Player $player
|
* @return Player $player
|
||||||
*/
|
*/
|
||||||
private function removePlayer($login, $savePlayedTime = true) {
|
private function removePlayer($login, $savePlayedTime = true) {
|
||||||
if (!isset($this->players[$login])) return null;
|
if(!isset($this->players[$login])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
$player = $this->players[$login];
|
$player = $this->players[$login];
|
||||||
unset($this->players[$login]);
|
unset($this->players[$login]);
|
||||||
if($savePlayedTime) {
|
if($savePlayedTime) {
|
||||||
|
Loading…
Reference in New Issue
Block a user