TrackManiaControl/core/Players/PlayerList.php

847 lines
31 KiB
PHP
Raw Normal View History

2013-12-18 15:48:33 +01:00
<?php
namespace ManiaControl\Players;
use FML\Controls\Frame;
2013-12-18 23:35:33 +01:00
use FML\Controls\Labels\Label_Text;
2013-12-18 15:48:33 +01:00
use FML\Controls\Quad;
use FML\Controls\Quads\Quad_BgRaceScore2;
use FML\Controls\Quads\Quad_BgsPlayerCard;
2013-12-19 21:59:10 +01:00
use FML\Controls\Quads\Quad_Emblems;
2013-12-18 15:48:33 +01:00
use FML\Controls\Quads\Quad_Icons64x64_1;
2013-12-31 12:58:50 +01:00
use FML\Controls\Quads\Quad_UIConstruction_Buttons;
2013-12-18 15:48:33 +01:00
use FML\ManiaLink;
2014-04-27 16:22:12 +02:00
use FML\Script\Features\Paging;
2013-12-18 23:35:33 +01:00
use ManiaControl\Admin\AuthenticationManager;
2013-12-18 15:48:33 +01:00
use ManiaControl\Callbacks\CallbackListener;
2013-12-19 21:59:10 +01:00
use ManiaControl\Callbacks\CallbackManager;
2014-01-30 22:35:32 +01:00
use ManiaControl\Callbacks\TimerListener;
2013-12-18 15:48:33 +01:00
use ManiaControl\ManiaControl;
2017-04-01 18:48:36 +02:00
use ManiaControl\Manialinks\LabelLine;
2013-12-18 15:48:33 +01:00
use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Utils\Formatter;
use Maniaplanet\DedicatedServer\Xmlrpc\PlayerStateException;
use Maniaplanet\DedicatedServer\Xmlrpc\ServerOptionsException;
use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException;
2014-05-02 17:50:30 +02:00
use MCTeam\CustomVotesPlugin;
2013-12-18 15:48:33 +01:00
2013-12-24 13:09:39 +01:00
/**
* PlayerList Widget Class
*
2014-05-02 17:50:30 +02:00
* @author ManiaControl Team <mail@maniacontrol.com>
2018-03-27 20:11:40 +02:00
* @copyright 2014-2018 ManiaControl Team
2014-04-19 23:14:37 +02:00
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
2013-12-24 13:09:39 +01:00
*/
2014-01-30 22:35:32 +01:00
class PlayerList implements ManialinkPageAnswerListener, CallbackListener, TimerListener {
/*
2013-12-18 15:48:33 +01:00
* Constants
*/
2014-01-09 18:19:37 +01:00
const ACTION_FORCE_RED = 'PlayerList.ForceRed';
const ACTION_FORCE_BLUE = 'PlayerList.ForceBlue';
const ACTION_FORCE_SPEC = 'PlayerList.ForceSpec';
2014-02-08 00:00:00 +01:00
const ACTION_FORCE_SPEC_VOTE = 'PlayerList.ForceSpecVote';
2014-02-01 19:36:47 +01:00
const ACTION_FORCE_PLAY = 'PlayerList.ForcePlay';
2014-01-09 18:19:37 +01:00
const ACTION_PLAYER_ADV = 'PlayerList.PlayerAdvancedActions';
const ACTION_CLOSE_PLAYER_ADV = 'PlayerList.ClosePlayerAdvWidget';
const ACTION_MUTE_PLAYER = 'PlayerList.MutePlayer';
const ACTION_UNMUTE_PLAYER = 'PlayerList.UnMutePlayer';
const ACTION_WARN_PLAYER = 'PlayerList.WarnPlayer';
const ACTION_KICK_PLAYER = 'PlayerList.KickPlayer';
2014-02-08 00:00:00 +01:00
const ACTION_KICK_PLAYER_VOTE = 'PlayerList.KickPlayerVote';
2014-01-09 18:19:37 +01:00
const ACTION_BAN_PLAYER = 'PlayerList.BanPlayer';
const ACTION_ADD_AS_MASTER = 'PlayerList.PlayerAddAsMaster';
const ACTION_ADD_AS_ADMIN = 'PlayerList.PlayerAddAsAdmin';
const ACTION_ADD_AS_MOD = 'PlayerList.PlayerAddAsModerator';
const ACTION_REVOKE_RIGHTS = 'PlayerList.RevokeRights';
2014-01-03 16:24:35 +01:00
const ACTION_OPEN_PLAYER_DETAILED = 'PlayerList.OpenPlayerDetailed';
2014-01-09 18:19:37 +01:00
const ACTION_SPECTATE_PLAYER = 'PlayerList.SpectatePlayer';
const ACTION_PAGING_CHUNKS = 'PlayerList.PagingChunks';
const CACHE_CURRENT_PAGE = 'PlayerList.CurrentPage';
2014-04-29 22:06:58 +02:00
const DEFAULT_CUSTOM_VOTE_PLUGIN = 'MCTeam\CustomVotesPlugin';
2014-01-09 18:19:37 +01:00
const SHOWN_MAIN_WINDOW = -1;
2014-01-27 19:41:07 +01:00
const MAX_PLAYERS_PER_PAGE = 15;
const MAX_PAGES_PER_CHUNK = 2;
2014-01-09 18:19:37 +01:00
/*
* Private properties
2013-12-18 15:48:33 +01:00
*/
/** @var ManiaControl $maniaControl */
2015-06-04 00:23:29 +02:00
private $maniaControl = null;
2013-12-19 21:59:10 +01:00
private $playersListShown = array();
2014-01-02 13:35:52 +01:00
2013-12-18 15:48:33 +01:00
/**
* Construct a new PlayerList instance
2013-12-18 15:48:33 +01:00
*
* @param ManiaControl $maniaControl
*/
public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl;
2014-01-09 18:19:37 +01:00
// Callbacks
2014-08-13 11:05:52 +02:00
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_CLOSE_PLAYER_ADV, $this, 'closePlayerAdvancedWidget');
$this->maniaControl->getCallbackManager()->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
$this->maniaControl->getCallbackManager()->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_OPENED, $this, 'handleWidgetOpened');
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
2014-01-09 18:19:37 +01:00
2013-12-31 12:17:25 +01:00
// Update Widget Events
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERINFOSCHANGED, $this, 'updateWidget');
2014-08-13 11:05:52 +02:00
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'updateWidget');
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'updateWidget');
$this->maniaControl->getCallbackManager()->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'updateWidget');
2014-01-30 23:38:13 +01:00
}
/**
* Add Player to Shown List
*
2014-01-30 23:38:13 +01:00
* @param Player $player
* @param int $showStatus
*/
2013-12-31 12:17:25 +01:00
public function addPlayerToShownList(Player $player, $showStatus = self::SHOWN_MAIN_WINDOW) {
2013-12-26 17:27:21 +01:00
$this->playersListShown[$player->login] = $showStatus;
}
2013-12-19 21:59:10 +01:00
2014-05-02 17:50:30 +02:00
/**
* Unset the player if he opened another Main Widget
*
* @param Player $player
* @param $openedWidget
*/
public function handleWidgetOpened(Player $player, $openedWidget) {
//unset when another main widget got opened
if ($openedWidget !== 'PlayerList') {
2014-05-02 17:50:30 +02:00
unset($this->playersListShown[$player->login]);
}
}
/**
* Closes the widget
*
* @param Player $player
*/
public function closeWidget(Player $player) {
2017-05-15 19:31:24 +02:00
$player->destroyCache($this, self::CACHE_CURRENT_PAGE);
2014-05-02 17:50:30 +02:00
unset($this->playersListShown[$player->login]);
}
/**
* Closes the player advanced widget widget
*
* @param array $callback
* @param Player $player
*/
public function closePlayerAdvancedWidget(array $callback, Player $player) {
$this->playersListShown[$player->login] = self::SHOWN_MAIN_WINDOW;
$this->showPlayerList($player); // overwrite the manialink
}
2014-01-06 18:50:26 +01:00
/**
* Show the PlayerList Widget to the Player
*
* @param Player $player
*/
public function showPlayerList(Player $player, $pageIndex = -1) {
2014-08-13 11:05:52 +02:00
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
2014-01-27 19:41:07 +01:00
// get PlayerList
2014-08-13 11:05:52 +02:00
$players = $this->maniaControl->getPlayerManager()->getPlayers();
2014-01-27 21:27:31 +01:00
if ($pageIndex < 0) {
$pageIndex = (int) $player->getCache($this, self::CACHE_CURRENT_PAGE);
}
$player->setCache($this, self::CACHE_CURRENT_PAGE, $pageIndex);
$totalPlayersCount = count($players);
$chunkIndex = $this->getChunkIndexFromPageNumber($pageIndex, $totalPlayersCount);
$playerBeginIndex = $this->getChunkStatsBeginIndex($chunkIndex);
$pagesCount = ceil($totalPlayersCount / self::MAX_PLAYERS_PER_PAGE);
2014-01-28 19:28:17 +01:00
//create manialink
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
$script = $maniaLink->getScript();
2014-05-02 17:50:30 +02:00
$paging = new Paging();
$script->addFeature($paging);
$paging->setCustomMaxPageNumber($pagesCount);
$paging->setChunkActionAppendsPageNumber(true);
$paging->setChunkActions(self::ACTION_PAGING_CHUNKS);
$paging->setStartPageNumber($pageIndex + 1);
2014-01-27 21:27:31 +01:00
2014-01-28 19:28:17 +01:00
// Main frame
2014-08-13 11:05:52 +02:00
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging);
2017-03-25 19:15:50 +01:00
$maniaLink->addChild($frame);
2014-01-27 19:41:07 +01:00
2013-12-31 12:17:25 +01:00
// Start offsets
$posX = -$width / 2;
$posY = $height / 2;
2014-01-09 18:19:37 +01:00
// Define z-values
2017-04-11 12:28:04 +02:00
$backgroundZ = -0.1;
2014-01-06 18:50:26 +01:00
// Predefine Description Label
2014-08-13 11:05:52 +02:00
$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel();
2017-03-25 19:15:50 +01:00
$frame->addChild($descriptionLabel);
2014-01-09 18:19:37 +01:00
2013-12-31 12:17:25 +01:00
// Headline
2013-12-18 15:48:33 +01:00
$headFrame = new Frame();
2017-03-25 19:15:50 +01:00
$frame->addChild($headFrame);
$headFrame->setY($posY - 5);
2015-06-04 00:23:29 +02:00
2017-04-01 18:48:36 +02:00
$labelLine = new LabelLine($headFrame);
$labelLine->addLabelEntryText('Id', $posX + 5);
$labelLine->addLabelEntryText('Nickname', $posX + 18);
$labelLine->addLabelEntryText('Login', $posX + 70);
$labelLine->addLabelEntryText('Location', $posX + 101);
2015-07-15 01:05:50 +02:00
if ($this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
2017-04-01 18:48:36 +02:00
$labelLine->addLabelEntryText('Actions', $posX + 135);
2013-12-31 12:17:25 +01:00
}
2017-04-01 18:48:36 +02:00
$labelLine->render();
2014-01-09 18:19:37 +01:00
$index = 1;
$posY = $height / 2 - 10;
$pageFrame = null;
$playerIndex = 1 + $playerBeginIndex;
//Slice Array to chunk length
$players = array_slice($players, $playerBeginIndex, self::MAX_PAGES_PER_CHUNK * self::MAX_PLAYERS_PER_PAGE, true);
$pageNumber = 1 + $chunkIndex * self::MAX_PAGES_PER_CHUNK;
2014-05-12 23:43:12 +02:00
2014-05-02 17:50:30 +02:00
foreach ($players as $listPlayer) {
if ($index % self::MAX_PLAYERS_PER_PAGE === 1) {
2014-01-27 19:41:07 +01:00
$pageFrame = new Frame();
2017-03-25 19:15:50 +01:00
$frame->addChild($pageFrame);
2014-05-12 23:43:12 +02:00
$paging->addPageControl($pageFrame, $pageNumber);
$pageNumber++;
$posY = $height / 2 - 10;
2014-01-27 19:41:07 +01:00
}
2014-01-09 18:19:37 +01:00
$path = $listPlayer->getProvince();
2013-12-18 15:48:33 +01:00
$playerFrame = new Frame();
2017-03-25 19:15:50 +01:00
$pageFrame->addChild($playerFrame);
2014-01-09 18:19:37 +01:00
if ($index % 2 !== 0) {
2013-12-31 02:27:40 +01:00
$lineQuad = new Quad_BgsPlayerCard();
2017-03-25 19:15:50 +01:00
$playerFrame->addChild($lineQuad);
2014-01-06 18:50:26 +01:00
$lineQuad->setSize($width, 4);
2013-12-31 02:27:40 +01:00
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
$lineQuad->setZ($backgroundZ);
2013-12-31 02:27:40 +01:00
}
2017-04-01 18:48:36 +02:00
$labelLine = new LabelLine($playerFrame);
$labelLine->addLabelEntryText($playerIndex, $posX + 5, 13);
2017-04-01 18:48:36 +02:00
$labelLine->addLabelEntryText($listPlayer->nickname, $posX + 18, 43);
$labelLine->addLabelEntryText($listPlayer->login, $posX + 70, 26);
$labelLine->addLabelEntryText($path, $posX + 101, 27);
2014-01-09 18:19:37 +01:00
2017-04-01 18:48:36 +02:00
$labelLine->render();
2014-01-09 18:19:37 +01:00
$playerFrame->setY($posY);
2014-01-09 18:19:37 +01:00
// Show current Player Arrow
if ($listPlayer->index === $player->index) {
2014-01-31 15:41:01 +01:00
$currentQuad = new Quad_Icons64x64_1();
2017-03-25 19:15:50 +01:00
$playerFrame->addChild($currentQuad);
$currentQuad->setX($posX + 3.5);
2014-01-31 15:41:01 +01:00
$currentQuad->setSize(4, 4);
$currentQuad->setSubStyle($currentQuad::SUBSTYLE_ArrowBlue);
}
2013-12-31 12:17:25 +01:00
// Team Emblem
2014-01-27 21:27:31 +01:00
if ($listPlayer->teamId >= 0) {
2013-12-31 16:17:50 +01:00
// Player is in a Team
$teamQuad = new Quad_Emblems();
2017-03-25 19:15:50 +01:00
$playerFrame->addChild($teamQuad);
$teamQuad->setX($posX + 10);
2013-12-31 16:17:50 +01:00
$teamQuad->setSize(3.8, 3.8);
2014-01-09 18:19:37 +01:00
2014-05-02 17:50:30 +02:00
switch ($listPlayer->teamId) {
2013-12-31 12:17:25 +01:00
case 0:
2013-12-31 17:15:32 +01:00
$teamQuad->setSubStyle($teamQuad::SUBSTYLE_1);
2013-12-31 12:17:25 +01:00
break;
case 1:
2013-12-31 17:15:32 +01:00
$teamQuad->setSubStyle($teamQuad::SUBSTYLE_2);
2013-12-31 12:17:25 +01:00
break;
2013-12-18 23:35:33 +01:00
}
2014-01-27 21:27:31 +01:00
} else if ($listPlayer->isSpectator) {
2013-12-31 16:17:50 +01:00
// Player is in Spectator Mode
$specQuad = new Quad_BgRaceScore2();
2017-03-25 19:15:50 +01:00
$playerFrame->addChild($specQuad);
$specQuad->setX($posX + 10);
2013-12-31 17:15:32 +01:00
$specQuad->setSubStyle($specQuad::SUBSTYLE_Spectator);
2013-12-31 16:17:50 +01:00
$specQuad->setSize(3.8, 3.8);
2013-12-19 21:59:10 +01:00
}
2014-01-09 18:19:37 +01:00
2014-01-31 14:48:24 +01:00
$countryCode = Formatter::mapCountry($listPlayer->getCountry());
if ($countryCode !== 'OTH') {
2013-12-31 12:17:25 +01:00
// Nation Quad
$countryQuad = new Quad();
2017-03-25 19:15:50 +01:00
$playerFrame->addChild($countryQuad);
$countryQuad->setImageUrl("file://ZoneFlags/Login/{$listPlayer->login}/country");
$countryQuad->setX($posX + 98);
$countryQuad->setSize(4, 4);
2014-01-09 18:19:37 +01:00
2014-05-02 17:50:30 +02:00
$countryQuad->addTooltipLabelFeature($descriptionLabel, '$<' . $listPlayer->nickname . '$> from ' . $listPlayer->path);
}
2014-01-09 18:19:37 +01:00
2013-12-31 12:17:25 +01:00
// Level Quad
2013-12-19 21:59:10 +01:00
$rightQuad = new Quad_BgRaceScore2();
2017-03-25 19:15:50 +01:00
$playerFrame->addChild($rightQuad);
$rightQuad->setX($posX + 13);
2013-12-31 12:17:25 +01:00
$rightQuad->setSize(7, 3.5);
$rightQuad->setSubStyle($rightQuad::SUBSTYLE_CupFinisher);
2014-01-09 18:19:37 +01:00
2013-12-19 21:59:10 +01:00
$rightLabel = new Label_Text();
2017-03-25 19:15:50 +01:00
$playerFrame->addChild($rightLabel);
$rightLabel->setX($posX + 13.9);
2014-08-13 11:05:52 +02:00
$rightLabel->setText($this->maniaControl->getAuthenticationManager()->getAuthLevelAbbreviation($listPlayer->authLevel));
$rightLabel->setTextSize(0.8);
2014-06-17 23:27:28 +02:00
$rightLabel->setTextColor('fff');
2014-01-09 18:19:37 +01:00
2014-08-13 11:05:52 +02:00
$description = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($listPlayer) . ' ' . $listPlayer->nickname;
2014-05-02 17:50:30 +02:00
$rightLabel->addTooltipLabelFeature($descriptionLabel, $description);
2014-01-09 18:19:37 +01:00
2014-01-05 00:02:13 +01:00
// Player Statistics
$playerQuad = new Quad_Icons64x64_1();
2017-03-25 19:15:50 +01:00
$playerFrame->addChild($playerQuad);
$playerQuad->setX($posX + 61);
2014-01-05 00:02:13 +01:00
$playerQuad->setSize(2.7, 2.7);
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_TrackInfo);
2014-06-17 23:27:28 +02:00
$playerQuad->setAction(self::ACTION_OPEN_PLAYER_DETAILED . '.' . $listPlayer->login);
2014-05-02 17:50:30 +02:00
$description = 'View Statistics of $<' . $listPlayer->nickname . '$>';
$playerQuad->addTooltipLabelFeature($descriptionLabel, $description);
2014-01-09 18:19:37 +01:00
2014-01-05 00:02:13 +01:00
// Camera Quad
$playerQuad = new Quad_UIConstruction_Buttons();
2017-03-25 19:15:50 +01:00
$playerFrame->addChild($playerQuad);
$playerQuad->setX($posX + 64.5);
2014-01-05 00:02:13 +01:00
$playerQuad->setSize(3.8, 3.8);
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Camera);
2014-05-02 17:50:30 +02:00
$description = 'Spectate $<' . $listPlayer->nickname . '$>';
$playerQuad->addTooltipLabelFeature($descriptionLabel, $description);
2014-06-17 23:27:28 +02:00
$playerQuad->setAction(self::ACTION_SPECTATE_PLAYER . '.' . $listPlayer->login);
2014-01-09 18:19:37 +01:00
2013-12-31 12:58:50 +01:00
// Player Profile Quad
$playerQuad = new Quad_UIConstruction_Buttons();
2017-03-25 19:15:50 +01:00
$playerFrame->addChild($playerQuad);
$playerQuad->setX($posX + 68);
2013-12-31 12:58:50 +01:00
$playerQuad->setSize(3.8, 3.8);
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Author);
2014-05-02 17:50:30 +02:00
$playerQuad->addPlayerProfileFeature($listPlayer->login);
2014-01-09 18:19:37 +01:00
2013-12-31 12:58:50 +01:00
// Description Label
2014-05-02 17:50:30 +02:00
$description = 'View Player Profile of $<' . $listPlayer->nickname . '$>';
$playerQuad->addTooltipLabelFeature($descriptionLabel, $description);
2014-01-09 18:19:37 +01:00
2015-07-15 01:05:50 +02:00
if ($this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
2013-12-31 12:17:25 +01:00
// Further Player actions Quad
2013-12-19 21:59:10 +01:00
$playerQuad = new Quad_Icons64x64_1();
2017-03-25 19:15:50 +01:00
$playerFrame->addChild($playerQuad);
$playerQuad->setX($posX + 132);
2013-12-31 12:17:25 +01:00
$playerQuad->setSize(3.8, 3.8);
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Buddy);
2014-06-17 23:27:28 +02:00
$playerQuad->setAction(self::ACTION_PLAYER_ADV . '.' . $listPlayer->login);
2014-01-09 18:19:37 +01:00
2014-01-03 21:29:22 +01:00
// Description Label
2014-05-02 17:50:30 +02:00
$description = 'Advanced Player Actions for $<' . $listPlayer->nickname . '$>';
$playerQuad->addTooltipLabelFeature($descriptionLabel, $description);
2014-02-08 00:00:00 +01:00
}
2014-01-09 18:19:37 +01:00
if ($this->maniaControl->getServer()->getScriptManager()->modeIsTeamMode()) {
2015-07-15 01:05:50 +02:00
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)) {
2014-02-01 19:06:21 +01:00
// Force to Red-Team Quad
$redQuad = new Quad_Emblems();
2017-03-25 19:15:50 +01:00
$playerFrame->addChild($redQuad);
2017-04-11 12:28:04 +02:00
$redQuad->setX($posX + 144);
2014-02-01 19:06:21 +01:00
$redQuad->setSize(3.8, 3.8);
$redQuad->setSubStyle($redQuad::SUBSTYLE_2);
$redQuad->setAction(self::ACTION_FORCE_RED . '.' . $listPlayer->login);
2014-02-01 19:06:21 +01:00
// Force to Red-Team Description Label
2014-05-02 17:50:30 +02:00
$description = 'Force $<' . $listPlayer->nickname . '$> to Red Team!';
$redQuad->addTooltipLabelFeature($descriptionLabel, $description);
2014-02-01 19:06:21 +01:00
// Force to Blue-Team Quad
$blueQuad = new Quad_Emblems();
2017-03-25 19:15:50 +01:00
$playerFrame->addChild($blueQuad);
2017-04-11 12:28:04 +02:00
$blueQuad->setX($posX + 140);
2014-02-01 19:06:21 +01:00
$blueQuad->setSize(3.8, 3.8);
$blueQuad->setSubStyle($blueQuad::SUBSTYLE_1);
$blueQuad->setAction(self::ACTION_FORCE_BLUE . '.' . $listPlayer->login);
2014-02-01 19:06:21 +01:00
// Force to Blue-Team Description Label
2014-05-02 17:50:30 +02:00
$description = 'Force $<' . $listPlayer->nickname . '$> to Blue Team!';
$blueQuad->addTooltipLabelFeature($descriptionLabel, $description);
2014-02-08 00:00:00 +01:00
2015-07-15 01:05:50 +02:00
} else if ($this->maniaControl->getPluginManager()->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)) {
2014-02-08 00:00:00 +01:00
// Kick Player Vote
$kickQuad = new Quad_UIConstruction_Buttons();
2017-03-25 19:15:50 +01:00
$playerFrame->addChild($kickQuad);
2017-04-11 12:28:04 +02:00
$kickQuad->setX($posX + 140);
2014-02-08 00:00:00 +01:00
$kickQuad->setSize(3.8, 3.8);
$kickQuad->setSubStyle($kickQuad::SUBSTYLE_Validate_Step2);
$kickQuad->setAction(self::ACTION_KICK_PLAYER_VOTE . '.' . $listPlayer->login);
2014-02-08 00:00:00 +01:00
2014-05-02 17:50:30 +02:00
$description = 'Start a Kick Vote on $<' . $listPlayer->nickname . '$>!';
$kickQuad->addTooltipLabelFeature($descriptionLabel, $description);
2014-02-08 00:00:00 +01:00
}
} else {
2015-07-15 01:05:50 +02:00
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_PLAY)) {
2014-02-01 19:36:47 +01:00
// Force to Play
2014-02-01 19:43:44 +01:00
$playQuad = new Quad_Emblems();
2017-03-25 19:15:50 +01:00
$playerFrame->addChild($playQuad);
2017-04-11 12:28:04 +02:00
$playQuad->setX($posX + 142);
2014-02-01 19:43:44 +01:00
$playQuad->setSize(3.8, 3.8);
$playQuad->setSubStyle($playQuad::SUBSTYLE_2);
$playQuad->setAction(self::ACTION_FORCE_PLAY . '.' . $listPlayer->login);
2014-02-01 19:43:44 +01:00
2014-05-02 17:50:30 +02:00
$description = 'Force $<' . $listPlayer->nickname . '$> to Play!';
$playQuad->addTooltipLabelFeature($descriptionLabel, $description);
2014-02-01 19:06:21 +01:00
}
2014-02-08 00:00:00 +01:00
}
2014-01-09 18:19:37 +01:00
2015-07-15 01:05:50 +02:00
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_SPEC)) {
2013-12-31 12:17:25 +01:00
// Force to Spectator Quad
2013-12-19 21:59:10 +01:00
$spectatorQuad = new Quad_BgRaceScore2();
2017-03-25 19:15:50 +01:00
$playerFrame->addChild($spectatorQuad);
2017-04-11 12:28:04 +02:00
$spectatorQuad->setX($posX + 136);
2013-12-31 12:17:25 +01:00
$spectatorQuad->setSize(3.8, 3.8);
$spectatorQuad->setSubStyle($spectatorQuad::SUBSTYLE_Spectator);
$spectatorQuad->setAction(self::ACTION_FORCE_SPEC . '.' . $listPlayer->login);
2014-01-09 18:19:37 +01:00
2013-12-31 12:17:25 +01:00
// Force to Spectator Description Label
2014-05-02 17:50:30 +02:00
$description = 'Force $<' . $listPlayer->nickname . '$> to Spectator!';
$spectatorQuad->addTooltipLabelFeature($descriptionLabel, $description);
2015-07-15 01:05:50 +02:00
} else if ($this->maniaControl->getPluginManager()->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)) {
2014-02-08 00:00:00 +01:00
// Force to Spectator Quad
$spectatorQuad = new Quad_BgRaceScore2();
2017-03-25 19:15:50 +01:00
$playerFrame->addChild($spectatorQuad);
2017-04-11 12:28:04 +02:00
$spectatorQuad->setX($posX + 136);
2014-02-08 00:00:00 +01:00
$spectatorQuad->setSize(3.8, 3.8);
$spectatorQuad->setSubStyle($spectatorQuad::SUBSTYLE_Spectator);
$spectatorQuad->setAction(self::ACTION_FORCE_SPEC_VOTE . '.' . $listPlayer->login);
2014-02-08 00:00:00 +01:00
// Force to Spectator Description Label
2014-05-02 17:50:30 +02:00
$description = 'Start a Vote to force $<' . $listPlayer->nickname . '$> to Spectator!';
$spectatorQuad->addTooltipLabelFeature($descriptionLabel, $description);
2013-12-18 23:35:33 +01:00
}
2014-02-08 00:00:00 +01:00
$posY -= 4;
$index++;
$playerIndex++;
2013-12-18 15:48:33 +01:00
}
2014-01-09 18:19:37 +01:00
2014-01-06 18:50:26 +01:00
// Show advanced window
$listShownValue = $this->playersListShown[$player->login];
if ($listShownValue && $listShownValue !== self::SHOWN_MAIN_WINDOW) {
$frame = $this->showAdvancedPlayerWidget($player, $listShownValue);
2017-03-25 19:25:20 +01:00
$maniaLink->addChild($frame);
2013-12-26 17:27:21 +01:00
}
2014-01-09 18:19:37 +01:00
2014-01-06 18:50:26 +01:00
// Render and display xml
2014-08-13 11:05:52 +02:00
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'PlayerList');
2013-12-18 15:48:33 +01:00
}
/**
* Extra window with special actions on players like warn,kick, ban, authorization levels...
2013-12-31 12:17:25 +01:00
*
* @param Player $admin
* @param string $login
2013-12-26 17:27:21 +01:00
* @return Frame
*/
public function showAdvancedPlayerWidget(Player $admin, $login) {
2014-08-13 11:05:52 +02:00
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowStyle();
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowSubStyle();
2014-01-09 18:19:37 +01:00
2014-01-09 19:15:06 +01:00
//Settings
$posX = $width / 2 + 0.2;
2014-01-09 18:19:37 +01:00
$width = 35;
$textSize = 1.5;
2014-06-22 19:02:18 +02:00
$textColor = 'fff';
2013-12-26 11:25:10 +01:00
$quadWidth = $width - 7;
2014-01-09 18:19:37 +01:00
2013-12-31 12:17:25 +01:00
// mainframe
$frame = new Frame();
2013-12-31 12:17:25 +01:00
$frame->setSize($width, $height);
$frame->setPosition($posX + $width / 2, 0, ManialinkManager::MAIN_MANIALINK_Z_VALUE);
2014-01-09 18:19:37 +01:00
// Add Close Quad (X)
$closeQuad = new Quad_Icons64x64_1();
2017-03-25 19:15:50 +01:00
$frame->addChild($closeQuad);
$closeQuad->setPosition($width / 2 - 2.5, $height / 2 - 2.5, 3);
$closeQuad->setSize(6, 6);
2014-06-22 19:02:18 +02:00
$closeQuad->setSubStyle($closeQuad::SUBSTYLE_QuitRace);
2013-12-31 12:17:25 +01:00
$closeQuad->setAction(self::ACTION_CLOSE_PLAYER_ADV);
2014-01-09 18:19:37 +01:00
2013-12-31 12:17:25 +01:00
// Background Quad
$backgroundQuad = new Quad();
2017-03-25 19:15:50 +01:00
$frame->addChild($backgroundQuad);
2013-12-31 12:17:25 +01:00
$backgroundQuad->setSize($width, $height);
2014-01-06 18:50:26 +01:00
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
$backgroundQuad->setZ(-0.3);
2014-01-09 18:19:37 +01:00
2013-12-31 12:17:25 +01:00
// Show headline
$label = new Label_Text();
2017-03-25 19:15:50 +01:00
$frame->addChild($label);
$label->setHorizontalAlign($label::LEFT);
$label->setX(-$width / 2 + 5);
$label->setY($height / 2 - 5);
2014-06-22 19:02:18 +02:00
$label->setStyle($label::STYLE_TextCardSmall);
$label->setTextSize($textSize);
2014-06-17 23:27:28 +02:00
$label->setText('Advanced Actions');
$label->setTextColor($textColor);
2014-01-09 18:19:37 +01:00
//Nickname background
$quad = new Quad();
$frame->addChild($quad);
$quad->setPosition(0, $height / 2 - 10, -0.1);
$quad->setStyles($quadStyle, $quadSubstyle);
$quad->setSize($width, 5);
2013-12-31 12:17:25 +01:00
// Show Nickname
$label = new Label_Text();
2017-03-25 19:15:50 +01:00
$frame->addChild($label);
$label->setWidth($width * 0.9);
$label->setY($height / 2 - 10);
2014-06-22 19:02:18 +02:00
$label->setStyle($label::STYLE_TextCardSmall);
$label->setTextSize($textSize);
$label->setText($player->nickname);
$label->setTextColor($textColor);
$label->setHorizontalAlign($label::CENTER);
$buttonSpacing = 6.5;
2014-01-09 18:19:37 +01:00
// Background for Buttons
$posY = $height / 2 - 20;
$quad = new Quad_BgsPlayerCard();
2017-03-25 19:15:50 +01:00
$frame->addChild($quad);
$quad->setX(0);
$quad->setY($posY);
$quad->setZ(-0.1);
2013-12-26 17:27:21 +01:00
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
2013-12-26 11:25:10 +01:00
$quad->setSize($quadWidth, 5);
2014-01-09 18:19:37 +01:00
// Mute Button
2014-06-23 22:54:27 +02:00
$label = new Label_Text();
2017-03-25 19:15:50 +01:00
$frame->addChild($label);
$label->setX(0);
$label->setY($posY);
2014-06-22 19:02:18 +02:00
$label->setStyle($label::STYLE_TextCardSmall);
$label->setTextSize($textSize);
2014-01-02 16:37:52 +01:00
$label->setTextColor($textColor);
2014-01-09 18:19:37 +01:00
if (!$player->isMuted()) {
2014-06-17 23:27:28 +02:00
$label->setText('Mute');
$quad->setAction(self::ACTION_MUTE_PLAYER . '.' . $login);
2014-01-09 18:19:37 +01:00
} else {
2014-06-17 23:27:28 +02:00
$label->setText('UnMute');
$quad->setAction(self::ACTION_UNMUTE_PLAYER . '.' . $login);
2014-01-02 16:37:52 +01:00
}
2014-01-09 18:19:37 +01:00
2014-01-06 18:50:26 +01:00
// Warn Player
$posY -= $buttonSpacing;
2014-01-02 16:37:52 +01:00
$quad = clone $quad;
2017-03-25 19:15:50 +01:00
$frame->addChild($quad);
$quad->setY($posY);
2014-06-17 23:27:28 +02:00
$quad->setAction(self::ACTION_WARN_PLAYER . '.' . $login);
2014-01-09 18:19:37 +01:00
2014-01-02 16:37:52 +01:00
$label = clone $label;
2017-03-25 19:15:50 +01:00
$frame->addChild($label);
$label->setY($posY);
2014-06-17 23:27:28 +02:00
$label->setText('Warn');
$label->setTextColor($textColor);
2014-01-09 18:19:37 +01:00
$posY -= $buttonSpacing;
2014-01-09 18:19:37 +01:00
2013-12-31 12:17:25 +01:00
// Show Kick
2014-01-02 13:35:52 +01:00
$quad = clone $quad;
2017-03-25 19:15:50 +01:00
$frame->addChild($quad);
$quad->setY($posY);
2014-06-17 23:27:28 +02:00
$quad->setAction(self::ACTION_KICK_PLAYER . '.' . $login);
2014-01-09 18:19:37 +01:00
2014-01-02 13:35:52 +01:00
$label = clone $label;
2017-03-25 19:15:50 +01:00
$frame->addChild($label);
$label->setY($posY);
2014-06-17 23:27:28 +02:00
$label->setText('Kick');
$label->setTextColor('f90');
2014-01-09 18:19:37 +01:00
$posY -= $buttonSpacing;
2013-12-31 12:17:25 +01:00
// Show Ban
2014-01-02 13:35:52 +01:00
$quad = clone $quad;
2017-03-25 19:15:50 +01:00
$frame->addChild($quad);
$quad->setY($posY);
2014-06-17 23:27:28 +02:00
$quad->setAction(self::ACTION_BAN_PLAYER . '.' . $login);
2014-01-09 18:19:37 +01:00
2014-01-02 13:35:52 +01:00
$label = clone $label;
2017-03-25 19:15:50 +01:00
$frame->addChild($label);
$label->setY($posY);
2014-06-17 23:27:28 +02:00
$label->setText('Ban');
$label->setTextColor('700');
2014-01-09 18:19:37 +01:00
$posY -= $buttonSpacing * 2;
2013-12-31 12:17:25 +01:00
// Show Add as Master-Admin
2014-01-02 13:35:52 +01:00
$quad = clone $quad;
2017-03-25 19:15:50 +01:00
$frame->addChild($quad);
$quad->setY($posY);
2014-06-17 23:27:28 +02:00
$quad->setAction(self::ACTION_ADD_AS_MASTER . '.' . $login);
2014-01-09 18:19:37 +01:00
2014-01-02 13:35:52 +01:00
$label = clone $label;
2017-03-25 19:15:50 +01:00
$frame->addChild($label);
$label->setY($posY);
2014-06-17 23:27:28 +02:00
$label->setText('Set SuperAdmin');
$label->setTextColor($textColor);
2014-01-09 18:19:37 +01:00
$posY -= $buttonSpacing;
2013-12-31 12:17:25 +01:00
// Show Add as Admin
2014-01-02 13:35:52 +01:00
$quad = clone $quad;
2017-03-25 19:15:50 +01:00
$frame->addChild($quad);
$quad->setY($posY);
2014-06-17 23:27:28 +02:00
$quad->setAction(self::ACTION_ADD_AS_ADMIN . '.' . $login);
2014-01-09 18:19:37 +01:00
2014-01-02 13:35:52 +01:00
$label = clone $label;
2017-03-25 19:15:50 +01:00
$frame->addChild($label);
$label->setY($posY);
2014-06-17 23:27:28 +02:00
$label->setText('Set Admin');
$label->setTextColor($textColor);
2014-01-09 18:19:37 +01:00
$posY -= $buttonSpacing;
2013-12-31 12:17:25 +01:00
// Show Add as Moderator
2014-01-02 13:35:52 +01:00
$quad = clone $quad;
2017-03-25 19:15:50 +01:00
$frame->addChild($quad);
$quad->setY($posY);
2014-06-17 23:27:28 +02:00
$quad->setAction(self::ACTION_ADD_AS_MOD . '.' . $login);
2014-01-09 18:19:37 +01:00
2014-01-02 13:35:52 +01:00
$label = clone $label;
2017-03-25 19:15:50 +01:00
$frame->addChild($label);
$label->setY($posY);
2014-06-17 23:27:28 +02:00
$label->setText('Set Moderator');
$label->setTextColor($textColor);
2014-01-09 18:19:37 +01:00
2014-08-05 02:17:41 +02:00
if ($player->authLevel > 0
2014-08-13 11:05:52 +02:00
&& $this->maniaControl->getAuthenticationManager()->checkRight($admin, $player->authLevel + 1)
2014-08-05 02:17:41 +02:00
) {
$posY -= $buttonSpacing;
2013-12-31 12:17:25 +01:00
// Revoke Rights
2014-01-02 13:35:52 +01:00
$quad = clone $quad;
2017-03-25 19:15:50 +01:00
$frame->addChild($quad);
$quad->setY($posY);
2014-06-17 23:27:28 +02:00
$quad->setAction(self::ACTION_REVOKE_RIGHTS . '.' . $login);
2014-01-09 18:19:37 +01:00
2014-01-02 13:35:52 +01:00
$label = clone $label;
2017-03-25 19:15:50 +01:00
$frame->addChild($label);
$label->setY($posY);
2014-06-17 23:27:28 +02:00
$label->setText('Revoke Rights');
$label->setTextColor('700');
2013-12-26 11:25:10 +01:00
}
2014-01-09 18:19:37 +01:00
2013-12-26 17:27:21 +01:00
return $frame;
}
2013-12-29 22:52:07 +01:00
/**
* Get the Chunk Index with the given Page Index
*
* @param int $pageIndex
* @return int
*/
private function getChunkIndexFromPageNumber($pageIndex, $totalPlayersCount) {
$pagesCount = ceil($totalPlayersCount / self::MAX_PLAYERS_PER_PAGE);
if ($pageIndex > $pagesCount - 1) {
$pageIndex = $pagesCount - 1;
}
return floor($pageIndex / self::MAX_PAGES_PER_CHUNK);
}
/**
* Calculate the First Player Index to show for the given Chunk
*
* @param int $chunkIndex
* @return int
*/
private function getChunkStatsBeginIndex($chunkIndex) {
return $chunkIndex * self::MAX_PAGES_PER_CHUNK * self::MAX_PLAYERS_PER_PAGE;
}
2013-12-19 21:59:10 +01:00
/**
2013-12-29 15:52:01 +01:00
* Called on ManialinkPageAnswer
2013-12-31 12:17:25 +01:00
*
2013-12-19 21:59:10 +01:00
* @param array $callback
*/
2013-12-31 12:17:25 +01:00
public function handleManialinkPageAnswer(array $callback) {
2014-01-09 18:19:37 +01:00
$actionId = $callback[1][2];
2014-01-16 13:38:53 +01:00
$actionArray = explode('.', $actionId, 3);
if(count($actionArray) < 2){
return;
}
2014-06-17 23:27:28 +02:00
$action = $actionArray[0] . '.' . $actionArray[1];
if (count($actionArray) > 2) {
2014-02-08 00:00:00 +01:00
$adminLogin = $callback[1][1];
$targetLogin = $actionArray[2];
switch ($action) {
case self::ACTION_SPECTATE_PLAYER:
2014-02-08 00:00:00 +01:00
try {
$this->maniaControl->getClient()->forceSpectator($adminLogin, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
$this->maniaControl->getClient()->forceSpectatorTarget($adminLogin, $targetLogin, 1);
} catch (PlayerStateException $e) {
2014-07-26 16:31:47 +02:00
} catch (UnknownPlayerException $e) {
} catch(ServerOptionsException $e){
//too many Spectators
2014-02-08 00:00:00 +01:00
}
break;
case self::ACTION_OPEN_PLAYER_DETAILED:
$player = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
$this->maniaControl->getPlayerManager()->getPlayerDetailed()->showPlayerDetailed($player, $targetLogin);
unset($this->playersListShown[$player->login]);
break;
case self::ACTION_FORCE_BLUE:
$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::TEAM_BLUE);
break;
case self::ACTION_FORCE_RED:
$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::TEAM_RED);
break;
case self::ACTION_FORCE_SPEC:
$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToSpectator($adminLogin, $targetLogin, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
break;
case self::ACTION_FORCE_PLAY:
$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToPlay($adminLogin, $targetLogin);
break;
case self::ACTION_MUTE_PLAYER:
$this->maniaControl->getPlayerManager()->getPlayerActions()->mutePlayer($adminLogin, $targetLogin);
$this->showPlayerList($this->maniaControl->getPlayerManager()->getPlayer($adminLogin));
break;
case self::ACTION_UNMUTE_PLAYER:
$this->maniaControl->getPlayerManager()->getPlayerActions()->unMutePlayer($adminLogin, $targetLogin);
$this->showPlayerList($this->maniaControl->getPlayerManager()->getPlayer($adminLogin));
break;
case self::ACTION_WARN_PLAYER:
$this->maniaControl->getPlayerManager()->getPlayerActions()->warnPlayer($adminLogin, $targetLogin);
break;
case self::ACTION_KICK_PLAYER:
$this->maniaControl->getPlayerManager()->getPlayerActions()->kickPlayer($adminLogin, $targetLogin);
break;
case self::ACTION_BAN_PLAYER:
$this->maniaControl->getPlayerManager()->getPlayerActions()->banPlayer($adminLogin, $targetLogin);
break;
case self::ACTION_PLAYER_ADV:
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
$this->advancedPlayerWidget($admin, $targetLogin);
break;
case self::ACTION_ADD_AS_MASTER:
$this->maniaControl->getPlayerManager()->getPlayerActions()->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
break;
case self::ACTION_ADD_AS_ADMIN:
$this->maniaControl->getPlayerManager()->getPlayerActions()->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_ADMIN);
break;
case self::ACTION_ADD_AS_MOD:
$this->maniaControl->getPlayerManager()->getPlayerActions()->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_MODERATOR);
break;
case self::ACTION_REVOKE_RIGHTS:
$this->maniaControl->getPlayerManager()->getPlayerActions()->revokeAuthLevel($adminLogin, $targetLogin);
break;
case self::ACTION_FORCE_SPEC_VOTE:
/** @var $votesPlugin CustomVotesPlugin */
$votesPlugin = $this->maniaControl->getPluginManager()->getPlugin(self::DEFAULT_CUSTOM_VOTE_PLUGIN);
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
$startMessage = $admin->getEscapedNickname() . '$s started a vote to force $<' . $target->nickname . '$> into spectator!';
$votesPlugin->defineVote('forcespec', 'Force ' . $target->getEscapedNickname() . ' Spec', true, $startMessage);
$votesPlugin->startVote($admin, 'forcespec', function ($result) use (&$votesPlugin, &$target) {
$this->maniaControl->getChat()->sendInformation('$sVote successful -> Player ' . $target->getEscapedNickname() . ' forced to Spectator!');
$votesPlugin->undefineVote('forcespec');
try {
$this->maniaControl->getClient()->forceSpectator($target->login, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
$this->maniaControl->getClient()->spectatorReleasePlayerSlot($target->login);
} catch (PlayerStateException $e) {
} catch (UnknownPlayerException $e) {
}
});
break;
case self::ACTION_KICK_PLAYER_VOTE:
/** @var $votesPlugin CustomVotesPlugin */
$votesPlugin = $this->maniaControl->getPluginManager()->getPlugin(self::DEFAULT_CUSTOM_VOTE_PLUGIN);
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
$startMessage = $admin->getEscapedNickname() . '$s started a vote to kick $<' . $target->nickname . '$>!';
$votesPlugin->defineVote('kick', 'Kick ' . $target->getEscapedNickname(), true, $startMessage);
$votesPlugin->startVote($admin, 'kick', function ($result) use (&$votesPlugin, &$target) {
$this->maniaControl->getChat()->sendInformation('$sVote successful -> ' . $target->getEscapedNickname() . ' got Kicked!');
$votesPlugin->undefineVote('kick');
$message = '$39F You got kicked due to a Public Vote!$z ';
try {
$this->maniaControl->getClient()->kick($target->login, $message);
} catch (UnknownPlayerException $e) {
}
});
break;
}
} else if (count($actionArray) == 2) {
$playerLogin = $callback[1][1];
$player = $this->maniaControl->getPlayerManager()->getPlayer($playerLogin);
if (substr($action, 0, strlen(self::ACTION_PAGING_CHUNKS)) === self::ACTION_PAGING_CHUNKS) {
// Paging chunks
$neededPage = (int) substr($action, strlen(self::ACTION_PAGING_CHUNKS));
$this->showPlayerList($player, $neededPage - 1);
}
2014-02-08 00:00:00 +01:00
2013-12-23 20:57:50 +01:00
}
2013-12-19 21:59:10 +01:00
}
2014-05-02 17:50:30 +02:00
/**
* Display the Advanced Player Window
2014-05-02 17:50:30 +02:00
*
* @param Player $caller
* @param string $login
2014-05-02 17:50:30 +02:00
*/
public function advancedPlayerWidget(Player $caller, $login) {
// Set status to target player login
$this->playersListShown[$caller->login] = $login;
2014-05-13 18:26:38 +02:00
// Reopen PlayerList
2014-05-02 17:50:30 +02:00
$this->showPlayerList($caller);
}
2013-12-19 21:59:10 +01:00
/**
2013-12-23 21:52:30 +01:00
* Reopen the widget on PlayerInfoChanged / Player Connect and Disconnect
2013-12-31 12:17:25 +01:00
*
2013-12-19 21:59:10 +01:00
*/
public function updateWidget() {
2014-05-02 17:50:30 +02:00
foreach ($this->playersListShown as $login => $shown) {
2014-04-19 23:14:37 +02:00
if (!$shown) {
continue;
}
// Check if shown player still exists
2014-08-13 11:05:52 +02:00
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
if (!$player) {
unset($this->playersListShown[$login]);
continue;
}
2014-04-19 23:14:37 +02:00
// Reopen widget
if ($shown !== self::SHOWN_MAIN_WINDOW) {
$this->playersListShown[$login] = false;
2013-12-19 21:59:10 +01:00
}
$this->showPlayerList($player);
2013-12-19 21:59:10 +01:00
}
}
}