workaround for unallowed characters in nicknames, player get kicked immideatly

This commit is contained in:
kremsy 2017-05-11 22:28:33 +02:00
parent c0d660adcd
commit 7c049d5222
2 changed files with 25 additions and 10 deletions

View File

@ -232,10 +232,18 @@ class CallbackManager implements UsageInformationAble {
}
// Handle callbacks
$timings = array();
$startTime = microtime(true);
$callbacks = $this->maniaControl->getClient()->executeCallbacks();
$timings = array();
$startTime = microtime(true);
try {
$callbacks = $this->maniaControl->getClient()->executeCallbacks();
} catch (ParseException $e) {
//TODO remove later, its for the wrong XML encoding of nadeo
return;
}
$timings["executeCallbacks"] = microtime(true) - $startTime;
foreach ($callbacks as $key => $callback) {
$time1 = microtime(true);
$this->handleCallback($callback);
@ -299,12 +307,8 @@ class CallbackManager implements UsageInformationAble {
$params = array_slice($params, 1, null, true);
foreach ($this->callbackListenings[$callbackName] as $listening) {
try {
/** @var Listening $listening */
$listening->triggerCallbackWithParams($params);
} catch (ParseException $e) {
//TODO remove later, its for the wrong XML encoding of nadeo
}
/** @var Listening $listening */
$listening->triggerCallbackWithParams($params);
}
}

View File

@ -16,6 +16,7 @@ use ManiaControl\Logger;
use ManiaControl\ManiaControl;
use ManiaControl\Statistics\StatisticManager;
use ManiaControl\Utils\Formatter;
use Maniaplanet\DedicatedServer\Xmlrpc\ParseException;
use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException;
/**
@ -220,7 +221,13 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis
*/
public function onInit() {
// Add all players
$players = $this->maniaControl->getClient()->getPlayerList(300, 0, 2);
try {
$players = $this->maniaControl->getClient()->getPlayerList(300, 0, 2);
} catch (ParseException $e) {
//TODO remove later, its for the wrong XML encoding of nadeo
return;
}
foreach ($players as $playerItem) {
if ($playerItem->playerId <= 0) {
continue;
@ -329,6 +336,10 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis
$this->addPlayer($player);
} catch (UnknownPlayerException $e) {
} catch (ParseException $e) {
$this->maniaControl->getClient()->kick($login, "\$f00You have an unallowed character in your nickname, please remove it!");
Logger::logError("Player With unallowed nickname joined and got kicked, login: " . $login);
//TODO remove later
}
}