From e7df439276fbb736e249bd41b7f50ac932d51ca1 Mon Sep 17 00:00:00 2001 From: kremsy Date: Mon, 22 May 2017 16:31:09 +0200 Subject: [PATCH] Dedimania some more improvements --- plugins/MCTeam/Dedimania/DedimaniaData.php | 4 ++++ plugins/MCTeam/Dedimania/DedimaniaWebHandler.php | 15 ++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/plugins/MCTeam/Dedimania/DedimaniaData.php b/plugins/MCTeam/Dedimania/DedimaniaData.php index 5b7fc468..25735c0d 100644 --- a/plugins/MCTeam/Dedimania/DedimaniaData.php +++ b/plugins/MCTeam/Dedimania/DedimaniaData.php @@ -55,6 +55,10 @@ class DedimaniaData { $this->serverBuild = $serverVersion->build; } + public function sessionIdSet(){ + return $this->sessionId != ''; + } + /** * Sort the Records */ diff --git a/plugins/MCTeam/Dedimania/DedimaniaWebHandler.php b/plugins/MCTeam/Dedimania/DedimaniaWebHandler.php index a1bba120..fc3fd032 100644 --- a/plugins/MCTeam/Dedimania/DedimaniaWebHandler.php +++ b/plugins/MCTeam/Dedimania/DedimaniaWebHandler.php @@ -93,7 +93,7 @@ class DedimaniaWebHandler implements TimerListener { * @return bool */ public function fetchDedimaniaRecords($reset = true) { - if (!isset($this->dedimaniaData) || !$this->dedimaniaData->sessionId) { + if (!isset($this->dedimaniaData) || !$this->dedimaniaData->sessionIdSet()) { return false; } @@ -169,7 +169,7 @@ class DedimaniaWebHandler implements TimerListener { * Checks If a Dedimania Session exists, if not create a new oen */ public function checkDedimaniaSession() { //TODO complete check and refactor - if (!$this->dedimaniaData->sessionId) { + if (!$this->dedimaniaData->sessionIdSet()) { $this->openDedimaniaSession(); return; } @@ -215,6 +215,10 @@ class DedimaniaWebHandler implements TimerListener { * Handle EndMap Callback */ public function submitChallengeTimes() { + if (!$this->dedimaniaData->sessionIdSet()) { + return; + } + if (!$this->getDedimaniaData()->recordsExisting()) { return; } @@ -307,7 +311,7 @@ class DedimaniaWebHandler implements TimerListener { * @param Player $player */ public function handlePlayerConnect(Player $player) { - if (!isset($this->dedimaniaData)) { + if (!isset($this->dedimaniaData) || !$this->dedimaniaData->sessionIdSet()) { return; } @@ -359,9 +363,10 @@ class DedimaniaWebHandler implements TimerListener { * @param Player $player */ public function handlePlayerDisconnect(Player $player) { //TODO move into webhandler - if (!isset($this->dedimaniaData)) { + if (!isset($this->dedimaniaData) || !$this->dedimaniaData->sessionIdSet()) { return; } + $this->dedimaniaData->removePlayer($player->login); // Send Dedimania request @@ -402,7 +407,7 @@ class DedimaniaWebHandler implements TimerListener { $serverInfo = $this->getServerInfo(); $playerList = $this->getPlayerList(); $votesInfo = $this->getVotesInfo(); - if (!$serverInfo || !$votesInfo || !$playerList || !isset($this->dedimaniaData) || !$this->dedimaniaData->sessionId) { + if (!$serverInfo || !$votesInfo || !$playerList || !isset($this->dedimaniaData) || !$this->dedimaniaData->sessionIdSet()) { return; }