small fixes
This commit is contained in:
parent
734619e744
commit
706f30636e
@ -136,10 +136,12 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
|
|||||||
return $this->maniaControl->client->sendDisplayManialinkPage(null, $manialinkText, $timeout, $hideOnClick);
|
return $this->maniaControl->client->sendDisplayManialinkPage(null, $manialinkText, $timeout, $hideOnClick);
|
||||||
}
|
}
|
||||||
if (is_string($logins)) {
|
if (is_string($logins)) {
|
||||||
return $this->maniaControl->client->sendDisplayManialinkPage($logins, $manialinkText, $timeout, $hideOnClick);
|
$success = $this->maniaControl->client->sendDisplayManialinkPage($logins, $manialinkText, $timeout, $hideOnClick);
|
||||||
|
return $success;
|
||||||
}
|
}
|
||||||
if ($logins instanceof Player) {
|
if ($logins instanceof Player) {
|
||||||
return $this->maniaControl->client->sendDisplayManialinkPage($logins->login, $manialinkText, $timeout, $hideOnClick);
|
$success = $this->maniaControl->client->sendDisplayManialinkPage($logins->login, $manialinkText, $timeout, $hideOnClick);
|
||||||
|
return $success;
|
||||||
}
|
}
|
||||||
if (is_array($logins)) {
|
if (is_array($logins)) {
|
||||||
$success = true;
|
$success = true;
|
||||||
@ -153,6 +155,10 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
|
|||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
|
if($e->getMessage() == "Login unknown."){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$this->maniaControl->errorHandler->triggerDebugNotice("Exception while sending Manialink: " . $e->getMessage());
|
||||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@ class PlayerManager implements CallbackListener {
|
|||||||
$player->updateSpectatorStatus($callback[1][0]["SpectatorStatus"]);
|
$player->updateSpectatorStatus($callback[1][0]["SpectatorStatus"]);
|
||||||
|
|
||||||
//Check if Player finished joining the game
|
//Check if Player finished joining the game
|
||||||
if ($player->hasJoinedGame && !$prevJoinState) {
|
if($player->hasJoinedGame && !$prevJoinState){
|
||||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer()) {
|
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer()) {
|
||||||
$string = array(0 => '$0f0Player', 1 => '$0f0Moderator', 2 => '$0f0Admin', 3 => '$0f0SuperAdmin', 4 => '$0f0MasterAdmin');
|
$string = array(0 => '$0f0Player', 1 => '$0f0Moderator', 2 => '$0f0Admin', 3 => '$0f0SuperAdmin', 4 => '$0f0MasterAdmin');
|
||||||
$chatMessage = '$s$0f0' . $string[$player->authLevel] . ' $fff' . $player->nickname . '$z$s$0f0 Nation:$fff ' . $player->getCountry() . ' $z$s$0f0joined!';
|
$chatMessage = '$s$0f0' . $string[$player->authLevel] . ' $fff' . $player->nickname . '$z$s$0f0 Nation:$fff ' . $player->getCountry() . ' $z$s$0f0joined!';
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
use ManiaControl\Callbacks\TimerListener;
|
|
||||||
use ManiaControl\Formatter;
|
|
||||||
use ManiaControl\ManiaControl;
|
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
|
||||||
use ManiaControl\Maps\Map;
|
|
||||||
use ManiaControl\Players\Player;
|
|
||||||
use ManiaControl\Players\PlayerManager;
|
|
||||||
use ManiaControl\Plugins\Plugin;
|
|
||||||
use FML\ManiaLink;
|
|
||||||
use FML\Controls\Control;
|
use FML\Controls\Control;
|
||||||
use FML\Controls\Frame;
|
use FML\Controls\Frame;
|
||||||
use FML\Controls\Label;
|
use FML\Controls\Label;
|
||||||
use FML\Controls\Quad;
|
use FML\Controls\Quad;
|
||||||
|
use FML\ManiaLink;
|
||||||
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
|
use ManiaControl\Callbacks\TimerListener;
|
||||||
|
use ManiaControl\Formatter;
|
||||||
|
use ManiaControl\ManiaControl;
|
||||||
|
use ManiaControl\Maps\Map;
|
||||||
use ManiaControl\Maps\MapManager;
|
use ManiaControl\Maps\MapManager;
|
||||||
|
use ManiaControl\Players\Player;
|
||||||
|
use ManiaControl\Players\PlayerManager;
|
||||||
|
use ManiaControl\Plugins\Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ManiaControl Local Records Plugin
|
* ManiaControl Local Records Plugin
|
||||||
@ -42,7 +42,6 @@ class LocalRecordsPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
* Private Properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var maniaControl $maniaControl
|
* @var maniaControl $maniaControl
|
||||||
*/
|
*/
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
@ -59,7 +58,6 @@ class LocalRecordsPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::load()
|
* @see \ManiaControl\Plugins\Plugin::load()
|
||||||
*/
|
*/
|
||||||
public function load(ManiaControl $maniaControl) {
|
public function load(ManiaControl $maniaControl) {
|
||||||
@ -81,14 +79,13 @@ class LocalRecordsPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
$this->maniaControl->timerManager->registerTimerListening($this, 'handle1Second', 1000);
|
$this->maniaControl->timerManager->registerTimerListening($this, 'handle1Second', 1000);
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_AFTERINIT, $this, 'handleAfterInit');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_AFTERINIT, $this, 'handleAfterInit');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_BEGINMAP, $this, 'handleMapBegin');
|
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_BEGINMAP, $this, 'handleMapBegin');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_TM_PLAYERFINISH, $this,
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_TM_PLAYERFINISH, $this, 'handlePlayerFinish');
|
||||||
'handlePlayerFinish');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::unload()
|
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||||
*/
|
*/
|
||||||
public function unload() {
|
public function unload() {
|
||||||
@ -118,7 +115,6 @@ class LocalRecordsPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getId()
|
* @see \ManiaControl\Plugins\Plugin::getId()
|
||||||
*/
|
*/
|
||||||
public static function getId() {
|
public static function getId() {
|
||||||
@ -126,7 +122,6 @@ class LocalRecordsPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getName()
|
* @see \ManiaControl\Plugins\Plugin::getName()
|
||||||
*/
|
*/
|
||||||
public static function getName() {
|
public static function getName() {
|
||||||
@ -134,7 +129,6 @@ class LocalRecordsPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
||||||
*/
|
*/
|
||||||
public static function getVersion() {
|
public static function getVersion() {
|
||||||
@ -142,7 +136,6 @@ class LocalRecordsPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
||||||
*/
|
*/
|
||||||
public static function getAuthor() {
|
public static function getAuthor() {
|
||||||
@ -150,7 +143,6 @@ class LocalRecordsPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
||||||
*/
|
*/
|
||||||
public static function getDescription() {
|
public static function getDescription() {
|
||||||
@ -181,9 +173,9 @@ class LocalRecordsPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Handle PlayerConnect callback
|
* Handle PlayerConnect callback
|
||||||
*
|
*
|
||||||
* @param array $callback
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function handlePlayerConnect(array $callback) {
|
public function handlePlayerConnect(Player $player) {
|
||||||
$this->updateManialink = true;
|
$this->updateManialink = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,8 +219,7 @@ class LocalRecordsPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
}
|
}
|
||||||
if ($oldRecord->time == $time) {
|
if ($oldRecord->time == $time) {
|
||||||
// Same time
|
// Same time
|
||||||
$message = '$<' . $player->nickname . '$> equalized her/his $<$o' . $oldRecord->rank . '.$> Local Record: ' .
|
$message = '$<' . $player->nickname . '$> equalized her/his $<$o' . $oldRecord->rank . '.$> Local Record: ' . Formatter::formatTime($oldRecord->time);
|
||||||
Formatter::formatTime($oldRecord->time);
|
|
||||||
$this->maniaControl->chat->sendInformation($message);
|
$this->maniaControl->chat->sendInformation($message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -259,14 +250,11 @@ class LocalRecordsPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
$notifyOnlyBestRecords = $this->maniaControl->settingManager->getSetting($this, self::SETTING_NOTIFY_BEST_RECORDS);
|
$notifyOnlyBestRecords = $this->maniaControl->settingManager->getSetting($this, self::SETTING_NOTIFY_BEST_RECORDS);
|
||||||
if ($notifyOnlyDriver || $notifyOnlyBestRecords > 0 && $newRecord->rank > $notifyOnlyBestRecords) {
|
if ($notifyOnlyDriver || $notifyOnlyBestRecords > 0 && $newRecord->rank > $notifyOnlyBestRecords) {
|
||||||
$improvement = ((!$oldRecord || $newRecord->rank < $oldRecord->rank) ? 'gained the' : 'improved Your');
|
$improvement = ((!$oldRecord || $newRecord->rank < $oldRecord->rank) ? 'gained the' : 'improved Your');
|
||||||
$message = 'You ' . $improvement . ' $<$o' . $newRecord->rank . '.$> Local Record: ' .
|
$message = 'You ' . $improvement . ' $<$o' . $newRecord->rank . '.$> Local Record: ' . Formatter::formatTime($newRecord->time);
|
||||||
Formatter::formatTime($newRecord->time);
|
|
||||||
$this->maniaControl->chat->sendInformation($message, $player->login);
|
$this->maniaControl->chat->sendInformation($message, $player->login);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$improvement = ((!$oldRecord || $newRecord->rank < $oldRecord->rank) ? 'gained the' : 'improved the');
|
$improvement = ((!$oldRecord || $newRecord->rank < $oldRecord->rank) ? 'gained the' : 'improved the');
|
||||||
$message = '$<' . $player->nickname . '$> ' . $improvement . ' $<$o' . $newRecord->rank . '.$> Local Record: ' .
|
$message = '$<' . $player->nickname . '$> ' . $improvement . ' $<$o' . $newRecord->rank . '.$> Local Record: ' . Formatter::formatTime($newRecord->time);
|
||||||
Formatter::formatTime($newRecord->time);
|
|
||||||
$this->maniaControl->chat->sendInformation($message);
|
$this->maniaControl->chat->sendInformation($message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +309,7 @@ class LocalRecordsPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
$titleLabel->setTranslate(true);
|
$titleLabel->setTranslate(true);
|
||||||
|
|
||||||
// Times
|
// Times
|
||||||
foreach ($records as $index => $record) {
|
foreach($records as $index => $record) {
|
||||||
if ($index >= $lines) {
|
if ($index >= $lines) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -389,7 +377,7 @@ class LocalRecordsPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$records = array();
|
$records = array();
|
||||||
while ($record = $result->fetch_object()) {
|
while($record = $result->fetch_object()) {
|
||||||
array_push($records, $record);
|
array_push($records, $record);
|
||||||
}
|
}
|
||||||
$result->free();
|
$result->free();
|
||||||
|
Loading…
Reference in New Issue
Block a user