minor performance improvements
This commit is contained in:
		| @@ -72,11 +72,12 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA | |||||||
| 	 * @param string      $message | 	 * @param string      $message | ||||||
| 	 * @param string      $login | 	 * @param string      $login | ||||||
| 	 * @param string|bool $prefix | 	 * @param string|bool $prefix | ||||||
|  | 	 * @param bool        $multiCall | ||||||
| 	 * @return bool | 	 * @return bool | ||||||
| 	 */ | 	 */ | ||||||
| 	public function sendInformation($message, $login = null, $prefix = true) { | 	public function sendInformation($message, $login = null, $prefix = true, $multiCall = false) { | ||||||
| 		$format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_INFORMATION); | 		$format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_INFORMATION); | ||||||
| 		return $this->sendChat($format . $message, $login, $prefix); | 		return $this->sendChat($format . $message, $login, $prefix, $multiCall); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -85,9 +86,10 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA | |||||||
| 	 * @param string      $message | 	 * @param string      $message | ||||||
| 	 * @param string      $login | 	 * @param string      $login | ||||||
| 	 * @param string|bool $prefix | 	 * @param string|bool $prefix | ||||||
|  | 	 * @param bool        $multiCall | ||||||
| 	 * @return bool | 	 * @return bool | ||||||
| 	 */ | 	 */ | ||||||
| 	public function sendChat($message, $login = null, $prefix = true) { | 	public function sendChat($message, $login = null, $prefix = true, $multiCall = false) { | ||||||
| 		if (!$this->maniaControl->getClient()) { | 		if (!$this->maniaControl->getClient()) { | ||||||
| 			return false; | 			return false; | ||||||
| 		} | 		} | ||||||
| @@ -100,13 +102,13 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA | |||||||
| 				$login = Player::parseLogin($login); | 				$login = Player::parseLogin($login); | ||||||
| 			} | 			} | ||||||
| 			try { | 			try { | ||||||
| 				return $this->maniaControl->getClient()->chatSendServerMessage($chatMessage, $login); | 				return $this->maniaControl->getClient()->chatSendServerMessage($chatMessage, $login, $multiCall); | ||||||
| 			} catch (UnknownPlayerException $e) { | 			} catch (UnknownPlayerException $e) { | ||||||
| 				return false; | 				return false; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		return $this->maniaControl->getClient()->chatSendServerMessage($chatMessage); | 		return $this->maniaControl->getClient()->chatSendServerMessage($chatMessage, null, $multiCall); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
|   | |||||||
| @@ -290,8 +290,9 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 	 * Shows the serverRank to a certain Player | 	 * Shows the serverRank to a certain Player | ||||||
| 	 * | 	 * | ||||||
| 	 * @param Player $player | 	 * @param Player $player | ||||||
|  | 	 * @param        $multiCall | ||||||
| 	 */ | 	 */ | ||||||
| 	public function showRank(Player $player) { | 	public function showRank(Player $player, $multiCall = false) { | ||||||
| 		$rankObj = $this->getRank($player); | 		$rankObj = $this->getRank($player); | ||||||
|  |  | ||||||
| 		$type = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_RANKING_TYPE); | 		$type = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_RANKING_TYPE); | ||||||
| @@ -325,7 +326,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 					$message    = '$0f3 You need $<$fff' . $minRecords . '$> Records on this server before receiving a rank...'; | 					$message    = '$0f3 You need $<$fff' . $minRecords . '$> Records on this server before receiving a rank...'; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		$this->maniaControl->getChat()->sendChat($message, $player); | 		$this->maniaControl->getChat()->sendChat($message, $player, $multiCall); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -359,9 +360,10 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 	 * Show which Player is next ranked to you | 	 * Show which Player is next ranked to you | ||||||
| 	 * | 	 * | ||||||
| 	 * @param Player $player | 	 * @param Player $player | ||||||
|  | 	 * @param bool   $multiCall | ||||||
| 	 * @return bool | 	 * @return bool | ||||||
| 	 */ | 	 */ | ||||||
| 	public function showNextRank(Player $player) { | 	public function showNextRank(Player $player, $multiCall = false) { | ||||||
| 		$rankObject = $this->getRank($player); | 		$rankObject = $this->getRank($player); | ||||||
| 		if (!$rankObject) { | 		if (!$rankObject) { | ||||||
| 			return false; | 			return false; | ||||||
| @@ -380,7 +382,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 		} else { | 		} else { | ||||||
| 			$message = '$0f3No better ranked player.'; | 			$message = '$0f3No better ranked player.'; | ||||||
| 		} | 		} | ||||||
| 		$this->maniaControl->getChat()->sendChat($message, $player); | 		$this->maniaControl->getChat()->sendChat($message, $player, $multiCall); | ||||||
|  |  | ||||||
| 		return true; | 		return true; | ||||||
| 	} | 	} | ||||||
| @@ -427,10 +429,13 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 				continue; | 				continue; | ||||||
| 			} | 			} | ||||||
| 			//TODO combine the following to message to one (saves half of calls) | 			//TODO combine the following to message to one (saves half of calls) | ||||||
| 			$this->showRank($player); | 			$this->showRank($player, true); | ||||||
| 			$this->showNextRank($player); | 			$this->showNextRank($player, true); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		//Execute as a MultiCall | ||||||
|  | 		$this->maniaControl->getClient()->executeMulticall(); | ||||||
|  |  | ||||||
| 		// Trigger callback | 		// Trigger callback | ||||||
| 		$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_RANK_BUILT); | 		$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_RANK_BUILT); | ||||||
| 	} | 	} | ||||||
| @@ -538,6 +543,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 			$playerObject = $this->maniaControl->getPlayerManager()->getPlayerByIndex($rankedPlayer->PlayerIndex); | 			$playerObject = $this->maniaControl->getPlayerManager()->getPlayerByIndex($rankedPlayer->PlayerIndex); | ||||||
| 			$array        = array($rankedPlayer->Rank => $posX + 5, $playerObject->nickname => $posX + 18, (string) round($rankedPlayer->Avg, 2) => $posX + 70); | 			$array        = array($rankedPlayer->Rank => $posX + 5, $playerObject->nickname => $posX + 18, (string) round($rankedPlayer->Avg, 2) => $posX + 70); | ||||||
| 			$this->maniaControl->getManialinkManager()->labelLine($playerFrame, $array); | 			$this->maniaControl->getManialinkManager()->labelLine($playerFrame, $array); | ||||||
|  | 			//TODO change labelline | ||||||
|  |  | ||||||
| 			$posY -= 4; | 			$posY -= 4; | ||||||
| 			$index++; | 			$index++; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user