improved PHPDoc & applied common style
This commit is contained in:
parent
8296e8457c
commit
9aea33951a
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Dedimania;
|
namespace Dedimania;
|
||||||
|
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
@ -7,11 +8,14 @@ use Maniaplanet\DedicatedServer\Structures\Version;
|
|||||||
/**
|
/**
|
||||||
* ManiaControl Dedimania Plugin DataStructure
|
* ManiaControl Dedimania Plugin DataStructure
|
||||||
*
|
*
|
||||||
* @author kremsy and steeffeen
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||||
* @copyright ManiaControl Copyright © 2014 ManiaControl Team
|
* @copyright 2014 ManiaControl Team
|
||||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
*/
|
*/
|
||||||
class DedimaniaData {
|
class DedimaniaData {
|
||||||
|
/*
|
||||||
|
* Constants
|
||||||
|
*/
|
||||||
public $game;
|
public $game;
|
||||||
public $path;
|
public $path;
|
||||||
public $packmask;
|
public $packmask;
|
||||||
@ -27,6 +31,15 @@ class DedimaniaData {
|
|||||||
public $directoryAccessChecked = false;
|
public $directoryAccessChecked = false;
|
||||||
public $serverMaxRank = 30;
|
public $serverMaxRank = 30;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a new Dedimania Data Model
|
||||||
|
*
|
||||||
|
* @param string $serverLogin
|
||||||
|
* @param string $dedimaniaCode
|
||||||
|
* @param string $path
|
||||||
|
* @param string $packmask
|
||||||
|
* @param Version $serverVersion
|
||||||
|
*/
|
||||||
public function __construct($serverLogin, $dedimaniaCode, $path, $packmask, Version $serverVersion) {
|
public function __construct($serverLogin, $dedimaniaCode, $path, $packmask, Version $serverVersion) {
|
||||||
$this->game = "TM2";
|
$this->game = "TM2";
|
||||||
$this->login = $serverLogin;
|
$this->login = $serverLogin;
|
||||||
@ -41,7 +54,7 @@ class DedimaniaData {
|
|||||||
|
|
||||||
public function toArray() {
|
public function toArray() {
|
||||||
$array = array();
|
$array = array();
|
||||||
foreach(get_object_vars($this) as $key => $value) {
|
foreach (get_object_vars($this) as $key => $value) {
|
||||||
if ($key == 'records' || $key == 'sessionId' || $key == 'directoryAccessChecked' || $key == 'serverMaxRank' || $key == 'players') {
|
if ($key == 'records' || $key == 'sessionId' || $key == 'directoryAccessChecked' || $key == 'serverMaxRank' || $key == 'players') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -62,7 +75,7 @@ class DedimaniaData {
|
|||||||
*/
|
*/
|
||||||
public function getPlayerMaxRank($login) {
|
public function getPlayerMaxRank($login) {
|
||||||
$maxRank = $this->serverMaxRank;
|
$maxRank = $this->serverMaxRank;
|
||||||
foreach($this->players as $player) {
|
foreach ($this->players as $player) {
|
||||||
/** @var DedimaniaPlayer $player */
|
/** @var DedimaniaPlayer $player */
|
||||||
if ($player->login === $login) {
|
if ($player->login === $login) {
|
||||||
if ($player->maxRank > $maxRank) {
|
if ($player->maxRank > $maxRank) {
|
||||||
|
@ -1,22 +1,32 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Dedimania;
|
namespace Dedimania;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ManiaControl Dedimania-Plugin Player DataStructure
|
* ManiaControl Dedimania-Plugin Player DataStructure
|
||||||
*
|
*
|
||||||
* @author kremsy and steeffeen
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||||
* @copyright ManiaControl Copyright © 2014 ManiaControl Team
|
* @copyright 2014 ManiaControl Team
|
||||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
*/
|
*/
|
||||||
class DedimaniaPlayer {
|
class DedimaniaPlayer {
|
||||||
|
/*
|
||||||
|
* Public Properties
|
||||||
|
*/
|
||||||
public $login = '';
|
public $login = '';
|
||||||
public $maxRank = -1;
|
public $maxRank = -1;
|
||||||
public $banned = false;
|
public $banned = false;
|
||||||
public $optionsEnabled = false;
|
public $optionsEnabled = false;
|
||||||
public $options = '';
|
public $options = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a new Dedimania Player Model
|
||||||
|
* @param mixed$player
|
||||||
|
*/
|
||||||
public function __construct($player) {
|
public function __construct($player) {
|
||||||
if (!$player) return;
|
if (!$player) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->login = $player['Login'];
|
$this->login = $player['Login'];
|
||||||
$this->maxRank = $player['MaxRank'];
|
$this->maxRank = $player['MaxRank'];
|
||||||
@ -28,8 +38,8 @@ class DedimaniaPlayer {
|
|||||||
/**
|
/**
|
||||||
* Construct a new Player by its login and maxRank
|
* Construct a new Player by its login and maxRank
|
||||||
*
|
*
|
||||||
* @param $login
|
* @param string $login
|
||||||
* @param $maxRank
|
* @param int $maxRank
|
||||||
*/
|
*/
|
||||||
public function constructNewPlayer($login, $maxRank) {
|
public function constructNewPlayer($login, $maxRank) {
|
||||||
$this->login = $login;
|
$this->login = $login;
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Dedimania;
|
namespace Dedimania;
|
||||||
|
|
||||||
|
use ManiaControl\Formatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ManiaControl Dedimania-Plugin Record DataStructure
|
* ManiaControl Dedimania-Plugin Record DataStructure
|
||||||
*
|
*
|
||||||
* @author kremsy and steeffeen
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||||
* @copyright ManiaControl Copyright © 2014 ManiaControl Team
|
* @copyright 2014 ManiaControl Team
|
||||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
*/
|
*/
|
||||||
use ManiaControl\Formatter;
|
|
||||||
|
|
||||||
class RecordData {
|
class RecordData {
|
||||||
|
/*
|
||||||
|
* Public Properties
|
||||||
|
*/
|
||||||
public $nullRecord = false;
|
public $nullRecord = false;
|
||||||
public $login = '';
|
public $login = '';
|
||||||
public $nickName = '';
|
public $nickName = '';
|
||||||
@ -25,7 +29,7 @@ class RecordData {
|
|||||||
/**
|
/**
|
||||||
* Construct a Record by a given Record Array
|
* Construct a Record by a given Record Array
|
||||||
*
|
*
|
||||||
* @param $record
|
* @param array $record
|
||||||
*/
|
*/
|
||||||
public function __construct($record) {
|
public function __construct($record) {
|
||||||
if (!$record) {
|
if (!$record) {
|
||||||
@ -42,12 +46,12 @@ class RecordData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new Record via it's properties
|
* Construct a new Record via its Properties
|
||||||
*
|
*
|
||||||
* @param $login
|
* @param string $login
|
||||||
* @param $nickName
|
* @param string $nickName
|
||||||
* @param $best
|
* @param float $best
|
||||||
* @param $checkpoints
|
* @param int $checkpoints
|
||||||
* @param bool $newRecord
|
* @param bool $newRecord
|
||||||
*/
|
*/
|
||||||
public function constructNewRecord($login, $nickName, $best, $checkpoints, $newRecord = false) {
|
public function constructNewRecord($login, $nickName, $best, $checkpoints, $newRecord = false) {
|
||||||
|
@ -11,12 +11,12 @@ use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
|||||||
/**
|
/**
|
||||||
* ManiaControl Chat-Message Plugin
|
* ManiaControl Chat-Message Plugin
|
||||||
*
|
*
|
||||||
* @author kremsy <kremsy@maniacontrol.com>
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||||
* @copyright 2014 ManiaControl Team
|
* @copyright 2014 ManiaControl Team
|
||||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
*/
|
*/
|
||||||
class ChatMessagePlugin implements CommandListener, Plugin {
|
class ChatMessagePlugin implements CommandListener, Plugin {
|
||||||
/**
|
/*
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const PLUGIN_ID = 4;
|
const PLUGIN_ID = 4;
|
||||||
@ -25,72 +25,55 @@ class ChatMessagePlugin implements CommandListener, Plugin {
|
|||||||
const PLUGIN_AUTHOR = 'kremsy';
|
const PLUGIN_AUTHOR = 'kremsy';
|
||||||
const SETTING_AFK_FORCE_SPEC = 'AFK command forces spec';
|
const SETTING_AFK_FORCE_SPEC = 'AFK command forces spec';
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Private Properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
/** @var maniaControl $maniaControl */
|
/** @var ManiaControl $maniaControl */
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares the Plugin
|
* @see \ManiaControl\Plugins\Plugin::prepare()
|
||||||
*
|
|
||||||
* @param ManiaControl $maniaControl
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public static function prepare(ManiaControl $maniaControl) {
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
//do nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get plugin id
|
* @see \ManiaControl\Plugins\Plugin::getId()
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
*/
|
||||||
public static function getId() {
|
public static function getId() {
|
||||||
return self::PLUGIN_ID;
|
return self::PLUGIN_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plugin Name
|
* @see \ManiaControl\Plugins\Plugin::getName()
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public static function getName() {
|
public static function getName() {
|
||||||
return self::PLUGIN_NAME;
|
return self::PLUGIN_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plugin Version
|
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
||||||
*
|
|
||||||
* @return float,,
|
|
||||||
*/
|
*/
|
||||||
public static function getVersion() {
|
public static function getVersion() {
|
||||||
return self::PLUGIN_VERSION;
|
return self::PLUGIN_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plugin Author
|
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public static function getAuthor() {
|
public static function getAuthor() {
|
||||||
return self::PLUGIN_AUTHOR;
|
return self::PLUGIN_AUTHOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plugin Description
|
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public static function getDescription() {
|
public static function getDescription() {
|
||||||
return "Plugin offers various Chat-Commands like /gg /hi /afk /rq...";
|
return "Plugin offers various Chat-Commands like /gg /hi /afk /rq...";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the plugin
|
* @see \ManiaControl\Plugins\Plugin::load()
|
||||||
*
|
|
||||||
* @param \ManiaControl\ManiaControl $maniaControl
|
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
public function load(ManiaControl $maniaControl) {
|
public function load(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
@ -119,7 +102,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unload the plugin and its resources
|
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||||
*/
|
*/
|
||||||
public function unload() {
|
public function unload() {
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ use ManiaControl\Settings\SettingManager;
|
|||||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
*/
|
*/
|
||||||
class ChatlogPlugin implements CallbackListener, Plugin {
|
class ChatlogPlugin implements CallbackListener, Plugin {
|
||||||
/**
|
/*
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const ID = 26;
|
const ID = 26;
|
||||||
@ -31,7 +31,7 @@ class ChatlogPlugin implements CallbackListener, Plugin {
|
|||||||
const SETTING_LOGSERVERMESSAGES = 'Log Server Messages';
|
const SETTING_LOGSERVERMESSAGES = 'Log Server Messages';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
/** @var ManiaControl $maniaControl */
|
/** @var ManiaControl $maniaControl */
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
|
@ -14,6 +14,7 @@ use FML\Controls\Quads\Quad_Icons128x32_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;
|
||||||
|
use FML\Script\Features\KeyAction;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
use ManiaControl\Callbacks\TimerListener;
|
use ManiaControl\Callbacks\TimerListener;
|
||||||
@ -28,14 +29,13 @@ use ManiaControl\Server\Server;
|
|||||||
use ManiaControl\Server\ServerCommands;
|
use ManiaControl\Server\ServerCommands;
|
||||||
use Maniaplanet\DedicatedServer\Structures\VoteRatio;
|
use Maniaplanet\DedicatedServer\Structures\VoteRatio;
|
||||||
use Maniaplanet\DedicatedServer\Xmlrpc\NotInScriptModeException;
|
use Maniaplanet\DedicatedServer\Xmlrpc\NotInScriptModeException;
|
||||||
use FML\Script\Features\KeyAction;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ManiaControl Custom-Votes Plugin
|
* ManiaControl Custom-Votes Plugin
|
||||||
*
|
*
|
||||||
* @author kremsy
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||||
* @copyright ManiaControl Copyright © 2014 ManiaControl Team
|
* @copyright 2014 ManiaControl Team
|
||||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
*/
|
*/
|
||||||
class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkPageAnswerListener, TimerListener, Plugin {
|
class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkPageAnswerListener, TimerListener, Plugin {
|
||||||
@ -73,7 +73,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
|
|
||||||
const CB_CUSTOM_VOTE_FINISHED = 'CustomVotesPlugin.CustomVoteFinished';
|
const CB_CUSTOM_VOTE_FINISHED = 'CustomVotesPlugin.CustomVoteFinished';
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Private Properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
/** @var maniaControl $maniaControl */
|
/** @var maniaControl $maniaControl */
|
||||||
@ -84,20 +84,48 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
private $currentVote = null;
|
private $currentVote = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares the Plugin
|
* @see \ManiaControl\Plugins\Plugin::prepare()
|
||||||
*
|
|
||||||
* @param ManiaControl $maniaControl
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public static function prepare(ManiaControl $maniaControl) {
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
//do nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the plugin
|
* @see \ManiaControl\Plugins\Plugin::getId()
|
||||||
*
|
*/
|
||||||
* @param \ManiaControl\ManiaControl $maniaControl
|
public static function getId() {
|
||||||
* @return bool
|
return self::PLUGIN_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getName()
|
||||||
|
*/
|
||||||
|
public static function getName() {
|
||||||
|
return self::PLUGIN_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
||||||
|
*/
|
||||||
|
public static function getVersion() {
|
||||||
|
return self::PLUGIN_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
||||||
|
*/
|
||||||
|
public static function getAuthor() {
|
||||||
|
return self::PLUGIN_AUTHOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
||||||
|
*/
|
||||||
|
public static function getDescription() {
|
||||||
|
return 'Plugin offers your Custom Votes like Restart, Skip, Balance...';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::load()
|
||||||
*/
|
*/
|
||||||
public function load(ManiaControl $maniaControl) {
|
public function load(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
@ -140,7 +168,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
$this->defineVote("pausegame", "Vote for Pause Game");
|
$this->defineVote("pausegame", "Vote for Pause Game");
|
||||||
$this->defineVote("replay", "Vote to replay current map");
|
$this->defineVote("replay", "Vote to replay current map");
|
||||||
|
|
||||||
foreach($this->voteCommands as $name => $voteCommand) {
|
foreach ($this->voteCommands as $name => $voteCommand) {
|
||||||
$this->maniaControl->commandManager->registerCommandListener($name, $this, 'handleChatVote', false, $voteCommand->name);
|
$this->maniaControl->commandManager->registerCommandListener($name, $this, 'handleChatVote', false, $voteCommand->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +197,190 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unload the plugin and its resources
|
* Defines a Vote
|
||||||
|
*
|
||||||
|
* @param $voteIndex
|
||||||
|
* @param $voteName
|
||||||
|
* @param bool $idBased
|
||||||
|
* @param $neededRatio
|
||||||
|
*/
|
||||||
|
public function defineVote($voteIndex, $voteName, $idBased = false, $startText = '', $neededRatio = -1) {
|
||||||
|
if ($neededRatio == -1) {
|
||||||
|
$neededRatio = $this->maniaControl->settingManager->getSetting($this, self::SETTING_DEFAULT_RATIO);
|
||||||
|
}
|
||||||
|
$voteCommand = new VoteCommand($voteIndex, $voteName, $idBased, $neededRatio);
|
||||||
|
$voteCommand->startText = $startText;
|
||||||
|
$this->voteCommands[$voteIndex] = $voteCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle ManiaControl OnInit callback
|
||||||
|
*
|
||||||
|
* @internal param array $callback
|
||||||
|
*/
|
||||||
|
public function constructMenu() {
|
||||||
|
// Menu RestartMap
|
||||||
|
$itemQuad = new Quad_UIConstruction_Buttons();
|
||||||
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Reload);
|
||||||
|
$itemQuad->setAction(self::ACTION_START_VOTE . 'restartmap');
|
||||||
|
$this->addVoteMenuItem($itemQuad, 5, 'Vote for Restart-Map');
|
||||||
|
|
||||||
|
//Check if Pause exists in current GameMode
|
||||||
|
try {
|
||||||
|
$scriptInfos = $this->maniaControl->client->getModeScriptInfo();
|
||||||
|
|
||||||
|
$pauseExists = false;
|
||||||
|
foreach ($scriptInfos->commandDescs as $param) {
|
||||||
|
if ($param->name == "Command_ForceWarmUp") {
|
||||||
|
$pauseExists = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Menu Pause
|
||||||
|
if ($pauseExists) {
|
||||||
|
$itemQuad = new Quad_Icons128x32_1();
|
||||||
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ManiaLinkSwitch);
|
||||||
|
$itemQuad->setAction(self::ACTION_START_VOTE . 'pausegame');
|
||||||
|
$this->addVoteMenuItem($itemQuad, 10, 'Vote for a pause of Current Game');
|
||||||
|
}
|
||||||
|
} catch (NotInScriptModeException $e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
//Menu SkipMap
|
||||||
|
$itemQuad = new Quad_Icons64x64_1();
|
||||||
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ArrowFastNext);
|
||||||
|
$itemQuad->setAction(self::ACTION_START_VOTE . 'skipmap');
|
||||||
|
$this->addVoteMenuItem($itemQuad, 15, 'Vote for a Mapskip');
|
||||||
|
|
||||||
|
if ($this->maniaControl->server->isTeamMode()) {
|
||||||
|
//Menu TeamBalance
|
||||||
|
$itemQuad = new Quad_Icons128x32_1();
|
||||||
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_RT_Team);
|
||||||
|
$itemQuad->setAction(self::ACTION_START_VOTE . 'teambalance');
|
||||||
|
$this->addVoteMenuItem($itemQuad, 20, 'Vote for Team-Balance');
|
||||||
|
}
|
||||||
|
//Show the Menu's icon
|
||||||
|
$this->showIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new Vote Menu Item
|
||||||
|
*
|
||||||
|
* @param Control $control
|
||||||
|
* @param int $order
|
||||||
|
* @param string $description
|
||||||
|
*/
|
||||||
|
public function addVoteMenuItem(Control $control, $order = 0, $description = null) {
|
||||||
|
if (!isset($this->voteMenuItems[$order])) {
|
||||||
|
$this->voteMenuItems[$order] = array();
|
||||||
|
array_push($this->voteMenuItems[$order], array($control, $description));
|
||||||
|
krsort($this->voteMenuItems);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows the Icon Widget
|
||||||
|
*
|
||||||
|
* @param bool $login
|
||||||
|
*/
|
||||||
|
private function showIcon($login = false) {
|
||||||
|
$posX = $this->maniaControl->settingManager->getSetting($this, self::SETTING_VOTE_ICON_POSX);
|
||||||
|
$posY = $this->maniaControl->settingManager->getSetting($this, self::SETTING_VOTE_ICON_POSY);
|
||||||
|
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_VOTE_ICON_WIDTH);
|
||||||
|
$height = $this->maniaControl->settingManager->getSetting($this, self::SETTING_VOTE_ICON_HEIGHT);
|
||||||
|
$shootManiaOffset = $this->maniaControl->manialinkManager->styleManager->getDefaultIconOffsetSM();
|
||||||
|
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
|
||||||
|
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
|
||||||
|
$itemMarginFactorX = 1.3;
|
||||||
|
$itemMarginFactorY = 1.2;
|
||||||
|
|
||||||
|
//If game is shootmania lower the icons position by 20
|
||||||
|
if ($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') {
|
||||||
|
$posY -= $shootManiaOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
$itemSize = $width;
|
||||||
|
|
||||||
|
$maniaLink = new ManiaLink(self::MLID_ICON);
|
||||||
|
|
||||||
|
//Custom Vote Menu Iconsframe
|
||||||
|
$frame = new Frame();
|
||||||
|
$maniaLink->add($frame);
|
||||||
|
$frame->setPosition($posX, $posY);
|
||||||
|
|
||||||
|
$backgroundQuad = new Quad();
|
||||||
|
$frame->add($backgroundQuad);
|
||||||
|
$backgroundQuad->setSize($width * $itemMarginFactorX, $height * $itemMarginFactorY);
|
||||||
|
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
||||||
|
|
||||||
|
$iconFrame = new Frame();
|
||||||
|
$frame->add($iconFrame);
|
||||||
|
|
||||||
|
$iconFrame->setSize($itemSize, $itemSize);
|
||||||
|
$itemQuad = new Quad_UIConstruction_Buttons();
|
||||||
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Add);
|
||||||
|
$itemQuad->setSize($itemSize, $itemSize);
|
||||||
|
$iconFrame->add($itemQuad);
|
||||||
|
|
||||||
|
//Define Description Label
|
||||||
|
$menuEntries = count($this->voteMenuItems);
|
||||||
|
$descriptionFrame = new Frame();
|
||||||
|
$maniaLink->add($descriptionFrame);
|
||||||
|
$descriptionFrame->setPosition($posX - $menuEntries * $itemSize * 1.15 - 6, $posY);
|
||||||
|
|
||||||
|
$descriptionLabel = new Label();
|
||||||
|
$descriptionFrame->add($descriptionLabel);
|
||||||
|
$descriptionLabel->setAlign(Control::RIGHT, Control::TOP);
|
||||||
|
$descriptionLabel->setSize(40, 4);
|
||||||
|
$descriptionLabel->setTextSize(1.4);
|
||||||
|
$descriptionLabel->setTextColor('fff');
|
||||||
|
|
||||||
|
//Popout Frame
|
||||||
|
$popoutFrame = new Frame();
|
||||||
|
$maniaLink->add($popoutFrame);
|
||||||
|
$popoutFrame->setPosition($posX - $itemSize * 0.5, $posY);
|
||||||
|
$popoutFrame->setHAlign(Control::RIGHT);
|
||||||
|
$popoutFrame->setSize(4 * $itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
|
||||||
|
$popoutFrame->setVisible(false);
|
||||||
|
|
||||||
|
$backgroundQuad = new Quad();
|
||||||
|
$popoutFrame->add($backgroundQuad);
|
||||||
|
$backgroundQuad->setHAlign(Control::RIGHT);
|
||||||
|
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
||||||
|
$backgroundQuad->setSize($menuEntries * $itemSize * 1.15 + 2, $itemSize * $itemMarginFactorY);
|
||||||
|
|
||||||
|
$itemQuad->addToggleFeature($popoutFrame);
|
||||||
|
|
||||||
|
// Add items
|
||||||
|
$x = -1;
|
||||||
|
foreach ($this->voteMenuItems as $menuItems) {
|
||||||
|
foreach ($menuItems as $menuItem) {
|
||||||
|
$menuQuad = $menuItem[0];
|
||||||
|
/**
|
||||||
|
* @var Quad $menuQuad
|
||||||
|
*/
|
||||||
|
$popoutFrame->add($menuQuad);
|
||||||
|
$menuQuad->setSize($itemSize, $itemSize);
|
||||||
|
$menuQuad->setX($x);
|
||||||
|
$menuQuad->setHAlign(Control::RIGHT);
|
||||||
|
$x -= $itemSize * 1.05;
|
||||||
|
|
||||||
|
if ($menuItem[1]) {
|
||||||
|
$menuQuad->removeScriptFeatures();
|
||||||
|
$description = '$s' . $menuItem[1];
|
||||||
|
$menuQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Send manialink
|
||||||
|
$this->maniaControl->manialinkManager->sendManialink($maniaLink, $login);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||||
*/
|
*/
|
||||||
public function unload() {
|
public function unload() {
|
||||||
//Enable Standard Votes
|
//Enable Standard Votes
|
||||||
@ -194,6 +405,16 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
$this->maniaControl->manialinkManager->hideManialink(self::MLID_ICON);
|
$this->maniaControl->manialinkManager->hideManialink(self::MLID_ICON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroys the current Vote
|
||||||
|
*/
|
||||||
|
private function destroyVote() {
|
||||||
|
$emptyManialink = new ManiaLink(self::MLID_WIDGET);
|
||||||
|
$this->maniaControl->manialinkManager->sendManialink($emptyManialink);
|
||||||
|
|
||||||
|
unset($this->currentVote);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle PlayerConnect callback
|
* Handle PlayerConnect callback
|
||||||
*
|
*
|
||||||
@ -203,21 +424,6 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
$this->showIcon($player->login);
|
$this->showIcon($player->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a new Vote Menu Item
|
|
||||||
*
|
|
||||||
* @param Control $control
|
|
||||||
* @param int $order
|
|
||||||
* @param string $description
|
|
||||||
*/
|
|
||||||
public function addVoteMenuItem(Control $control, $order = 0, $description = null) {
|
|
||||||
if (!isset($this->voteMenuItems[$order])) {
|
|
||||||
$this->voteMenuItems[$order] = array();
|
|
||||||
array_push($this->voteMenuItems[$order], array($control, $description));
|
|
||||||
krsort($this->voteMenuItems);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chat Vote
|
* Chat Vote
|
||||||
*
|
*
|
||||||
@ -233,167 +439,6 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle ManiaControl OnInit callback
|
|
||||||
*
|
|
||||||
* @internal param array $callback
|
|
||||||
*/
|
|
||||||
public function constructMenu() {
|
|
||||||
// Menu RestartMap
|
|
||||||
$itemQuad = new Quad_UIConstruction_Buttons();
|
|
||||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Reload);
|
|
||||||
$itemQuad->setAction(self::ACTION_START_VOTE . 'restartmap');
|
|
||||||
$this->addVoteMenuItem($itemQuad, 5, 'Vote for Restart-Map');
|
|
||||||
|
|
||||||
//Check if Pause exists in current GameMode
|
|
||||||
try {
|
|
||||||
$scriptInfos = $this->maniaControl->client->getModeScriptInfo();
|
|
||||||
|
|
||||||
$pauseExists = false;
|
|
||||||
foreach($scriptInfos->commandDescs as $param) {
|
|
||||||
if ($param->name == "Command_ForceWarmUp") {
|
|
||||||
$pauseExists = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Menu Pause
|
|
||||||
if ($pauseExists) {
|
|
||||||
$itemQuad = new Quad_Icons128x32_1();
|
|
||||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ManiaLinkSwitch);
|
|
||||||
$itemQuad->setAction(self::ACTION_START_VOTE . 'pausegame');
|
|
||||||
$this->addVoteMenuItem($itemQuad, 10, 'Vote for a pause of Current Game');
|
|
||||||
}
|
|
||||||
} catch(NotInScriptModeException $e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
//Menu SkipMap
|
|
||||||
$itemQuad = new Quad_Icons64x64_1();
|
|
||||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ArrowFastNext);
|
|
||||||
$itemQuad->setAction(self::ACTION_START_VOTE . 'skipmap');
|
|
||||||
$this->addVoteMenuItem($itemQuad, 15, 'Vote for a Mapskip');
|
|
||||||
|
|
||||||
if ($this->maniaControl->server->isTeamMode()) {
|
|
||||||
//Menu TeamBalance
|
|
||||||
$itemQuad = new Quad_Icons128x32_1();
|
|
||||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_RT_Team);
|
|
||||||
$itemQuad->setAction(self::ACTION_START_VOTE . 'teambalance');
|
|
||||||
$this->addVoteMenuItem($itemQuad, 20, 'Vote for Team-Balance');
|
|
||||||
}
|
|
||||||
//Show the Menu's icon
|
|
||||||
$this->showIcon();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroy the Vote on Canceled Callback
|
|
||||||
*
|
|
||||||
* @param Player $player
|
|
||||||
*/
|
|
||||||
public function handleVoteCanceled(Player $player) {
|
|
||||||
//reset vote
|
|
||||||
$this->destroyVote();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle Standard Votes
|
|
||||||
*
|
|
||||||
* @param $voteName
|
|
||||||
* @param $voteResult
|
|
||||||
*/
|
|
||||||
public function handleVoteFinished($voteName, $voteResult) {
|
|
||||||
if ($voteResult >= $this->currentVote->neededRatio) {
|
|
||||||
// Call Closure if one exists
|
|
||||||
if (is_callable($this->currentVote->function)) {
|
|
||||||
call_user_func($this->currentVote->function, $voteResult);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch($voteName) {
|
|
||||||
case 'teambalance':
|
|
||||||
$this->maniaControl->client->autoTeamBalance();
|
|
||||||
$this->maniaControl->chat->sendInformation('$f8fVote to $fffbalance the teams$f8f has been successfull!');
|
|
||||||
break;
|
|
||||||
case 'skipmap':
|
|
||||||
case 'skip':
|
|
||||||
case 'nextmap':
|
|
||||||
$this->maniaControl->client->nextMap();
|
|
||||||
$this->maniaControl->chat->sendInformation('$f8fVote to $fffskip the map$f8f has been successfull!');
|
|
||||||
break;
|
|
||||||
case 'restartmap':
|
|
||||||
$this->maniaControl->client->restartMap();
|
|
||||||
$this->maniaControl->chat->sendInformation('$f8fVote to $fffrestart the map$f8f has been successfull!');
|
|
||||||
break;
|
|
||||||
case 'pausegame':
|
|
||||||
$this->maniaControl->client->sendModeScriptCommands(array('Command_ForceWarmUp' => True));
|
|
||||||
$this->maniaControl->chat->sendInformation('$f8fVote to $fffpause the current game$f8f has been successfull!');
|
|
||||||
break;
|
|
||||||
case 'replay':
|
|
||||||
$this->maniaControl->mapManager->mapQueue->addFirstMapToMapQueue($this->currentVote->voter, $this->maniaControl->mapManager->getCurrentMap());
|
|
||||||
$this->maniaControl->chat->sendInformation('$f8fVote to $fffreplay the map$f8f has been successfull!');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$this->maniaControl->chat->sendError('Vote Failed!');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles the ManialinkPageAnswers and start a vote if a button in the panel got clicked
|
|
||||||
*
|
|
||||||
* @param array $callback
|
|
||||||
*/
|
|
||||||
public function handleManialinkPageAnswer(array $callback) {
|
|
||||||
$actionId = $callback[1][2];
|
|
||||||
$actionArray = explode('.', $actionId);
|
|
||||||
if (count($actionArray) <= 2) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$voteIndex = $actionArray[2];
|
|
||||||
if (isset($this->voteCommands[$voteIndex])) {
|
|
||||||
$login = $callback[1][1];
|
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
|
||||||
$this->startVote($player, $voteIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handleChatVote(array $chat, Player $player) {
|
|
||||||
$chatCommand = explode(' ', $chat[1][2]);
|
|
||||||
$chatCommand = $chatCommand[0];
|
|
||||||
$chatCommand = str_replace('/', '', $chatCommand);
|
|
||||||
|
|
||||||
if (isset($this->voteCommands[$chatCommand])) {
|
|
||||||
$this->startVote($player, $chatCommand);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defines a Vote
|
|
||||||
*
|
|
||||||
* @param $voteIndex
|
|
||||||
* @param $voteName
|
|
||||||
* @param bool $idBased
|
|
||||||
* @param $neededRatio
|
|
||||||
*/
|
|
||||||
public function defineVote($voteIndex, $voteName, $idBased = false, $startText = '', $neededRatio = -1) {
|
|
||||||
if ($neededRatio == -1) {
|
|
||||||
$neededRatio = $this->maniaControl->settingManager->getSetting($this, self::SETTING_DEFAULT_RATIO);
|
|
||||||
}
|
|
||||||
$voteCommand = new VoteCommand($voteIndex, $voteName, $idBased, $neededRatio);
|
|
||||||
$voteCommand->startText = $startText;
|
|
||||||
$this->voteCommands[$voteIndex] = $voteCommand;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Undefines a Vote
|
|
||||||
*
|
|
||||||
* @param $voteIndex
|
|
||||||
*/
|
|
||||||
public function undefineVote($voteIndex) {
|
|
||||||
unset($this->voteCommands[$voteIndex]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts a vote
|
* Starts a vote
|
||||||
*
|
*
|
||||||
@ -444,6 +489,98 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
$this->maniaControl->chat->sendSuccess($message);
|
$this->maniaControl->chat->sendSuccess($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy the Vote on Canceled Callback
|
||||||
|
*
|
||||||
|
* @param Player $player
|
||||||
|
*/
|
||||||
|
public function handleVoteCanceled(Player $player) {
|
||||||
|
//reset vote
|
||||||
|
$this->destroyVote();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle Standard Votes
|
||||||
|
*
|
||||||
|
* @param $voteName
|
||||||
|
* @param $voteResult
|
||||||
|
*/
|
||||||
|
public function handleVoteFinished($voteName, $voteResult) {
|
||||||
|
if ($voteResult >= $this->currentVote->neededRatio) {
|
||||||
|
// Call Closure if one exists
|
||||||
|
if (is_callable($this->currentVote->function)) {
|
||||||
|
call_user_func($this->currentVote->function, $voteResult);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($voteName) {
|
||||||
|
case 'teambalance':
|
||||||
|
$this->maniaControl->client->autoTeamBalance();
|
||||||
|
$this->maniaControl->chat->sendInformation('$f8fVote to $fffbalance the teams$f8f has been successfull!');
|
||||||
|
break;
|
||||||
|
case 'skipmap':
|
||||||
|
case 'skip':
|
||||||
|
case 'nextmap':
|
||||||
|
$this->maniaControl->client->nextMap();
|
||||||
|
$this->maniaControl->chat->sendInformation('$f8fVote to $fffskip the map$f8f has been successfull!');
|
||||||
|
break;
|
||||||
|
case 'restartmap':
|
||||||
|
$this->maniaControl->client->restartMap();
|
||||||
|
$this->maniaControl->chat->sendInformation('$f8fVote to $fffrestart the map$f8f has been successfull!');
|
||||||
|
break;
|
||||||
|
case 'pausegame':
|
||||||
|
$this->maniaControl->client->sendModeScriptCommands(array('Command_ForceWarmUp' => true));
|
||||||
|
$this->maniaControl->chat->sendInformation('$f8fVote to $fffpause the current game$f8f has been successfull!');
|
||||||
|
break;
|
||||||
|
case 'replay':
|
||||||
|
$this->maniaControl->mapManager->mapQueue->addFirstMapToMapQueue($this->currentVote->voter, $this->maniaControl->mapManager->getCurrentMap());
|
||||||
|
$this->maniaControl->chat->sendInformation('$f8fVote to $fffreplay the map$f8f has been successfull!');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->maniaControl->chat->sendError('Vote Failed!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the ManialinkPageAnswers and start a vote if a button in the panel got clicked
|
||||||
|
*
|
||||||
|
* @param array $callback
|
||||||
|
*/
|
||||||
|
public function handleManialinkPageAnswer(array $callback) {
|
||||||
|
$actionId = $callback[1][2];
|
||||||
|
$actionArray = explode('.', $actionId);
|
||||||
|
if (count($actionArray) <= 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$voteIndex = $actionArray[2];
|
||||||
|
if (isset($this->voteCommands[$voteIndex])) {
|
||||||
|
$login = $callback[1][1];
|
||||||
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||||
|
$this->startVote($player, $voteIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handleChatVote(array $chat, Player $player) {
|
||||||
|
$chatCommand = explode(' ', $chat[1][2]);
|
||||||
|
$chatCommand = $chatCommand[0];
|
||||||
|
$chatCommand = str_replace('/', '', $chatCommand);
|
||||||
|
|
||||||
|
if (isset($this->voteCommands[$chatCommand])) {
|
||||||
|
$this->startVote($player, $chatCommand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undefines a Vote
|
||||||
|
*
|
||||||
|
* @param $voteIndex
|
||||||
|
*/
|
||||||
|
public function undefineVote($voteIndex) {
|
||||||
|
unset($this->voteCommands[$voteIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a Positive Vote
|
* Handles a Positive Vote
|
||||||
*
|
*
|
||||||
@ -500,16 +637,6 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroys the current Vote
|
|
||||||
*/
|
|
||||||
private function destroyVote() {
|
|
||||||
$emptyManialink = new ManiaLink(self::MLID_WIDGET);
|
|
||||||
$this->maniaControl->manialinkManager->sendManialink($emptyManialink);
|
|
||||||
|
|
||||||
unset($this->currentVote);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows the vote widget
|
* Shows the vote widget
|
||||||
*
|
*
|
||||||
@ -566,7 +693,9 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
$timeGauge->setY(1.5);
|
$timeGauge->setY(1.5);
|
||||||
$timeGauge->setSize($width * 0.95, 6);
|
$timeGauge->setSize($width * 0.95, 6);
|
||||||
$timeGauge->setDrawBg(false);
|
$timeGauge->setDrawBg(false);
|
||||||
if (!$timeUntilExpire) $timeUntilExpire = 1;
|
if (!$timeUntilExpire) {
|
||||||
|
$timeUntilExpire = 1;
|
||||||
|
}
|
||||||
$timeGaugeRatio = (100 / $maxTime * $timeUntilExpire) / 100;
|
$timeGaugeRatio = (100 / $maxTime * $timeUntilExpire) / 100;
|
||||||
$timeGauge->setRatio($timeGaugeRatio + 0.15 - $timeGaugeRatio * 0.15);
|
$timeGauge->setRatio($timeGaugeRatio + 0.15 - $timeGaugeRatio * 0.15);
|
||||||
$gaugeColor = ColorUtil::floatToStatusColor($timeGaugeRatio);
|
$gaugeColor = ColorUtil::floatToStatusColor($timeGaugeRatio);
|
||||||
@ -640,152 +769,6 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
// Send manialink
|
// Send manialink
|
||||||
$this->maniaControl->manialinkManager->sendManialink($maniaLink);
|
$this->maniaControl->manialinkManager->sendManialink($maniaLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Shows the Icon Widget
|
|
||||||
*
|
|
||||||
* @param bool $login
|
|
||||||
*/
|
|
||||||
private function showIcon($login = false) {
|
|
||||||
$posX = $this->maniaControl->settingManager->getSetting($this, self::SETTING_VOTE_ICON_POSX);
|
|
||||||
$posY = $this->maniaControl->settingManager->getSetting($this, self::SETTING_VOTE_ICON_POSY);
|
|
||||||
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_VOTE_ICON_WIDTH);
|
|
||||||
$height = $this->maniaControl->settingManager->getSetting($this, self::SETTING_VOTE_ICON_HEIGHT);
|
|
||||||
$shootManiaOffset = $this->maniaControl->manialinkManager->styleManager->getDefaultIconOffsetSM();
|
|
||||||
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
|
|
||||||
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
|
|
||||||
$itemMarginFactorX = 1.3;
|
|
||||||
$itemMarginFactorY = 1.2;
|
|
||||||
|
|
||||||
//If game is shootmania lower the icons position by 20
|
|
||||||
if($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') {
|
|
||||||
$posY -= $shootManiaOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
$itemSize = $width;
|
|
||||||
|
|
||||||
$maniaLink = new ManiaLink(self::MLID_ICON);
|
|
||||||
|
|
||||||
//Custom Vote Menu Iconsframe
|
|
||||||
$frame = new Frame();
|
|
||||||
$maniaLink->add($frame);
|
|
||||||
$frame->setPosition($posX, $posY);
|
|
||||||
|
|
||||||
$backgroundQuad = new Quad();
|
|
||||||
$frame->add($backgroundQuad);
|
|
||||||
$backgroundQuad->setSize($width * $itemMarginFactorX, $height * $itemMarginFactorY);
|
|
||||||
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
|
||||||
|
|
||||||
$iconFrame = new Frame();
|
|
||||||
$frame->add($iconFrame);
|
|
||||||
|
|
||||||
$iconFrame->setSize($itemSize, $itemSize);
|
|
||||||
$itemQuad = new Quad_UIConstruction_Buttons();
|
|
||||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Add);
|
|
||||||
$itemQuad->setSize($itemSize, $itemSize);
|
|
||||||
$iconFrame->add($itemQuad);
|
|
||||||
|
|
||||||
//Define Description Label
|
|
||||||
$menuEntries = count($this->voteMenuItems);
|
|
||||||
$descriptionFrame = new Frame();
|
|
||||||
$maniaLink->add($descriptionFrame);
|
|
||||||
$descriptionFrame->setPosition($posX - $menuEntries * $itemSize * 1.15 - 6, $posY);
|
|
||||||
|
|
||||||
$descriptionLabel = new Label();
|
|
||||||
$descriptionFrame->add($descriptionLabel);
|
|
||||||
$descriptionLabel->setAlign(Control::RIGHT, Control::TOP);
|
|
||||||
$descriptionLabel->setSize(40, 4);
|
|
||||||
$descriptionLabel->setTextSize(1.4);
|
|
||||||
$descriptionLabel->setTextColor('fff');
|
|
||||||
|
|
||||||
//Popout Frame
|
|
||||||
$popoutFrame = new Frame();
|
|
||||||
$maniaLink->add($popoutFrame);
|
|
||||||
$popoutFrame->setPosition($posX - $itemSize * 0.5, $posY);
|
|
||||||
$popoutFrame->setHAlign(Control::RIGHT);
|
|
||||||
$popoutFrame->setSize(4 * $itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
|
|
||||||
$popoutFrame->setVisible(false);
|
|
||||||
|
|
||||||
$backgroundQuad = new Quad();
|
|
||||||
$popoutFrame->add($backgroundQuad);
|
|
||||||
$backgroundQuad->setHAlign(Control::RIGHT);
|
|
||||||
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
|
||||||
$backgroundQuad->setSize($menuEntries * $itemSize * 1.15 + 2, $itemSize * $itemMarginFactorY);
|
|
||||||
|
|
||||||
$itemQuad->addToggleFeature($popoutFrame);
|
|
||||||
|
|
||||||
// Add items
|
|
||||||
$x = -1;
|
|
||||||
foreach($this->voteMenuItems as $menuItems) {
|
|
||||||
foreach($menuItems as $menuItem) {
|
|
||||||
$menuQuad = $menuItem[0];
|
|
||||||
/**
|
|
||||||
* @var Quad $menuQuad
|
|
||||||
*/
|
|
||||||
$popoutFrame->add($menuQuad);
|
|
||||||
$menuQuad->setSize($itemSize, $itemSize);
|
|
||||||
$menuQuad->setX($x);
|
|
||||||
$menuQuad->setHAlign(Control::RIGHT);
|
|
||||||
$x -= $itemSize * 1.05;
|
|
||||||
|
|
||||||
if ($menuItem[1]) {
|
|
||||||
$menuQuad->removeScriptFeatures();
|
|
||||||
$description = '$s' . $menuItem[1];
|
|
||||||
$menuQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Send manialink
|
|
||||||
$this->maniaControl->manialinkManager->sendManialink($maniaLink, $login);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get plugin id
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public static function getId() {
|
|
||||||
return self::PLUGIN_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Plugin Name
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function getName() {
|
|
||||||
return self::PLUGIN_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Plugin Version
|
|
||||||
*
|
|
||||||
* @return float,,
|
|
||||||
*/
|
|
||||||
public static function getVersion() {
|
|
||||||
return self::PLUGIN_VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Plugin Author
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function getAuthor() {
|
|
||||||
return self::PLUGIN_AUTHOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Plugin Description
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function getDescription() {
|
|
||||||
return 'Plugin offers your Custom Votes like Restart, Skip, Balance...';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,7 +12,6 @@ use FML\Controls\Quads\Quad_BgsPlayerCard;
|
|||||||
use FML\Controls\Quads\Quad_Icons128x128_1;
|
use FML\Controls\Quads\Quad_Icons128x128_1;
|
||||||
use FML\ManiaLink;
|
use FML\ManiaLink;
|
||||||
use FML\Script\Features\Paging;
|
use FML\Script\Features\Paging;
|
||||||
|
|
||||||
use ManiaControl\Admin\AuthenticationManager;
|
use ManiaControl\Admin\AuthenticationManager;
|
||||||
use ManiaControl\Bills\BillManager;
|
use ManiaControl\Bills\BillManager;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
@ -23,21 +22,22 @@ use ManiaControl\Manialinks\ManialinkManager;
|
|||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
use ManiaControl\Players\PlayerManager;
|
use ManiaControl\Players\PlayerManager;
|
||||||
use ManiaControl\Plugins\Plugin;
|
use ManiaControl\Plugins\Plugin;
|
||||||
use ManiaControl\Statistics\StatisticManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ManiaControl Donation Plugin
|
* ManiaControl Donation Plugin
|
||||||
*
|
*
|
||||||
* @author kremsy and steeffeen
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||||
* @copyright ManiaControl Copyright © 2014 ManiaControl Team
|
* @copyright 2014 ManiaControl Team
|
||||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
*/
|
*/
|
||||||
class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
||||||
/**
|
/*
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const ID = 3;
|
const ID = 3;
|
||||||
const VERSION = 0.1;
|
const VERSION = 0.1;
|
||||||
|
const AUTHOR = 'MCTeam';
|
||||||
|
const NAME = 'Donation Plugin';
|
||||||
const SETTING_ANNOUNCE_SERVERDONATION = 'Enable Server-Donation Announcements';
|
const SETTING_ANNOUNCE_SERVERDONATION = 'Enable Server-Donation Announcements';
|
||||||
const STAT_PLAYER_DONATIONS = 'Donated Planets';
|
const STAT_PLAYER_DONATIONS = 'Donated Planets';
|
||||||
const ACTION_DONATE_VALUE = 'Donate.DonateValue';
|
const ACTION_DONATE_VALUE = 'Donate.DonateValue';
|
||||||
@ -52,8 +52,8 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
const SETTING_DONATION_VALUES = 'Donation Values';
|
const SETTING_DONATION_VALUES = 'Donation Values';
|
||||||
const SETTING_MIN_AMOUNT_SHOWN = 'Minimum Donation amount to get shown';
|
const SETTING_MIN_AMOUNT_SHOWN = 'Minimum Donation amount to get shown';
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Private properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @var maniaControl $maniaControl
|
* @var maniaControl $maniaControl
|
||||||
@ -61,15 +61,45 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares the Plugin
|
* @see \ManiaControl\Plugins\Plugin::prepare()
|
||||||
*
|
|
||||||
* @param ManiaControl $maniaControl
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public static function prepare(ManiaControl $maniaControl) {
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
//do nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getId()
|
||||||
|
*/
|
||||||
|
public static function getId() {
|
||||||
|
return self::ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getName()
|
||||||
|
*/
|
||||||
|
public static function getName() {
|
||||||
|
return self::NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
||||||
|
*/
|
||||||
|
public static function getVersion() {
|
||||||
|
return self::VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
||||||
|
*/
|
||||||
|
public static function getAuthor() {
|
||||||
|
return self::AUTHOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
||||||
|
*/
|
||||||
|
public static function getDescription() {
|
||||||
|
return 'Plugin offering commands like /donate, /pay and /planets and a donation widget.';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see \ManiaControl\Plugins\Plugin::load()
|
* @see \ManiaControl\Plugins\Plugin::load()
|
||||||
@ -105,48 +135,6 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::unload()
|
|
||||||
*/
|
|
||||||
public function unload() {
|
|
||||||
$this->maniaControl->manialinkManager->hideManialink(self::MLID_DONATE_WIDGET);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getId()
|
|
||||||
*/
|
|
||||||
public static function getId() {
|
|
||||||
return self::ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getName()
|
|
||||||
*/
|
|
||||||
public static function getName() {
|
|
||||||
return 'Donations Plugin';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
|
||||||
*/
|
|
||||||
public static function getVersion() {
|
|
||||||
return self::VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
|
||||||
*/
|
|
||||||
public static function getAuthor() {
|
|
||||||
return 'steeffeen and kremsy';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
|
||||||
*/
|
|
||||||
public static function getDescription() {
|
|
||||||
return 'Plugin offering commands like /donate, /pay and /planets and a donation widget.';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle ManiaControl OnStartup
|
* Handle ManiaControl OnStartup
|
||||||
*
|
*
|
||||||
@ -158,35 +146,6 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle ManialinkPageAnswer Callback
|
|
||||||
*
|
|
||||||
* @param array $callback
|
|
||||||
*/
|
|
||||||
public function handleManialinkPageAnswer(array $callback) {
|
|
||||||
$actionId = $callback[1][2];
|
|
||||||
$boolSetting = (strpos($actionId, self::ACTION_DONATE_VALUE) === 0);
|
|
||||||
if (!$boolSetting) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$login = $callback[1][1];
|
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
|
||||||
$actionArray = explode(".", $callback[1][2]);
|
|
||||||
$this->handleDonation($player, intval($actionArray[2]));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle PlayerConnect callback
|
|
||||||
*
|
|
||||||
* @param Player $player
|
|
||||||
*/
|
|
||||||
public function handlePlayerConnect(Player $player) {
|
|
||||||
// Display Map Widget
|
|
||||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_DONATE_WIDGET_ACTIVATED)) {
|
|
||||||
$this->displayDonateWidget($player->login);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the Donate Widget
|
* Displays the Donate Widget
|
||||||
*
|
*
|
||||||
@ -205,7 +164,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
$itemMarginFactorY = 1.2;
|
$itemMarginFactorY = 1.2;
|
||||||
|
|
||||||
//If game is shootmania lower the icons position by 20
|
//If game is shootmania lower the icons position by 20
|
||||||
if($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') {
|
if ($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') {
|
||||||
$posY -= $shootManiaOffset;
|
$posY -= $shootManiaOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,7 +226,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
|
|
||||||
// Add items
|
// Add items
|
||||||
$x = -2;
|
$x = -2;
|
||||||
foreach(array_reverse($valueArray) as $value) {
|
foreach (array_reverse($valueArray) as $value) {
|
||||||
$label = new Label_Button();
|
$label = new Label_Button();
|
||||||
$popoutFrame->add($label);
|
$popoutFrame->add($label);
|
||||||
$label->setX($x);
|
$label->setX($x);
|
||||||
@ -286,6 +245,90 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
$this->maniaControl->manialinkManager->sendManialink($maniaLink, $login);
|
$this->maniaControl->manialinkManager->sendManialink($maniaLink, $login);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||||
|
*/
|
||||||
|
public function unload() {
|
||||||
|
$this->maniaControl->manialinkManager->hideManialink(self::MLID_DONATE_WIDGET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle ManialinkPageAnswer Callback
|
||||||
|
*
|
||||||
|
* @param array $callback
|
||||||
|
*/
|
||||||
|
public function handleManialinkPageAnswer(array $callback) {
|
||||||
|
$actionId = $callback[1][2];
|
||||||
|
$boolSetting = (strpos($actionId, self::ACTION_DONATE_VALUE) === 0);
|
||||||
|
if (!$boolSetting) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$login = $callback[1][1];
|
||||||
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||||
|
$actionArray = explode(".", $callback[1][2]);
|
||||||
|
$this->handleDonation($player, intval($actionArray[2]));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles a Player Donate
|
||||||
|
*
|
||||||
|
* @param Player $player
|
||||||
|
* @param $value
|
||||||
|
*/
|
||||||
|
private function handleDonation(Player $player, $amount, $receiver = '', $receiverName = false) {
|
||||||
|
|
||||||
|
if (!$receiverName) {
|
||||||
|
$serverName = $this->maniaControl->client->getServerName();
|
||||||
|
$message = 'Donate ' . $amount . ' Planets to $<' . $serverName . '$>?';
|
||||||
|
} else {
|
||||||
|
$message = 'Donate ' . $amount . ' Planets to $<' . $receiverName . '$>?';
|
||||||
|
}
|
||||||
|
|
||||||
|
//Send and Handle the Bill
|
||||||
|
$self = $this;
|
||||||
|
$this->maniaControl->billManager->sendBill(function ($data, $status) use (&$self, &$player, $amount, $receiver) {
|
||||||
|
switch ($status) {
|
||||||
|
case BillManager::DONATED_TO_SERVER:
|
||||||
|
if ($self->maniaControl->settingManager->getSetting($self, DonationPlugin::SETTING_ANNOUNCE_SERVERDONATION, true) && $amount >= $self->maniaControl->settingManager->getSetting($self, DonationPlugin::SETTING_MIN_AMOUNT_SHOWN, true)) {
|
||||||
|
$login = null;
|
||||||
|
$message = '$<' . $player->nickname . '$> donated ' . $amount . ' Planets! Thanks.';
|
||||||
|
} else {
|
||||||
|
$login = $player->login;
|
||||||
|
$message = 'Donation successful! Thanks.';
|
||||||
|
}
|
||||||
|
$self->maniaControl->chat->sendSuccess($message, $login);
|
||||||
|
$self->maniaControl->statisticManager->insertStat(DonationPlugin::STAT_PLAYER_DONATIONS, $player, $self->maniaControl->server->index, $amount);
|
||||||
|
break;
|
||||||
|
case BillManager::DONATED_TO_RECEIVER:
|
||||||
|
$message = "Successfully donated {$amount} to '{$receiver}'!";
|
||||||
|
$self->maniaControl->chat->sendSuccess($message, $player->login);
|
||||||
|
break;
|
||||||
|
case BillManager::PLAYER_REFUSED_DONATION:
|
||||||
|
$message = 'Transaction cancelled.';
|
||||||
|
$self->maniaControl->chat->sendError($message, $player->login);
|
||||||
|
break;
|
||||||
|
case BillManager::ERROR_WHILE_TRANSACTION:
|
||||||
|
$message = $data;
|
||||||
|
$self->maniaControl->chat->sendError($message, $player->login);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}, $player, $amount, $message);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle PlayerConnect callback
|
||||||
|
*
|
||||||
|
* @param Player $player
|
||||||
|
*/
|
||||||
|
public function handlePlayerConnect(Player $player) {
|
||||||
|
// Display Map Widget
|
||||||
|
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_DONATE_WIDGET_ACTIVATED)) {
|
||||||
|
$this->displayDonateWidget($player->login);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle /donate command
|
* Handle /donate command
|
||||||
*
|
*
|
||||||
@ -318,51 +361,14 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a Player Donate
|
* Send an usage example for /donate to the player
|
||||||
*
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @param $value
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
private function handleDonation(Player $player, $amount, $receiver = '', $receiverName = false) {
|
private function sendDonateUsageExample(Player $player) {
|
||||||
|
$message = "Usage Example: '/donate 100'";
|
||||||
if (!$receiverName) {
|
return $this->maniaControl->chat->sendChat($message, $player->login);
|
||||||
$serverName = $this->maniaControl->client->getServerName();
|
|
||||||
$message = 'Donate ' . $amount . ' Planets to $<' . $serverName . '$>?';
|
|
||||||
} else {
|
|
||||||
$message = 'Donate ' . $amount . ' Planets to $<' . $receiverName . '$>?';
|
|
||||||
}
|
|
||||||
|
|
||||||
//Send and Handle the Bill
|
|
||||||
$self = $this;
|
|
||||||
$this->maniaControl->billManager->sendBill(function ($data, $status) use (&$self, &$player, $amount, $receiver) {
|
|
||||||
switch($status) {
|
|
||||||
case BillManager::DONATED_TO_SERVER:
|
|
||||||
if ($self->maniaControl->settingManager->getSetting($self, DonationPlugin::SETTING_ANNOUNCE_SERVERDONATION, true) && $amount >= $self->maniaControl->settingManager->getSetting($self, DonationPlugin::SETTING_MIN_AMOUNT_SHOWN, true)) {
|
|
||||||
$login = null;
|
|
||||||
$message = '$<' . $player->nickname . '$> donated ' . $amount . ' Planets! Thanks.';
|
|
||||||
} else {
|
|
||||||
$login = $player->login;
|
|
||||||
$message = 'Donation successful! Thanks.';
|
|
||||||
}
|
|
||||||
$self->maniaControl->chat->sendSuccess($message, $login);
|
|
||||||
$self->maniaControl->statisticManager->insertStat(DonationPlugin::STAT_PLAYER_DONATIONS, $player, $self->maniaControl->server->index, $amount);
|
|
||||||
break;
|
|
||||||
case BillManager::DONATED_TO_RECEIVER:
|
|
||||||
$message = "Successfully donated {$amount} to '{$receiver}'!";
|
|
||||||
$self->maniaControl->chat->sendSuccess($message, $player->login);
|
|
||||||
break;
|
|
||||||
case BillManager::PLAYER_REFUSED_DONATION:
|
|
||||||
$message = 'Transaction cancelled.';
|
|
||||||
$self->maniaControl->chat->sendError($message, $player->login);
|
|
||||||
break;
|
|
||||||
case BillManager::ERROR_WHILE_TRANSACTION:
|
|
||||||
$message = $data;
|
|
||||||
$self->maniaControl->chat->sendError($message, $player->login);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}, $player, $amount, $message);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -397,7 +403,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
|
|
||||||
$self = $this;
|
$self = $this;
|
||||||
$this->maniaControl->billManager->sendPlanets(function ($data, $status) use (&$self, &$player, $amount, $receiver) {
|
$this->maniaControl->billManager->sendPlanets(function ($data, $status) use (&$self, &$player, $amount, $receiver) {
|
||||||
switch($status) {
|
switch ($status) {
|
||||||
case BillManager::PAYED_FROM_SERVER:
|
case BillManager::PAYED_FROM_SERVER:
|
||||||
$message = "Successfully payed out {$amount} to '{$receiver}'!";
|
$message = "Successfully payed out {$amount} to '{$receiver}'!";
|
||||||
$self->maniaControl->chat->sendSuccess($message, $player->login);
|
$self->maniaControl->chat->sendSuccess($message, $player->login);
|
||||||
@ -416,6 +422,17 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send an usage example for /pay to the player
|
||||||
|
*
|
||||||
|
* @param Player $player
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
private function sendPayUsageExample(Player $player) {
|
||||||
|
$message = "Usage Example: '/pay 100 login'";
|
||||||
|
return $this->maniaControl->chat->sendChat($message, $player->login);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle //getplanets command
|
* Handle //getplanets command
|
||||||
*
|
*
|
||||||
@ -433,28 +450,6 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
return $this->maniaControl->chat->sendInformation($message, $player->login);
|
return $this->maniaControl->chat->sendInformation($message, $player->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Send an usage example for /donate to the player
|
|
||||||
*
|
|
||||||
* @param Player $player
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
private function sendDonateUsageExample(Player $player) {
|
|
||||||
$message = "Usage Example: '/donate 100'";
|
|
||||||
return $this->maniaControl->chat->sendChat($message, $player->login);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send an usage example for /pay to the player
|
|
||||||
*
|
|
||||||
* @param Player $player
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
private function sendPayUsageExample(Player $player) {
|
|
||||||
$message = "Usage Example: '/pay 100 login'";
|
|
||||||
return $this->maniaControl->chat->sendChat($message, $player->login);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the /topdons command
|
* Handles the /topdons command
|
||||||
*
|
*
|
||||||
@ -505,7 +500,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
$i = 1;
|
$i = 1;
|
||||||
$y = $y - 10;
|
$y = $y - 10;
|
||||||
$pageFrames = array();
|
$pageFrames = array();
|
||||||
foreach($stats as $playerIndex => $donations) {
|
foreach ($stats as $playerIndex => $donations) {
|
||||||
if (!isset($pageFrame)) {
|
if (!isset($pageFrame)) {
|
||||||
$pageFrame = new Frame();
|
$pageFrame = new Frame();
|
||||||
$frame->add($pageFrame);
|
$frame->add($pageFrame);
|
||||||
@ -540,7 +535,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
unset($pageFrame);
|
unset($pageFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($i > 100) {
|
if ($i > 100) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,8 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
*/
|
*/
|
||||||
const ID = 2;
|
const ID = 2;
|
||||||
const VERSION = 0.1;
|
const VERSION = 0.1;
|
||||||
|
const NAME = 'Karma Plugin';
|
||||||
|
const AUTHOR = 'MCTeam';
|
||||||
const MLID_KARMA = 'KarmaPlugin.MLID';
|
const MLID_KARMA = 'KarmaPlugin.MLID';
|
||||||
const TABLE_KARMA = 'mc_karma';
|
const TABLE_KARMA = 'mc_karma';
|
||||||
const CB_KARMA_CHANGED = 'KarmaPlugin.Changed';
|
const CB_KARMA_CHANGED = 'KarmaPlugin.Changed';
|
||||||
@ -62,19 +64,15 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
/*
|
/*
|
||||||
* Private Properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
/**
|
/** @var ManiaControl $maniaControl */
|
||||||
* @var ManiaControl $maniaControl
|
|
||||||
*/
|
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
private $updateManialink = false;
|
private $updateManialink = false;
|
||||||
/**
|
/** @var ManiaLink $manialink */
|
||||||
* @var ManiaLink $manialink
|
|
||||||
*/
|
|
||||||
private $manialink = null;
|
private $manialink = null;
|
||||||
private $mxKarma = array();
|
private $mxKarma = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see \ManiaControl\Plugins\Plugin
|
* @see \ManiaControl\Plugins\Plugin::prepare()
|
||||||
*/
|
*/
|
||||||
public static function prepare(ManiaControl $maniaControl) {
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
$maniaControl->settingManager->initSetting(get_class(), self::SETTING_MX_KARMA_ACTIVATED, true);
|
$maniaControl->settingManager->initSetting(get_class(), self::SETTING_MX_KARMA_ACTIVATED, true);
|
||||||
@ -97,7 +95,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
* @see \ManiaControl\Plugins\Plugin::getName()
|
* @see \ManiaControl\Plugins\Plugin::getName()
|
||||||
*/
|
*/
|
||||||
public static function getName() {
|
public static function getName() {
|
||||||
return 'Karma Plugin';
|
return self::NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,7 +109,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
||||||
*/
|
*/
|
||||||
public static function getAuthor() {
|
public static function getAuthor() {
|
||||||
return 'steeffeen and kremsy';
|
return self::AUTHOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,21 +15,20 @@ use ManiaControl\Callbacks\CallbackManager;
|
|||||||
use ManiaControl\Callbacks\Callbacks;
|
use ManiaControl\Callbacks\Callbacks;
|
||||||
use ManiaControl\Callbacks\TimerListener;
|
use ManiaControl\Callbacks\TimerListener;
|
||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
use ManiaControl\Settings\SettingManager;
|
|
||||||
use ManiaControl\Formatter;
|
use ManiaControl\Formatter;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Maps\Map;
|
|
||||||
use ManiaControl\Maps\MapManager;
|
|
||||||
use ManiaControl\Manialinks\ManialinkManager;
|
use ManiaControl\Manialinks\ManialinkManager;
|
||||||
|
use ManiaControl\Maps\Map;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
use ManiaControl\Players\PlayerManager;
|
use ManiaControl\Players\PlayerManager;
|
||||||
use ManiaControl\Plugins\Plugin;
|
use ManiaControl\Plugins\Plugin;
|
||||||
|
use ManiaControl\Settings\SettingManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ManiaControl Local Records Plugin
|
* ManiaControl Local Records Plugin
|
||||||
*
|
*
|
||||||
* @author steeffeen
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||||
* @copyright ManiaControl Copyright © 2014 ManiaControl Team
|
* @copyright 2014 ManiaControl Team
|
||||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
*/
|
*/
|
||||||
class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerListener, Plugin {
|
class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerListener, Plugin {
|
||||||
@ -38,6 +37,8 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
|
|||||||
*/
|
*/
|
||||||
const ID = 7;
|
const ID = 7;
|
||||||
const VERSION = 0.2;
|
const VERSION = 0.2;
|
||||||
|
const NAME = 'Local Records Plugin';
|
||||||
|
const AUTHOR = 'MCTeam';
|
||||||
const MLID_RECORDS = 'ml_local_records';
|
const MLID_RECORDS = 'ml_local_records';
|
||||||
const TABLE_RECORDS = 'mc_localrecords';
|
const TABLE_RECORDS = 'mc_localrecords';
|
||||||
const SETTING_WIDGET_TITLE = 'Widget Title';
|
const SETTING_WIDGET_TITLE = 'Widget Title';
|
||||||
@ -56,26 +57,53 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
|
|||||||
/*
|
/*
|
||||||
* Private Properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
/**
|
/** @var ManiaControl $maniaControl */
|
||||||
*
|
|
||||||
* @var maniaControl $maniaControl
|
|
||||||
*/
|
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
private $updateManialink = false;
|
private $updateManialink = false;
|
||||||
private $checkpoints = array();
|
private $checkpoints = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares the Plugin
|
* @see \ManiaControl\Plugins\Plugin::prepare()
|
||||||
*
|
|
||||||
* @param ManiaControl $maniaControl
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public static function prepare(ManiaControl $maniaControl) {
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
// do nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @see \ManiaControl\Plugins\Plugin::getId()
|
||||||
|
*/
|
||||||
|
public static function getId() {
|
||||||
|
return self::ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getName()
|
||||||
|
*/
|
||||||
|
public static function getName() {
|
||||||
|
return self::NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
||||||
|
*/
|
||||||
|
public static function getVersion() {
|
||||||
|
return self::VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
||||||
|
*/
|
||||||
|
public static function getAuthor() {
|
||||||
|
return self::AUTHOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
||||||
|
*/
|
||||||
|
public static function getDescription() {
|
||||||
|
return 'Plugin offering tracking of local records and manialinks to display them.';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* @see \ManiaControl\Plugins\Plugin::load()
|
* @see \ManiaControl\Plugins\Plugin::load()
|
||||||
*/
|
*/
|
||||||
public function load(ManiaControl $maniaControl) {
|
public function load(ManiaControl $maniaControl) {
|
||||||
@ -111,13 +139,6 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::unload()
|
|
||||||
*/
|
|
||||||
public function unload() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize needed database tables
|
* Initialize needed database tables
|
||||||
*/
|
*/
|
||||||
@ -146,43 +167,9 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||||
* @see \ManiaControl\Plugins\Plugin::getId()
|
|
||||||
*/
|
*/
|
||||||
public static function getId() {
|
public function unload() {
|
||||||
return self::ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getName()
|
|
||||||
*/
|
|
||||||
public static function getName() {
|
|
||||||
return 'Local Records Plugin';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
|
||||||
*/
|
|
||||||
public static function getVersion() {
|
|
||||||
return self::VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
|
||||||
*/
|
|
||||||
public static function getAuthor() {
|
|
||||||
return 'steeffeen';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
|
||||||
*/
|
|
||||||
public static function getDescription() {
|
|
||||||
return 'Plugin offering tracking of local records and manialinks to display them.';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -209,301 +196,6 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handleSettingsChanged($class, $settingName, $value) {
|
|
||||||
if (!$class = get_class()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($settingName == 'Enable Local Records Widget' && $value == true) {
|
|
||||||
$this->updateManialink = true;
|
|
||||||
}
|
|
||||||
elseif ($settingName == 'Enable Local Records Widget' && $value == false) {
|
|
||||||
$ml = new ManiaLink(self::MLID_RECORDS);
|
|
||||||
$mltext = $ml->render()->saveXML();
|
|
||||||
$this->maniaControl->manialinkManager->sendManialink($mltext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle PlayerCheckpoint callback
|
|
||||||
*
|
|
||||||
* @param $callback
|
|
||||||
*/
|
|
||||||
public function handlePlayerCheckpoint($callback) {
|
|
||||||
$data = $callback[1];
|
|
||||||
$login = $data[1];
|
|
||||||
$time = $data[2];
|
|
||||||
// $lap = $data[3];
|
|
||||||
$cpIndex = $data[4];
|
|
||||||
if (!isset($this->checkpoints[$login]) || $cpIndex <= 0) {
|
|
||||||
$this->checkpoints[$login] = array();
|
|
||||||
}
|
|
||||||
$this->checkpoints[$login][$cpIndex] = $time;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle PlayerConnect callback
|
|
||||||
*
|
|
||||||
* @param Player $player
|
|
||||||
*/
|
|
||||||
public function handlePlayerConnect(Player $player) {
|
|
||||||
$this->updateManialink = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle BeginMap callback
|
|
||||||
*
|
|
||||||
* @param Map $map
|
|
||||||
*/
|
|
||||||
public function handleMapBegin(Map $map) {
|
|
||||||
$this->updateManialink = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle PlayerFinish callback
|
|
||||||
*
|
|
||||||
* @param array $callback
|
|
||||||
*/
|
|
||||||
public function handlePlayerFinish(array $callback) {
|
|
||||||
$data = $callback[1];
|
|
||||||
if ($data[0] <= 0 || $data[2] <= 0) {
|
|
||||||
// Invalid player or time
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$login = $data[1];
|
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
|
||||||
if (!$player) {
|
|
||||||
// Invalid player
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$time = $data[2];
|
|
||||||
$map = $this->maniaControl->mapManager->getCurrentMap();
|
|
||||||
|
|
||||||
// Check old record of the player
|
|
||||||
$oldRecord = $this->getLocalRecord($map, $player);
|
|
||||||
$oldRank = -1;
|
|
||||||
if ($oldRecord) {
|
|
||||||
$oldRank = $oldRecord->rank;
|
|
||||||
if ($oldRecord->time < $time) {
|
|
||||||
// Not improved
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($oldRecord->time == $time) {
|
|
||||||
// Same time
|
|
||||||
$message = '$<$fff' . $player->nickname . '$> equalized his/her $<$ff0' . $oldRecord->rank . '.$> Local Record: $<$fff' . Formatter::formatTime($oldRecord->time) . '$>!';
|
|
||||||
$this->maniaControl->chat->sendInformation('$3c0' . $message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save time
|
|
||||||
$mysqli = $this->maniaControl->database->mysqli;
|
|
||||||
$query = "INSERT INTO `" . self::TABLE_RECORDS . "` (
|
|
||||||
`mapIndex`,
|
|
||||||
`playerIndex`,
|
|
||||||
`time`,
|
|
||||||
`checkpoints`
|
|
||||||
) VALUES (
|
|
||||||
{$map->index},
|
|
||||||
{$player->index},
|
|
||||||
{$time},
|
|
||||||
'{$this->getCheckpoints($player->login)}'
|
|
||||||
) ON DUPLICATE KEY UPDATE
|
|
||||||
`time` = VALUES(`time`),
|
|
||||||
`checkpoints` = VALUES(`checkpoints`);";
|
|
||||||
$mysqli->query($query);
|
|
||||||
if ($mysqli->error) {
|
|
||||||
trigger_error($mysqli->error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$this->updateManialink = true;
|
|
||||||
|
|
||||||
// Announce record
|
|
||||||
$newRecord = $this->getLocalRecord($map, $player);
|
|
||||||
|
|
||||||
$notifyOnlyDriver = $this->maniaControl->settingManager->getSetting($this, self::SETTING_NOTIFY_ONLY_DRIVER);
|
|
||||||
$notifyOnlyBestRecords = $this->maniaControl->settingManager->getSetting($this, self::SETTING_NOTIFY_BEST_RECORDS);
|
|
||||||
if ($notifyOnlyDriver || $notifyOnlyBestRecords > 0 && $newRecord->rank > $notifyOnlyBestRecords) {
|
|
||||||
$improvement = ((!$oldRecord || $newRecord->rank < $oldRecord->rank) ? 'gained the' : 'improved your');
|
|
||||||
$message = 'You ' . $improvement . ' $<$ff0' . $newRecord->rank . '.$> Local Record: $<$fff' . Formatter::formatTime($newRecord->time) . '$>';
|
|
||||||
if ($oldRecord) $oldRank = ($improvement == 'improved your') ? '' : $oldRecord->rank . '. ';
|
|
||||||
if ($oldRecord) $message .= ' ($<$ff0' . $oldRank . '$>$<$fff-' . Formatter::formatTime(($oldRecord->time - $newRecord->time)) . '$>!';
|
|
||||||
$this->maniaControl->chat->sendInformation('$3c0' . $message.'!', $player->login);
|
|
||||||
} else {
|
|
||||||
$improvement = ((!$oldRecord || $newRecord->rank < $oldRecord->rank) ? 'gained the' : 'improved the');
|
|
||||||
$message = '$<$fff' . $player->nickname . '$> ' . $improvement . ' $<$ff0' . $newRecord->rank . '.$> Local Record: $<$fff' . Formatter::formatTime($newRecord->time) . '$>';
|
|
||||||
if ($oldRecord) $oldRank = ($improvement == 'improved the') ? '' : $oldRecord->rank . '. ';
|
|
||||||
if ($oldRecord) $message .= ' ($<$ff0' . $oldRank . '$>$<$fff-' . Formatter::formatTime(($oldRecord->time - $newRecord->time)) . '$>)';
|
|
||||||
$this->maniaControl->chat->sendInformation('$3c0' . $message.'!');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_LOCALRECORDS_CHANGED, $newRecord);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle PlayerManialinkPageAnswer callback
|
|
||||||
*
|
|
||||||
* @param array $callback
|
|
||||||
*/
|
|
||||||
public function handleManialinkPageAnswer(array $callback) {
|
|
||||||
$actionId = $callback[1][2];
|
|
||||||
|
|
||||||
$login = $callback[1][1];
|
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
|
||||||
|
|
||||||
if ($actionId == self::ACTION_SHOW_RECORDSLIST) {
|
|
||||||
$this->showRecordsList(array(), $player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete a Player's record
|
|
||||||
*
|
|
||||||
* @param array $chat
|
|
||||||
* @param Player $player
|
|
||||||
*/
|
|
||||||
public function deleteRecord(array $chat, Player $player) {
|
|
||||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MASTERADMIN)) {
|
|
||||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$chatCommand = explode(' ', $chat[1][2]);
|
|
||||||
$recordId = (int) $chatCommand[1];
|
|
||||||
if (is_integer($recordId)) {
|
|
||||||
$currentMap = $this->maniaControl->mapManager->getCurrentMap();
|
|
||||||
$records = $this->getLocalRecords($currentMap);
|
|
||||||
if (count($records) < $recordId) {
|
|
||||||
$this->maniaControl->chat->sendError('Cannot remove record $<$fff' . $recordId . '$>!', $player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$mysqli = $this->maniaControl->database->mysqli;
|
|
||||||
$query = "DELETE FROM `" . self::TABLE_RECORDS . "` WHERE `mapIndex` = " . $currentMap->index . " AND `playerIndex` = " . $player->index . "";
|
|
||||||
$mysqli->query($query);
|
|
||||||
if ($mysqli->error) {
|
|
||||||
trigger_error($mysqli->error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_LOCALRECORDS_CHANGED, null);
|
|
||||||
$this->maniaControl->chat->sendInformation('Record no. $<$fff' . $recordId . '$> has been removed!');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$this->maniaControl->chat->sendError('Cannot remove record $<$fff' . $recordId . '$>, because it\'s not an integer!', $player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shows a ManiaLink list with the local records.
|
|
||||||
*
|
|
||||||
* @param array $chat
|
|
||||||
* @param Player $player
|
|
||||||
*/
|
|
||||||
public function showRecordsList(array $chat, Player $player) {
|
|
||||||
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
|
||||||
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
|
||||||
|
|
||||||
// get PlayerList
|
|
||||||
$records = $this->getLocalRecords($this->maniaControl->mapManager->getCurrentMap());
|
|
||||||
|
|
||||||
$pagesId = '';
|
|
||||||
if (count($records) > 15) {
|
|
||||||
$pagesId = 'RecordsListPages';
|
|
||||||
}
|
|
||||||
|
|
||||||
// create manialink
|
|
||||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
|
||||||
$script = $maniaLink->getScript();
|
|
||||||
$paging = new Paging();
|
|
||||||
$script->addFeature($paging);
|
|
||||||
|
|
||||||
// Main frame
|
|
||||||
$frame = $this->maniaControl->manialinkManager->styleManager->getDefaultListFrame($script, $paging);
|
|
||||||
$maniaLink->add($frame);
|
|
||||||
|
|
||||||
// Start offsets
|
|
||||||
$x = -$width / 2;
|
|
||||||
$y = $height / 2;
|
|
||||||
|
|
||||||
// Predefine Description Label
|
|
||||||
$descriptionLabel = $this->maniaControl->manialinkManager->styleManager->getDefaultDescriptionLabel();
|
|
||||||
$frame->add($descriptionLabel);
|
|
||||||
|
|
||||||
// Headline
|
|
||||||
$headFrame = new Frame();
|
|
||||||
$frame->add($headFrame);
|
|
||||||
$headFrame->setY($y - 5);
|
|
||||||
$array = array("Rank" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 70, "Time" => $x + 101);
|
|
||||||
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
|
|
||||||
|
|
||||||
$i = 0;
|
|
||||||
$y = $height / 2 - 10;
|
|
||||||
$pageFrames = array();
|
|
||||||
foreach ($records as $listRecord) {
|
|
||||||
if (!isset($pageFrame)) {
|
|
||||||
$pageFrame = new Frame();
|
|
||||||
$frame->add($pageFrame);
|
|
||||||
if (!empty($pageFrames)) {
|
|
||||||
$pageFrame->setVisible(false);
|
|
||||||
}
|
|
||||||
array_push($pageFrames, $pageFrame);
|
|
||||||
$y = $height / 2 - 10;
|
|
||||||
|
|
||||||
$paging->addPage($pageFrame);
|
|
||||||
}
|
|
||||||
|
|
||||||
$recordFrame = new Frame();
|
|
||||||
$pageFrame->add($recordFrame);
|
|
||||||
|
|
||||||
if ($i % 2 != 0) {
|
|
||||||
$lineQuad = new Quad_BgsPlayerCard();
|
|
||||||
$recordFrame->add($lineQuad);
|
|
||||||
$lineQuad->setSize($width, 4);
|
|
||||||
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
|
|
||||||
$lineQuad->setZ(0.001);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strlen($listRecord->nickname) < 2) $listRecord->nickname = $listRecord->login;
|
|
||||||
$array = array($listRecord->rank => $x + 5, '$fff' . $listRecord->nickname => $x + 18, $listRecord->login => $x + 70,
|
|
||||||
Formatter::formatTime($listRecord->time) => $x + 101);
|
|
||||||
$this->maniaControl->manialinkManager->labelLine($recordFrame, $array);
|
|
||||||
|
|
||||||
$recordFrame->setY($y);
|
|
||||||
|
|
||||||
$y -= 4;
|
|
||||||
$i++;
|
|
||||||
if ($i % 15 == 0) {
|
|
||||||
unset($pageFrame);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render and display xml
|
|
||||||
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player, 'PlayerList');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get current checkpoint string for dedimania record
|
|
||||||
*
|
|
||||||
* @param string $login
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function getCheckpoints($login) {
|
|
||||||
if (!$login || !isset($this->checkpoints[$login])) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$string = '';
|
|
||||||
$count = count($this->checkpoints[$login]);
|
|
||||||
foreach ($this->checkpoints[$login] as $index => $check) {
|
|
||||||
$string .= $check;
|
|
||||||
if ($index < $count - 1) {
|
|
||||||
$string .= ',';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the local records manialink
|
* Build the local records manialink
|
||||||
*
|
*
|
||||||
@ -632,6 +324,145 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
|
|||||||
return $records;
|
return $records;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function handleSettingsChanged($class, $settingName, $value) {
|
||||||
|
if (!$class = get_class()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($settingName == 'Enable Local Records Widget' && $value == true) {
|
||||||
|
$this->updateManialink = true;
|
||||||
|
} elseif ($settingName == 'Enable Local Records Widget' && $value == false) {
|
||||||
|
$ml = new ManiaLink(self::MLID_RECORDS);
|
||||||
|
$mltext = $ml->render()->saveXML();
|
||||||
|
$this->maniaControl->manialinkManager->sendManialink($mltext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle PlayerCheckpoint callback
|
||||||
|
*
|
||||||
|
* @param $callback
|
||||||
|
*/
|
||||||
|
public function handlePlayerCheckpoint($callback) {
|
||||||
|
$data = $callback[1];
|
||||||
|
$login = $data[1];
|
||||||
|
$time = $data[2];
|
||||||
|
// $lap = $data[3];
|
||||||
|
$cpIndex = $data[4];
|
||||||
|
if (!isset($this->checkpoints[$login]) || $cpIndex <= 0) {
|
||||||
|
$this->checkpoints[$login] = array();
|
||||||
|
}
|
||||||
|
$this->checkpoints[$login][$cpIndex] = $time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle PlayerConnect callback
|
||||||
|
*
|
||||||
|
* @param Player $player
|
||||||
|
*/
|
||||||
|
public function handlePlayerConnect(Player $player) {
|
||||||
|
$this->updateManialink = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle BeginMap callback
|
||||||
|
*
|
||||||
|
* @param Map $map
|
||||||
|
*/
|
||||||
|
public function handleMapBegin(Map $map) {
|
||||||
|
$this->updateManialink = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle PlayerFinish callback
|
||||||
|
*
|
||||||
|
* @param array $callback
|
||||||
|
*/
|
||||||
|
public function handlePlayerFinish(array $callback) {
|
||||||
|
$data = $callback[1];
|
||||||
|
if ($data[0] <= 0 || $data[2] <= 0) {
|
||||||
|
// Invalid player or time
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$login = $data[1];
|
||||||
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||||
|
if (!$player) {
|
||||||
|
// Invalid player
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$time = $data[2];
|
||||||
|
$map = $this->maniaControl->mapManager->getCurrentMap();
|
||||||
|
|
||||||
|
// Check old record of the player
|
||||||
|
$oldRecord = $this->getLocalRecord($map, $player);
|
||||||
|
$oldRank = -1;
|
||||||
|
if ($oldRecord) {
|
||||||
|
$oldRank = $oldRecord->rank;
|
||||||
|
if ($oldRecord->time < $time) {
|
||||||
|
// Not improved
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($oldRecord->time == $time) {
|
||||||
|
// Same time
|
||||||
|
$message = '$<$fff' . $player->nickname . '$> equalized his/her $<$ff0' . $oldRecord->rank . '.$> Local Record: $<$fff' . Formatter::formatTime($oldRecord->time) . '$>!';
|
||||||
|
$this->maniaControl->chat->sendInformation('$3c0' . $message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save time
|
||||||
|
$mysqli = $this->maniaControl->database->mysqli;
|
||||||
|
$query = "INSERT INTO `" . self::TABLE_RECORDS . "` (
|
||||||
|
`mapIndex`,
|
||||||
|
`playerIndex`,
|
||||||
|
`time`,
|
||||||
|
`checkpoints`
|
||||||
|
) VALUES (
|
||||||
|
{$map->index},
|
||||||
|
{$player->index},
|
||||||
|
{$time},
|
||||||
|
'{$this->getCheckpoints($player->login)}'
|
||||||
|
) ON DUPLICATE KEY UPDATE
|
||||||
|
`time` = VALUES(`time`),
|
||||||
|
`checkpoints` = VALUES(`checkpoints`);";
|
||||||
|
$mysqli->query($query);
|
||||||
|
if ($mysqli->error) {
|
||||||
|
trigger_error($mysqli->error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->updateManialink = true;
|
||||||
|
|
||||||
|
// Announce record
|
||||||
|
$newRecord = $this->getLocalRecord($map, $player);
|
||||||
|
|
||||||
|
$notifyOnlyDriver = $this->maniaControl->settingManager->getSetting($this, self::SETTING_NOTIFY_ONLY_DRIVER);
|
||||||
|
$notifyOnlyBestRecords = $this->maniaControl->settingManager->getSetting($this, self::SETTING_NOTIFY_BEST_RECORDS);
|
||||||
|
if ($notifyOnlyDriver || $notifyOnlyBestRecords > 0 && $newRecord->rank > $notifyOnlyBestRecords) {
|
||||||
|
$improvement = ((!$oldRecord || $newRecord->rank < $oldRecord->rank) ? 'gained the' : 'improved your');
|
||||||
|
$message = 'You ' . $improvement . ' $<$ff0' . $newRecord->rank . '.$> Local Record: $<$fff' . Formatter::formatTime($newRecord->time) . '$>';
|
||||||
|
if ($oldRecord) {
|
||||||
|
$oldRank = ($improvement == 'improved your') ? '' : $oldRecord->rank . '. ';
|
||||||
|
}
|
||||||
|
if ($oldRecord) {
|
||||||
|
$message .= ' ($<$ff0' . $oldRank . '$>$<$fff-' . Formatter::formatTime(($oldRecord->time - $newRecord->time)) . '$>!';
|
||||||
|
}
|
||||||
|
$this->maniaControl->chat->sendInformation('$3c0' . $message . '!', $player->login);
|
||||||
|
} else {
|
||||||
|
$improvement = ((!$oldRecord || $newRecord->rank < $oldRecord->rank) ? 'gained the' : 'improved the');
|
||||||
|
$message = '$<$fff' . $player->nickname . '$> ' . $improvement . ' $<$ff0' . $newRecord->rank . '.$> Local Record: $<$fff' . Formatter::formatTime($newRecord->time) . '$>';
|
||||||
|
if ($oldRecord) {
|
||||||
|
$oldRank = ($improvement == 'improved the') ? '' : $oldRecord->rank . '. ';
|
||||||
|
}
|
||||||
|
if ($oldRecord) {
|
||||||
|
$message .= ' ($<$ff0' . $oldRank . '$>$<$fff-' . Formatter::formatTime(($oldRecord->time - $newRecord->time)) . '$>)';
|
||||||
|
}
|
||||||
|
$this->maniaControl->chat->sendInformation('$3c0' . $message . '!');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_LOCALRECORDS_CHANGED, $newRecord);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the local record for the given map and login
|
* Retrieve the local record for the given map and login
|
||||||
*
|
*
|
||||||
@ -655,4 +486,167 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
|
|||||||
$result->free();
|
$result->free();
|
||||||
return $record;
|
return $record;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current checkpoint string for dedimania record
|
||||||
|
*
|
||||||
|
* @param string $login
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getCheckpoints($login) {
|
||||||
|
if (!$login || !isset($this->checkpoints[$login])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$string = '';
|
||||||
|
$count = count($this->checkpoints[$login]);
|
||||||
|
foreach ($this->checkpoints[$login] as $index => $check) {
|
||||||
|
$string .= $check;
|
||||||
|
if ($index < $count - 1) {
|
||||||
|
$string .= ',';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle PlayerManialinkPageAnswer callback
|
||||||
|
*
|
||||||
|
* @param array $callback
|
||||||
|
*/
|
||||||
|
public function handleManialinkPageAnswer(array $callback) {
|
||||||
|
$actionId = $callback[1][2];
|
||||||
|
|
||||||
|
$login = $callback[1][1];
|
||||||
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||||
|
|
||||||
|
if ($actionId == self::ACTION_SHOW_RECORDSLIST) {
|
||||||
|
$this->showRecordsList(array(), $player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows a ManiaLink list with the local records.
|
||||||
|
*
|
||||||
|
* @param array $chat
|
||||||
|
* @param Player $player
|
||||||
|
*/
|
||||||
|
public function showRecordsList(array $chat, Player $player) {
|
||||||
|
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||||
|
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
||||||
|
|
||||||
|
// get PlayerList
|
||||||
|
$records = $this->getLocalRecords($this->maniaControl->mapManager->getCurrentMap());
|
||||||
|
|
||||||
|
$pagesId = '';
|
||||||
|
if (count($records) > 15) {
|
||||||
|
$pagesId = 'RecordsListPages';
|
||||||
|
}
|
||||||
|
|
||||||
|
// create manialink
|
||||||
|
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||||
|
$script = $maniaLink->getScript();
|
||||||
|
$paging = new Paging();
|
||||||
|
$script->addFeature($paging);
|
||||||
|
|
||||||
|
// Main frame
|
||||||
|
$frame = $this->maniaControl->manialinkManager->styleManager->getDefaultListFrame($script, $paging);
|
||||||
|
$maniaLink->add($frame);
|
||||||
|
|
||||||
|
// Start offsets
|
||||||
|
$x = -$width / 2;
|
||||||
|
$y = $height / 2;
|
||||||
|
|
||||||
|
// Predefine Description Label
|
||||||
|
$descriptionLabel = $this->maniaControl->manialinkManager->styleManager->getDefaultDescriptionLabel();
|
||||||
|
$frame->add($descriptionLabel);
|
||||||
|
|
||||||
|
// Headline
|
||||||
|
$headFrame = new Frame();
|
||||||
|
$frame->add($headFrame);
|
||||||
|
$headFrame->setY($y - 5);
|
||||||
|
$array = array("Rank" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 70, "Time" => $x + 101);
|
||||||
|
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
$y = $height / 2 - 10;
|
||||||
|
$pageFrames = array();
|
||||||
|
foreach ($records as $listRecord) {
|
||||||
|
if (!isset($pageFrame)) {
|
||||||
|
$pageFrame = new Frame();
|
||||||
|
$frame->add($pageFrame);
|
||||||
|
if (!empty($pageFrames)) {
|
||||||
|
$pageFrame->setVisible(false);
|
||||||
|
}
|
||||||
|
array_push($pageFrames, $pageFrame);
|
||||||
|
$y = $height / 2 - 10;
|
||||||
|
|
||||||
|
$paging->addPage($pageFrame);
|
||||||
|
}
|
||||||
|
|
||||||
|
$recordFrame = new Frame();
|
||||||
|
$pageFrame->add($recordFrame);
|
||||||
|
|
||||||
|
if ($i % 2 != 0) {
|
||||||
|
$lineQuad = new Quad_BgsPlayerCard();
|
||||||
|
$recordFrame->add($lineQuad);
|
||||||
|
$lineQuad->setSize($width, 4);
|
||||||
|
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
|
||||||
|
$lineQuad->setZ(0.001);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen($listRecord->nickname) < 2) {
|
||||||
|
$listRecord->nickname = $listRecord->login;
|
||||||
|
}
|
||||||
|
$array = array($listRecord->rank => $x + 5, '$fff' . $listRecord->nickname => $x + 18, $listRecord->login => $x + 70, Formatter::formatTime($listRecord->time) => $x + 101);
|
||||||
|
$this->maniaControl->manialinkManager->labelLine($recordFrame, $array);
|
||||||
|
|
||||||
|
$recordFrame->setY($y);
|
||||||
|
|
||||||
|
$y -= 4;
|
||||||
|
$i++;
|
||||||
|
if ($i % 15 == 0) {
|
||||||
|
unset($pageFrame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render and display xml
|
||||||
|
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player, 'PlayerList');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a Player's record
|
||||||
|
*
|
||||||
|
* @param array $chat
|
||||||
|
* @param Player $player
|
||||||
|
*/
|
||||||
|
public function deleteRecord(array $chat, Player $player) {
|
||||||
|
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MASTERADMIN)) {
|
||||||
|
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$chatCommand = explode(' ', $chat[1][2]);
|
||||||
|
$recordId = (int)$chatCommand[1];
|
||||||
|
if (is_integer($recordId)) {
|
||||||
|
$currentMap = $this->maniaControl->mapManager->getCurrentMap();
|
||||||
|
$records = $this->getLocalRecords($currentMap);
|
||||||
|
if (count($records) < $recordId) {
|
||||||
|
$this->maniaControl->chat->sendError('Cannot remove record $<$fff' . $recordId . '$>!', $player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$mysqli = $this->maniaControl->database->mysqli;
|
||||||
|
$query = "DELETE FROM `" . self::TABLE_RECORDS . "` WHERE `mapIndex` = " . $currentMap->index . " AND `playerIndex` = " . $player->index . "";
|
||||||
|
$mysqli->query($query);
|
||||||
|
if ($mysqli->error) {
|
||||||
|
trigger_error($mysqli->error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_LOCALRECORDS_CHANGED, null);
|
||||||
|
$this->maniaControl->chat->sendInformation('Record no. $<$fff' . $recordId . '$> has been removed!');
|
||||||
|
} else {
|
||||||
|
$this->maniaControl->chat->sendError('Cannot remove record $<$fff' . $recordId . '$>, because it\'s not an integer!', $player);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,12 @@ use FML\Controls\Frame;
|
|||||||
use FML\Controls\Quads\Quad_BgsPlayerCard;
|
use FML\Controls\Quads\Quad_BgsPlayerCard;
|
||||||
use FML\ManiaLink;
|
use FML\ManiaLink;
|
||||||
use FML\Script\Features\Paging;
|
use FML\Script\Features\Paging;
|
||||||
|
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\Callbacks;
|
use ManiaControl\Callbacks\Callbacks;
|
||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Maps\Map;
|
|
||||||
use ManiaControl\Manialinks\ManialinkManager;
|
use ManiaControl\Manialinks\ManialinkManager;
|
||||||
|
use ManiaControl\Maps\Map;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
use ManiaControl\Players\PlayerManager;
|
use ManiaControl\Players\PlayerManager;
|
||||||
use ManiaControl\Plugins\Plugin;
|
use ManiaControl\Plugins\Plugin;
|
||||||
@ -23,8 +22,8 @@ use Maniaplanet\DedicatedServer\Structures\AbstractStructure;
|
|||||||
/**
|
/**
|
||||||
* ManiaControl ServerRanking Plugin
|
* ManiaControl ServerRanking Plugin
|
||||||
*
|
*
|
||||||
* @author kremsy
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||||
* @copyright ManiaControl Copyright © 2014 ManiaControl Team
|
* @copyright 2014 ManiaControl Team
|
||||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
*/
|
*/
|
||||||
class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
||||||
@ -33,8 +32,8 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
*/
|
*/
|
||||||
const PLUGIN_ID = 6;
|
const PLUGIN_ID = 6;
|
||||||
const PLUGIN_VERSION = 0.1;
|
const PLUGIN_VERSION = 0.1;
|
||||||
const PLUGIN_NAME = 'ServerRankingPlugin';
|
const PLUGIN_NAME = 'Server Ranking Plugin';
|
||||||
const PLUGIN_AUTHOR = 'kremsy';
|
const PLUGIN_AUTHOR = 'MCTeam';
|
||||||
const TABLE_RANK = 'mc_rank';
|
const TABLE_RANK = 'mc_rank';
|
||||||
const RANKING_TYPE_RECORDS = 'Records';
|
const RANKING_TYPE_RECORDS = 'Records';
|
||||||
const RANKING_TYPE_RATIOS = 'Ratios';
|
const RANKING_TYPE_RATIOS = 'Ratios';
|
||||||
@ -49,26 +48,53 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
/**
|
/**
|
||||||
* Private Properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
/** @var maniaControl $maniaControl * */
|
/** @var ManiaControl $maniaControl * */
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
private $recordCount = 0;
|
private $recordCount = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares the Plugin
|
* @see \ManiaControl\Plugins\Plugin::prepare()
|
||||||
*
|
|
||||||
* @param ManiaControl $maniaControl
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public static function prepare(ManiaControl $maniaControl) {
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
//Todo
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the plugin
|
* @see \ManiaControl\Plugins\Plugin::getId()
|
||||||
*
|
*/
|
||||||
* @param \ManiaControl\ManiaControl $maniaControl
|
public static function getId() {
|
||||||
* @throws Exception
|
return self::PLUGIN_ID;
|
||||||
* @return bool
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getName()
|
||||||
|
*/
|
||||||
|
public static function getName() {
|
||||||
|
return self::PLUGIN_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
||||||
|
*/
|
||||||
|
public static function getVersion() {
|
||||||
|
return self::PLUGIN_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
||||||
|
*/
|
||||||
|
public static function getAuthor() {
|
||||||
|
return self::PLUGIN_AUTHOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
||||||
|
*/
|
||||||
|
public static function getDescription() {
|
||||||
|
return "ServerRanking Plugin, ServerRanking by an avg build from the records, per count of points, or by a multiplication from Kill/Death Ratio and Laser accuracy";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::load()
|
||||||
*/
|
*/
|
||||||
public function load(ManiaControl $maniaControl) {
|
public function load(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
@ -111,57 +137,6 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
$this->resetRanks(); //TODO only update records count
|
$this->resetRanks(); //TODO only update records count
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::unload()
|
|
||||||
*/
|
|
||||||
public function unload() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get plugin id
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public static function getId() {
|
|
||||||
return self::PLUGIN_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Plugin Name
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function getName() {
|
|
||||||
return self::PLUGIN_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Plugin Version
|
|
||||||
*
|
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
public static function getVersion() {
|
|
||||||
return self::PLUGIN_VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Plugin Author
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function getAuthor() {
|
|
||||||
return self::PLUGIN_AUTHOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Plugin Description
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function getDescription() {
|
|
||||||
return "ServerRanking Plugin, ServerRanking by an avg build from the records, per count of points, or by a multiplication from Kill/Death Ratio and Laser accuracy";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create necessary database tables
|
* Create necessary database tables
|
||||||
*/
|
*/
|
||||||
@ -190,7 +165,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
$mysqli->query('TRUNCATE TABLE ' . self::TABLE_RANK);
|
$mysqli->query('TRUNCATE TABLE ' . self::TABLE_RANK);
|
||||||
$type = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_RANKING_TYPE);
|
$type = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_RANKING_TYPE);
|
||||||
|
|
||||||
switch($type) {
|
switch ($type) {
|
||||||
case self::RANKING_TYPE_RATIOS:
|
case self::RANKING_TYPE_RATIOS:
|
||||||
$minHits = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_HITS_RATIO_RANKING);
|
$minHits = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_HITS_RATIO_RANKING);
|
||||||
|
|
||||||
@ -199,7 +174,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
$accuracies = $this->maniaControl->statisticManager->getStatsRanking(StatisticManager::SPECIAL_STAT_LASER_ACC);
|
$accuracies = $this->maniaControl->statisticManager->getStatsRanking(StatisticManager::SPECIAL_STAT_LASER_ACC);
|
||||||
|
|
||||||
$ranks = array();
|
$ranks = array();
|
||||||
foreach($hits as $player => $hitCount) {
|
foreach ($hits as $player => $hitCount) {
|
||||||
if (!isset($killDeathRatios[$player]) || !isset($accuracies[$player])) {
|
if (!isset($killDeathRatios[$player]) || !isset($accuracies[$player])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -232,7 +207,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
|
|
||||||
$result = $mysqli->query($query);
|
$result = $mysqli->query($query);
|
||||||
$players = array();
|
$players = array();
|
||||||
while($row = $result->fetch_object()) {
|
while ($row = $result->fetch_object()) {
|
||||||
$players[$row->playerIndex] = array(0, 0); //sum, count
|
$players[$row->playerIndex] = array(0, 0); //sum, count
|
||||||
}
|
}
|
||||||
$result->free_result();
|
$result->free_result();
|
||||||
@ -240,11 +215,11 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
/** @var \MCTeam\LocalRecordsPlugin $localRecordsPlugin */
|
/** @var \MCTeam\LocalRecordsPlugin $localRecordsPlugin */
|
||||||
$localRecordsPlugin = $this->maniaControl->pluginManager->getPlugin('MCTeam\LocalRecordsPlugin');
|
$localRecordsPlugin = $this->maniaControl->pluginManager->getPlugin('MCTeam\LocalRecordsPlugin');
|
||||||
$maps = $this->maniaControl->mapManager->getMaps();
|
$maps = $this->maniaControl->mapManager->getMaps();
|
||||||
foreach($maps as $map) {
|
foreach ($maps as $map) {
|
||||||
$records = $localRecordsPlugin->getLocalRecords($map, $maxRecords);
|
$records = $localRecordsPlugin->getLocalRecords($map, $maxRecords);
|
||||||
|
|
||||||
$i = 1;
|
$i = 1;
|
||||||
foreach($records as $record) {
|
foreach ($records as $record) {
|
||||||
if (isset($players[$record->playerIndex])) {
|
if (isset($players[$record->playerIndex])) {
|
||||||
$players[$record->playerIndex][0] += $i;
|
$players[$record->playerIndex][0] += $i;
|
||||||
$players[$record->playerIndex][1]++;
|
$players[$record->playerIndex][1]++;
|
||||||
@ -257,7 +232,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
|
|
||||||
//compute each players new average score
|
//compute each players new average score
|
||||||
$ranks = array();
|
$ranks = array();
|
||||||
foreach($players as $player => $val) {
|
foreach ($players as $player => $val) {
|
||||||
$sum = $val[0];
|
$sum = $val[0];
|
||||||
$cnt = $val[1];
|
$cnt = $val[1];
|
||||||
// ranked maps sum + $maxRecs rank for all remaining maps
|
// ranked maps sum + $maxRecs rank for all remaining maps
|
||||||
@ -278,7 +253,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
$query = "INSERT INTO " . self::TABLE_RANK . " VALUES ";
|
$query = "INSERT INTO " . self::TABLE_RANK . " VALUES ";
|
||||||
$i = 1;
|
$i = 1;
|
||||||
|
|
||||||
foreach($ranks as $player => $rankValue) {
|
foreach ($ranks as $player => $rankValue) {
|
||||||
$query .= '(' . $player . ',' . $i . ',' . $rankValue . '),';
|
$query .= '(' . $player . ',' . $i . ',' . $rankValue . '),';
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@ -287,6 +262,12 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
$mysqli->query($query);
|
$mysqli->query($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||||
|
*/
|
||||||
|
public function unload() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle PlayerConnect callback
|
* Handle PlayerConnect callback
|
||||||
*
|
*
|
||||||
@ -297,27 +278,6 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
$this->showNextRank($player);
|
$this->showNextRank($player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Shows Ranks on endMap
|
|
||||||
*
|
|
||||||
* @param Map $map
|
|
||||||
*/
|
|
||||||
public function handleEndMap(Map $map) {
|
|
||||||
$this->resetRanks();
|
|
||||||
|
|
||||||
foreach($this->maniaControl->playerManager->getPlayers() as $player) {
|
|
||||||
/** @var Player $player */
|
|
||||||
if ($player->isFakePlayer()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$this->showRank($player);
|
|
||||||
$this->showNextRank($player);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Trigger callback
|
|
||||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_RANK_BUILT);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows the serverRank to a certain Player
|
* Shows the serverRank to a certain Player
|
||||||
*
|
*
|
||||||
@ -330,7 +290,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
|
|
||||||
$message = '';
|
$message = '';
|
||||||
if ($rankObj) {
|
if ($rankObj) {
|
||||||
switch($type) {
|
switch ($type) {
|
||||||
case self::RANKING_TYPE_RATIOS:
|
case self::RANKING_TYPE_RATIOS:
|
||||||
$kd = $this->maniaControl->statisticManager->getStatisticData(StatisticManager::SPECIAL_STAT_KD_RATIO, $player->index);
|
$kd = $this->maniaControl->statisticManager->getStatisticData(StatisticManager::SPECIAL_STAT_KD_RATIO, $player->index);
|
||||||
$acc = $this->maniaControl->statisticManager->getStatisticData(StatisticManager::SPECIAL_STAT_LASER_ACC, $player->index);
|
$acc = $this->maniaControl->statisticManager->getStatisticData(StatisticManager::SPECIAL_STAT_LASER_ACC, $player->index);
|
||||||
@ -343,7 +303,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
$message = '$0f3Your Server rank is $<$ff3' . $rankObj->rank . '$> / $<$fff' . $this->recordCount . '$> Avg: $fff' . round($rankObj->avg, 2);
|
$message = '$0f3Your Server rank is $<$ff3' . $rankObj->rank . '$> / $<$fff' . $this->recordCount . '$> Avg: $fff' . round($rankObj->avg, 2);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch($type) {
|
switch ($type) {
|
||||||
case self::RANKING_TYPE_RATIOS:
|
case self::RANKING_TYPE_RATIOS:
|
||||||
$minHits = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_HITS_RATIO_RANKING);
|
$minHits = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_HITS_RATIO_RANKING);
|
||||||
$message = '$0f3 You must make $<$fff' . $minHits . '$> Hits on this server before receiving a rank...';
|
$message = '$0f3 You must make $<$fff' . $minHits . '$> Hits on this server before receiving a rank...';
|
||||||
@ -385,6 +345,29 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
return Rank::fromArray($row);
|
return Rank::fromArray($row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows which Player is next ranked to you
|
||||||
|
*
|
||||||
|
* @param Player $player
|
||||||
|
*/
|
||||||
|
public function showNextRank(Player $player) {
|
||||||
|
$rankObject = $this->getRank($player);
|
||||||
|
|
||||||
|
if ($rankObject) {
|
||||||
|
if ($rankObject->rank > 1) {
|
||||||
|
$nextRank = $this->getNextRank($player);
|
||||||
|
$nextPlayer = $this->maniaControl->playerManager->getPlayerByIndex($nextRank->playerIndex);
|
||||||
|
$message = '$0f3The next better ranked player is $fff' . $nextPlayer->nickname;
|
||||||
|
} else {
|
||||||
|
$message = '$0f3No better ranked player :-)';
|
||||||
|
}
|
||||||
|
$this->maniaControl->chat->sendChat($message, $player->login);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Next Ranked Player
|
* Get the Next Ranked Player
|
||||||
*
|
*
|
||||||
@ -407,6 +390,26 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows Ranks on endMap
|
||||||
|
*
|
||||||
|
* @param Map $map
|
||||||
|
*/
|
||||||
|
public function handleEndMap(Map $map) {
|
||||||
|
$this->resetRanks();
|
||||||
|
|
||||||
|
foreach ($this->maniaControl->playerManager->getPlayers() as $player) {
|
||||||
|
/** @var Player $player */
|
||||||
|
if ($player->isFakePlayer()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$this->showRank($player);
|
||||||
|
$this->showNextRank($player);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trigger callback
|
||||||
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_RANK_BUILT);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows the current Server-Rank
|
* Shows the current Server-Rank
|
||||||
@ -431,30 +434,6 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shows which Player is next ranked to you
|
|
||||||
*
|
|
||||||
* @param Player $player
|
|
||||||
*/
|
|
||||||
public function showNextRank(Player $player) {
|
|
||||||
$rankObject = $this->getRank($player);
|
|
||||||
|
|
||||||
if ($rankObject) {
|
|
||||||
if ($rankObject->rank > 1) {
|
|
||||||
$nextRank = $this->getNextRank($player);
|
|
||||||
$nextPlayer = $this->maniaControl->playerManager->getPlayerByIndex($nextRank->playerIndex);
|
|
||||||
$message = '$0f3The next better ranked player is $fff' . $nextPlayer->nickname;
|
|
||||||
} else {
|
|
||||||
$message = '$0f3No better ranked player :-)';
|
|
||||||
}
|
|
||||||
$this->maniaControl->chat->sendChat($message, $player->login);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles /topranks|top100 command
|
* Handles /topranks|top100 command
|
||||||
*
|
*
|
||||||
@ -471,7 +450,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
private function showTopRanksList(Player $player) {
|
private function showTopRanksList(Player $player) {
|
||||||
$query = "SELECT * FROM `".self::TABLE_RANK."` ORDER BY `Rank` ASC LIMIT 0, 100";
|
$query = "SELECT * FROM `" . self::TABLE_RANK . "` ORDER BY `Rank` ASC LIMIT 0, 100";
|
||||||
$mysqli = $this->maniaControl->database->mysqli;
|
$mysqli = $this->maniaControl->database->mysqli;
|
||||||
$result = $mysqli->query($query);
|
$result = $mysqli->query($query);
|
||||||
if ($mysqli->error) {
|
if ($mysqli->error) {
|
||||||
@ -510,7 +489,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
$i = 1;
|
$i = 1;
|
||||||
$y = $y - 10;
|
$y = $y - 10;
|
||||||
$pageFrames = array();
|
$pageFrames = array();
|
||||||
while($rankedPlayer = $result->fetch_object()) {
|
while ($rankedPlayer = $result->fetch_object()) {
|
||||||
if (!isset($pageFrame)) {
|
if (!isset($pageFrame)) {
|
||||||
$pageFrame = new Frame();
|
$pageFrame = new Frame();
|
||||||
$frame->add($pageFrame);
|
$frame->add($pageFrame);
|
||||||
|
@ -29,8 +29,7 @@ use ManiaControl\Plugins\Plugin;
|
|||||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
*/
|
*/
|
||||||
class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
|
class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
|
||||||
|
/*
|
||||||
/**
|
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const PLUGIN_ID = 1;
|
const PLUGIN_ID = 1;
|
||||||
@ -70,74 +69,55 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
const SETTING_SERVERINFO_WIDGET_WIDTH = 'ServerInfo-Widget-Size: Width';
|
const SETTING_SERVERINFO_WIDGET_WIDTH = 'ServerInfo-Widget-Size: Width';
|
||||||
const SETTING_SERVERINFO_WIDGET_HEIGHT = 'ServerInfo-Widget-Size: Height';
|
const SETTING_SERVERINFO_WIDGET_HEIGHT = 'ServerInfo-Widget-Size: Height';
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Private Properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
/**
|
/** @var ManiaControl $maniaControl */
|
||||||
* @var maniaControl $maniaControl
|
|
||||||
*/
|
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares the Plugin
|
* @see \ManiaControl\Plugins\Plugin::prepare()
|
||||||
*
|
|
||||||
* @param ManiaControl $maniaControl
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public static function prepare(ManiaControl $maniaControl) {
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
//do nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get plugin id
|
* @see \ManiaControl\Plugins\Plugin::getId()
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
*/
|
||||||
public static function getId() {
|
public static function getId() {
|
||||||
return self::PLUGIN_ID;
|
return self::PLUGIN_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plugin Name
|
* @see \ManiaControl\Plugins\Plugin::getName()
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public static function getName() {
|
public static function getName() {
|
||||||
return self::PLUGIN_NAME;
|
return self::PLUGIN_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plugin Version
|
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
||||||
*
|
|
||||||
* @return float,,
|
|
||||||
*/
|
*/
|
||||||
public static function getVersion() {
|
public static function getVersion() {
|
||||||
return self::PLUGIN_VERSION;
|
return self::PLUGIN_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plugin Author
|
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public static function getAuthor() {
|
public static function getAuthor() {
|
||||||
return self::PLUGIN_AUTHOR;
|
return self::PLUGIN_AUTHOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plugin Description
|
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public static function getDescription() {
|
public static function getDescription() {
|
||||||
return 'Plugin offers some Widgets';
|
return 'Plugin offers some Widgets';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the plugin
|
* @see \ManiaControl\Plugins\Plugin::load()
|
||||||
*
|
|
||||||
* @param ManiaControl $maniaControl
|
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
public function load(ManiaControl $maniaControl) {
|
public function load(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
@ -413,7 +393,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unload the plugin and its resources
|
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||||
*/
|
*/
|
||||||
public function unload() {
|
public function unload() {
|
||||||
//Restore Siege Progression Layer
|
//Restore Siege Progression Layer
|
||||||
@ -426,9 +406,9 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes a Widget
|
* Close a Widget
|
||||||
*
|
*
|
||||||
* @param $widgetId
|
* @param string $widgetId
|
||||||
*/
|
*/
|
||||||
public function closeWidget($widgetId) {
|
public function closeWidget($widgetId) {
|
||||||
$emptyManialink = new ManiaLink($widgetId);
|
$emptyManialink = new ManiaLink($widgetId);
|
||||||
|
@ -2,13 +2,12 @@
|
|||||||
|
|
||||||
namespace steeffeen;
|
namespace steeffeen;
|
||||||
|
|
||||||
use ManiaControl\Callbacks\Callbacks;
|
|
||||||
use ManiaControl\ManiaControl;
|
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
|
use ManiaControl\Callbacks\Callbacks;
|
||||||
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Maps\Map;
|
use ManiaControl\Maps\Map;
|
||||||
use ManiaControl\Plugins\Plugin;
|
use ManiaControl\Plugins\Plugin;
|
||||||
use ManiaControl\Maps\MapManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin for the TM Game Mode 'Endurance' by TGYoshi
|
* Plugin for the TM Game Mode 'Endurance' by TGYoshi
|
||||||
@ -16,34 +15,67 @@ use ManiaControl\Maps\MapManager;
|
|||||||
* @author steeffeen
|
* @author steeffeen
|
||||||
*/
|
*/
|
||||||
class EndurancePlugin implements CallbackListener, Plugin {
|
class EndurancePlugin implements CallbackListener, Plugin {
|
||||||
/**
|
/*
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const ID = 25;
|
const ID = 25;
|
||||||
const VERSION = 0.2;
|
const VERSION = 0.2;
|
||||||
|
const NAME = 'Endurance Plugin';
|
||||||
|
const AUTHOR = 'steeffeen';
|
||||||
const CB_CHECKPOINT = 'Endurance.Checkpoint';
|
const CB_CHECKPOINT = 'Endurance.Checkpoint';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
/** @var maniaControl $maniaControl */
|
/** @var ManiaControl $maniaControl */
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
/** @var Map $currentMap */
|
/** @var Map $currentMap */
|
||||||
private $currentMap = null;
|
private $currentMap = null;
|
||||||
private $playerLapTimes = array();
|
private $playerLapTimes = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares the Plugin
|
* @see \ManiaControl\Plugins\Plugin::prepare()
|
||||||
*
|
|
||||||
* @param ManiaControl $maniaControl
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public static function prepare(ManiaControl $maniaControl) {
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
//do nothing
|
//do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @see \ManiaControl\Plugins\Plugin::getId()
|
||||||
|
*/
|
||||||
|
public static function getId() {
|
||||||
|
return self::ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getName()
|
||||||
|
*/
|
||||||
|
public static function getName() {
|
||||||
|
return self::NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
||||||
|
*/
|
||||||
|
public static function getVersion() {
|
||||||
|
return self::VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
||||||
|
*/
|
||||||
|
public static function getAuthor() {
|
||||||
|
return self::AUTHOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
||||||
|
*/
|
||||||
|
public static function getDescription() {
|
||||||
|
return "Plugin enabling Support for the TM Game Mode 'Endurance' by TGYoshi.";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* @see \ManiaControl\Plugins\Plugin::load()
|
* @see \ManiaControl\Plugins\Plugin::load()
|
||||||
*/
|
*/
|
||||||
public function load(ManiaControl $maniaControl) {
|
public function load(ManiaControl $maniaControl) {
|
||||||
@ -58,52 +90,11 @@ class EndurancePlugin implements CallbackListener, Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::unload()
|
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||||
*/
|
*/
|
||||||
public function unload() {
|
public function unload() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getId()
|
|
||||||
*/
|
|
||||||
public static function getId() {
|
|
||||||
return self::ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getName()
|
|
||||||
*/
|
|
||||||
public static function getName() {
|
|
||||||
return 'Endurance Plugin';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
|
||||||
*/
|
|
||||||
public static function getVersion() {
|
|
||||||
return self::VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
|
||||||
*/
|
|
||||||
public static function getAuthor() {
|
|
||||||
return 'steeffeen';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
|
||||||
*/
|
|
||||||
public static function getDescription() {
|
|
||||||
return "Plugin enabling Support for the TM Game Mode 'Endurance' by TGYoshi.";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle ManiaControl OnInit callback
|
* Handle ManiaControl OnInit callback
|
||||||
*
|
*
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
namespace steeffeen;
|
namespace steeffeen;
|
||||||
|
|
||||||
use ManiaControl\ManiaControl;
|
|
||||||
use ManiaControl\Admin\AuthenticationManager;
|
use ManiaControl\Admin\AuthenticationManager;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
use ManiaControl\Plugins\Plugin;
|
use ManiaControl\Plugins\Plugin;
|
||||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||||
@ -17,11 +17,13 @@ use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
|||||||
* @author steeffeen
|
* @author steeffeen
|
||||||
*/
|
*/
|
||||||
class ObstaclePlugin implements CallbackListener, CommandListener, Plugin {
|
class ObstaclePlugin implements CallbackListener, CommandListener, Plugin {
|
||||||
/**
|
/*
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const ID = 24;
|
const ID = 24;
|
||||||
const VERSION = 0.2;
|
const VERSION = 0.2;
|
||||||
|
const NAME = 'Obstacle Plugin';
|
||||||
|
const AUTHOR = 'steeffeen';
|
||||||
const CB_JUMPTO = 'Obstacle.JumpTo';
|
const CB_JUMPTO = 'Obstacle.JumpTo';
|
||||||
const SCB_ONFINISH = 'OnFinish';
|
const SCB_ONFINISH = 'OnFinish';
|
||||||
const SCB_ONCHECKPOINT = 'OnCheckpoint';
|
const SCB_ONCHECKPOINT = 'OnCheckpoint';
|
||||||
@ -30,23 +32,52 @@ class ObstaclePlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Private Properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
/**
|
/** @var ManiaControl $maniaControl */
|
||||||
* @var maniaControl $maniaControl
|
|
||||||
*/
|
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares the Plugin
|
* @see \ManiaControl\Plugins\Plugin::prepare()
|
||||||
*
|
|
||||||
* @param ManiaControl $maniaControl
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public static function prepare(ManiaControl $maniaControl) {
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @see \ManiaControl\Plugins\Plugin::getId()
|
||||||
|
*/
|
||||||
|
public static function getId() {
|
||||||
|
return self::ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getName()
|
||||||
|
*/
|
||||||
|
public static function getName() {
|
||||||
|
return self::NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
||||||
|
*/
|
||||||
|
public static function getVersion() {
|
||||||
|
return self::VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
||||||
|
*/
|
||||||
|
public static function getAuthor() {
|
||||||
|
return self::AUTHOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
||||||
|
*/
|
||||||
|
public static function getDescription() {
|
||||||
|
return "Plugin offering CP Jumping and Local Records Support for the ShootManie Gamemode 'Obstacle'.";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* @see \ManiaControl\Plugins\Plugin::load()
|
* @see \ManiaControl\Plugins\Plugin::load()
|
||||||
*/
|
*/
|
||||||
public function load(ManiaControl $maniaControl) {
|
public function load(ManiaControl $maniaControl) {
|
||||||
@ -66,52 +97,11 @@ class ObstaclePlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::unload()
|
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||||
*/
|
*/
|
||||||
public function unload() {
|
public function unload() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getId()
|
|
||||||
*/
|
|
||||||
public static function getId() {
|
|
||||||
return self::ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getName()
|
|
||||||
*/
|
|
||||||
public static function getName() {
|
|
||||||
return 'Obstacle Plugin';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
|
||||||
*/
|
|
||||||
public static function getVersion() {
|
|
||||||
return self::VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
|
||||||
*/
|
|
||||||
public static function getAuthor() {
|
|
||||||
return 'steeffeen';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
|
||||||
*/
|
|
||||||
public static function getDescription() {
|
|
||||||
return "Plugin offering CP Jumping and Local Records Support for the ShootManie Gamemode 'Obstacle'.";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle JumpTo command
|
* Handle JumpTo command
|
||||||
*
|
*
|
||||||
@ -130,8 +120,7 @@ class ObstaclePlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
$param = $player->login . ";" . $params[1] . ";";
|
$param = $player->login . ";" . $params[1] . ";";
|
||||||
try {
|
try {
|
||||||
$this->maniaControl->client->triggerModeScriptEvent(self::CB_JUMPTO, $param);
|
$this->maniaControl->client->triggerModeScriptEvent(self::CB_JUMPTO, $param);
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e) {
|
|
||||||
if ($e->getMessage() == 'Not in script mode.') {
|
if ($e->getMessage() == 'Not in script mode.') {
|
||||||
trigger_error("Couldn't send jump callback for '{$player->login}'. " . $e->getMessage());
|
trigger_error("Couldn't send jump callback for '{$player->login}'. " . $e->getMessage());
|
||||||
return;
|
return;
|
||||||
@ -154,8 +143,7 @@ class ObstaclePlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
$time = $data->Run->Time;
|
$time = $data->Run->Time;
|
||||||
// Trigger trackmania player finish callback
|
// Trigger trackmania player finish callback
|
||||||
$finishCallback = array($player->pid, $player->login, $time);
|
$finishCallback = array($player->pid, $player->login, $time);
|
||||||
$this->maniaControl->callbackManager->triggerCallback(CallbackManager::CB_TM_PLAYERFINISH,
|
$this->maniaControl->callbackManager->triggerCallback(CallbackManager::CB_TM_PLAYERFINISH, array(CallbackManager::CB_TM_PLAYERFINISH, $finishCallback));
|
||||||
array(CallbackManager::CB_TM_PLAYERFINISH, $finishCallback));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -172,7 +160,6 @@ class ObstaclePlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
}
|
}
|
||||||
// Trigger Trackmania player checkpoint callback
|
// Trigger Trackmania player checkpoint callback
|
||||||
$checkpointCallback = array($player->pid, $player->login, $time, 0, 0);
|
$checkpointCallback = array($player->pid, $player->login, $time, 0, 0);
|
||||||
$this->maniaControl->callbackManager->triggerCallback(CallbackManager::CB_TM_PLAYERCHECKPOINT,
|
$this->maniaControl->callbackManager->triggerCallback(CallbackManager::CB_TM_PLAYERCHECKPOINT, array(CallbackManager::CB_TM_PLAYERCHECKPOINT, $checkpointCallback));
|
||||||
array(CallbackManager::CB_TM_PLAYERCHECKPOINT, $checkpointCallback));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user