reformat code in plugins
This commit is contained in:
		| @@ -80,43 +80,25 @@ class ChatMessagePlugin implements CommandListener, Plugin { | |||||||
| 		$this->maniaControl = $maniaControl; | 		$this->maniaControl = $maniaControl; | ||||||
|  |  | ||||||
| 		// Chat commands | 		// Chat commands | ||||||
| 		$this->maniaControl->getCommandManager() | 		$this->maniaControl->getCommandManager()->registerCommandListener('me', $this, 'chat_me', false, 'Can be used to express your feelings/ideas.'); | ||||||
| 		                   ->registerCommandListener('me', $this, 'chat_me', false, 'Can be used to express your feelings/ideas.'); | 		$this->maniaControl->getCommandManager()->registerCommandListener('hi', $this, 'chat_hi', false, 'Writes an hello message to the chat.'); | ||||||
| 		$this->maniaControl->getCommandManager() | 		$this->maniaControl->getCommandManager()->registerCommandListener(array('bb', 'bye'), $this, 'chat_bye', false, 'Writes a goodbye message to the chat.'); | ||||||
| 		                   ->registerCommandListener('hi', $this, 'chat_hi', false, 'Writes an hello message to the chat.'); | 		$this->maniaControl->getCommandManager()->registerCommandListener('thx', $this, 'chat_thx', false, 'Writes a thanks message to the chat.'); | ||||||
| 		$this->maniaControl->getCommandManager() | 		$this->maniaControl->getCommandManager()->registerCommandListener('gg', $this, 'chat_gg', false, 'Writes a good game message to the chat.'); | ||||||
| 		                   ->registerCommandListener(array('bb', 'bye'), $this, 'chat_bye', false, 'Writes a goodbye message to the chat.'); | 		$this->maniaControl->getCommandManager()->registerCommandListener('gl', $this, 'chat_gl', false, 'Writes a good luck message to the chat.'); | ||||||
| 		$this->maniaControl->getCommandManager() | 		$this->maniaControl->getCommandManager()->registerCommandListener('hf', $this, 'chat_hf', false, 'Writes an have fun message to the chat.'); | ||||||
| 		                   ->registerCommandListener('thx', $this, 'chat_thx', false, 'Writes a thanks message to the chat.'); | 		$this->maniaControl->getCommandManager()->registerCommandListener('glhf', $this, 'chat_glhf', false, 'Writes a good luck, have fun message to the chat.'); | ||||||
| 		$this->maniaControl->getCommandManager() | 		$this->maniaControl->getCommandManager()->registerCommandListener('ns', $this, 'chat_ns', false, 'Writes a nice shot message to the chat.'); | ||||||
| 		                   ->registerCommandListener('gg', $this, 'chat_gg', false, 'Writes a good game message to the chat.'); | 		$this->maniaControl->getCommandManager()->registerCommandListener('n1', $this, 'chat_n1', false, 'Writes a nice one message to the chat.'); | ||||||
| 		$this->maniaControl->getCommandManager() | 		$this->maniaControl->getCommandManager()->registerCommandListener('lol', $this, 'chat_lol', false, 'Writes a lol message to the chat.'); | ||||||
| 		                   ->registerCommandListener('gl', $this, 'chat_gl', false, 'Writes a good luck message to the chat.'); | 		$this->maniaControl->getCommandManager()->registerCommandListener('lool', $this, 'chat_lool', false, 'Writes a lool message to the chat.'); | ||||||
| 		$this->maniaControl->getCommandManager() | 		$this->maniaControl->getCommandManager()->registerCommandListener('brb', $this, 'chat_brb', false, 'Writes a be right back message to the chat.'); | ||||||
| 		                   ->registerCommandListener('hf', $this, 'chat_hf', false, 'Writes an have fun message to the chat.'); | 		$this->maniaControl->getCommandManager()->registerCommandListener('bgm', $this, 'chat_bgm', false, 'Writes a bad game for me message to the chat.'); | ||||||
| 		$this->maniaControl->getCommandManager() | 		$this->maniaControl->getCommandManager()->registerCommandListener('afk', $this, 'chat_afk', false, 'Writes an away from keyboard message to the chat.'); | ||||||
| 		                   ->registerCommandListener('glhf', $this, 'chat_glhf', false, 'Writes a good luck, have fun message to the chat.'); | 		$this->maniaControl->getCommandManager()->registerCommandListener(array('bm', 'bootme'), $this, 'chat_bootme', false, 'Gets you away from this server quickly!'); | ||||||
| 		$this->maniaControl->getCommandManager() | 		$this->maniaControl->getCommandManager()->registerCommandListener(array('rq', 'ragequit'), $this, 'chat_ragequit', false, 'Gets you away from this server in rage!'); | ||||||
| 		                   ->registerCommandListener('ns', $this, 'chat_ns', false, 'Writes a nice shot message to the chat.'); |  | ||||||
| 		$this->maniaControl->getCommandManager() |  | ||||||
| 		                   ->registerCommandListener('n1', $this, 'chat_n1', false, 'Writes a nice one message to the chat.'); |  | ||||||
| 		$this->maniaControl->getCommandManager() |  | ||||||
| 		                   ->registerCommandListener('lol', $this, 'chat_lol', false, 'Writes a lol message to the chat.'); |  | ||||||
| 		$this->maniaControl->getCommandManager() |  | ||||||
| 		                   ->registerCommandListener('lool', $this, 'chat_lool', false, 'Writes a lool message to the chat.'); |  | ||||||
| 		$this->maniaControl->getCommandManager() |  | ||||||
| 		                   ->registerCommandListener('brb', $this, 'chat_brb', false, 'Writes a be right back message to the chat.'); |  | ||||||
| 		$this->maniaControl->getCommandManager() |  | ||||||
| 		                   ->registerCommandListener('bgm', $this, 'chat_bgm', false, 'Writes a bad game for me message to the chat.'); |  | ||||||
| 		$this->maniaControl->getCommandManager() |  | ||||||
| 		                   ->registerCommandListener('afk', $this, 'chat_afk', false, 'Writes an away from keyboard message to the chat.'); |  | ||||||
| 		$this->maniaControl->getCommandManager() |  | ||||||
| 		                   ->registerCommandListener(array('bm', 'bootme'), $this, 'chat_bootme', false, 'Gets you away from this server quickly!'); |  | ||||||
| 		$this->maniaControl->getCommandManager() |  | ||||||
| 		                   ->registerCommandListener(array('rq', 'ragequit'), $this, 'chat_ragequit', false, 'Gets you away from this server in rage!'); |  | ||||||
| 		//TODO block command listener for muted people | 		//TODO block command listener for muted people | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_AFK_FORCE_SPEC, true); | ||||||
| 		                   ->initSetting($this, self::SETTING_AFK_FORCE_SPEC, true); |  | ||||||
|  |  | ||||||
| 		return true; | 		return true; | ||||||
| 	} | 	} | ||||||
| @@ -137,8 +119,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { | |||||||
| 		$message = substr($chat[1][2], 4); | 		$message = substr($chat[1][2], 4); | ||||||
|  |  | ||||||
| 		$msg = '$<' . $player->nickname . '$>$s$i$fa0 ' . $message; | 		$msg = '$<' . $player->nickname . '$>$s$i$fa0 ' . $message; | ||||||
| 		$this->maniaControl->getChat() | 		$this->maniaControl->getChat()->sendChat($msg, null, false); | ||||||
| 		                   ->sendChat($msg, null, false); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -155,8 +136,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { | |||||||
| 		} else { | 		} else { | ||||||
| 			$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iHello All!'; | 			$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iHello All!'; | ||||||
| 		} | 		} | ||||||
| 		$this->maniaControl->getChat() | 		$this->maniaControl->getChat()->sendChat($msg, null, false); | ||||||
| 		                   ->sendChat($msg, null, false); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -168,8 +148,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { | |||||||
| 	 */ | 	 */ | ||||||
| 	private function getTarget($login) { | 	private function getTarget($login) { | ||||||
| 		$player = null; | 		$player = null; | ||||||
| 		foreach ($this->maniaControl->getPlayerManager() | 		foreach ($this->maniaControl->getPlayerManager()->getPlayers() as $player) { | ||||||
| 		                            ->getPlayers() as $player) { |  | ||||||
| 			if ($login == $player || $login == $player->login || $login == $player->pid || $login == $player->nickname) { | 			if ($login == $player || $login == $player->login || $login == $player->pid || $login == $player->nickname) { | ||||||
| 				return $player->nickname; | 				return $player->nickname; | ||||||
| 			} | 			} | ||||||
| @@ -198,8 +177,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { | |||||||
| 			$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iI have to go... Bye All!'; | 			$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iI have to go... Bye All!'; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$this->maniaControl->getChat() | 		$this->maniaControl->getChat()->sendChat($msg, null, false); | ||||||
| 		                   ->sendChat($msg, null, false); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -217,8 +195,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { | |||||||
| 			$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iThanks All!'; | 			$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iThanks All!'; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$this->maniaControl->getChat() | 		$this->maniaControl->getChat()->sendChat($msg, null, false); | ||||||
| 		                   ->sendChat($msg, null, false); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -236,8 +213,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { | |||||||
| 			$msg = '$ff0[' . $player->getEscapedNickname() . '] $ff0$iGood Game All!'; | 			$msg = '$ff0[' . $player->getEscapedNickname() . '] $ff0$iGood Game All!'; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$this->maniaControl->getChat() | 		$this->maniaControl->getChat()->sendChat($msg, null, false); | ||||||
| 		                   ->sendChat($msg, null, false); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -255,8 +231,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { | |||||||
| 			$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iGood Luck All!'; | 			$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iGood Luck All!'; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$this->maniaControl->getChat() | 		$this->maniaControl->getChat()->sendChat($msg, null, false); | ||||||
| 		                   ->sendChat($msg, null, false); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -274,8 +249,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { | |||||||
| 			$msg = '$ff0[' . $player->getEscapedNickname() . '] $ff0$iHave Fun All!'; | 			$msg = '$ff0[' . $player->getEscapedNickname() . '] $ff0$iHave Fun All!'; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$this->maniaControl->getChat() | 		$this->maniaControl->getChat()->sendChat($msg, null, false); | ||||||
| 		                   ->sendChat($msg, null, false); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -293,8 +267,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { | |||||||
| 			$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iGood Luck and Have Fun All!'; | 			$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iGood Luck and Have Fun All!'; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$this->maniaControl->getChat() | 		$this->maniaControl->getChat()->sendChat($msg, null, false); | ||||||
| 		                   ->sendChat($msg, null, false); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -312,8 +285,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { | |||||||
| 			$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iNice Shot!'; | 			$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iNice Shot!'; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$this->maniaControl->getChat() | 		$this->maniaControl->getChat()->sendChat($msg, null, false); | ||||||
| 		                   ->sendChat($msg, null, false); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -331,8 +303,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { | |||||||
| 			$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iNice One!'; | 			$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iNice One!'; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$this->maniaControl->getChat() | 		$this->maniaControl->getChat()->sendChat($msg, null, false); | ||||||
| 		                   ->sendChat($msg, null, false); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -343,8 +314,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { | |||||||
| 	 */ | 	 */ | ||||||
| 	public function chat_lol(array $chat, Player $player) { | 	public function chat_lol(array $chat, Player $player) { | ||||||
| 		$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iLoL!'; | 		$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iLoL!'; | ||||||
| 		$this->maniaControl->getChat() | 		$this->maniaControl->getChat()->sendChat($msg, null, false); | ||||||
| 		                   ->sendChat($msg, null, false); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -355,8 +325,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { | |||||||
| 	 */ | 	 */ | ||||||
| 	public function chat_lool(array $chat, Player $player) { | 	public function chat_lool(array $chat, Player $player) { | ||||||
| 		$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iLooOOooL!'; | 		$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iLooOOooL!'; | ||||||
| 		$this->maniaControl->getChat() | 		$this->maniaControl->getChat()->sendChat($msg, null, false); | ||||||
| 		                   ->sendChat($msg, null, false); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -367,8 +336,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { | |||||||
| 	 */ | 	 */ | ||||||
| 	public function chat_brb(array $chat, Player $player) { | 	public function chat_brb(array $chat, Player $player) { | ||||||
| 		$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iBe Right Back!'; | 		$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iBe Right Back!'; | ||||||
| 		$this->maniaControl->getChat() | 		$this->maniaControl->getChat()->sendChat($msg, null, false); | ||||||
| 		                   ->sendChat($msg, null, false); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -379,8 +347,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { | |||||||
| 	 */ | 	 */ | ||||||
| 	public function chat_bgm(array $chat, Player $player) { | 	public function chat_bgm(array $chat, Player $player) { | ||||||
| 		$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iBad Game for me :('; | 		$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iBad Game for me :('; | ||||||
| 		$this->maniaControl->getChat() | 		$this->maniaControl->getChat()->sendChat($msg, null, false); | ||||||
| 		                   ->sendChat($msg, null, false); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -391,16 +358,13 @@ class ChatMessagePlugin implements CommandListener, Plugin { | |||||||
| 	 */ | 	 */ | ||||||
| 	public function chat_bootme(array $chat, Player $player) { | 	public function chat_bootme(array $chat, Player $player) { | ||||||
| 		$msg = '$i$ff0 $<' . $player->nickname . '$>$s$39f chooses to boot back to the real world!'; | 		$msg = '$i$ff0 $<' . $player->nickname . '$>$s$39f chooses to boot back to the real world!'; | ||||||
| 		$this->maniaControl->getChat() | 		$this->maniaControl->getChat()->sendChat($msg, null, true); | ||||||
| 		                   ->sendChat($msg, null, true); |  | ||||||
|  |  | ||||||
| 		$message = '$39F Thanks for Playing, see you around!$z'; | 		$message = '$39F Thanks for Playing, see you around!$z'; | ||||||
| 		try { | 		try { | ||||||
| 			$this->maniaControl->getClient() | 			$this->maniaControl->getClient()->kick($player->login, $message); | ||||||
| 			                   ->kick($player->login, $message); |  | ||||||
| 		} catch (UnknownPlayerException $exception) { | 		} catch (UnknownPlayerException $exception) { | ||||||
| 			$this->maniaControl->getChat() | 			$this->maniaControl->getChat()->sendException($exception, $player); | ||||||
| 			                   ->sendException($exception, $player); |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -413,14 +377,11 @@ class ChatMessagePlugin implements CommandListener, Plugin { | |||||||
| 	public function chat_ragequit(array $chat, Player $player) { | 	public function chat_ragequit(array $chat, Player $player) { | ||||||
| 		try { | 		try { | ||||||
| 			$message = '$39F Thanks for Playing, please come back soon!$z '; | 			$message = '$39F Thanks for Playing, please come back soon!$z '; | ||||||
| 			$this->maniaControl->getClient() | 			$this->maniaControl->getClient()->kick($player->login, $message); | ||||||
| 			                   ->kick($player->login, $message); |  | ||||||
| 			$msg = '$i$ff0 $<' . $player->nickname . '$>$s$f00 said: "@"#!" and ragequitted!'; | 			$msg = '$i$ff0 $<' . $player->nickname . '$>$s$f00 said: "@"#!" and ragequitted!'; | ||||||
| 			$this->maniaControl->getChat() | 			$this->maniaControl->getChat()->sendChat($msg, null, true); | ||||||
| 			                   ->sendChat($msg, null, true); |  | ||||||
| 		} catch (UnknownPlayerException $e) { | 		} catch (UnknownPlayerException $e) { | ||||||
| 			$this->maniaControl->getChat() | 			$this->maniaControl->getChat()->sendError('Error occurred: ' . $e->getMessage(), $player); | ||||||
| 			                   ->sendError('Error occurred: ' . $e->getMessage(), $player); |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -432,11 +393,9 @@ class ChatMessagePlugin implements CommandListener, Plugin { | |||||||
| 	 */ | 	 */ | ||||||
| 	public function chat_afk(array $chat, Player $player) { | 	public function chat_afk(array $chat, Player $player) { | ||||||
| 		$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iAway From Keyboard!'; | 		$msg = '$ff0[$<' . $player->nickname . '$>] $ff0$iAway From Keyboard!'; | ||||||
| 		$this->maniaControl->getChat() | 		$this->maniaControl->getChat()->sendChat($msg, null, false); | ||||||
| 		                   ->sendChat($msg, null, false); |  | ||||||
|  |  | ||||||
| 		if (!$this->maniaControl->getSettingManager() | 		if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_AFK_FORCE_SPEC) | ||||||
| 		                        ->getSettingValue($this, self::SETTING_AFK_FORCE_SPEC) |  | ||||||
| 		) { | 		) { | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| @@ -446,14 +405,11 @@ class ChatMessagePlugin implements CommandListener, Plugin { | |||||||
|  |  | ||||||
| 		try { | 		try { | ||||||
| 			// Force into spec | 			// Force into spec | ||||||
| 			$this->maniaControl->getClient() | 			$this->maniaControl->getClient()->forceSpectator($player->login, 3); | ||||||
| 			                   ->forceSpectator($player->login, 3); |  | ||||||
| 			// Free player slot | 			// Free player slot | ||||||
| 			$this->maniaControl->getClient() | 			$this->maniaControl->getClient()->spectatorReleasePlayerSlot($player->login); | ||||||
| 			                   ->spectatorReleasePlayerSlot($player->login); |  | ||||||
| 		} catch (UnknownPlayerException $exception) { | 		} catch (UnknownPlayerException $exception) { | ||||||
| 			$this->maniaControl->getChat() | 			$this->maniaControl->getChat()->sendException($exception, $player); | ||||||
| 			                   ->sendException($exception, $player); |  | ||||||
| 		} catch (PlayerStateException $exception) { | 		} catch (PlayerStateException $exception) { | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -133,76 +133,48 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP | |||||||
| 		$this->maniaControl = $maniaControl; | 		$this->maniaControl = $maniaControl; | ||||||
|  |  | ||||||
| 		// Commands | 		// Commands | ||||||
| 		$this->maniaControl->getCommandManager() | 		$this->maniaControl->getCommandManager()->registerCommandListener('vote', $this, 'chat_vote', false, 'Starts a new vote.'); | ||||||
| 		                   ->registerCommandListener('vote', $this, 'chat_vote', false, 'Starts a new vote.'); |  | ||||||
|  |  | ||||||
| 		// Callbacks | 		// Callbacks | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_POSITIVE_VOTE, $this, 'handlePositiveVote'); | ||||||
| 		                   ->registerManialinkPageAnswerListener(self::ACTION_POSITIVE_VOTE, $this, 'handlePositiveVote'); | 		$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_NEGATIVE_VOTE, $this, 'handleNegativeVote'); | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getTimerManager()->registerTimerListening($this, 'handle1Second', 1000); | ||||||
| 		                   ->registerManialinkPageAnswerListener(self::ACTION_NEGATIVE_VOTE, $this, 'handleNegativeVote'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Commands::CB_VOTE_CANCELLED, $this, 'handleVoteCancelled'); | ||||||
| 		$this->maniaControl->getTimerManager() |  | ||||||
| 		                   ->registerTimerListening($this, 'handle1Second', 1000); |  | ||||||
| 		$this->maniaControl->getCallbackManager() |  | ||||||
| 		                   ->registerCallbackListener(Commands::CB_VOTE_CANCELLED, $this, 'handleVoteCancelled'); |  | ||||||
|  |  | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer'); | ||||||
| 		                   ->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(self::CB_CUSTOM_VOTE_FINISHED, $this, 'handleVoteFinished'); | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); | ||||||
| 		                   ->registerCallbackListener(self::CB_CUSTOM_VOTE_FINISHED, $this, 'handleVoteFinished'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Server::CB_TEAM_MODE_CHANGED, $this, 'constructMenu'); | ||||||
| 		$this->maniaControl->getCallbackManager() |  | ||||||
| 		                   ->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); |  | ||||||
| 		$this->maniaControl->getCallbackManager() |  | ||||||
| 		                   ->registerCallbackListener(Server::CB_TEAM_MODE_CHANGED, $this, 'constructMenu'); |  | ||||||
|  |  | ||||||
| 		// Settings | 		// Settings | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_VOTE_ICON_POSX, 156.); | ||||||
| 		                   ->initSetting($this, self::SETTING_VOTE_ICON_POSX, 156.); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_VOTE_ICON_POSY, -38.6); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_VOTE_ICON_WIDTH, 6); | ||||||
| 		                   ->initSetting($this, self::SETTING_VOTE_ICON_POSY, -38.6); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_VOTE_ICON_HEIGHT, 6); | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_VOTE_ICON_WIDTH, 6); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_VOTE_ICON_HEIGHT, 6); |  | ||||||
|  |  | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_POSX, -80); //160 -15 | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_POSX, -80); //160 -15 | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_POSY, 80); //-15 | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_WIDTH, 50); //30 | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_POSY, 80); //-15 | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_HEIGHT, 20); //25 | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_WIDTH, 50); //30 |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_HEIGHT, 20); //25 |  | ||||||
|  |  | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_DEFAULT_RATIO, 0.75); | ||||||
| 		                   ->initSetting($this, self::SETTING_DEFAULT_RATIO, 0.75); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_DEFAULT_PLAYER_RATIO, 0.65); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SPECTATOR_ALLOW_VOTE, false); | ||||||
| 		                   ->initSetting($this, self::SETTING_DEFAULT_PLAYER_RATIO, 0.65); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SPECTATOR_ALLOW_START_VOTE, true); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_VOTE_TIME, 40); | ||||||
| 		                   ->initSetting($this, self::SETTING_SPECTATOR_ALLOW_VOTE, false); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_SPECTATOR_ALLOW_START_VOTE, true); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_VOTE_TIME, 40); |  | ||||||
|  |  | ||||||
| 		//Define Votes | 		//Define Votes | ||||||
| 		$this->defineVote("teambalance", "Vote for Team Balance"); | 		$this->defineVote("teambalance", "Vote for Team Balance"); | ||||||
| 		$this->defineVote("skipmap", "Vote for Skip Map") | 		$this->defineVote("skipmap", "Vote for Skip Map")->setStopCallback(Callbacks::ENDMAP); | ||||||
| 		     ->setStopCallback(Callbacks::ENDMAP); | 		$this->defineVote("nextmap", "Vote for Skip Map")->setStopCallback(Callbacks::ENDMAP); | ||||||
| 		$this->defineVote("nextmap", "Vote for Skip Map") | 		$this->defineVote("skip", "Vote for Skip Map")->setStopCallback(Callbacks::ENDMAP); | ||||||
| 		     ->setStopCallback(Callbacks::ENDMAP); | 		$this->defineVote("restartmap", "Vote for Restart Map")->setStopCallback(Callbacks::ENDMAP); | ||||||
| 		$this->defineVote("skip", "Vote for Skip Map") | 		$this->defineVote("restart", "Vote for Restart Map")->setStopCallback(Callbacks::ENDMAP); | ||||||
| 		     ->setStopCallback(Callbacks::ENDMAP); |  | ||||||
| 		$this->defineVote("restartmap", "Vote for Restart Map") |  | ||||||
| 		     ->setStopCallback(Callbacks::ENDMAP); |  | ||||||
| 		$this->defineVote("restart", "Vote for Restart Map") |  | ||||||
| 		     ->setStopCallback(Callbacks::ENDMAP); |  | ||||||
| 		$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->getCommandManager() | 			$this->maniaControl->getCommandManager()->registerCommandListener($name, $this, 'handleChatVote', false, $voteCommand->name); | ||||||
| 			                   ->registerCommandListener($name, $this, 'handleChatVote', false, $voteCommand->name); |  | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		/* Disable Standard Votes */ | 		/* Disable Standard Votes */ | ||||||
| @@ -212,8 +184,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP | |||||||
| 		$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_TEAM_BALANCE, -1.); | 		$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_TEAM_BALANCE, -1.); | ||||||
| 		$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_NEXT_MAP, -1.); | 		$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_NEXT_MAP, -1.); | ||||||
|  |  | ||||||
| 		$this->maniaControl->getClient() | 		$this->maniaControl->getClient()->setCallVoteRatios($ratioArray, false); | ||||||
| 		                   ->setCallVoteRatios($ratioArray, false); |  | ||||||
|  |  | ||||||
| 		$this->constructMenu(); | 		$this->constructMenu(); | ||||||
| 		return true; | 		return true; | ||||||
| @@ -231,8 +202,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP | |||||||
| 	 */ | 	 */ | ||||||
| 	public function defineVote($voteIndex, $voteName, $idBased = false, $startText = '', $neededRatio = -1) { | 	public function defineVote($voteIndex, $voteName, $idBased = false, $startText = '', $neededRatio = -1) { | ||||||
| 		if ($neededRatio < 0) { | 		if ($neededRatio < 0) { | ||||||
| 			$neededRatio = $this->maniaControl->getSettingManager() | 			$neededRatio = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DEFAULT_RATIO); | ||||||
| 			                                  ->getSettingValue($this, self::SETTING_DEFAULT_RATIO); |  | ||||||
| 		} | 		} | ||||||
| 		$voteCommand                    = new VoteCommand($voteIndex, $voteName, $idBased, $neededRatio); | 		$voteCommand                    = new VoteCommand($voteIndex, $voteName, $idBased, $neededRatio); | ||||||
| 		$voteCommand->startText         = $startText; | 		$voteCommand->startText         = $startText; | ||||||
| @@ -255,8 +225,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP | |||||||
|  |  | ||||||
| 		//Check if Pause exists in current GameMode | 		//Check if Pause exists in current GameMode | ||||||
| 		try { | 		try { | ||||||
| 			$scriptInfos = $this->maniaControl->getClient() | 			$scriptInfos = $this->maniaControl->getClient()->getModeScriptInfo(); | ||||||
| 			                                  ->getModeScriptInfo(); |  | ||||||
|  |  | ||||||
| 			$pauseExists = false; | 			$pauseExists = false; | ||||||
| 			foreach ($scriptInfos->commandDescs as $param) { | 			foreach ($scriptInfos->commandDescs as $param) { | ||||||
| @@ -282,8 +251,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP | |||||||
| 		$itemQuad->setAction(self::ACTION_START_VOTE . 'skipmap'); | 		$itemQuad->setAction(self::ACTION_START_VOTE . 'skipmap'); | ||||||
| 		$this->addVoteMenuItem($itemQuad, 15, 'Vote for a Map Skip'); | 		$this->addVoteMenuItem($itemQuad, 15, 'Vote for a Map Skip'); | ||||||
|  |  | ||||||
| 		if ($this->maniaControl->getServer() | 		if ($this->maniaControl->getServer()->isTeamMode() | ||||||
| 		                       ->isTeamMode() |  | ||||||
| 		) { | 		) { | ||||||
| 			//Menu TeamBalance | 			//Menu TeamBalance | ||||||
| 			$itemQuad = new Quad_Icons128x32_1(); | 			$itemQuad = new Quad_Icons128x32_1(); | ||||||
| @@ -316,30 +284,18 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP | |||||||
| 	 * @param bool $login | 	 * @param bool $login | ||||||
| 	 */ | 	 */ | ||||||
| 	private function showIcon($login = false) { | 	private function showIcon($login = false) { | ||||||
| 		$posX              = $this->maniaControl->getSettingManager() | 		$posX              = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_VOTE_ICON_POSX); | ||||||
| 		                                        ->getSettingValue($this, self::SETTING_VOTE_ICON_POSX); | 		$posY              = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_VOTE_ICON_POSY); | ||||||
| 		$posY              = $this->maniaControl->getSettingManager() | 		$width             = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_VOTE_ICON_WIDTH); | ||||||
| 		                                        ->getSettingValue($this, self::SETTING_VOTE_ICON_POSY); | 		$height            = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_VOTE_ICON_HEIGHT); | ||||||
| 		$width             = $this->maniaControl->getSettingManager() | 		$shootManiaOffset  = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultIconOffsetSM(); | ||||||
| 		                                        ->getSettingValue($this, self::SETTING_VOTE_ICON_WIDTH); | 		$quadStyle         = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle(); | ||||||
| 		$height            = $this->maniaControl->getSettingManager() | 		$quadSubstyle      = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle(); | ||||||
| 		                                        ->getSettingValue($this, self::SETTING_VOTE_ICON_HEIGHT); |  | ||||||
| 		$shootManiaOffset  = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                        ->getStyleManager() |  | ||||||
| 		                                        ->getDefaultIconOffsetSM(); |  | ||||||
| 		$quadStyle         = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                        ->getStyleManager() |  | ||||||
| 		                                        ->getDefaultQuadStyle(); |  | ||||||
| 		$quadSubstyle      = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                        ->getStyleManager() |  | ||||||
| 		                                        ->getDefaultQuadSubstyle(); |  | ||||||
| 		$itemMarginFactorX = 1.3; | 		$itemMarginFactorX = 1.3; | ||||||
| 		$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->getMapManager() | 		if ($this->maniaControl->getMapManager()->getCurrentMap()->getGame() === 'sm' | ||||||
| 		                       ->getCurrentMap() |  | ||||||
| 		                       ->getGame() === 'sm' |  | ||||||
| 		) { | 		) { | ||||||
| 			$posY -= $shootManiaOffset; | 			$posY -= $shootManiaOffset; | ||||||
| 		} | 		} | ||||||
| @@ -418,8 +374,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP | |||||||
|  |  | ||||||
|  |  | ||||||
| 		// Send manialink | 		// Send manialink | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->sendManialink($maniaLink, $login); | ||||||
| 		                   ->sendManialink($maniaLink, $login); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -427,8 +382,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP | |||||||
| 	 */ | 	 */ | ||||||
| 	public function unload() { | 	public function unload() { | ||||||
| 		//Enable Standard Votes | 		//Enable Standard Votes | ||||||
| 		$defaultRatio = $this->maniaControl->getClient() | 		$defaultRatio = $this->maniaControl->getClient()->getCallVoteRatio(); | ||||||
| 		                                   ->getCallVoteRatio(); |  | ||||||
|  |  | ||||||
| 		$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_BAN, $defaultRatio); | 		$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_BAN, $defaultRatio); | ||||||
| 		$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_KICK, $defaultRatio); | 		$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_KICK, $defaultRatio); | ||||||
| @@ -436,12 +390,10 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP | |||||||
| 		$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_TEAM_BALANCE, $defaultRatio); | 		$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_TEAM_BALANCE, $defaultRatio); | ||||||
| 		$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_NEXT_MAP, $defaultRatio); | 		$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_NEXT_MAP, $defaultRatio); | ||||||
|  |  | ||||||
| 		$this->maniaControl->getClient() | 		$this->maniaControl->getClient()->setCallVoteRatios($ratioArray, false); | ||||||
| 		                   ->setCallVoteRatios($ratioArray, false); |  | ||||||
|  |  | ||||||
| 		$this->destroyVote(); | 		$this->destroyVote(); | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->hideManialink(self::MLID_ICON); | ||||||
| 		                   ->hideManialink(self::MLID_ICON); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -449,13 +401,11 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP | |||||||
| 	 */ | 	 */ | ||||||
| 	private function destroyVote() { | 	private function destroyVote() { | ||||||
| 		$emptyManialink = new ManiaLink(self::MLID_WIDGET); | 		$emptyManialink = new ManiaLink(self::MLID_WIDGET); | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->sendManialink($emptyManialink); | ||||||
| 		                   ->sendManialink($emptyManialink); |  | ||||||
|  |  | ||||||
| 		// Remove the Listener for the Stop Callback if a stop callback is defined | 		// Remove the Listener for the Stop Callback if a stop callback is defined | ||||||
| 		if ($this->currentVote && $this->currentVote->stopCallback) { | 		if ($this->currentVote && $this->currentVote->stopCallback) { | ||||||
| 			$this->maniaControl->getCallbackManager() | 			$this->maniaControl->getCallbackManager()->unregisterCallbackListening($this->currentVote->stopCallback, $this); | ||||||
| 			                   ->unregisterCallbackListening($this->currentVote->stopCallback, $this); |  | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$this->currentVote = null; | 		$this->currentVote = null; | ||||||
| @@ -494,55 +444,44 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP | |||||||
| 	 */ | 	 */ | ||||||
| 	public function startVote(Player $player, $voteIndex, $function = null) { | 	public function startVote(Player $player, $voteIndex, $function = null) { | ||||||
| 		//Player is muted | 		//Player is muted | ||||||
| 		if ($this->maniaControl->getPlayerManager() | 		if ($this->maniaControl->getPlayerManager()->getPlayerActions()->isPlayerMuted($player) | ||||||
| 		                       ->getPlayerActions() |  | ||||||
| 		                       ->isPlayerMuted($player) |  | ||||||
| 		) { | 		) { | ||||||
| 			$this->maniaControl->getChat() | 			$this->maniaControl->getChat()->sendError('Muted Players are not allowed to start a vote.', $player); | ||||||
| 			                   ->sendError('Muted Players are not allowed to start a vote.', $player); |  | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Spectators are not allowed to start a vote | 		// Spectators are not allowed to start a vote | ||||||
| 		if ($player->isSpectator | 		if ($player->isSpectator | ||||||
| 		    && !$this->maniaControl->getSettingManager() | 		    && !$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SPECTATOR_ALLOW_START_VOTE) | ||||||
| 		                           ->getSettingValue($this, self::SETTING_SPECTATOR_ALLOW_START_VOTE) |  | ||||||
| 		) { | 		) { | ||||||
| 			$this->maniaControl->getChat() | 			$this->maniaControl->getChat()->sendError('Spectators are not allowed to start a vote.', $player); | ||||||
| 			                   ->sendError('Spectators are not allowed to start a vote.', $player); |  | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		//Vote does not exist | 		//Vote does not exist | ||||||
| 		if (!isset($this->voteCommands[$voteIndex])) { | 		if (!isset($this->voteCommands[$voteIndex])) { | ||||||
| 			$this->maniaControl->getChat() | 			$this->maniaControl->getChat()->sendError('Undefined vote.', $player); | ||||||
| 			                   ->sendError('Undefined vote.', $player); |  | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		//A vote is currently running | 		//A vote is currently running | ||||||
| 		if (isset($this->currentVote)) { | 		if (isset($this->currentVote)) { | ||||||
| 			$this->maniaControl->getChat() | 			$this->maniaControl->getChat()->sendError('There is currently another vote running.', $player); | ||||||
| 			                   ->sendError('There is currently another vote running.', $player); |  | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$maxTime = $this->maniaControl->getSettingManager() | 		$maxTime = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_VOTE_TIME); | ||||||
| 		                              ->getSettingValue($this, self::SETTING_VOTE_TIME); |  | ||||||
|  |  | ||||||
| 		/** @var VoteCommand $voteCommand */ | 		/** @var VoteCommand $voteCommand */ | ||||||
| 		$voteCommand = $this->voteCommands[$voteIndex]; | 		$voteCommand = $this->voteCommands[$voteIndex]; | ||||||
|  |  | ||||||
| 		$this->currentVote                    = new CurrentVote($voteCommand, $player, time() + $maxTime); | 		$this->currentVote                    = new CurrentVote($voteCommand, $player, time() + $maxTime); | ||||||
| 		$this->currentVote->neededRatio       = floatval($this->maniaControl->getSettingManager() | 		$this->currentVote->neededRatio       = floatval($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DEFAULT_RATIO)); | ||||||
| 		                                                                    ->getSettingValue($this, self::SETTING_DEFAULT_RATIO)); | 		$this->currentVote->neededPlayerRatio = floatval($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DEFAULT_PLAYER_RATIO)); | ||||||
| 		$this->currentVote->neededPlayerRatio = floatval($this->maniaControl->getSettingManager() |  | ||||||
| 		                                                                    ->getSettingValue($this, self::SETTING_DEFAULT_PLAYER_RATIO)); |  | ||||||
| 		$this->currentVote->function          = $function; | 		$this->currentVote->function          = $function; | ||||||
|  |  | ||||||
| 		if ($voteCommand->getStopCallback()) { | 		if ($voteCommand->getStopCallback()) { | ||||||
| 			$this->maniaControl->getCallbackManager() | 			$this->maniaControl->getCallbackManager()->registerCallbackListener($voteCommand->getStopCallback(), $this, 'handleStopCallback'); | ||||||
| 			                   ->registerCallbackListener($voteCommand->getStopCallback(), $this, 'handleStopCallback'); |  | ||||||
| 			$this->currentVote->stopCallback = $voteCommand->getStopCallback(); | 			$this->currentVote->stopCallback = $voteCommand->getStopCallback(); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @@ -552,8 +491,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP | |||||||
| 			$message = '$fff' . $player->getEscapedNickname() . '$s$f8f started a $fff$<' . $this->currentVote->voteCommand->name . '$>$f8f!'; | 			$message = '$fff' . $player->getEscapedNickname() . '$s$f8f started a $fff$<' . $this->currentVote->voteCommand->name . '$>$f8f!'; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$this->maniaControl->getChat() | 		$this->maniaControl->getChat()->sendSuccess($message); | ||||||
| 		                   ->sendSuccess($message); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -586,54 +524,40 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP | |||||||
|  |  | ||||||
| 			switch ($voteName) { | 			switch ($voteName) { | ||||||
| 				case 'teambalance': | 				case 'teambalance': | ||||||
| 					$this->maniaControl->getClient() | 					$this->maniaControl->getClient()->autoTeamBalance(); | ||||||
| 					                   ->autoTeamBalance(); | 					$this->maniaControl->getChat()->sendInformation('$f8fVote to $fffbalance the Teams$f8f has been successful!'); | ||||||
| 					$this->maniaControl->getChat() |  | ||||||
| 					                   ->sendInformation('$f8fVote to $fffbalance the Teams$f8f has been successful!'); |  | ||||||
| 					break; | 					break; | ||||||
| 				case 'skipmap': | 				case 'skipmap': | ||||||
| 				case 'skip': | 				case 'skip': | ||||||
| 				case 'nextmap': | 				case 'nextmap': | ||||||
| 					try { | 					try { | ||||||
| 						$this->maniaControl->getMapManager() | 						$this->maniaControl->getMapManager()->getMapActions()->skipMap(); | ||||||
| 						                   ->getMapActions() |  | ||||||
| 						                   ->skipMap(); |  | ||||||
| 					} catch (ChangeInProgressException $e) { | 					} catch (ChangeInProgressException $e) { | ||||||
| 					} | 					} | ||||||
| 					$this->maniaControl->getChat() | 					$this->maniaControl->getChat()->sendInformation('$f8fVote to $fffskip the Map$f8f has been successful!'); | ||||||
| 					                   ->sendInformation('$f8fVote to $fffskip the Map$f8f has been successful!'); |  | ||||||
| 					break; | 					break; | ||||||
| 				case 'restartmap': | 				case 'restartmap': | ||||||
| 					try { | 					try { | ||||||
| 						$this->maniaControl->getClient() | 						$this->maniaControl->getClient()->restartMap(); | ||||||
| 						                   ->restartMap(); |  | ||||||
| 					} catch (ChangeInProgressException $e) { | 					} catch (ChangeInProgressException $e) { | ||||||
| 					} | 					} | ||||||
| 					$this->maniaControl->getChat() | 					$this->maniaControl->getChat()->sendInformation('$f8fVote to $fffrestart the Map$f8f has been successful!'); | ||||||
| 					                   ->sendInformation('$f8fVote to $fffrestart the Map$f8f has been successful!'); |  | ||||||
| 					break; | 					break; | ||||||
| 				case 'pausegame': | 				case 'pausegame': | ||||||
| 					try { | 					try { | ||||||
| 						$this->maniaControl->getClient() | 						$this->maniaControl->getClient()->sendModeScriptCommands(array('Command_ForceWarmUp' => true)); | ||||||
| 						                   ->sendModeScriptCommands(array('Command_ForceWarmUp' => true)); | 						$this->maniaControl->getChat()->sendInformation('$f8fVote to $fffpause the current Game$f8f has been successful!'); | ||||||
| 						$this->maniaControl->getChat() |  | ||||||
| 						                   ->sendInformation('$f8fVote to $fffpause the current Game$f8f has been successful!'); |  | ||||||
| 					} catch (GameModeException $ex) { | 					} catch (GameModeException $ex) { | ||||||
| 					} | 					} | ||||||
| 					break; | 					break; | ||||||
| 				case 'replay': | 				case 'replay': | ||||||
| 					$this->maniaControl->getMapManager() | 					$this->maniaControl->getMapManager()->getMapQueue()->addFirstMapToMapQueue($this->currentVote->voter, $this->maniaControl->getMapManager()->getCurrentMap()); | ||||||
| 					                   ->getMapQueue() | 					$this->maniaControl->getChat()->sendInformation('$f8fVote to $fffreplay the Map$f8f has been successful!'); | ||||||
| 					                   ->addFirstMapToMapQueue($this->currentVote->voter, $this->maniaControl->getMapManager() |  | ||||||
| 					                                                                                         ->getCurrentMap()); |  | ||||||
| 					$this->maniaControl->getChat() |  | ||||||
| 					                   ->sendInformation('$f8fVote to $fffreplay the Map$f8f has been successful!'); |  | ||||||
| 					break; | 					break; | ||||||
| 			} | 			} | ||||||
| 		} else { | 		} else { | ||||||
| 			//FIXME bugreport, no fail message on vote fail sometimes | 			//FIXME bugreport, no fail message on vote fail sometimes | ||||||
| 			$this->maniaControl->getChat() | 			$this->maniaControl->getChat()->sendError('Vote Failed!'); | ||||||
| 			                   ->sendError('Vote Failed!'); |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -652,8 +576,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP | |||||||
| 		$voteIndex = $actionArray[2]; | 		$voteIndex = $actionArray[2]; | ||||||
| 		if (isset($this->voteCommands[$voteIndex])) { | 		if (isset($this->voteCommands[$voteIndex])) { | ||||||
| 			$login  = $callback[1][1]; | 			$login  = $callback[1][1]; | ||||||
| 			$player = $this->maniaControl->getPlayerManager() | 			$player = $this->maniaControl->getPlayerManager()->getPlayer($login); | ||||||
| 			                             ->getPlayer($login); |  | ||||||
| 			$this->startVote($player, $voteIndex); | 			$this->startVote($player, $voteIndex); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -692,8 +615,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP | |||||||
| 	public function handlePositiveVote(array $callback, Player $player) { | 	public function handlePositiveVote(array $callback, Player $player) { | ||||||
| 		if (!isset($this->currentVote) | 		if (!isset($this->currentVote) | ||||||
| 		    || $player->isSpectator | 		    || $player->isSpectator | ||||||
| 		       && !$this->maniaControl->getSettingManager() | 		       && !$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SPECTATOR_ALLOW_VOTE) | ||||||
| 		                              ->getSettingValue($this, self::SETTING_SPECTATOR_ALLOW_VOTE) |  | ||||||
| 		) { | 		) { | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| @@ -710,8 +632,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP | |||||||
| 	public function handleNegativeVote(array $callback, Player $player) { | 	public function handleNegativeVote(array $callback, Player $player) { | ||||||
| 		if (!isset($this->currentVote) | 		if (!isset($this->currentVote) | ||||||
| 		    || $player->isSpectator | 		    || $player->isSpectator | ||||||
| 		       && !$this->maniaControl->getSettingManager() | 		       && !$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SPECTATOR_ALLOW_VOTE) | ||||||
| 		                              ->getSettingValue($this, self::SETTING_SPECTATOR_ALLOW_VOTE) |  | ||||||
| 		) { | 		) { | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| @@ -736,8 +657,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP | |||||||
| 		$timeUntilExpire = $this->currentVote->expireTime - time(); | 		$timeUntilExpire = $this->currentVote->expireTime - time(); | ||||||
| 		$this->showVoteWidget($timeUntilExpire, $votePercentage); | 		$this->showVoteWidget($timeUntilExpire, $votePercentage); | ||||||
|  |  | ||||||
| 		$playerCount      = $this->maniaControl->getPlayerManager() | 		$playerCount      = $this->maniaControl->getPlayerManager()->getPlayerCount(); | ||||||
| 		                                       ->getPlayerCount(); |  | ||||||
| 		$playersVoteRatio = 0; | 		$playersVoteRatio = 0; | ||||||
| 		if ($playerCount > 0 && $voteCount > 0) { | 		if ($playerCount > 0 && $voteCount > 0) { | ||||||
| 			$playersVoteRatio = floatval($voteCount) / floatval($playerCount); | 			$playersVoteRatio = floatval($voteCount) / floatval($playerCount); | ||||||
| @@ -746,8 +666,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP | |||||||
| 		//Check if vote is over | 		//Check if vote is over | ||||||
| 		if ($timeUntilExpire <= 0 || (($playersVoteRatio >= $this->currentVote->neededPlayerRatio) && (($votePercentage >= $this->currentVote->neededRatio) || ($votePercentage <= 1 - $this->currentVote->neededRatio)))) { | 		if ($timeUntilExpire <= 0 || (($playersVoteRatio >= $this->currentVote->neededPlayerRatio) && (($votePercentage >= $this->currentVote->neededRatio) || ($votePercentage <= 1 - $this->currentVote->neededRatio)))) { | ||||||
| 			// Trigger callback | 			// Trigger callback | ||||||
| 			$this->maniaControl->getCallbackManager() | 			$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_CUSTOM_VOTE_FINISHED, $this->currentVote->voteCommand->index, $votePercentage); | ||||||
| 			                   ->triggerCallback(self::CB_CUSTOM_VOTE_FINISHED, $this->currentVote->voteCommand->index, $votePercentage); |  | ||||||
|  |  | ||||||
| 			//reset vote | 			//reset vote | ||||||
| 			$this->destroyVote(); | 			$this->destroyVote(); | ||||||
| @@ -761,26 +680,15 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP | |||||||
| 	 * @param float $votePercentage | 	 * @param float $votePercentage | ||||||
| 	 */ | 	 */ | ||||||
| 	private function showVoteWidget($timeUntilExpire, $votePercentage) { | 	private function showVoteWidget($timeUntilExpire, $votePercentage) { | ||||||
| 		$posX    = $this->maniaControl->getSettingManager() | 		$posX    = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_POSX); | ||||||
| 		                              ->getSettingValue($this, self::SETTING_WIDGET_POSX); | 		$posY    = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_POSY); | ||||||
| 		$posY    = $this->maniaControl->getSettingManager() | 		$width   = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_WIDTH); | ||||||
| 		                              ->getSettingValue($this, self::SETTING_WIDGET_POSY); | 		$height  = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_HEIGHT); | ||||||
| 		$width   = $this->maniaControl->getSettingManager() | 		$maxTime = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_VOTE_TIME); | ||||||
| 		                              ->getSettingValue($this, self::SETTING_WIDGET_WIDTH); |  | ||||||
| 		$height  = $this->maniaControl->getSettingManager() |  | ||||||
| 		                              ->getSettingValue($this, self::SETTING_WIDGET_HEIGHT); |  | ||||||
| 		$maxTime = $this->maniaControl->getSettingManager() |  | ||||||
| 		                              ->getSettingValue($this, self::SETTING_VOTE_TIME); |  | ||||||
|  |  | ||||||
| 		$quadStyle    = $this->maniaControl->getManialinkManager() | 		$quadStyle    = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle(); | ||||||
| 		                                   ->getStyleManager() | 		$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle(); | ||||||
| 		                                   ->getDefaultQuadStyle(); | 		$labelStyle   = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultLabelStyle(); | ||||||
| 		$quadSubstyle = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                   ->getStyleManager() |  | ||||||
| 		                                   ->getDefaultQuadSubstyle(); |  | ||||||
| 		$labelStyle   = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                   ->getStyleManager() |  | ||||||
| 		                                   ->getDefaultLabelStyle(); |  | ||||||
|  |  | ||||||
| 		$maniaLink = new ManiaLink(self::MLID_WIDGET); | 		$maniaLink = new ManiaLink(self::MLID_WIDGET); | ||||||
|  |  | ||||||
| @@ -892,8 +800,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP | |||||||
| 		$script->addFeature($keyActionNegative); | 		$script->addFeature($keyActionNegative); | ||||||
|  |  | ||||||
| 		// Send manialink | 		// Send manialink | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->sendManialink($maniaLink); | ||||||
| 		                   ->sendManialink($maniaLink); |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -80,11 +80,9 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 	 * @see \ManiaControl\Plugins\Plugin::prepare() | 	 * @see \ManiaControl\Plugins\Plugin::prepare() | ||||||
| 	 */ | 	 */ | ||||||
| 	public static function prepare(ManiaControl $maniaControl) { | 	public static function prepare(ManiaControl $maniaControl) { | ||||||
| 		$servers = $maniaControl->getServer() | 		$servers = $maniaControl->getServer()->getAllServers(); | ||||||
| 		                        ->getAllServers(); |  | ||||||
| 		foreach ($servers as $server) { | 		foreach ($servers as $server) { | ||||||
| 			$maniaControl->getSettingManager() | 			$maniaControl->getSettingManager()->initSetting(get_class(), self::SETTING_DEDIMANIA_CODE . $server->login . '$l', ''); | ||||||
| 			             ->initSetting(get_class(), self::SETTING_DEDIMANIA_CODE . $server->login . '$l', ''); |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -134,61 +132,39 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Settings | 		// Settings | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_ENABLE, true); | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_ENABLE, true); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_TITLE, 'Dedimania'); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_POSX, -139); | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_TITLE, 'Dedimania'); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_POSY, 7); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_WIDTH, 40); | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_POSX, -139); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_LINE_HEIGHT, 4); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_LINE_COUNT, 12); | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_POSY, 7); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_WIDTH, 40); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_LINE_HEIGHT, 4); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_LINE_COUNT, 12); |  | ||||||
|  |  | ||||||
| 		// Callbacks | 		// Callbacks | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINMAP, $this, 'handleBeginMap'); | ||||||
| 		                   ->registerCallbackListener(Callbacks::BEGINMAP, $this, 'handleBeginMap'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ENDMAP, $this, 'handleMapEnd'); | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer'); | ||||||
| 		                   ->registerCallbackListener(Callbacks::ENDMAP, $this, 'handleMapEnd'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect'); | ||||||
| 		                   ->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(RecordCallback::CHECKPOINT, $this, 'handleCheckpointCallback'); | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(RecordCallback::LAPFINISH, $this, 'handleLapFinishCallback'); | ||||||
| 		                   ->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(RecordCallback::FINISH, $this, 'handleFinishCallback'); | ||||||
| 		$this->maniaControl->getCallbackManager() |  | ||||||
| 		                   ->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect'); |  | ||||||
| 		$this->maniaControl->getCallbackManager() |  | ||||||
| 		                   ->registerCallbackListener(RecordCallback::CHECKPOINT, $this, 'handleCheckpointCallback'); |  | ||||||
| 		$this->maniaControl->getCallbackManager() |  | ||||||
| 		                   ->registerCallbackListener(RecordCallback::LAPFINISH, $this, 'handleLapFinishCallback'); |  | ||||||
| 		$this->maniaControl->getCallbackManager() |  | ||||||
| 		                   ->registerCallbackListener(RecordCallback::FINISH, $this, 'handleFinishCallback'); |  | ||||||
|  |  | ||||||
| 		$this->maniaControl->getTimerManager() | 		$this->maniaControl->getTimerManager()->registerTimerListening($this, 'updateEverySecond', 1000); | ||||||
| 		                   ->registerTimerListening($this, 'updateEverySecond', 1000); | 		$this->maniaControl->getTimerManager()->registerTimerListening($this, 'handleEveryMinute', 1000 * 60); | ||||||
| 		$this->maniaControl->getTimerManager() | 		$this->maniaControl->getTimerManager()->registerTimerListening($this, 'updatePlayerList', 1000 * 60 * 3); | ||||||
| 		                   ->registerTimerListening($this, 'handleEveryMinute', 1000 * 60); |  | ||||||
| 		$this->maniaControl->getTimerManager() |  | ||||||
| 		                   ->registerTimerListening($this, 'updatePlayerList', 1000 * 60 * 3); |  | ||||||
|  |  | ||||||
| 		$this->maniaControl->getCommandManager() | 		$this->maniaControl->getCommandManager()->registerCommandListener(array('dedirecs', 'dedirecords'), $this, 'showDediRecordsList', false, 'Shows a list of Dedimania records of the current map.'); | ||||||
| 		                   ->registerCommandListener(array('dedirecs', 'dedirecords'), $this, 'showDediRecordsList', false, 'Shows a list of Dedimania records of the current map.'); |  | ||||||
|  |  | ||||||
| 		// Open session | 		// Open session | ||||||
| 		$serverInfo    = $this->maniaControl->getServer() | 		$serverInfo    = $this->maniaControl->getServer()->getInfo(); | ||||||
| 		                                    ->getInfo(); |  | ||||||
| 		$packMask      = $this->maniaControl->getServer()->titleId; | 		$packMask      = $this->maniaControl->getServer()->titleId; | ||||||
| 		$serverVersion = $this->maniaControl->getClient() | 		$serverVersion = $this->maniaControl->getClient()->getVersion(); | ||||||
| 		                                    ->getVersion(); |  | ||||||
| 		if ($packMask !== 'Trackmania_2@nadeolabs') { | 		if ($packMask !== 'Trackmania_2@nadeolabs') { | ||||||
| 			$packMask = substr($this->maniaControl->getServer()->titleId, 2); | 			$packMask = substr($this->maniaControl->getServer()->titleId, 2); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$dedimaniaCode = $this->maniaControl->getSettingManager() | 		$dedimaniaCode = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DEDIMANIA_CODE . $serverInfo->login . '$l'); | ||||||
| 		                                    ->getSettingValue($this, self::SETTING_DEDIMANIA_CODE . $serverInfo->login . '$l'); |  | ||||||
| 		if (!$dedimaniaCode) { | 		if (!$dedimaniaCode) { | ||||||
| 			throw new \Exception("No Dedimania Code Specified, check the settings!"); | 			throw new \Exception("No Dedimania Code Specified, check the settings!"); | ||||||
| 		} | 		} | ||||||
| @@ -219,43 +195,42 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
|  |  | ||||||
|  |  | ||||||
| 		//$this->maniaControl->fileReader->postDataTest($this->request, self::DEDIMANIA_URL, function ($data, $error) { | 		//$this->maniaControl->fileReader->postDataTest($this->request, self::DEDIMANIA_URL, function ($data, $error) { | ||||||
| 		$this->maniaControl->getFileReader() | 		$this->maniaControl->getFileReader()->postData(self::DEDIMANIA_URL, function ($data, $error) { | ||||||
| 		                   ->postData(self::DEDIMANIA_URL, function ($data, $error) { | 			                                    Logger::log("Try to connect on Dedimania"); | ||||||
| 			Logger::log("Try to connect on Dedimania"); |  | ||||||
|  |  | ||||||
| 			if (!$data || $error) { | 			                                    if (!$data || $error) { | ||||||
| 				Logger::logError("Dedimania Error: '{$error}'"); | 				                                    Logger::logError("Dedimania Error: '{$error}'"); | ||||||
| 			} | 			                                    } | ||||||
|  |  | ||||||
| 			$data = $this->decode($data); | 			                                    $data = $this->decode($data); | ||||||
| 			if (!is_array($data) || empty($data)) { | 			                                    if (!is_array($data) || empty($data)) { | ||||||
| 				return; | 				                                    return; | ||||||
| 			} | 			                                    } | ||||||
|  |  | ||||||
| 			$methodResponse = $data[0]; | 			                                    $methodResponse = $data[0]; | ||||||
| 			if (xmlrpc_is_fault($methodResponse)) { | 			                                    if (xmlrpc_is_fault($methodResponse)) { | ||||||
| 				$this->handleXmlRpcFault($methodResponse, self::DEDIMANIA_OPEN_SESSION); | 				                                    $this->handleXmlRpcFault($methodResponse, self::DEDIMANIA_OPEN_SESSION); | ||||||
| 				return; | 				                                    return; | ||||||
| 			} | 			                                    } | ||||||
|  |  | ||||||
| 			$responseData                   = $methodResponse[0]; | 			                                    $responseData                   = $methodResponse[0]; | ||||||
| 			$this->dedimaniaData->sessionId = $responseData['SessionId']; | 			                                    $this->dedimaniaData->sessionId = $responseData['SessionId']; | ||||||
| 			if ($this->dedimaniaData->sessionId) { | 			                                    if ($this->dedimaniaData->sessionId) { | ||||||
| 				Logger::log("Dedimania connection successfully established."); | 				                                    Logger::log("Dedimania connection successfully established."); | ||||||
| 				$this->fetchDedimaniaRecords(); | 				                                    $this->fetchDedimaniaRecords(); | ||||||
| 				$this->init = true; | 				                                    $this->init = true; | ||||||
| 			} else { | 			                                    } else { | ||||||
| 				Logger::logError("Error while opening Dedimania Connection"); | 				                                    Logger::logError("Error while opening Dedimania Connection"); | ||||||
| 			} | 			                                    } | ||||||
|  |  | ||||||
| 			if (self::DEDIMANIA_DEBUG) { | 			                                    if (self::DEDIMANIA_DEBUG) { | ||||||
| 				var_dump("Dedi Debug: Connect Method Response"); | 				                                    var_dump("Dedi Debug: Connect Method Response"); | ||||||
| 				var_dump($methodResponse); | 				                                    var_dump($methodResponse); | ||||||
|  |  | ||||||
| 				var_dump("Dedi Debug: DedimaniaData after Startup"); | 				                                    var_dump("Dedi Debug: DedimaniaData after Startup"); | ||||||
| 				var_dump($this->dedimaniaData); | 				                                    var_dump($this->dedimaniaData); | ||||||
| 			} | 			                                    } | ||||||
| 		}, $content, true); | 		                                    }, $content, true); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -319,48 +294,45 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 		$content = $this->encode_request(self::DEDIMANIA_GET_RECORDS, $data); | 		$content = $this->encode_request(self::DEDIMANIA_GET_RECORDS, $data); | ||||||
| 		//var_dump("get recs"); | 		//var_dump("get recs"); | ||||||
| 		//$this->maniaControl->fileReader->postDataTest($this->request,self::DEDIMANIA_URL, function ($data, $error) { | 		//$this->maniaControl->fileReader->postDataTest($this->request,self::DEDIMANIA_URL, function ($data, $error) { | ||||||
| 		$this->maniaControl->getFileReader() | 		$this->maniaControl->getFileReader()->postData(self::DEDIMANIA_URL, function ($data, $error) { | ||||||
| 		                   ->postData(self::DEDIMANIA_URL, function ($data, $error) { | 			                                    if ($error) { | ||||||
| 			if ($error) { | 				                                    Logger::logError('Dedimania Error: ' . $error); | ||||||
| 				Logger::logError('Dedimania Error: ' . $error); | 			                                    } | ||||||
| 			} |  | ||||||
|  |  | ||||||
| 			$data = $this->decode($data); | 			                                    $data = $this->decode($data); | ||||||
| 			if (!is_array($data) || empty($data)) { | 			                                    if (!is_array($data) || empty($data)) { | ||||||
| 				return; | 				                                    return; | ||||||
| 			} | 			                                    } | ||||||
|  |  | ||||||
| 			$methodResponse = $data[0]; | 			                                    $methodResponse = $data[0]; | ||||||
| 			if (xmlrpc_is_fault($methodResponse)) { | 			                                    if (xmlrpc_is_fault($methodResponse)) { | ||||||
| 				$this->handleXmlRpcFault($methodResponse, self::DEDIMANIA_GET_RECORDS); | 				                                    $this->handleXmlRpcFault($methodResponse, self::DEDIMANIA_GET_RECORDS); | ||||||
| 				return; | 				                                    return; | ||||||
| 			} | 			                                    } | ||||||
|  |  | ||||||
| 			$responseData = $methodResponse[0]; | 			                                    $responseData = $methodResponse[0]; | ||||||
| 			if (!isset($responseData['Players']) || !isset($responseData['Records'])) { | 			                                    if (!isset($responseData['Players']) || !isset($responseData['Records'])) { | ||||||
| 				$this->maniaControl->getErrorHandler() | 				                                    $this->maniaControl->getErrorHandler()->triggerDebugNotice('Invalid Dedimania response!', $responseData); | ||||||
| 				                   ->triggerDebugNotice('Invalid Dedimania response!', $responseData); | 				                                    return; | ||||||
| 				return; | 			                                    } | ||||||
| 			} |  | ||||||
|  |  | ||||||
| 			$this->dedimaniaData->serverMaxRank = $responseData['ServerMaxRank']; | 			                                    $this->dedimaniaData->serverMaxRank = $responseData['ServerMaxRank']; | ||||||
|  |  | ||||||
| 			foreach ($responseData['Players'] as $player) { | 			                                    foreach ($responseData['Players'] as $player) { | ||||||
| 				$dediPlayer = new DedimaniaPlayer($player); | 				                                    $dediPlayer = new DedimaniaPlayer($player); | ||||||
| 				$this->dedimaniaData->addPlayer($dediPlayer); | 				                                    $this->dedimaniaData->addPlayer($dediPlayer); | ||||||
| 			} | 			                                    } | ||||||
| 			foreach ($responseData['Records'] as $key => $record) { | 			                                    foreach ($responseData['Records'] as $key => $record) { | ||||||
| 				$this->dedimaniaData->records[$key] = new RecordData($record); | 				                                    $this->dedimaniaData->records[$key] = new RecordData($record); | ||||||
| 			} | 			                                    } | ||||||
|  |  | ||||||
| 			if (self::DEDIMANIA_DEBUG) { | 			                                    if (self::DEDIMANIA_DEBUG) { | ||||||
| 				var_dump("Dedimania Records Fetched"); | 				                                    var_dump("Dedimania Records Fetched"); | ||||||
| 			} | 			                                    } | ||||||
|  |  | ||||||
| 			$this->updateManialink = true; | 			                                    $this->updateManialink = true; | ||||||
| 			$this->maniaControl->getCallbackManager() | 			                                    $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_DEDIMANIA_UPDATED, $this->dedimaniaData->records); | ||||||
| 			                   ->triggerCallback(self::CB_DEDIMANIA_UPDATED, $this->dedimaniaData->records); | 		                                    }, $content, true); | ||||||
| 		}, $content, true); |  | ||||||
|  |  | ||||||
| 		return true; | 		return true; | ||||||
| 	} | 	} | ||||||
| @@ -369,22 +341,18 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 	 * Build server info Structure for callbacks | 	 * Build server info Structure for callbacks | ||||||
| 	 */ | 	 */ | ||||||
| 	private function getServerInfo() { | 	private function getServerInfo() { | ||||||
| 		$server = $this->maniaControl->getClient() | 		$server = $this->maniaControl->getClient()->getServerOptions(); | ||||||
| 		                             ->getServerOptions(); |  | ||||||
| 		if (!$server) { | 		if (!$server) { | ||||||
| 			return null; | 			return null; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if ($this->maniaControl->getPlayerManager() | 		if ($this->maniaControl->getPlayerManager()->getPlayerCount(false) <= 0 | ||||||
| 		                       ->getPlayerCount(false) <= 0 |  | ||||||
| 		) { | 		) { | ||||||
| 			return null; | 			return null; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$playerCount    = $this->maniaControl->getPlayerManager() | 		$playerCount    = $this->maniaControl->getPlayerManager()->getPlayerCount(); | ||||||
| 		                                     ->getPlayerCount(); | 		$spectatorCount = $this->maniaControl->getPlayerManager()->getSpectatorCount(); | ||||||
| 		$spectatorCount = $this->maniaControl->getPlayerManager() |  | ||||||
| 		                                     ->getSpectatorCount(); |  | ||||||
|  |  | ||||||
| 		return array('SrvName' => $server->name, 'Comment' => $server->comment, 'Private' => (strlen($server->password) > 0), 'NumPlayers' => $playerCount, 'MaxPlayers' => $server->currentMaxPlayers, 'NumSpecs' => $spectatorCount, 'MaxSpecs' => $server->currentMaxSpectators); | 		return array('SrvName' => $server->name, 'Comment' => $server->comment, 'Private' => (strlen($server->password) > 0), 'NumPlayers' => $playerCount, 'MaxPlayers' => $server->currentMaxPlayers, 'NumSpecs' => $spectatorCount, 'MaxSpecs' => $server->currentMaxSpectators); | ||||||
| 	} | 	} | ||||||
| @@ -393,8 +361,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 	 * Build simple player list for callbacks | 	 * Build simple player list for callbacks | ||||||
| 	 */ | 	 */ | ||||||
| 	private function getPlayerList() { | 	private function getPlayerList() { | ||||||
| 		$players = $this->maniaControl->getPlayerManager() | 		$players = $this->maniaControl->getPlayerManager()->getPlayers(); | ||||||
| 		                              ->getPlayers(); |  | ||||||
|  |  | ||||||
| 		if (empty($players)) { | 		if (empty($players)) { | ||||||
| 			return null; | 			return null; | ||||||
| @@ -412,8 +379,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 	 * @return array | 	 * @return array | ||||||
| 	 */ | 	 */ | ||||||
| 	private function getMapInfo() { | 	private function getMapInfo() { | ||||||
| 		$map = $this->maniaControl->getMapManager() | 		$map = $this->maniaControl->getMapManager()->getCurrentMap(); | ||||||
| 		                          ->getCurrentMap(); |  | ||||||
| 		if (!$map) { | 		if (!$map) { | ||||||
| 			return null; | 			return null; | ||||||
| 		} | 		} | ||||||
| @@ -433,8 +399,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 	 * @return String | 	 * @return String | ||||||
| 	 */ | 	 */ | ||||||
| 	private function getGameModeString() { | 	private function getGameModeString() { | ||||||
| 		$gameMode = $this->maniaControl->getServer() | 		$gameMode = $this->maniaControl->getServer()->getGameMode(); | ||||||
| 		                               ->getGameMode(); |  | ||||||
| 		if ($gameMode === null) { | 		if ($gameMode === null) { | ||||||
| 			Logger::logError("Couldn't retrieve game mode."); | 			Logger::logError("Couldn't retrieve game mode."); | ||||||
| 			return null; | 			return null; | ||||||
| @@ -442,8 +407,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 		switch ($gameMode) { | 		switch ($gameMode) { | ||||||
| 			case 0: | 			case 0: | ||||||
| 			{ | 			{ | ||||||
| 				$scriptNameResponse = $this->maniaControl->getClient() | 				$scriptNameResponse = $this->maniaControl->getClient()->getScriptName(); | ||||||
| 				                                         ->getScriptName(); |  | ||||||
| 				$scriptName         = str_replace('.Script.txt', '', $scriptNameResponse['CurrentValue']); | 				$scriptName         = str_replace('.Script.txt', '', $scriptNameResponse['CurrentValue']); | ||||||
| 				switch ($scriptName) { | 				switch ($scriptName) { | ||||||
| 					case 'Rounds': | 					case 'Rounds': | ||||||
| @@ -487,12 +451,10 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 			var_dump("Dedimania Debug: Update Manialink"); | 			var_dump("Dedimania Debug: Update Manialink"); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if ($this->maniaControl->getSettingManager() | 		if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_ENABLE) | ||||||
| 		                       ->getSettingValue($this, self::SETTING_WIDGET_ENABLE) |  | ||||||
| 		) { | 		) { | ||||||
| 			$manialink = $this->buildManialink(); | 			$manialink = $this->buildManialink(); | ||||||
| 			$this->maniaControl->getManialinkManager() | 			$this->maniaControl->getManialinkManager()->sendManialink($manialink); | ||||||
| 			                   ->sendManialink($manialink); |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -504,27 +466,15 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 	private function buildManialink() { | 	private function buildManialink() { | ||||||
| 		$records = $this->dedimaniaData->records; | 		$records = $this->dedimaniaData->records; | ||||||
|  |  | ||||||
| 		$title        = $this->maniaControl->getSettingManager() | 		$title        = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_TITLE); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_WIDGET_TITLE); | 		$posX         = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_POSX); | ||||||
| 		$posX         = $this->maniaControl->getSettingManager() | 		$posY         = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_POSY); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_WIDGET_POSX); | 		$width        = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_WIDTH); | ||||||
| 		$posY         = $this->maniaControl->getSettingManager() | 		$lines        = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_LINE_COUNT); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_WIDGET_POSY); | 		$lineHeight   = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_LINE_HEIGHT); | ||||||
| 		$width        = $this->maniaControl->getSettingManager() | 		$labelStyle   = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultLabelStyle(); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_WIDGET_WIDTH); | 		$quadStyle    = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle(); | ||||||
| 		$lines        = $this->maniaControl->getSettingManager() | 		$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle(); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_WIDGET_LINE_COUNT); |  | ||||||
| 		$lineHeight   = $this->maniaControl->getSettingManager() |  | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_WIDGET_LINE_HEIGHT); |  | ||||||
| 		$labelStyle   = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                   ->getStyleManager() |  | ||||||
| 		                                   ->getDefaultLabelStyle(); |  | ||||||
| 		$quadStyle    = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                   ->getStyleManager() |  | ||||||
| 		                                   ->getDefaultQuadStyle(); |  | ||||||
| 		$quadSubstyle = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                   ->getStyleManager() |  | ||||||
| 		                                   ->getDefaultQuadSubstyle(); |  | ||||||
|  |  | ||||||
|  |  | ||||||
| 		$manialink = new ManiaLink(self::MLID_DEDIMANIA); | 		$manialink = new ManiaLink(self::MLID_DEDIMANIA); | ||||||
| @@ -622,35 +572,34 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 		$content = $this->encode_request(self::DEDIMANIA_CHECK_SESSION, array($this->dedimaniaData->sessionId)); | 		$content = $this->encode_request(self::DEDIMANIA_CHECK_SESSION, array($this->dedimaniaData->sessionId)); | ||||||
| 		//var_dump("check session"); //TODO remove | 		//var_dump("check session"); //TODO remove | ||||||
| 		//$this->maniaControl->fileReader->postDataTest($this->request, self::DEDIMANIA_URL, function ($data, $error) { | 		//$this->maniaControl->fileReader->postDataTest($this->request, self::DEDIMANIA_URL, function ($data, $error) { | ||||||
| 		$this->maniaControl->getFileReader() | 		$this->maniaControl->getFileReader()->postData(self::DEDIMANIA_URL, function ($data, $error) { | ||||||
| 		                   ->postData(self::DEDIMANIA_URL, function ($data, $error) { | 			                                    if ($error) { | ||||||
| 			if ($error) { | 				                                    Logger::logError("Dedimania Error: " . $error); | ||||||
| 				Logger::logError("Dedimania Error: " . $error); | 			                                    } | ||||||
| 			} |  | ||||||
|  |  | ||||||
| 			$data = $this->decode($data); | 			                                    $data = $this->decode($data); | ||||||
| 			if (!is_array($data) || empty($data)) { | 			                                    if (!is_array($data) || empty($data)) { | ||||||
| 				return; | 				                                    return; | ||||||
| 			} | 			                                    } | ||||||
|  |  | ||||||
| 			$methodResponse = $data[0]; | 			                                    $methodResponse = $data[0]; | ||||||
| 			if (xmlrpc_is_fault($methodResponse)) { | 			                                    if (xmlrpc_is_fault($methodResponse)) { | ||||||
| 				$this->handleXmlRpcFault($methodResponse, self::DEDIMANIA_CHECK_SESSION); | 				                                    $this->handleXmlRpcFault($methodResponse, self::DEDIMANIA_CHECK_SESSION); | ||||||
| 				return; | 				                                    return; | ||||||
| 			} | 			                                    } | ||||||
|  |  | ||||||
| 			$responseData = $methodResponse[0]; | 			                                    $responseData = $methodResponse[0]; | ||||||
| 			if (is_bool($responseData)) { | 			                                    if (is_bool($responseData)) { | ||||||
| 				if (!$responseData) { | 				                                    if (!$responseData) { | ||||||
| 					$this->openDedimaniaSession(); | 					                                    $this->openDedimaniaSession(); | ||||||
| 				} | 				                                    } | ||||||
| 			} | 			                                    } | ||||||
|  |  | ||||||
| 			if (self::DEDIMANIA_DEBUG) { | 			                                    if (self::DEDIMANIA_DEBUG) { | ||||||
| 				var_dump("Dedi Debug: Session Check ResponseData "); | 				                                    var_dump("Dedi Debug: Session Check ResponseData "); | ||||||
| 				var_dump($responseData); | 				                                    var_dump($responseData); | ||||||
| 			} | 			                                    } | ||||||
| 		}, $content, true); | 		                                    }, $content, true); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -667,42 +616,38 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 		$data    = array($this->dedimaniaData->sessionId, $player->login, $player->rawNickname, $player->path, $player->isSpectator); | 		$data    = array($this->dedimaniaData->sessionId, $player->login, $player->rawNickname, $player->path, $player->isSpectator); | ||||||
| 		$content = $this->encode_request(self::DEDIMANIA_PLAYERCONNECT, $data); | 		$content = $this->encode_request(self::DEDIMANIA_PLAYERCONNECT, $data); | ||||||
|  |  | ||||||
| 		$this->maniaControl->getFileReader() | 		$this->maniaControl->getFileReader()->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$player) { | ||||||
| 		                   ->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$player) { | 			                                    if ($error) { | ||||||
| 			if ($error) { | 				                                    Logger::logError("Dedimania Error: " . $error); | ||||||
| 				Logger::logError("Dedimania Error: " . $error); | 			                                    } | ||||||
| 			} |  | ||||||
|  |  | ||||||
| 			$data = $this->decode($data); | 			                                    $data = $this->decode($data); | ||||||
| 			if (!is_array($data) || empty($data)) { | 			                                    if (!is_array($data) || empty($data)) { | ||||||
| 				return; | 				                                    return; | ||||||
| 			} | 			                                    } | ||||||
|  |  | ||||||
| 			$methodResponse = $data[0]; | 			                                    $methodResponse = $data[0]; | ||||||
| 			if (xmlrpc_is_fault($methodResponse)) { | 			                                    if (xmlrpc_is_fault($methodResponse)) { | ||||||
| 				$this->handleXmlRpcFault($methodResponse, self::DEDIMANIA_PLAYERCONNECT); | 				                                    $this->handleXmlRpcFault($methodResponse, self::DEDIMANIA_PLAYERCONNECT); | ||||||
| 				return; | 				                                    return; | ||||||
| 			} | 			                                    } | ||||||
|  |  | ||||||
| 			$responseData = $methodResponse[0]; | 			                                    $responseData = $methodResponse[0]; | ||||||
| 			$dediPlayer   = new DedimaniaPlayer($responseData); | 			                                    $dediPlayer   = new DedimaniaPlayer($responseData); | ||||||
| 			$this->dedimaniaData->addPlayer($dediPlayer); | 			                                    $this->dedimaniaData->addPlayer($dediPlayer); | ||||||
|  |  | ||||||
| 			// Fetch records if he is the first who joined the server | 			                                    // Fetch records if he is the first who joined the server | ||||||
| 			if ($this->maniaControl->getPlayerManager() | 			                                    if ($this->maniaControl->getPlayerManager()->getPlayerCount(false) === 1 | ||||||
| 			                       ->getPlayerCount(false) === 1 | 			                                    ) { | ||||||
| 			) { | 				                                    $this->fetchDedimaniaRecords(true); | ||||||
| 				$this->fetchDedimaniaRecords(true); | 			                                    } | ||||||
| 			} |  | ||||||
|  |  | ||||||
| 			if ($this->maniaControl->getSettingManager() | 			                                    if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_ENABLE) | ||||||
| 			                       ->getSettingValue($this, self::SETTING_WIDGET_ENABLE) | 			                                    ) { | ||||||
| 			) { | 				                                    $manialink = $this->buildManialink(); | ||||||
| 				$manialink = $this->buildManialink(); | 				                                    $this->maniaControl->getManialinkManager()->sendManialink($manialink, $player->login); | ||||||
| 				$this->maniaControl->getManialinkManager() | 			                                    } | ||||||
| 				                   ->sendManialink($manialink, $player->login); | 		                                    }, $content, true); | ||||||
| 			} |  | ||||||
| 		}, $content, true); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -720,22 +665,21 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 		$data    = array($this->dedimaniaData->sessionId, $player->login, ''); | 		$data    = array($this->dedimaniaData->sessionId, $player->login, ''); | ||||||
| 		$content = $this->encode_request(self::DEDIMANIA_PLAYERDISCONNECT, $data); | 		$content = $this->encode_request(self::DEDIMANIA_PLAYERDISCONNECT, $data); | ||||||
|  |  | ||||||
| 		$this->maniaControl->getFileReader() | 		$this->maniaControl->getFileReader()->postData(self::DEDIMANIA_URL, function ($data, $error) { | ||||||
| 		                   ->postData(self::DEDIMANIA_URL, function ($data, $error) { | 			                                    if ($error) { | ||||||
| 			if ($error) { | 				                                    Logger::logError("Dedimania Error: " . $error); | ||||||
| 				Logger::logError("Dedimania Error: " . $error); | 			                                    } | ||||||
| 			} |  | ||||||
|  |  | ||||||
| 			$data = $this->decode($data); | 			                                    $data = $this->decode($data); | ||||||
| 			if (!is_array($data) || empty($data)) { | 			                                    if (!is_array($data) || empty($data)) { | ||||||
| 				return; | 				                                    return; | ||||||
| 			} | 			                                    } | ||||||
|  |  | ||||||
| 			$methodResponse = $data[0]; | 			                                    $methodResponse = $data[0]; | ||||||
| 			if (xmlrpc_is_fault($methodResponse)) { | 			                                    if (xmlrpc_is_fault($methodResponse)) { | ||||||
| 				$this->handleXmlRpcFault($methodResponse, self::DEDIMANIA_PLAYERDISCONNECT); | 				                                    $this->handleXmlRpcFault($methodResponse, self::DEDIMANIA_PLAYERDISCONNECT); | ||||||
| 			} | 			                                    } | ||||||
| 		}, $content, true); | 		                                    }, $content, true); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -791,40 +735,39 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 			var_dump("Dedimania Debug: Submitting Times at End-Map", $content); | 			var_dump("Dedimania Debug: Submitting Times at End-Map", $content); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$this->maniaControl->getFileReader() | 		$this->maniaControl->getFileReader()->postData(self::DEDIMANIA_URL, function ($data, $error) { | ||||||
| 		                   ->postData(self::DEDIMANIA_URL, function ($data, $error) { | 			                                    if ($error) { | ||||||
| 			if ($error) { | 				                                    Logger::logError("Dedimania Error: " . $error); | ||||||
| 				Logger::logError("Dedimania Error: " . $error); | 			                                    } | ||||||
| 			} |  | ||||||
|  |  | ||||||
| 			if (self::DEDIMANIA_DEBUG) { | 			                                    if (self::DEDIMANIA_DEBUG) { | ||||||
| 				var_dump("Dedimania Debug: Submit Data Response"); | 				                                    var_dump("Dedimania Debug: Submit Data Response"); | ||||||
| 				var_dump($data); | 				                                    var_dump($data); | ||||||
| 			} | 			                                    } | ||||||
|  |  | ||||||
| 			$data = $this->decode($data); | 			                                    $data = $this->decode($data); | ||||||
| 			if (!is_array($data) || empty($data)) { | 			                                    if (!is_array($data) || empty($data)) { | ||||||
| 				return; | 				                                    return; | ||||||
| 			} | 			                                    } | ||||||
|  |  | ||||||
| 			$methodResponse = $data[0]; | 			                                    $methodResponse = $data[0]; | ||||||
| 			if (xmlrpc_is_fault($methodResponse)) { | 			                                    if (xmlrpc_is_fault($methodResponse)) { | ||||||
| 				$this->handleXmlRpcFault($methodResponse, self::DEDIMANIA_SET_CHALLENGE_TIMES); | 				                                    $this->handleXmlRpcFault($methodResponse, self::DEDIMANIA_SET_CHALLENGE_TIMES); | ||||||
| 				return; | 				                                    return; | ||||||
| 			} | 			                                    } | ||||||
|  |  | ||||||
| 			// Called method response | 			                                    // Called method response | ||||||
| 			if (!$methodResponse[0]) { | 			                                    if (!$methodResponse[0]) { | ||||||
| 				Logger::logError("Records Plugin: Submitting dedimania records failed."); | 				                                    Logger::logError("Records Plugin: Submitting dedimania records failed."); | ||||||
| 			} | 			                                    } | ||||||
|  |  | ||||||
| 			if (self::DEDIMANIA_DEBUG) { | 			                                    if (self::DEDIMANIA_DEBUG) { | ||||||
| 				var_dump("Dedimania Debug: endMap response"); | 				                                    var_dump("Dedimania Debug: endMap response"); | ||||||
| 				var_dump($methodResponse); | 				                                    var_dump($methodResponse); | ||||||
| 				var_dump("Dedimania Data"); | 				                                    var_dump("Dedimania Data"); | ||||||
| 				var_dump($this->dedimaniaData); | 				                                    var_dump($this->dedimaniaData); | ||||||
| 			} | 			                                    } | ||||||
| 		}, $content, false); | 		                                    }, $content, false); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -842,30 +785,28 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 		$data    = array($this->dedimaniaData->sessionId, $serverInfo, $votesInfo, $playerList); | 		$data    = array($this->dedimaniaData->sessionId, $serverInfo, $votesInfo, $playerList); | ||||||
| 		$content = $this->encode_request(self::DEDIMANIA_UPDATE_SERVER_PLAYERS, $data); | 		$content = $this->encode_request(self::DEDIMANIA_UPDATE_SERVER_PLAYERS, $data); | ||||||
|  |  | ||||||
| 		$this->maniaControl->getFileReader() | 		$this->maniaControl->getFileReader()->postData(self::DEDIMANIA_URL, function ($data, $error) { | ||||||
| 		                   ->postData(self::DEDIMANIA_URL, function ($data, $error) { | 			                                    if ($error) { | ||||||
| 			if ($error) { | 				                                    Logger::logError("Dedimania Error: " . $error); | ||||||
| 				Logger::logError("Dedimania Error: " . $error); | 			                                    } | ||||||
| 			} |  | ||||||
|  |  | ||||||
| 			$data = $this->decode($data); | 			                                    $data = $this->decode($data); | ||||||
| 			if (!is_array($data) || empty($data)) { | 			                                    if (!is_array($data) || empty($data)) { | ||||||
| 				return; | 				                                    return; | ||||||
| 			} | 			                                    } | ||||||
|  |  | ||||||
| 			$methodResponse = $data[0]; | 			                                    $methodResponse = $data[0]; | ||||||
| 			if (xmlrpc_is_fault($methodResponse)) { | 			                                    if (xmlrpc_is_fault($methodResponse)) { | ||||||
| 				$this->handleXmlRpcFault($methodResponse, self::DEDIMANIA_UPDATE_SERVER_PLAYERS); | 				                                    $this->handleXmlRpcFault($methodResponse, self::DEDIMANIA_UPDATE_SERVER_PLAYERS); | ||||||
| 			} | 			                                    } | ||||||
| 		}, $content, true); | 		                                    }, $content, true); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * Build Votes Info Array for Callbacks | 	 * Build Votes Info Array for Callbacks | ||||||
| 	 */ | 	 */ | ||||||
| 	private function getVotesInfo() { | 	private function getVotesInfo() { | ||||||
| 		$map = $this->maniaControl->getMapManager() | 		$map = $this->maniaControl->getMapManager()->getCurrentMap(); | ||||||
| 		                          ->getCurrentMap(); |  | ||||||
| 		if (!$map) { | 		if (!$map) { | ||||||
| 			return null; | 			return null; | ||||||
| 		} | 		} | ||||||
| @@ -919,8 +860,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$map = $this->maniaControl->getMapManager() | 		$map = $this->maniaControl->getMapManager()->getCurrentMap(); | ||||||
| 		                          ->getCurrentMap(); |  | ||||||
| 		if (!$map) { | 		if (!$map) { | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| @@ -940,8 +880,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 					break; | 					break; | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 				$this->maniaControl->getCallbackManager() | 				$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_DEDIMANIA_CHANGED, $newRecord); | ||||||
| 				                   ->triggerCallback(self::CB_DEDIMANIA_CHANGED, $newRecord); |  | ||||||
|  |  | ||||||
| 				// Announce record | 				// Announce record | ||||||
| 				if ($oldRecord->nullRecord || $newRecord->rank < $oldRecord->rank) { | 				if ($oldRecord->nullRecord || $newRecord->rank < $oldRecord->rank) { | ||||||
| @@ -955,8 +894,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 				if (!$oldRecord->nullRecord) { | 				if (!$oldRecord->nullRecord) { | ||||||
| 					$message .= ' ($<$ff0' . $oldRecord->rank . '.$> $<$fff-' . Formatter::formatTime(($oldRecord->best - $callback->lapTime)) . '$>)'; | 					$message .= ' ($<$ff0' . $oldRecord->rank . '.$> $<$fff-' . Formatter::formatTime(($oldRecord->best - $callback->lapTime)) . '$>)'; | ||||||
| 				} | 				} | ||||||
| 				$this->maniaControl->getChat() | 				$this->maniaControl->getChat()->sendInformation($message . '!'); | ||||||
| 				                   ->sendInformation($message . '!'); |  | ||||||
|  |  | ||||||
| 				$this->updateManialink = true; | 				$this->updateManialink = true; | ||||||
| 			} | 			} | ||||||
| @@ -1092,8 +1030,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 	 */ | 	 */ | ||||||
| 	private function updateDedimaniaRecordRanks() { | 	private function updateDedimaniaRecordRanks() { | ||||||
| 		if ($this->dedimaniaData->getRecordCount() === 0) { | 		if ($this->dedimaniaData->getRecordCount() === 0) { | ||||||
| 			$this->maniaControl->getCallbackManager() | 			$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_DEDIMANIA_UPDATED, $this->dedimaniaData->records); | ||||||
| 			                   ->triggerCallback(self::CB_DEDIMANIA_UPDATED, $this->dedimaniaData->records); |  | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @@ -1105,8 +1042,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 			$record->rank = $rank; | 			$record->rank = $rank; | ||||||
| 			$rank++; | 			$rank++; | ||||||
| 		} | 		} | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_DEDIMANIA_UPDATED, $this->dedimaniaData->records); | ||||||
| 		                   ->triggerCallback(self::CB_DEDIMANIA_UPDATED, $this->dedimaniaData->records); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -1116,28 +1052,23 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 	 */ | 	 */ | ||||||
| 	private function setRecordReplays(RecordData &$record) { | 	private function setRecordReplays(RecordData &$record) { | ||||||
| 		// Set validation replay | 		// Set validation replay | ||||||
| 		$validationReplay = $this->maniaControl->getServer() | 		$validationReplay = $this->maniaControl->getServer()->getValidationReplay($record->login); | ||||||
| 		                                       ->getValidationReplay($record->login); |  | ||||||
| 		if ($validationReplay) { | 		if ($validationReplay) { | ||||||
| 			$record->vReplay = $validationReplay; | 			$record->vReplay = $validationReplay; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Set ghost replay | 		// Set ghost replay | ||||||
| 		if ($record->rank <= 1) { | 		if ($record->rank <= 1) { | ||||||
| 			$dataDirectory = $this->maniaControl->getServer() | 			$dataDirectory = $this->maniaControl->getServer()->getDirectory()->getGameDataFolder(); | ||||||
| 			                                    ->getDirectory() |  | ||||||
| 			                                    ->getGameDataFolder(); |  | ||||||
| 			if (!isset($this->dedimaniaData->directoryAccessChecked)) { | 			if (!isset($this->dedimaniaData->directoryAccessChecked)) { | ||||||
| 				$access = $this->maniaControl->getServer() | 				$access = $this->maniaControl->getServer()->checkAccess($dataDirectory); | ||||||
| 				                             ->checkAccess($dataDirectory); |  | ||||||
| 				if (!$access) { | 				if (!$access) { | ||||||
| 					trigger_error("No access to the servers data directory. Can't retrieve ghost replays."); | 					trigger_error("No access to the servers data directory. Can't retrieve ghost replays."); | ||||||
| 				} | 				} | ||||||
| 				$this->dedimaniaData->directoryAccessChecked = $access; | 				$this->dedimaniaData->directoryAccessChecked = $access; | ||||||
| 			} | 			} | ||||||
| 			if ($this->dedimaniaData->directoryAccessChecked) { | 			if ($this->dedimaniaData->directoryAccessChecked) { | ||||||
| 				$ghostReplay = $this->maniaControl->getServer() | 				$ghostReplay = $this->maniaControl->getServer()->getGhostReplay($record->login); | ||||||
| 				                                  ->getGhostReplay($record->login); |  | ||||||
| 				if ($ghostReplay) { | 				if ($ghostReplay) { | ||||||
| 					$record->top1GReplay = $ghostReplay; | 					$record->top1GReplay = $ghostReplay; | ||||||
| 				} | 				} | ||||||
| @@ -1154,8 +1085,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 		$actionId = $callback[1][2]; | 		$actionId = $callback[1][2]; | ||||||
|  |  | ||||||
| 		$login  = $callback[1][1]; | 		$login  = $callback[1][1]; | ||||||
| 		$player = $this->maniaControl->getPlayerManager() | 		$player = $this->maniaControl->getPlayerManager()->getPlayer($login); | ||||||
| 		                             ->getPlayer($login); |  | ||||||
|  |  | ||||||
| 		if ($actionId === self::ACTION_SHOW_DEDIRECORDSLIST) { | 		if ($actionId === self::ACTION_SHOW_DEDIRECORDSLIST) { | ||||||
| 			$this->showDediRecordsList(array(), $player); | 			$this->showDediRecordsList(array(), $player); | ||||||
| @@ -1169,18 +1099,13 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 	 * @param Player $player | 	 * @param Player $player | ||||||
| 	 */ | 	 */ | ||||||
| 	public function showDediRecordsList(array $chat, Player $player) { | 	public function showDediRecordsList(array $chat, Player $player) { | ||||||
| 		$width  = $this->maniaControl->getManialinkManager() | 		$width  = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth(); | ||||||
| 		                             ->getStyleManager() | 		$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight(); | ||||||
| 		                             ->getListWidgetsWidth(); |  | ||||||
| 		$height = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                             ->getStyleManager() |  | ||||||
| 		                             ->getListWidgetsHeight(); |  | ||||||
|  |  | ||||||
| 		// get PlayerList | 		// get PlayerList | ||||||
| 		$records = $this->dedimaniaData->records; | 		$records = $this->dedimaniaData->records; | ||||||
| 		if (!$records) { | 		if (!$records) { | ||||||
| 			$this->maniaControl->getChat() | 			$this->maniaControl->getChat()->sendInformation('There are no Dedimania records on this map!'); | ||||||
| 			                   ->sendInformation('There are no Dedimania records on this map!'); |  | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @@ -1191,9 +1116,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 		$script->addFeature($paging); | 		$script->addFeature($paging); | ||||||
|  |  | ||||||
| 		// Main frame | 		// Main frame | ||||||
| 		$frame = $this->maniaControl->getManialinkManager() | 		$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging); | ||||||
| 		                            ->getStyleManager() |  | ||||||
| 		                            ->getDefaultListFrame($script, $paging); |  | ||||||
| 		$maniaLink->add($frame); | 		$maniaLink->add($frame); | ||||||
|  |  | ||||||
| 		// Start offsets | 		// Start offsets | ||||||
| @@ -1201,9 +1124,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 		$posY = $height / 2; | 		$posY = $height / 2; | ||||||
|  |  | ||||||
| 		// Predefine Description Label | 		// Predefine Description Label | ||||||
| 		$descriptionLabel = $this->maniaControl->getManialinkManager() | 		$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel(); | ||||||
| 		                                       ->getStyleManager() |  | ||||||
| 		                                       ->getDefaultDescriptionLabel(); |  | ||||||
| 		$frame->add($descriptionLabel); | 		$frame->add($descriptionLabel); | ||||||
|  |  | ||||||
| 		// Headline | 		// Headline | ||||||
| @@ -1211,8 +1132,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 		$frame->add($headFrame); | 		$frame->add($headFrame); | ||||||
| 		$headFrame->setY($posY - 5); | 		$headFrame->setY($posY - 5); | ||||||
| 		$array = array('Rank' => $posX + 5, 'Nickname' => $posX + 18, 'Login' => $posX + 70, 'Time' => $posX + 101); | 		$array = array('Rank' => $posX + 5, 'Nickname' => $posX + 18, 'Login' => $posX + 70, 'Time' => $posX + 101); | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->labelLine($headFrame, $array); | ||||||
| 		                   ->labelLine($headFrame, $array); |  | ||||||
|  |  | ||||||
| 		$index     = 0; | 		$index     = 0; | ||||||
| 		$posY      = $height / 2 - 10; | 		$posY      = $height / 2 - 10; | ||||||
| @@ -1241,8 +1161,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 				$listRecord->nickName = $listRecord->login; | 				$listRecord->nickName = $listRecord->login; | ||||||
| 			} | 			} | ||||||
| 			$array = array($listRecord->rank => $posX + 5, '$fff' . $listRecord->nickName => $posX + 18, $listRecord->login => $posX + 70, Formatter::formatTime($listRecord->best) => $posX + 101); | 			$array = array($listRecord->rank => $posX + 5, '$fff' . $listRecord->nickName => $posX + 18, $listRecord->login => $posX + 70, Formatter::formatTime($listRecord->best) => $posX + 101); | ||||||
| 			$this->maniaControl->getManialinkManager() | 			$this->maniaControl->getManialinkManager()->labelLine($recordFrame, $array); | ||||||
| 			                   ->labelLine($recordFrame, $array); |  | ||||||
|  |  | ||||||
| 			$recordFrame->setY($posY); | 			$recordFrame->setY($posY); | ||||||
|  |  | ||||||
| @@ -1251,8 +1170,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Render and display xml | 		// Render and display xml | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'DediRecordsList'); | ||||||
| 		                   ->displayWidget($maniaLink, $player, 'DediRecordsList'); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
|   | |||||||
| @@ -104,44 +104,28 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { | |||||||
| 		$this->maniaControl = $maniaControl; | 		$this->maniaControl = $maniaControl; | ||||||
|  |  | ||||||
| 		// Register for commands | 		// Register for commands | ||||||
| 		$this->maniaControl->getCommandManager() | 		$this->maniaControl->getCommandManager()->registerCommandListener('donate', $this, 'command_Donate', false, 'Donate some planets to the server.'); | ||||||
| 		                   ->registerCommandListener('donate', $this, 'command_Donate', false, 'Donate some planets to the server.'); | 		$this->maniaControl->getCommandManager()->registerCommandListener('pay', $this, 'command_Pay', true, 'Pays planets from the server to a player.'); | ||||||
| 		$this->maniaControl->getCommandManager() | 		$this->maniaControl->getCommandManager()->registerCommandListener(array('getplanets', 'planets'), $this, 'command_GetPlanets', true, 'Checks the planets-balance of the server.'); | ||||||
| 		                   ->registerCommandListener('pay', $this, 'command_Pay', true, 'Pays planets from the server to a player.'); | 		$this->maniaControl->getCommandManager()->registerCommandListener('topdons', $this, 'command_TopDons', false, 'Provides an overview of who donated the most planets.'); | ||||||
| 		$this->maniaControl->getCommandManager() |  | ||||||
| 		                   ->registerCommandListener(array('getplanets', 'planets'), $this, 'command_GetPlanets', true, 'Checks the planets-balance of the server.'); |  | ||||||
| 		$this->maniaControl->getCommandManager() |  | ||||||
| 		                   ->registerCommandListener('topdons', $this, 'command_TopDons', false, 'Provides an overview of who donated the most planets.'); |  | ||||||
|  |  | ||||||
| 		// Register for callbacks | 		// Register for callbacks | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); | ||||||
| 		                   ->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer'); | ||||||
| 		$this->maniaControl->getCallbackManager() |  | ||||||
| 		                   ->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer'); |  | ||||||
|  |  | ||||||
| 		// Define player stats | 		// Define player stats | ||||||
| 		$this->maniaControl->getStatisticManager() | 		$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_PLAYER_DONATIONS); | ||||||
| 		                   ->defineStatMetaData(self::STAT_PLAYER_DONATIONS); |  | ||||||
|  |  | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_DONATE_WIDGET_ACTIVATED, true); | ||||||
| 		                   ->initSetting($this, self::SETTING_DONATE_WIDGET_ACTIVATED, true); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_DONATE_WIDGET_POSX, 156.); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_DONATE_WIDGET_POSY, -31.4); | ||||||
| 		                   ->initSetting($this, self::SETTING_DONATE_WIDGET_POSX, 156.); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_DONATE_WIDGET_WIDTH, 6); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_DONATE_WIDGET_HEIGHT, 6); | ||||||
| 		                   ->initSetting($this, self::SETTING_DONATE_WIDGET_POSY, -31.4); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_DONATION_VALUES, "20,50,100,500,1000,2000"); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MIN_AMOUNT_SHOWN, 100); | ||||||
| 		                   ->initSetting($this, self::SETTING_DONATE_WIDGET_WIDTH, 6); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_DONATE_WIDGET_HEIGHT, 6); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_DONATION_VALUES, "20,50,100,500,1000,2000"); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_MIN_AMOUNT_SHOWN, 100); |  | ||||||
|  |  | ||||||
| 		// Register Stat in Simple StatsList | 		// Register Stat in Simple StatsList | ||||||
| 		$this->maniaControl->getStatisticManager() | 		$this->maniaControl->getStatisticManager()->getSimpleStatsList()->registerStat(self::STAT_PLAYER_DONATIONS, 90, "DP", 15); | ||||||
| 		                   ->getSimpleStatsList() |  | ||||||
| 		                   ->registerStat(self::STAT_PLAYER_DONATIONS, 90, "DP", 15); |  | ||||||
|  |  | ||||||
| 		$this->displayWidget(); | 		$this->displayWidget(); | ||||||
| 		return true; | 		return true; | ||||||
| @@ -151,8 +135,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { | |||||||
| 	 * Display the widget | 	 * Display the widget | ||||||
| 	 */ | 	 */ | ||||||
| 	public function displayWidget() { | 	public function displayWidget() { | ||||||
| 		if ($this->maniaControl->getSettingManager() | 		if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DONATE_WIDGET_ACTIVATED) | ||||||
| 		                       ->getSettingValue($this, self::SETTING_DONATE_WIDGET_ACTIVATED) |  | ||||||
| 		) { | 		) { | ||||||
| 			$this->displayDonateWidget(); | 			$this->displayDonateWidget(); | ||||||
| 		} | 		} | ||||||
| @@ -164,32 +147,19 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { | |||||||
| 	 * @param string $login | 	 * @param string $login | ||||||
| 	 */ | 	 */ | ||||||
| 	public function displayDonateWidget($login = null) { | 	public function displayDonateWidget($login = null) { | ||||||
| 		$posX              = $this->maniaControl->getSettingManager() | 		$posX              = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DONATE_WIDGET_POSX); | ||||||
| 		                                        ->getSettingValue($this, self::SETTING_DONATE_WIDGET_POSX); | 		$posY              = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DONATE_WIDGET_POSY); | ||||||
| 		$posY              = $this->maniaControl->getSettingManager() | 		$width             = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DONATE_WIDGET_WIDTH); | ||||||
| 		                                        ->getSettingValue($this, self::SETTING_DONATE_WIDGET_POSY); | 		$height            = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DONATE_WIDGET_HEIGHT); | ||||||
| 		$width             = $this->maniaControl->getSettingManager() | 		$values            = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DONATION_VALUES); | ||||||
| 		                                        ->getSettingValue($this, self::SETTING_DONATE_WIDGET_WIDTH); | 		$shootManiaOffset  = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultIconOffsetSM(); | ||||||
| 		$height            = $this->maniaControl->getSettingManager() | 		$quadStyle         = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle(); | ||||||
| 		                                        ->getSettingValue($this, self::SETTING_DONATE_WIDGET_HEIGHT); | 		$quadSubstyle      = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle(); | ||||||
| 		$values            = $this->maniaControl->getSettingManager() |  | ||||||
| 		                                        ->getSettingValue($this, self::SETTING_DONATION_VALUES); |  | ||||||
| 		$shootManiaOffset  = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                        ->getStyleManager() |  | ||||||
| 		                                        ->getDefaultIconOffsetSM(); |  | ||||||
| 		$quadStyle         = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                        ->getStyleManager() |  | ||||||
| 		                                        ->getDefaultQuadStyle(); |  | ||||||
| 		$quadSubstyle      = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                        ->getStyleManager() |  | ||||||
| 		                                        ->getDefaultQuadSubstyle(); |  | ||||||
| 		$itemMarginFactorX = 1.3; | 		$itemMarginFactorX = 1.3; | ||||||
| 		$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->getMapManager() | 		if ($this->maniaControl->getMapManager()->getCurrentMap()->getGame() === 'sm' | ||||||
| 		                       ->getCurrentMap() |  | ||||||
| 		                       ->getGame() === 'sm' |  | ||||||
| 		) { | 		) { | ||||||
| 			$posY -= $shootManiaOffset; | 			$posY -= $shootManiaOffset; | ||||||
| 		} | 		} | ||||||
| @@ -268,16 +238,14 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Send manialink | 		// Send manialink | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->sendManialink($maniaLink, $login); | ||||||
| 		                   ->sendManialink($maniaLink, $login); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * @see \ManiaControl\Plugins\Plugin::unload() | 	 * @see \ManiaControl\Plugins\Plugin::unload() | ||||||
| 	 */ | 	 */ | ||||||
| 	public function unload() { | 	public function unload() { | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->hideManialink(self::MLID_DONATE_WIDGET); | ||||||
| 		                   ->hideManialink(self::MLID_DONATE_WIDGET); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -292,8 +260,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { | |||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 		$login       = $callback[1][1]; | 		$login       = $callback[1][1]; | ||||||
| 		$player      = $this->maniaControl->getPlayerManager() | 		$player      = $this->maniaControl->getPlayerManager()->getPlayer($login); | ||||||
| 		                                  ->getPlayer($login); |  | ||||||
| 		$actionArray = explode(".", $callback[1][2]); | 		$actionArray = explode(".", $callback[1][2]); | ||||||
| 		$this->handleDonation($player, intval($actionArray[2])); | 		$this->handleDonation($player, intval($actionArray[2])); | ||||||
| 	} | 	} | ||||||
| @@ -310,57 +277,47 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { | |||||||
| 		if ($amount > 1000000) { | 		if ($amount > 1000000) { | ||||||
| 			// Prevent too huge donation amounts that would cause xmlrpc parsing errors | 			// Prevent too huge donation amounts that would cause xmlrpc parsing errors | ||||||
| 			$message = "You can only donate 1.000.000 Planets at a time!"; | 			$message = "You can only donate 1.000.000 Planets at a time!"; | ||||||
| 			$this->maniaControl->getChat() | 			$this->maniaControl->getChat()->sendError($message, $player); | ||||||
| 			                   ->sendError($message, $player); |  | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if (!$receiverName) { | 		if (!$receiverName) { | ||||||
| 			$serverName = $this->maniaControl->getClient() | 			$serverName = $this->maniaControl->getClient()->getServerName(); | ||||||
| 			                                 ->getServerName(); |  | ||||||
| 			$message    = 'Donate ' . $amount . ' Planets to $<' . $serverName . '$>?'; | 			$message    = 'Donate ' . $amount . ' Planets to $<' . $serverName . '$>?'; | ||||||
| 		} else { | 		} else { | ||||||
| 			$message = 'Donate ' . $amount . ' Planets to $<' . $receiverName . '$>?'; | 			$message = 'Donate ' . $amount . ' Planets to $<' . $receiverName . '$>?'; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		//Send and Handle the Bill | 		//Send and Handle the Bill | ||||||
| 		$this->maniaControl->getBillManager() | 		$this->maniaControl->getBillManager()->sendBill(function ($data, $status) use (&$player, $amount, $receiver) { | ||||||
| 		                   ->sendBill(function ($data, $status) use (&$player, $amount, $receiver) { | 			                                     switch ($status) { | ||||||
| 			switch ($status) { | 				                                     case BillManager::DONATED_TO_SERVER: | ||||||
| 				case BillManager::DONATED_TO_SERVER: | 					                                     if ($this->maniaControl->getSettingManager()->getSettingValue($this, DonationPlugin::SETTING_ANNOUNCE_SERVER_DONATION, true) | ||||||
| 					if ($this->maniaControl->getSettingManager() | 					                                         && $amount >= $this->maniaControl->getSettingManager()->getSettingValue($this, DonationPlugin::SETTING_MIN_AMOUNT_SHOWN, true) | ||||||
| 					                       ->getSettingValue($this, DonationPlugin::SETTING_ANNOUNCE_SERVER_DONATION, true) | 					                                     ) { | ||||||
| 					    && $amount >= $this->maniaControl->getSettingManager() | 						                                     $login   = null; | ||||||
| 					                                     ->getSettingValue($this, DonationPlugin::SETTING_MIN_AMOUNT_SHOWN, true) | 						                                     $message = $player->getEscapedNickname() . ' donated ' . $amount . ' Planets! Thanks.'; | ||||||
| 					) { | 					                                     } else { | ||||||
| 						$login   = null; | 						                                     $login   = $player->login; | ||||||
| 						$message = $player->getEscapedNickname() . ' donated ' . $amount . ' Planets! Thanks.'; | 						                                     $message = 'Donation successful! Thanks.'; | ||||||
| 					} else { | 					                                     } | ||||||
| 						$login   = $player->login; | 					                                     $this->maniaControl->getChat()->sendSuccess($message, $login); | ||||||
| 						$message = 'Donation successful! Thanks.'; | 					                                     $this->maniaControl->getStatisticManager()->insertStat(DonationPlugin::STAT_PLAYER_DONATIONS, $player, $this->maniaControl->getServer()->index, $amount); | ||||||
| 					} | 					                                     break; | ||||||
| 					$this->maniaControl->getChat() | 				                                     case BillManager::DONATED_TO_RECEIVER: | ||||||
| 					                   ->sendSuccess($message, $login); | 					                                     $message = "Successfully donated {$amount} to '{$receiver}'!"; | ||||||
| 					$this->maniaControl->getStatisticManager() | 					                                     $this->maniaControl->getChat()->sendSuccess($message, $player); | ||||||
| 					                   ->insertStat(DonationPlugin::STAT_PLAYER_DONATIONS, $player, $this->maniaControl->getServer()->index, $amount); | 					                                     break; | ||||||
| 					break; | 				                                     case BillManager::PLAYER_REFUSED_DONATION: | ||||||
| 				case BillManager::DONATED_TO_RECEIVER: | 					                                     $message = 'Transaction cancelled.'; | ||||||
| 					$message = "Successfully donated {$amount} to '{$receiver}'!"; | 					                                     $this->maniaControl->getChat()->sendError($message, $player); | ||||||
| 					$this->maniaControl->getChat() | 					                                     break; | ||||||
| 					                   ->sendSuccess($message, $player); | 				                                     case BillManager::ERROR_WHILE_TRANSACTION: | ||||||
| 					break; | 					                                     $message = $data; | ||||||
| 				case BillManager::PLAYER_REFUSED_DONATION: | 					                                     $this->maniaControl->getChat()->sendError($message, $player); | ||||||
| 					$message = 'Transaction cancelled.'; | 					                                     break; | ||||||
| 					$this->maniaControl->getChat() | 			                                     } | ||||||
| 					                   ->sendError($message, $player); | 		                                     }, $player, $amount, $message); | ||||||
| 					break; |  | ||||||
| 				case BillManager::ERROR_WHILE_TRANSACTION: |  | ||||||
| 					$message = $data; |  | ||||||
| 					$this->maniaControl->getChat() |  | ||||||
| 					                   ->sendError($message, $player); |  | ||||||
| 					break; |  | ||||||
| 			} |  | ||||||
| 		}, $player, $amount, $message); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -370,8 +327,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { | |||||||
| 	 */ | 	 */ | ||||||
| 	public function handlePlayerConnect(Player $player) { | 	public function handlePlayerConnect(Player $player) { | ||||||
| 		// Display Map Widget | 		// Display Map Widget | ||||||
| 		if ($this->maniaControl->getSettingManager() | 		if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DONATE_WIDGET_ACTIVATED) | ||||||
| 		                       ->getSettingValue($this, self::SETTING_DONATE_WIDGET_ACTIVATED) |  | ||||||
| 		) { | 		) { | ||||||
| 			$this->displayDonateWidget($player->login); | 			$this->displayDonateWidget($player->login); | ||||||
| 		} | 		} | ||||||
| @@ -397,13 +353,11 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { | |||||||
| 		} | 		} | ||||||
| 		if (count($params) >= 3) { | 		if (count($params) >= 3) { | ||||||
| 			$receiver       = $params[2]; | 			$receiver       = $params[2]; | ||||||
| 			$receiverPlayer = $this->maniaControl->getPlayerManager() | 			$receiverPlayer = $this->maniaControl->getPlayerManager()->getPlayer($receiver); | ||||||
| 			                                     ->getPlayer($receiver); |  | ||||||
| 			$receiverName   = ($receiverPlayer ? $receiverPlayer->nickname : $receiver); | 			$receiverName   = ($receiverPlayer ? $receiverPlayer->nickname : $receiver); | ||||||
| 		} else { | 		} else { | ||||||
| 			$receiver     = ''; | 			$receiver     = ''; | ||||||
| 			$receiverName = $this->maniaControl->getClient() | 			$receiverName = $this->maniaControl->getClient()->getServerName(); | ||||||
| 			                                   ->getServerName(); |  | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$this->handleDonation($player, $amount, $receiver, $receiverName); | 		$this->handleDonation($player, $amount, $receiver, $receiverName); | ||||||
| @@ -416,8 +370,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { | |||||||
| 	 */ | 	 */ | ||||||
| 	private function sendDonateUsageExample(Player $player) { | 	private function sendDonateUsageExample(Player $player) { | ||||||
| 		$message = "Usage Example: '/donate 100'"; | 		$message = "Usage Example: '/donate 100'"; | ||||||
| 		$this->maniaControl->getChat() | 		$this->maniaControl->getChat()->sendChat($message, $player); | ||||||
| 		                   ->sendChat($message, $player); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -427,11 +380,9 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { | |||||||
| 	 * @param Player $player | 	 * @param Player $player | ||||||
| 	 */ | 	 */ | ||||||
| 	public function command_Pay(array $chatCallback, Player $player) { | 	public function command_Pay(array $chatCallback, Player $player) { | ||||||
| 		if (!$this->maniaControl->getAuthenticationManager() | 		if (!$this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN) | ||||||
| 		                        ->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN) |  | ||||||
| 		) { | 		) { | ||||||
| 			$this->maniaControl->getAuthenticationManager() | 			$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); | ||||||
| 			                   ->sendNotAllowed($player); |  | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 		$text   = $chatCallback[1][2]; | 		$text   = $chatCallback[1][2]; | ||||||
| @@ -450,29 +401,24 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { | |||||||
| 		} else { | 		} else { | ||||||
| 			$receiver = $player->login; | 			$receiver = $player->login; | ||||||
| 		} | 		} | ||||||
| 		$message = 'Payout from $<' . $this->maniaControl->getClient() | 		$message = 'Payout from $<' . $this->maniaControl->getClient()->getServerName() . '$>.'; | ||||||
| 		                                                 ->getServerName() . '$>.'; |  | ||||||
|  |  | ||||||
| 		$this->maniaControl->getBillManager() | 		$this->maniaControl->getBillManager()->sendPlanets(function ($data, $status) use (&$player, $amount, $receiver) { | ||||||
| 		                   ->sendPlanets(function ($data, $status) use (&$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}'!"; | 					                                     $this->maniaControl->getChat()->sendSuccess($message, $player); | ||||||
| 					$this->maniaControl->getChat() | 					                                     break; | ||||||
| 					                   ->sendSuccess($message, $player); | 				                                     case BillManager::PLAYER_REFUSED_DONATION: | ||||||
| 					break; | 					                                     $message = 'Transaction cancelled.'; | ||||||
| 				case BillManager::PLAYER_REFUSED_DONATION: | 					                                     $this->maniaControl->getChat()->sendError($message, $player); | ||||||
| 					$message = 'Transaction cancelled.'; | 					                                     break; | ||||||
| 					$this->maniaControl->getChat() | 				                                     case BillManager::ERROR_WHILE_TRANSACTION: | ||||||
| 					                   ->sendError($message, $player); | 					                                     $message = $data; | ||||||
| 					break; | 					                                     $this->maniaControl->getChat()->sendError($message, $player); | ||||||
| 				case BillManager::ERROR_WHILE_TRANSACTION: | 					                                     break; | ||||||
| 					$message = $data; | 			                                     } | ||||||
| 					$this->maniaControl->getChat() | 		                                     }, $receiver, $amount, $message); | ||||||
| 					                   ->sendError($message, $player); |  | ||||||
| 					break; |  | ||||||
| 			} |  | ||||||
| 		}, $receiver, $amount, $message); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -482,8 +428,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { | |||||||
| 	 */ | 	 */ | ||||||
| 	private function sendPayUsageExample(Player $player) { | 	private function sendPayUsageExample(Player $player) { | ||||||
| 		$message = "Usage Example: '//pay 100 login'"; | 		$message = "Usage Example: '//pay 100 login'"; | ||||||
| 		$this->maniaControl->getChat() | 		$this->maniaControl->getChat()->sendChat($message, $player); | ||||||
| 		                   ->sendChat($message, $player); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -493,18 +438,14 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { | |||||||
| 	 * @param Player $player | 	 * @param Player $player | ||||||
| 	 */ | 	 */ | ||||||
| 	public function command_GetPlanets(array $chatCallback, Player $player) { | 	public function command_GetPlanets(array $chatCallback, Player $player) { | ||||||
| 		if (!$this->maniaControl->getAuthenticationManager() | 		if (!$this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN) | ||||||
| 		                        ->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN) |  | ||||||
| 		) { | 		) { | ||||||
| 			$this->maniaControl->getAuthenticationManager() | 			$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); | ||||||
| 			                   ->sendNotAllowed($player); |  | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 		$planets = $this->maniaControl->getClient() | 		$planets = $this->maniaControl->getClient()->getServerPlanets(); | ||||||
| 		                              ->getServerPlanets(); |  | ||||||
| 		$message = "This Server has {$planets} Planets!"; | 		$message = "This Server has {$planets} Planets!"; | ||||||
| 		$this->maniaControl->getChat() | 		$this->maniaControl->getChat()->sendInformation($message, $player); | ||||||
| 		                   ->sendInformation($message, $player); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -523,15 +464,10 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { | |||||||
| 	 * @param Player $player | 	 * @param Player $player | ||||||
| 	 */ | 	 */ | ||||||
| 	private function showTopDonsList(Player $player) { | 	private function showTopDonsList(Player $player) { | ||||||
| 		$stats = $this->maniaControl->getStatisticManager() | 		$stats = $this->maniaControl->getStatisticManager()->getStatsRanking(self::STAT_PLAYER_DONATIONS); | ||||||
| 		                            ->getStatsRanking(self::STAT_PLAYER_DONATIONS); |  | ||||||
|  |  | ||||||
| 		$width  = $this->maniaControl->getManialinkManager() | 		$width  = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth(); | ||||||
| 		                             ->getStyleManager() | 		$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight(); | ||||||
| 		                             ->getListWidgetsWidth(); |  | ||||||
| 		$height = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                             ->getStyleManager() |  | ||||||
| 		                             ->getListWidgetsHeight(); |  | ||||||
|  |  | ||||||
| 		// create manialink | 		// create manialink | ||||||
| 		$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID); | 		$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID); | ||||||
| @@ -540,9 +476,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { | |||||||
| 		$script->addFeature($paging); | 		$script->addFeature($paging); | ||||||
|  |  | ||||||
| 		// Main frame | 		// Main frame | ||||||
| 		$frame = $this->maniaControl->getManialinkManager() | 		$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging); | ||||||
| 		                            ->getStyleManager() |  | ||||||
| 		                            ->getDefaultListFrame($script, $paging); |  | ||||||
| 		$maniaLink->add($frame); | 		$maniaLink->add($frame); | ||||||
|  |  | ||||||
| 		// Start offsets | 		// Start offsets | ||||||
| @@ -550,9 +484,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { | |||||||
| 		$posY = $height / 2; | 		$posY = $height / 2; | ||||||
|  |  | ||||||
| 		//Predefine description Label | 		//Predefine description Label | ||||||
| 		$descriptionLabel = $this->maniaControl->getManialinkManager() | 		$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel(); | ||||||
| 		                                       ->getStyleManager() |  | ||||||
| 		                                       ->getDefaultDescriptionLabel(); |  | ||||||
| 		$frame->add($descriptionLabel); | 		$frame->add($descriptionLabel); | ||||||
|  |  | ||||||
| 		// Headline | 		// Headline | ||||||
| @@ -560,8 +492,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { | |||||||
| 		$frame->add($headFrame); | 		$frame->add($headFrame); | ||||||
| 		$headFrame->setY($posY - 5); | 		$headFrame->setY($posY - 5); | ||||||
| 		$array = array('$oId' => $posX + 5, '$oNickname' => $posX + 18, '$oDonated planets' => $posX + 70); | 		$array = array('$oId' => $posX + 5, '$oNickname' => $posX + 18, '$oDonated planets' => $posX + 70); | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->labelLine($headFrame, $array); | ||||||
| 		                   ->labelLine($headFrame, $array); |  | ||||||
|  |  | ||||||
| 		$index     = 1; | 		$index     = 1; | ||||||
| 		$posY      = $posY - 10; | 		$posY      = $posY - 10; | ||||||
| @@ -587,11 +518,9 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { | |||||||
| 				$lineQuad->setZ(0.001); | 				$lineQuad->setZ(0.001); | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			$donatingPlayer = $this->maniaControl->getPlayerManager() | 			$donatingPlayer = $this->maniaControl->getPlayerManager()->getPlayerByIndex($playerIndex); | ||||||
| 			                                     ->getPlayerByIndex($playerIndex); |  | ||||||
| 			$array          = array($index => $posX + 5, $donatingPlayer->nickname => $posX + 18, $donations => $posX + 70); | 			$array          = array($index => $posX + 5, $donatingPlayer->nickname => $posX + 18, $donations => $posX + 70); | ||||||
| 			$this->maniaControl->getManialinkManager() | 			$this->maniaControl->getManialinkManager()->labelLine($playerFrame, $array); | ||||||
| 			                   ->labelLine($playerFrame, $array); |  | ||||||
|  |  | ||||||
| 			$posY -= 4; | 			$posY -= 4; | ||||||
| 			$index++; | 			$index++; | ||||||
| @@ -602,7 +531,6 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Render and display xml | 		// Render and display xml | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'TopDons'); | ||||||
| 		                   ->displayWidget($maniaLink, $player, 'TopDons'); |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -52,16 +52,11 @@ class DynamicPointLimitPlugin implements CallbackListener, CommandListener, Plug | |||||||
| 	 * @see \ManiaControl\Plugins\Plugin::prepare() | 	 * @see \ManiaControl\Plugins\Plugin::prepare() | ||||||
| 	 */ | 	 */ | ||||||
| 	public static function prepare(ManiaControl $maniaControl) { | 	public static function prepare(ManiaControl $maniaControl) { | ||||||
| 		$maniaControl->getSettingManager() | 		$maniaControl->getSettingManager()->initSetting(get_class(), self::SETTING_POINT_LIMIT_MULTIPLIER, 10); | ||||||
| 		             ->initSetting(get_class(), self::SETTING_POINT_LIMIT_MULTIPLIER, 10); | 		$maniaControl->getSettingManager()->initSetting(get_class(), self::SETTING_POINT_LIMIT_OFFSET, 0); | ||||||
| 		$maniaControl->getSettingManager() | 		$maniaControl->getSettingManager()->initSetting(get_class(), self::SETTING_MIN_POINT_LIMIT, 30); | ||||||
| 		             ->initSetting(get_class(), self::SETTING_POINT_LIMIT_OFFSET, 0); | 		$maniaControl->getSettingManager()->initSetting(get_class(), self::SETTING_MAX_POINT_LIMIT, 200); | ||||||
| 		$maniaControl->getSettingManager() | 		$maniaControl->getSettingManager()->initSetting(get_class(), self::SETTING_ACCEPT_OTHER_MODES, false); | ||||||
| 		             ->initSetting(get_class(), self::SETTING_MIN_POINT_LIMIT, 30); |  | ||||||
| 		$maniaControl->getSettingManager() |  | ||||||
| 		             ->initSetting(get_class(), self::SETTING_MAX_POINT_LIMIT, 200); |  | ||||||
| 		$maniaControl->getSettingManager() |  | ||||||
| 		             ->initSetting(get_class(), self::SETTING_ACCEPT_OTHER_MODES, false); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -105,29 +100,21 @@ class DynamicPointLimitPlugin implements CallbackListener, CommandListener, Plug | |||||||
| 	public function load(ManiaControl $maniaControl) { | 	public function load(ManiaControl $maniaControl) { | ||||||
| 		$this->maniaControl = $maniaControl; | 		$this->maniaControl = $maniaControl; | ||||||
|  |  | ||||||
| 		$allowOthers = $this->maniaControl->getSettingManager() | 		$allowOthers = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_ACCEPT_OTHER_MODES); | ||||||
| 		                                  ->getSettingValue($this, self::SETTING_ACCEPT_OTHER_MODES); |  | ||||||
| 		if (!$allowOthers && $this->maniaControl->getServer()->titleId !== 'SMStormRoyal@nadeolabs') { | 		if (!$allowOthers && $this->maniaControl->getServer()->titleId !== 'SMStormRoyal@nadeolabs') { | ||||||
| 			$error = 'This plugin only supports Royal (check Settings)!'; | 			$error = 'This plugin only supports Royal (check Settings)!'; | ||||||
| 			throw new \Exception($error); | 			throw new \Exception($error); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'updatePointLimit'); | ||||||
| 		                   ->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'updatePointLimit'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'updatePointLimit'); | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'handlePlayerInfoChangedCallback'); | ||||||
| 		                   ->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'updatePointLimit'); |  | ||||||
| 		$this->maniaControl->getCallbackManager() |  | ||||||
| 		                   ->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'handlePlayerInfoChangedCallback'); |  | ||||||
|  |  | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINROUND, $this, 'updatePointLimit'); | ||||||
| 		                   ->registerCallbackListener(Callbacks::BEGINROUND, $this, 'updatePointLimit'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINMAP, $this, 'handleBeginMap'); | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'handleSettingChangedCallback'); | ||||||
| 		                   ->registerCallbackListener(Callbacks::BEGINMAP, $this, 'handleBeginMap'); |  | ||||||
| 		$this->maniaControl->getCallbackManager() |  | ||||||
| 		                   ->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'handleSettingChangedCallback'); |  | ||||||
|  |  | ||||||
| 		$this->maniaControl->getCommandManager() | 		$this->maniaControl->getCommandManager()->registerCommandListener('setpointlimit', $this, 'commandSetPointlimit', true, 'Setpointlimit XXX or auto'); | ||||||
| 		                   ->registerCommandListener('setpointlimit', $this, 'commandSetPointlimit', true, 'Setpointlimit XXX or auto'); |  | ||||||
|  |  | ||||||
| 		$this->updatePointLimit(); | 		$this->updatePointLimit(); | ||||||
| 	} | 	} | ||||||
| @@ -139,17 +126,12 @@ class DynamicPointLimitPlugin implements CallbackListener, CommandListener, Plug | |||||||
| 		if ($this->staticMode) { | 		if ($this->staticMode) { | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 		$numberOfPlayers = $this->maniaControl->getPlayerManager() | 		$numberOfPlayers = $this->maniaControl->getPlayerManager()->getPlayerCount(); | ||||||
| 		                                      ->getPlayerCount(); |  | ||||||
|  |  | ||||||
| 		$multiplier = $this->maniaControl->getSettingManager() | 		$multiplier = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_POINT_LIMIT_MULTIPLIER); | ||||||
| 		                                 ->getSettingValue($this, self::SETTING_POINT_LIMIT_MULTIPLIER); | 		$offset     = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_POINT_LIMIT_OFFSET); | ||||||
| 		$offset     = $this->maniaControl->getSettingManager() | 		$minValue   = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MIN_POINT_LIMIT); | ||||||
| 		                                 ->getSettingValue($this, self::SETTING_POINT_LIMIT_OFFSET); | 		$maxValue   = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAX_POINT_LIMIT); | ||||||
| 		$minValue   = $this->maniaControl->getSettingManager() |  | ||||||
| 		                                 ->getSettingValue($this, self::SETTING_MIN_POINT_LIMIT); |  | ||||||
| 		$maxValue   = $this->maniaControl->getSettingManager() |  | ||||||
| 		                                 ->getSettingValue($this, self::SETTING_MAX_POINT_LIMIT); |  | ||||||
|  |  | ||||||
| 		$pointLimit = $offset + $numberOfPlayers * $multiplier; | 		$pointLimit = $offset + $numberOfPlayers * $multiplier; | ||||||
| 		if ($pointLimit < $minValue) { | 		if ($pointLimit < $minValue) { | ||||||
| @@ -162,18 +144,15 @@ class DynamicPointLimitPlugin implements CallbackListener, CommandListener, Plug | |||||||
|  |  | ||||||
| 		if ($this->lastPointLimit !== $pointLimit) { | 		if ($this->lastPointLimit !== $pointLimit) { | ||||||
| 			try { | 			try { | ||||||
| 				$this->maniaControl->getClient() | 				$this->maniaControl->getClient()->setModeScriptSettings(array(self::SCRIPT_SETTING_MAP_POINTS_LIMIT => $pointLimit)); | ||||||
| 				                   ->setModeScriptSettings(array(self::SCRIPT_SETTING_MAP_POINTS_LIMIT => $pointLimit)); |  | ||||||
| 				$message = "Dynamic PointLimit changed to: {$pointLimit}!"; | 				$message = "Dynamic PointLimit changed to: {$pointLimit}!"; | ||||||
| 				if ($this->lastPointLimit !== null) { | 				if ($this->lastPointLimit !== null) { | ||||||
| 					$message .= " (From {$this->lastPointLimit})"; | 					$message .= " (From {$this->lastPointLimit})"; | ||||||
| 				} | 				} | ||||||
| 				$this->maniaControl->getChat() | 				$this->maniaControl->getChat()->sendInformation($message); | ||||||
| 				                   ->sendInformation($message); |  | ||||||
| 				$this->lastPointLimit = $pointLimit; | 				$this->lastPointLimit = $pointLimit; | ||||||
| 			} catch (GameModeException $exception) { | 			} catch (GameModeException $exception) { | ||||||
| 				$this->maniaControl->getChat() | 				$this->maniaControl->getChat()->sendExceptionToAdmins($exception); | ||||||
| 				                   ->sendExceptionToAdmins($exception); |  | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -187,38 +166,31 @@ class DynamicPointLimitPlugin implements CallbackListener, CommandListener, Plug | |||||||
| 	public function commandSetPointlimit(array $chatCallback, Player $player) { | 	public function commandSetPointlimit(array $chatCallback, Player $player) { | ||||||
| 		$commandParts = explode(' ', $chatCallback[1][2]); | 		$commandParts = explode(' ', $chatCallback[1][2]); | ||||||
| 		if (count($commandParts) < 2) { | 		if (count($commandParts) < 2) { | ||||||
| 			$this->maniaControl->getChat() | 			$this->maniaControl->getChat()->sendUsageInfo('Example: //setpointlimit auto', $player); | ||||||
| 			                   ->sendUsageInfo('Example: //setpointlimit auto', $player); |  | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 		$value = strtolower($commandParts[1]); | 		$value = strtolower($commandParts[1]); | ||||||
| 		if ($value === "auto") { | 		if ($value === "auto") { | ||||||
| 			$this->staticMode = false; | 			$this->staticMode = false; | ||||||
| 			$this->maniaControl->getChat() | 			$this->maniaControl->getChat()->sendInformation('Enabled Dynamic PointLimit!'); | ||||||
| 			                   ->sendInformation('Enabled Dynamic PointLimit!'); |  | ||||||
| 			$this->updatePointLimit(); | 			$this->updatePointLimit(); | ||||||
| 		} else { | 		} else { | ||||||
| 			if (is_numeric($value)) { | 			if (is_numeric($value)) { | ||||||
| 				$value = (int)$value; | 				$value = (int)$value; | ||||||
| 				if ($value <= 0) { | 				if ($value <= 0) { | ||||||
| 					$this->maniaControl->getChat() | 					$this->maniaControl->getChat()->sendError('PointLimit needs to be greater than Zero.', $player); | ||||||
| 					                   ->sendError('PointLimit needs to be greater than Zero.', $player); |  | ||||||
| 					return; | 					return; | ||||||
| 				} | 				} | ||||||
| 				try { | 				try { | ||||||
| 					$this->maniaControl->getClient() | 					$this->maniaControl->getClient()->setModeScriptSettings(array(self::SCRIPT_SETTING_MAP_POINTS_LIMIT => $value)); | ||||||
| 					                   ->setModeScriptSettings(array(self::SCRIPT_SETTING_MAP_POINTS_LIMIT => $value)); |  | ||||||
| 					$this->staticMode     = true; | 					$this->staticMode     = true; | ||||||
| 					$this->lastPointLimit = $value; | 					$this->lastPointLimit = $value; | ||||||
| 					$this->maniaControl->getChat() | 					$this->maniaControl->getChat()->sendInformation("PointLimit changed to: {$value} (Fixed)"); | ||||||
| 					                   ->sendInformation("PointLimit changed to: {$value} (Fixed)"); |  | ||||||
| 				} catch (GameModeException $exception) { | 				} catch (GameModeException $exception) { | ||||||
| 					$this->maniaControl->getChat() | 					$this->maniaControl->getChat()->sendException($exception, $player); | ||||||
| 					                   ->sendException($exception, $player); |  | ||||||
| 				} | 				} | ||||||
| 			} else { | 			} else { | ||||||
| 				$this->maniaControl->getChat() | 				$this->maniaControl->getChat()->sendUsageInfo('Example: //setpointlimit 150', $player); | ||||||
| 				                   ->sendUsageInfo('Example: //setpointlimit 150', $player); |  | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -248,11 +220,9 @@ class DynamicPointLimitPlugin implements CallbackListener, CommandListener, Plug | |||||||
| 		if ($this->staticMode && !is_null($this->lastPointLimit)) { | 		if ($this->staticMode && !is_null($this->lastPointLimit)) { | ||||||
| 			// Refresh static point limit in case it has been reset | 			// Refresh static point limit in case it has been reset | ||||||
| 			try { | 			try { | ||||||
| 				$this->maniaControl->getClient() | 				$this->maniaControl->getClient()->setModeScriptSettings(array(self::SCRIPT_SETTING_MAP_POINTS_LIMIT => $this->lastPointLimit)); | ||||||
| 				                   ->setModeScriptSettings(array(self::SCRIPT_SETTING_MAP_POINTS_LIMIT => $this->lastPointLimit)); |  | ||||||
| 				$message = "PointLimit fixed at {$this->lastPointLimit}."; | 				$message = "PointLimit fixed at {$this->lastPointLimit}."; | ||||||
| 				$this->maniaControl->getChat() | 				$this->maniaControl->getChat()->sendInformation($message); | ||||||
| 				                   ->sendInformation($message); |  | ||||||
| 			} catch (GameModeException $e) { | 			} catch (GameModeException $e) { | ||||||
| 				$this->lastPointLimit = null; | 				$this->lastPointLimit = null; | ||||||
| 			} | 			} | ||||||
|   | |||||||
| @@ -81,18 +81,13 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 */ | 	 */ | ||||||
| 	public static function prepare(ManiaControl $maniaControl) { | 	public static function prepare(ManiaControl $maniaControl) { | ||||||
| 		$thisClass = get_class(); | 		$thisClass = get_class(); | ||||||
| 		$maniaControl->getSettingManager() | 		$maniaControl->getSettingManager()->initSetting($thisClass, self::SETTING_MX_KARMA_ACTIVATED, true); | ||||||
| 		             ->initSetting($thisClass, self::SETTING_MX_KARMA_ACTIVATED, true); | 		$maniaControl->getSettingManager()->initSetting($thisClass, self::SETTING_MX_KARMA_IMPORTING, true); | ||||||
| 		$maniaControl->getSettingManager() | 		$maniaControl->getSettingManager()->initSetting($thisClass, self::SETTING_WIDGET_DISPLAY_MX, true); | ||||||
| 		             ->initSetting($thisClass, self::SETTING_MX_KARMA_IMPORTING, true); | 		$servers = $maniaControl->getServer()->getAllServers(); | ||||||
| 		$maniaControl->getSettingManager() |  | ||||||
| 		             ->initSetting($thisClass, self::SETTING_WIDGET_DISPLAY_MX, true); |  | ||||||
| 		$servers = $maniaControl->getServer() |  | ||||||
| 		                        ->getAllServers(); |  | ||||||
| 		foreach ($servers as $server) { | 		foreach ($servers as $server) { | ||||||
| 			$settingName = self::buildKarmaSettingName($server->login); | 			$settingName = self::buildKarmaSettingName($server->login); | ||||||
| 			$maniaControl->getSettingManager() | 			$maniaControl->getSettingManager()->initSetting($thisClass, $settingName, ''); | ||||||
| 			             ->initSetting($thisClass, $settingName, ''); |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -151,47 +146,29 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 		$this->initTables(); | 		$this->initTables(); | ||||||
|  |  | ||||||
| 		// Settings | 		// Settings | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_AVAILABLE_VOTES, '-2,2'); | ||||||
| 		                   ->initSetting($this, self::SETTING_AVAILABLE_VOTES, '-2,2'); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_ENABLE, true); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_TITLE, 'Map-Karma'); | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_ENABLE, true); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_POSX, 160 - 27.5); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_POSY, 90 - 10 - 6); | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_TITLE, 'Map-Karma'); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_WIDTH, 25.); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_HEIGHT, 12.); | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_POSX, 160 - 27.5); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NEWKARMA, true); | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_POSY, 90 - 10 - 6); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_WIDTH, 25.); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_HEIGHT, 12.); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_NEWKARMA, true); |  | ||||||
|  |  | ||||||
| 		// Callbacks | 		// Callbacks | ||||||
| 		$this->maniaControl->getTimerManager() | 		$this->maniaControl->getTimerManager()->registerTimerListening($this, 'handle1Second', 1000); | ||||||
| 		                   ->registerTimerListening($this, 'handle1Second', 1000); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINMAP, $this, 'handleBeginMap'); | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINMAP, $this, 'importMxKarmaVotes'); | ||||||
| 		                   ->registerCallbackListener(Callbacks::BEGINMAP, $this, 'handleBeginMap'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ENDMAP, $this, 'sendMxKarmaVotes'); | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); | ||||||
| 		                   ->registerCallbackListener(Callbacks::BEGINMAP, $this, 'importMxKarmaVotes'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this, 'handlePlayerChat'); | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'updateSettings'); | ||||||
| 		                   ->registerCallbackListener(Callbacks::ENDMAP, $this, 'sendMxKarmaVotes'); |  | ||||||
| 		$this->maniaControl->getCallbackManager() |  | ||||||
| 		                   ->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); |  | ||||||
| 		$this->maniaControl->getCallbackManager() |  | ||||||
| 		                   ->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this, 'handlePlayerChat'); |  | ||||||
| 		$this->maniaControl->getCallbackManager() |  | ||||||
| 		                   ->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'updateSettings'); |  | ||||||
|  |  | ||||||
| 		// Define player stats | 		// Define player stats | ||||||
| 		$this->maniaControl->getStatisticManager() | 		$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_PLAYER_MAPVOTES); | ||||||
| 		                   ->defineStatMetaData(self::STAT_PLAYER_MAPVOTES); |  | ||||||
|  |  | ||||||
| 		// Register Stat in Simple StatsList | 		// Register Stat in Simple StatsList | ||||||
| 		$this->maniaControl->getStatisticManager() | 		$this->maniaControl->getStatisticManager()->getSimpleStatsList()->registerStat(self::STAT_PLAYER_MAPVOTES, 100, "VM"); | ||||||
| 		                   ->getSimpleStatsList() |  | ||||||
| 		                   ->registerStat(self::STAT_PLAYER_MAPVOTES, 100, "VM"); |  | ||||||
|  |  | ||||||
| 		$this->updateManialink = true; | 		$this->updateManialink = true; | ||||||
|  |  | ||||||
| @@ -202,14 +179,11 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 		//Check if Karma Code got specified, and inform admin that it would be good to specify one | 		//Check if Karma Code got specified, and inform admin that it would be good to specify one | ||||||
| 		$serverLogin      = $this->maniaControl->getServer()->login; | 		$serverLogin      = $this->maniaControl->getServer()->login; | ||||||
| 		$karmaSettingName = self::buildKarmaSettingName($serverLogin); | 		$karmaSettingName = self::buildKarmaSettingName($serverLogin); | ||||||
| 		$mxKarmaCode      = $this->maniaControl->getSettingManager() | 		$mxKarmaCode      = $this->maniaControl->getSettingManager()->getSettingValue($this, $karmaSettingName); | ||||||
| 		                                       ->getSettingValue($this, $karmaSettingName); |  | ||||||
|  |  | ||||||
| 		if (!$mxKarmaCode) { | 		if (!$mxKarmaCode) { | ||||||
| 			$permission = $this->maniaControl->getSettingManager() | 			$permission = $this->maniaControl->getSettingManager()->getSettingValue($this->maniaControl->getAuthenticationManager(), PluginMenu::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS); | ||||||
| 			                                 ->getSettingValue($this->maniaControl->getAuthenticationManager(), PluginMenu::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS); | 			$this->maniaControl->getChat()->sendErrorToAdmins("Please specify a Mania-Exchange Karma Key in the Karma-Plugin settings!", $permission); | ||||||
| 			$this->maniaControl->getChat() |  | ||||||
| 			                   ->sendErrorToAdmins("Please specify a Mania-Exchange Karma Key in the Karma-Plugin settings!", $permission); |  | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		return true; | 		return true; | ||||||
| @@ -219,8 +193,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 * Create necessary database tables | 	 * Create necessary database tables | ||||||
| 	 */ | 	 */ | ||||||
| 	private function initTables() { | 	private function initTables() { | ||||||
| 		$mysqli = $this->maniaControl->getDatabase() | 		$mysqli = $this->maniaControl->getDatabase()->getMysqli(); | ||||||
| 		                             ->getMysqli(); |  | ||||||
|  |  | ||||||
| 		// Create local table | 		// Create local table | ||||||
| 		$query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_KARMA . "` ( | 		$query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_KARMA . "` ( | ||||||
| @@ -256,16 +229,14 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 * Open a Mx Karma Session | 	 * Open a Mx Karma Session | ||||||
| 	 */ | 	 */ | ||||||
| 	private function mxKarmaOpenSession() { | 	private function mxKarmaOpenSession() { | ||||||
| 		if (!$this->maniaControl->getSettingManager() | 		if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED) | ||||||
| 		                        ->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED) |  | ||||||
| 		) { | 		) { | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$serverLogin      = $this->maniaControl->getServer()->login; | 		$serverLogin      = $this->maniaControl->getServer()->login; | ||||||
| 		$karmaSettingName = self::buildKarmaSettingName($serverLogin); | 		$karmaSettingName = self::buildKarmaSettingName($serverLogin); | ||||||
| 		$mxKarmaCode      = $this->maniaControl->getSettingManager() | 		$mxKarmaCode      = $this->maniaControl->getSettingManager()->getSettingValue($this, $karmaSettingName); | ||||||
| 		                                       ->getSettingValue($this, $karmaSettingName); |  | ||||||
|  |  | ||||||
| 		if (!$mxKarmaCode) { | 		if (!$mxKarmaCode) { | ||||||
| 			return; | 			return; | ||||||
| @@ -281,31 +252,27 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
|  |  | ||||||
| 		$this->mxKarma['connectionInProgress'] = true; | 		$this->mxKarma['connectionInProgress'] = true; | ||||||
|  |  | ||||||
| 		$this->maniaControl->getFileReader() | 		$this->maniaControl->getFileReader()->loadFile($query, function ($json, $error) use ($mxKarmaCode) { | ||||||
| 		                   ->loadFile($query, function ($json, $error) use ($mxKarmaCode) { | 			                                    $this->mxKarma['connectionInProgress'] = false; | ||||||
| 			$this->mxKarma['connectionInProgress'] = false; | 			                                    if ($error) { | ||||||
| 			if ($error) { | 				                                    $this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error: ' . $error); | ||||||
| 				$this->maniaControl->getErrorHandler() | 				                                    return; | ||||||
| 				                   ->triggerDebugNotice('mx karma error: ' . $error); | 			                                    } | ||||||
| 				return; | 			                                    $data = json_decode($json); | ||||||
| 			} | 			                                    if (!$data) { | ||||||
| 			$data = json_decode($json); | 				                                    $this->maniaControl->getErrorHandler()->triggerDebugNotice('auth error', $json, $data); | ||||||
| 			if (!$data) { | 				                                    return; | ||||||
| 				$this->maniaControl->getErrorHandler() | 			                                    } | ||||||
| 				                   ->triggerDebugNotice('auth error', $json, $data); | 			                                    if ($data->success) { | ||||||
| 				return; | 				                                    $this->mxKarma['session'] = $data->data; | ||||||
| 			} | 				                                    $this->activateSession($mxKarmaCode); | ||||||
| 			if ($data->success) { | 			                                    } else { | ||||||
| 				$this->mxKarma['session'] = $data->data; | 				                                    Logger::logError("Error while authenticating on Mania-Exchange Karma"); | ||||||
| 				$this->activateSession($mxKarmaCode); | 				                                    // TODO remove temp trigger | ||||||
| 			} else { | 				                                    $this->maniaControl->getErrorHandler()->triggerDebugNotice('auth error', $data->data->message); | ||||||
| 				Logger::logError("Error while authenticating on Mania-Exchange Karma"); | 				                                    $this->mxKarma['connectionInProgress'] = false; | ||||||
| 				// TODO remove temp trigger | 			                                    } | ||||||
| 				$this->maniaControl->getErrorHandler() | 		                                    }, AsynchronousFileReader::CONTENT_TYPE_JSON, 1000); | ||||||
| 				                   ->triggerDebugNotice('auth error', $data->data->message); |  | ||||||
| 				$this->mxKarma['connectionInProgress'] = false; |  | ||||||
| 			} |  | ||||||
| 		}, AsynchronousFileReader::CONTENT_TYPE_JSON, 1000); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -320,39 +287,33 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 		$query .= '?sessionKey=' . urlencode($this->mxKarma['session']->sessionKey); | 		$query .= '?sessionKey=' . urlencode($this->mxKarma['session']->sessionKey); | ||||||
| 		$query .= '&activationHash=' . urlencode($hash); | 		$query .= '&activationHash=' . urlencode($hash); | ||||||
|  |  | ||||||
| 		$this->maniaControl->getFileReader() | 		$this->maniaControl->getFileReader()->loadFile($query, function ($json, $error) use ($query) { | ||||||
| 		                   ->loadFile($query, function ($json, $error) use ($query) { | 			                                    $this->mxKarma['connectionInProgress'] = false; | ||||||
| 			$this->mxKarma['connectionInProgress'] = false; | 			                                    if ($error) { | ||||||
| 			if ($error) { | 				                                    $this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error', $error); | ||||||
| 				$this->maniaControl->getErrorHandler() | 				                                    return; | ||||||
| 				                   ->triggerDebugNotice('mx karma error', $error); | 			                                    } | ||||||
| 				return; | 			                                    $data = json_decode($json); | ||||||
| 			} | 			                                    if (!$data) { | ||||||
| 			$data = json_decode($json); | 				                                    $this->maniaControl->getErrorHandler()->triggerDebugNotice('parse error', $json, $data); | ||||||
| 			if (!$data) { | 				                                    return; | ||||||
| 				$this->maniaControl->getErrorHandler() | 			                                    } | ||||||
| 				                   ->triggerDebugNotice('parse error', $json, $data); | 			                                    if ($data->success && $data->data->activated) { | ||||||
| 				return; | 				                                    Logger::log('Successfully authenticated on Mania-Exchange Karma'); | ||||||
| 			} |  | ||||||
| 			if ($data->success && $data->data->activated) { |  | ||||||
| 				Logger::log('Successfully authenticated on Mania-Exchange Karma'); |  | ||||||
|  |  | ||||||
| 				// Fetch the Mx Karma Votes | 				                                    // Fetch the Mx Karma Votes | ||||||
| 				$this->getMxKarmaVotes(); | 				                                    $this->getMxKarmaVotes(); | ||||||
| 			} else { | 			                                    } else { | ||||||
| 				if ($data->data->message === 'invalid hash') { | 				                                    if ($data->data->message === 'invalid hash') { | ||||||
| 					$permission = $this->maniaControl->getSettingManager() | 					                                    $permission = $this->maniaControl->getSettingManager()->getSettingValue($this->maniaControl->getAuthenticationManager(), PluginMenu::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS); | ||||||
| 					                                 ->getSettingValue($this->maniaControl->getAuthenticationManager(), PluginMenu::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS); | 					                                    $this->maniaControl->getChat()->sendErrorToAdmins("Invalid Mania-Exchange Karma code in Karma Plugin specified!", $permission); | ||||||
| 					$this->maniaControl->getChat() | 				                                    } else { | ||||||
| 					                   ->sendErrorToAdmins("Invalid Mania-Exchange Karma code in Karma Plugin specified!", $permission); | 					                                    $this->maniaControl->getErrorHandler()->triggerDebugNotice('auth error', $data->data->message, $query); | ||||||
| 				} else { | 				                                    } | ||||||
| 					$this->maniaControl->getErrorHandler() | 				                                    Logger::logError("Error while activating Mania-Exchange Karma Session: " . $data->data->message); | ||||||
| 					                   ->triggerDebugNotice('auth error', $data->data->message, $query); | 				                                    unset($this->mxKarma['session']); | ||||||
| 				} | 			                                    } | ||||||
| 				Logger::logError("Error while activating Mania-Exchange Karma Session: " . $data->data->message); | 		                                    }, AsynchronousFileReader::CONTENT_TYPE_JSON, 1000); | ||||||
| 				unset($this->mxKarma['session']); |  | ||||||
| 			} |  | ||||||
| 		}, AsynchronousFileReader::CONTENT_TYPE_JSON, 1000); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -370,8 +331,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 * Fetch the mxKarmaVotes for the current map | 	 * Fetch the mxKarmaVotes for the current map | ||||||
| 	 */ | 	 */ | ||||||
| 	public function getMxKarmaVotes(Player $player = null) { | 	public function getMxKarmaVotes(Player $player = null) { | ||||||
| 		if (!$this->maniaControl->getSettingManager() | 		if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED) | ||||||
| 		                        ->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED) |  | ||||||
| 		) { | 		) { | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| @@ -383,16 +343,13 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$map = $this->maniaControl->getMapManager() | 		$map = $this->maniaControl->getMapManager()->getCurrentMap(); | ||||||
| 		                          ->getCurrentMap(); |  | ||||||
|  |  | ||||||
| 		$properties = array(); | 		$properties = array(); | ||||||
|  |  | ||||||
| 		$gameMode = $this->maniaControl->getServer() | 		$gameMode = $this->maniaControl->getServer()->getGameMode(true); | ||||||
| 		                               ->getGameMode(true); |  | ||||||
| 		if ($gameMode === 'Script') { | 		if ($gameMode === 'Script') { | ||||||
| 			$scriptName             = $this->maniaControl->getClient() | 			$scriptName             = $this->maniaControl->getClient()->getScriptName(); | ||||||
| 			                                             ->getScriptName(); |  | ||||||
| 			$properties['gamemode'] = $scriptName['CurrentValue']; | 			$properties['gamemode'] = $scriptName['CurrentValue']; | ||||||
| 		} else { | 		} else { | ||||||
| 			$properties['gamemode'] = $gameMode; | 			$properties['gamemode'] = $gameMode; | ||||||
| @@ -404,8 +361,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 		if (!$player) { | 		if (!$player) { | ||||||
| 			$properties['getvotesonly'] = false; | 			$properties['getvotesonly'] = false; | ||||||
| 			$properties['playerlogins'] = array(); | 			$properties['playerlogins'] = array(); | ||||||
| 			foreach ($this->maniaControl->getPlayerManager() | 			foreach ($this->maniaControl->getPlayerManager()->getPlayers() as $loopPlayer) { | ||||||
| 			                            ->getPlayers() as $loopPlayer) { |  | ||||||
| 				$properties['playerlogins'][] = $loopPlayer->login; | 				$properties['playerlogins'][] = $loopPlayer->login; | ||||||
| 			} | 			} | ||||||
| 		} else { | 		} else { | ||||||
| @@ -414,60 +370,54 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$content = json_encode($properties); | 		$content = json_encode($properties); | ||||||
| 		$this->maniaControl->getFileReader() | 		$this->maniaControl->getFileReader()->postData(self::MX_KARMA_URL . self::MX_KARMA_GET_MAP_RATING . '?sessionKey=' . urlencode($this->mxKarma['session']->sessionKey), function ($json, | ||||||
| 		                   ->postData(self::MX_KARMA_URL . self::MX_KARMA_GET_MAP_RATING . '?sessionKey=' . urlencode($this->mxKarma['session']->sessionKey), function ($json, | 		                                                                                                                                                                                 $error) use | ||||||
| 		                                                                                                                                                                $error) use | 		                                    ( | ||||||
| 		( | 			                                    &$player | ||||||
| 			&$player | 		                                    ) { | ||||||
| 		) { | 			                                    if ($error) { | ||||||
| 			if ($error) { | 				                                    $this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error', $error); | ||||||
| 				$this->maniaControl->getErrorHandler() | 				                                    return; | ||||||
| 				                   ->triggerDebugNotice('mx karma error', $error); | 			                                    } | ||||||
| 				return; | 			                                    $data = json_decode($json); | ||||||
| 			} | 			                                    if (!$data) { | ||||||
| 			$data = json_decode($json); | 				                                    $this->maniaControl->getErrorHandler()->triggerDebugNotice('parse error', $json, $data); | ||||||
| 			if (!$data) { | 				                                    return; | ||||||
| 				$this->maniaControl->getErrorHandler() | 			                                    } | ||||||
| 				                   ->triggerDebugNotice('parse error', $json, $data); |  | ||||||
| 				return; |  | ||||||
| 			} |  | ||||||
|  |  | ||||||
| 			if ($data->success) { | 			                                    if ($data->success) { | ||||||
| 				// Fetch averages if it's for the whole server | 				                                    // Fetch averages if it's for the whole server | ||||||
| 				if (!$player) { | 				                                    if (!$player) { | ||||||
| 					$this->mxKarma['voteCount']       = $data->data->votecount; | 					                                    $this->mxKarma['voteCount']       = $data->data->votecount; | ||||||
| 					$this->mxKarma['voteAverage']     = $data->data->voteaverage; | 					                                    $this->mxKarma['voteAverage']     = $data->data->voteaverage; | ||||||
| 					$this->mxKarma['modeVoteCount']   = $data->data->modevotecount; | 					                                    $this->mxKarma['modeVoteCount']   = $data->data->modevotecount; | ||||||
| 					$this->mxKarma['modeVoteAverage'] = $data->data->modevoteaverage; | 					                                    $this->mxKarma['modeVoteAverage'] = $data->data->modevoteaverage; | ||||||
| 				} | 				                                    } | ||||||
|  |  | ||||||
| 				foreach ($data->data->votes as $votes) { | 				                                    foreach ($data->data->votes as $votes) { | ||||||
| 					$this->mxKarma['votes'][$votes->login] = $votes->vote; | 					                                    $this->mxKarma['votes'][$votes->login] = $votes->vote; | ||||||
| 				} | 				                                    } | ||||||
|  |  | ||||||
| 				$this->updateManialink = true; | 				                                    $this->updateManialink = true; | ||||||
| 				$this->maniaControl->getCallbackManager() | 				                                    $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_KARMA_MXUPDATED, $this->mxKarma); | ||||||
| 				                   ->triggerCallback(self::CB_KARMA_MXUPDATED, $this->mxKarma); | 				                                    Logger::logInfo('MX-Karma Votes successfully fetched!'); | ||||||
| 				Logger::logInfo('MX-Karma Votes successfully fetched!'); | 			                                    } else { | ||||||
| 			} else { | 				                                    // Problem occurred | ||||||
| 				// Problem occurred | 				                                    Logger::logError('Error while fetching votes: ' . $data->data->message); | ||||||
| 				Logger::logError('Error while fetching votes: ' . $data->data->message); | 				                                    if ($data->data->message === 'invalid session') { | ||||||
| 				if ($data->data->message === 'invalid session') { | 					                                    unset($this->mxKarma['session']); | ||||||
| 					unset($this->mxKarma['session']); | 				                                    } else { | ||||||
| 				} else { | 					                                    $this->maniaControl->getErrorHandler()->triggerDebugNotice('fetch error', $data->data->message, self::MX_KARMA_GET_MAP_RATING, $this->mxKarma['session']); | ||||||
| 					$this->maniaControl->getErrorHandler() | 				                                    } | ||||||
| 					                   ->triggerDebugNotice('fetch error', $data->data->message, self::MX_KARMA_GET_MAP_RATING, $this->mxKarma['session']); | 			                                    } | ||||||
| 				} | 		                                    }, $content, false, AsynchronousFileReader::CONTENT_TYPE_JSON); | ||||||
| 			} |  | ||||||
| 		}, $content, false, AsynchronousFileReader::CONTENT_TYPE_JSON); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * @see \ManiaControl\Plugins\Plugin::unload() | 	 * @see \ManiaControl\Plugins\Plugin::unload() | ||||||
| 	 */ | 	 */ | ||||||
| 	public function unload() { | 	public function unload() { | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->hideManialink(self::MLID_KARMA); | ||||||
| 		                   ->hideManialink(self::MLID_KARMA); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -478,8 +428,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 		if (isset($this->mxKarma['map'])) { | 		if (isset($this->mxKarma['map'])) { | ||||||
| 			$votes = array(); | 			$votes = array(); | ||||||
| 			foreach ($this->mxKarma['votes'] as $login => $value) { | 			foreach ($this->mxKarma['votes'] as $login => $value) { | ||||||
| 				$player = $this->maniaControl->getPlayerManager() | 				$player = $this->maniaControl->getPlayerManager()->getPlayer($login); | ||||||
| 				                             ->getPlayer($login); |  | ||||||
| 				array_push($votes, array('login' => $login, 'nickname' => $player->rawNickname, 'vote' => $value)); | 				array_push($votes, array('login' => $login, 'nickname' => $player->rawNickname, 'vote' => $value)); | ||||||
| 			} | 			} | ||||||
| 			$this->postKarmaVotes($this->mxKarma['map'], $votes); | 			$this->postKarmaVotes($this->mxKarma['map'], $votes); | ||||||
| @@ -509,8 +458,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$gameMode = $this->maniaControl->getServer() | 		$gameMode = $this->maniaControl->getServer()->getGameMode(true); | ||||||
| 		                               ->getGameMode(true); |  | ||||||
|  |  | ||||||
| 		if (empty($votes)) { | 		if (empty($votes)) { | ||||||
| 			return; | 			return; | ||||||
| @@ -518,8 +466,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
|  |  | ||||||
| 		$properties = array(); | 		$properties = array(); | ||||||
| 		if ($gameMode === 'Script') { | 		if ($gameMode === 'Script') { | ||||||
| 			$scriptName             = $this->maniaControl->getClient() | 			$scriptName             = $this->maniaControl->getClient()->getScriptName(); | ||||||
| 			                                             ->getScriptName(); |  | ||||||
| 			$properties['gamemode'] = $scriptName['CurrentValue']; | 			$properties['gamemode'] = $scriptName['CurrentValue']; | ||||||
| 		} else { | 		} else { | ||||||
| 			$properties['gamemode'] = $gameMode; | 			$properties['gamemode'] = $gameMode; | ||||||
| @@ -540,33 +487,29 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
|  |  | ||||||
| 		$content = json_encode($properties); | 		$content = json_encode($properties); | ||||||
|  |  | ||||||
| 		$this->maniaControl->getFileReader() | 		$this->maniaControl->getFileReader()->postData(self::MX_KARMA_URL . self::MX_KARMA_SAVE_VOTES . "?sessionKey=" . urlencode($this->mxKarma['session']->sessionKey), function ($json, | ||||||
| 		                   ->postData(self::MX_KARMA_URL . self::MX_KARMA_SAVE_VOTES . "?sessionKey=" . urlencode($this->mxKarma['session']->sessionKey), function ($json, | 		                                                                                                                                                                             $error) { | ||||||
| 		                                                                                                                                                            $error) { | 			                                    if ($error) { | ||||||
| 			if ($error) { | 				                                    $this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error', $error); | ||||||
| 				$this->maniaControl->getErrorHandler() | 				                                    return; | ||||||
| 				                   ->triggerDebugNotice('mx karma error', $error); | 			                                    } | ||||||
| 				return; | 			                                    $data = json_decode($json); | ||||||
| 			} | 			                                    if (!$data) { | ||||||
| 			$data = json_decode($json); | 				                                    $this->maniaControl->getErrorHandler()->triggerDebugNotice('parse error', $json, $data); | ||||||
| 			if (!$data) { | 				                                    return; | ||||||
| 				$this->maniaControl->getErrorHandler() | 			                                    } | ||||||
| 				                   ->triggerDebugNotice('parse error', $json, $data); | 			                                    if ($data->success) { | ||||||
| 				return; | 				                                    Logger::logInfo('Votes successfully submitted!'); | ||||||
| 			} | 			                                    } else { | ||||||
| 			if ($data->success) { | 				                                    // Problem occurred | ||||||
| 				Logger::logInfo('Votes successfully submitted!'); | 				                                    Logger::logError("Error while updating votes: '{$data->data->message}'"); | ||||||
| 			} else { | 				                                    if ($data->data->message === "invalid session") { | ||||||
| 				// Problem occurred | 					                                    unset($this->mxKarma['session']); | ||||||
| 				Logger::logError("Error while updating votes: '{$data->data->message}'"); | 				                                    } else { | ||||||
| 				if ($data->data->message === "invalid session") { | 					                                    $this->maniaControl->getErrorHandler()->triggerDebugNotice('saving error', $data->data->message, self::MX_KARMA_SAVE_VOTES, $this->mxKarma['session']); | ||||||
| 					unset($this->mxKarma['session']); | 				                                    } | ||||||
| 				} else { | 			                                    } | ||||||
| 					$this->maniaControl->getErrorHandler() | 		                                    }, $content, false, AsynchronousFileReader::CONTENT_TYPE_JSON); | ||||||
| 					                   ->triggerDebugNotice('saving error', $data->data->message, self::MX_KARMA_SAVE_VOTES, $this->mxKarma['session']); |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 		}, $content, false, AsynchronousFileReader::CONTENT_TYPE_JSON); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -606,8 +549,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 */ | 	 */ | ||||||
| 	public function handlePlayerChat(array $chatCallback) { | 	public function handlePlayerChat(array $chatCallback) { | ||||||
| 		$login  = $chatCallback[1][1]; | 		$login  = $chatCallback[1][1]; | ||||||
| 		$player = $this->maniaControl->getPlayerManager() | 		$player = $this->maniaControl->getPlayerManager()->getPlayer($login); | ||||||
| 		                             ->getPlayer($login); |  | ||||||
| 		if (!$player) { | 		if (!$player) { | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| @@ -626,12 +568,10 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 		$vote    = $countPositive - $countNegative; | 		$vote    = $countPositive - $countNegative; | ||||||
| 		$success = $this->handleVote($player, $vote); | 		$success = $this->handleVote($player, $vote); | ||||||
| 		if (!$success) { | 		if (!$success) { | ||||||
| 			$this->maniaControl->getChat() | 			$this->maniaControl->getChat()->sendError('Error occurred.', $player->login); | ||||||
| 			                   ->sendError('Error occurred.', $player->login); |  | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 		$this->maniaControl->getChat() | 		$this->maniaControl->getChat()->sendSuccess('Vote updated!', $player->login); | ||||||
| 		                   ->sendSuccess('Vote updated!', $player->login); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -643,8 +583,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 */ | 	 */ | ||||||
| 	private function handleVote(Player $player, $vote) { | 	private function handleVote(Player $player, $vote) { | ||||||
| 		// Check vote | 		// Check vote | ||||||
| 		$votesSetting = $this->maniaControl->getSettingManager() | 		$votesSetting = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_AVAILABLE_VOTES); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_AVAILABLE_VOTES); |  | ||||||
| 		$votes        = explode(',', $votesSetting); | 		$votes        = explode(',', $votesSetting); | ||||||
| 		$voteLow      = intval($votes[0]); | 		$voteLow      = intval($votes[0]); | ||||||
| 		$voteHigh     = $voteLow + 2; | 		$voteHigh     = $voteLow + 2; | ||||||
| @@ -661,12 +600,10 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 		$vote /= $voteHigh; | 		$vote /= $voteHigh; | ||||||
|  |  | ||||||
| 		// Save vote | 		// Save vote | ||||||
| 		$map = $this->maniaControl->getMapManager() | 		$map = $this->maniaControl->getMapManager()->getCurrentMap(); | ||||||
| 		                          ->getCurrentMap(); |  | ||||||
|  |  | ||||||
| 		// Update vote in MX karma array | 		// Update vote in MX karma array | ||||||
| 		if ($this->maniaControl->getSettingManager() | 		if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED) | ||||||
| 		                       ->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED) |  | ||||||
| 		    && isset($this->mxKarma['session']) | 		    && isset($this->mxKarma['session']) | ||||||
| 		) { | 		) { | ||||||
| 			if (!isset($this->mxKarma['votes'][$player->login])) { | 			if (!isset($this->mxKarma['votes'][$player->login])) { | ||||||
| @@ -701,16 +638,14 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
|  |  | ||||||
| 		$voted = $this->getPlayerVote($player, $map); | 		$voted = $this->getPlayerVote($player, $map); | ||||||
| 		if (!$voted) { | 		if (!$voted) { | ||||||
| 			$this->maniaControl->getStatisticManager() | 			$this->maniaControl->getStatisticManager()->incrementStat(self::STAT_PLAYER_MAPVOTES, $player, $this->maniaControl->getServer()->index); | ||||||
| 			                   ->incrementStat(self::STAT_PLAYER_MAPVOTES, $player, $this->maniaControl->getServer()->index); |  | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$success = $this->savePlayerVote($player, $map, $vote); | 		$success = $this->savePlayerVote($player, $map, $vote); | ||||||
| 		if (!$success) { | 		if (!$success) { | ||||||
| 			return false; | 			return false; | ||||||
| 		} | 		} | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_KARMA_CHANGED); | ||||||
| 		                   ->triggerCallback(self::CB_KARMA_CHANGED); |  | ||||||
| 		$this->updateManialink = true; | 		$this->updateManialink = true; | ||||||
| 		return true; | 		return true; | ||||||
| 	} | 	} | ||||||
| @@ -723,8 +658,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 * @return int | 	 * @return int | ||||||
| 	 */ | 	 */ | ||||||
| 	public function getPlayerVote(Player $player, Map $map) { | 	public function getPlayerVote(Player $player, Map $map) { | ||||||
| 		$mysqli = $this->maniaControl->getDatabase() | 		$mysqli = $this->maniaControl->getDatabase()->getMysqli(); | ||||||
| 		                             ->getMysqli(); |  | ||||||
| 		$query  = "SELECT * FROM `" . self::TABLE_KARMA . "` | 		$query  = "SELECT * FROM `" . self::TABLE_KARMA . "` | ||||||
| 				WHERE `playerIndex` = {$player->index} | 				WHERE `playerIndex` = {$player->index} | ||||||
| 				AND `mapIndex` = {$map->index} | 				AND `mapIndex` = {$map->index} | ||||||
| @@ -753,8 +687,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 * @return bool | 	 * @return bool | ||||||
| 	 */ | 	 */ | ||||||
| 	private function savePlayerVote(Player $player, Map $map, $vote) { | 	private function savePlayerVote(Player $player, Map $map, $vote) { | ||||||
| 		$mysqli = $this->maniaControl->getDatabase() | 		$mysqli = $this->maniaControl->getDatabase()->getMysqli(); | ||||||
| 		                             ->getMysqli(); |  | ||||||
| 		$query  = "INSERT INTO `" . self::TABLE_KARMA . "` ( | 		$query  = "INSERT INTO `" . self::TABLE_KARMA . "` ( | ||||||
| 				`mapIndex`, | 				`mapIndex`, | ||||||
| 				`playerIndex`, | 				`playerIndex`, | ||||||
| @@ -781,8 +714,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 * @return array | 	 * @return array | ||||||
| 	 */ | 	 */ | ||||||
| 	public function getMapPlayerVotes(Map $map) { | 	public function getMapPlayerVotes(Map $map) { | ||||||
| 		$mysqli = $this->maniaControl->getDatabase() | 		$mysqli = $this->maniaControl->getDatabase()->getMysqli(); | ||||||
| 		                             ->getMysqli(); |  | ||||||
| 		$query  = "SELECT * FROM `" . self::TABLE_KARMA . "` | 		$query  = "SELECT * FROM `" . self::TABLE_KARMA . "` | ||||||
| 				WHERE `mapIndex` = {$map->index} | 				WHERE `mapIndex` = {$map->index} | ||||||
| 				AND `vote` >= 0;"; | 				AND `vote` >= 0;"; | ||||||
| @@ -794,8 +726,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
|  |  | ||||||
| 		$votes = array(); | 		$votes = array(); | ||||||
| 		while ($vote = $result->fetch_object()) { | 		while ($vote = $result->fetch_object()) { | ||||||
| 			$player    = $this->maniaControl->getPlayerManager() | 			$player    = $this->maniaControl->getPlayerManager()->getPlayerByIndex($vote->playerIndex); | ||||||
| 			                                ->getPlayerByIndex($vote->playerIndex); |  | ||||||
| 			$karma     = $vote->vote; | 			$karma     = $vote->vote; | ||||||
| 			$voteArray = array('player' => $player, 'karma' => $karma); | 			$voteArray = array('player' => $player, 'karma' => $karma); | ||||||
| 			array_push($votes, $voteArray); | 			array_push($votes, $voteArray); | ||||||
| @@ -835,8 +766,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 					$this->handle1Second(time()); | 					$this->handle1Second(time()); | ||||||
| 				} else { | 				} else { | ||||||
| 					$this->updateManialink = false; | 					$this->updateManialink = false; | ||||||
| 					$this->maniaControl->getManialinkManager() | 					$this->maniaControl->getManialinkManager()->hideManialink(self::MLID_KARMA); | ||||||
| 					                   ->hideManialink(self::MLID_KARMA); |  | ||||||
| 				} | 				} | ||||||
| 				break; | 				break; | ||||||
| 			} | 			} | ||||||
| @@ -851,20 +781,17 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$displayMxKarma = $this->maniaControl->getSettingManager() | 		$displayMxKarma = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_DISPLAY_MX); | ||||||
| 		                                     ->getSettingValue($this, self::SETTING_WIDGET_DISPLAY_MX); |  | ||||||
|  |  | ||||||
| 		// Get players | 		// Get players | ||||||
| 		$players = $this->updateManialink; | 		$players = $this->updateManialink; | ||||||
| 		if ($players === true) { | 		if ($players === true) { | ||||||
| 			$players = $this->maniaControl->getPlayerManager() | 			$players = $this->maniaControl->getPlayerManager()->getPlayers(); | ||||||
| 			                              ->getPlayers(); |  | ||||||
| 		} | 		} | ||||||
| 		$this->updateManialink = false; | 		$this->updateManialink = false; | ||||||
|  |  | ||||||
| 		// Get map karma | 		// Get map karma | ||||||
| 		$map = $this->maniaControl->getMapManager() | 		$map = $this->maniaControl->getMapManager()->getCurrentMap(); | ||||||
| 		                          ->getCurrentMap(); |  | ||||||
|  |  | ||||||
| 		// Display the mx Karma if the setting is chosen and the MX session is available | 		// Display the mx Karma if the setting is chosen and the MX session is available | ||||||
| 		if ($displayMxKarma && isset($this->mxKarma['session']) && isset($this->mxKarma['voteCount'])) { | 		if ($displayMxKarma && isset($this->mxKarma['session']) && isset($this->mxKarma['voteCount'])) { | ||||||
| @@ -876,8 +803,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 			$voteCount = $votes['count']; | 			$voteCount = $votes['count']; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if ($this->maniaControl->getSettingManager() | 		if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_ENABLE) | ||||||
| 		                       ->getSettingValue($this, self::SETTING_WIDGET_ENABLE) |  | ||||||
| 		) { | 		) { | ||||||
| 			// Build karma manialink | 			// Build karma manialink | ||||||
| 			$this->buildManialink(); | 			$this->buildManialink(); | ||||||
| @@ -912,8 +838,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 				// $votesFrame->removeChildren(); | 				// $votesFrame->removeChildren(); | ||||||
|  |  | ||||||
| 				// Send manialink | 				// Send manialink | ||||||
| 				$this->maniaControl->getManialinkManager() | 				$this->maniaControl->getManialinkManager()->sendManialink($this->manialink, $login); | ||||||
| 				                   ->sendManialink($this->manialink, $login); |  | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -925,8 +850,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 * @return float | bool | 	 * @return float | bool | ||||||
| 	 */ | 	 */ | ||||||
| 	public function getMapKarma(Map $map) { | 	public function getMapKarma(Map $map) { | ||||||
| 		$mysqli = $this->maniaControl->getDatabase() | 		$mysqli = $this->maniaControl->getDatabase()->getMysqli(); | ||||||
| 		                             ->getMysqli(); |  | ||||||
| 		$query  = "SELECT AVG(`vote`) AS `karma` FROM `" . self::TABLE_KARMA . "` | 		$query  = "SELECT AVG(`vote`) AS `karma` FROM `" . self::TABLE_KARMA . "` | ||||||
| 				WHERE `mapIndex` = {$map->index} | 				WHERE `mapIndex` = {$map->index} | ||||||
| 				AND `vote` >= 0;"; | 				AND `vote` >= 0;"; | ||||||
| @@ -955,8 +879,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 * @return array | 	 * @return array | ||||||
| 	 */ | 	 */ | ||||||
| 	public function getMapVotes(Map $map) { | 	public function getMapVotes(Map $map) { | ||||||
| 		$mysqli = $this->maniaControl->getDatabase() | 		$mysqli = $this->maniaControl->getDatabase()->getMysqli(); | ||||||
| 		                             ->getMysqli(); |  | ||||||
| 		$query  = "SELECT `vote`, COUNT(`vote`) AS `count` FROM `" . self::TABLE_KARMA . "` | 		$query  = "SELECT `vote`, COUNT(`vote`) AS `count` FROM `" . self::TABLE_KARMA . "` | ||||||
| 				WHERE `mapIndex` = {$map->index} | 				WHERE `mapIndex` = {$map->index} | ||||||
| 				AND `vote` >= 0 | 				AND `vote` >= 0 | ||||||
| @@ -987,25 +910,14 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$title        = $this->maniaControl->getSettingManager() | 		$title        = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_TITLE); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_WIDGET_TITLE); | 		$posX         = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_POSX); | ||||||
| 		$posX         = $this->maniaControl->getSettingManager() | 		$posY         = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_POSY); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_WIDGET_POSX); | 		$width        = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_WIDTH); | ||||||
| 		$posY         = $this->maniaControl->getSettingManager() | 		$height       = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_HEIGHT); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_WIDGET_POSY); | 		$labelStyle   = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultLabelStyle(); | ||||||
| 		$width        = $this->maniaControl->getSettingManager() | 		$quadStyle    = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle(); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_WIDGET_WIDTH); | 		$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle(); | ||||||
| 		$height       = $this->maniaControl->getSettingManager() |  | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_WIDGET_HEIGHT); |  | ||||||
| 		$labelStyle   = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                   ->getStyleManager() |  | ||||||
| 		                                   ->getDefaultLabelStyle(); |  | ||||||
| 		$quadStyle    = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                   ->getStyleManager() |  | ||||||
| 		                                   ->getDefaultQuadStyle(); |  | ||||||
| 		$quadSubstyle = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                   ->getStyleManager() |  | ||||||
| 		                                   ->getDefaultQuadSubstyle(); |  | ||||||
|  |  | ||||||
| 		$manialink = new ManiaLink(self::MLID_KARMA); | 		$manialink = new ManiaLink(self::MLID_KARMA); | ||||||
|  |  | ||||||
| @@ -1056,14 +968,12 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 * @param Map $map | 	 * @param Map $map | ||||||
| 	 */ | 	 */ | ||||||
| 	public function importMxKarmaVotes(Map $map) { | 	public function importMxKarmaVotes(Map $map) { | ||||||
| 		if (!$this->maniaControl->getSettingManager() | 		if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED) | ||||||
| 		                        ->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED) |  | ||||||
| 		) { | 		) { | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if (!$this->maniaControl->getSettingManager() | 		if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_IMPORTING) | ||||||
| 		                        ->getSettingValue($this, self::SETTING_MX_KARMA_IMPORTING) |  | ||||||
| 		) { | 		) { | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| @@ -1075,8 +985,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$mysqli = $this->maniaControl->getDatabase() | 		$mysqli = $this->maniaControl->getDatabase()->getMysqli(); | ||||||
| 		                             ->getMysqli(); |  | ||||||
| 		$query  = "SELECT `mapImported` FROM `" . self::MX_IMPORT_TABLE . "` | 		$query  = "SELECT `mapImported` FROM `" . self::MX_IMPORT_TABLE . "` | ||||||
| 				WHERE `mapIndex` = {$map->index};"; | 				WHERE `mapIndex` = {$map->index};"; | ||||||
| 		$result = $mysqli->query($query); | 		$result = $mysqli->query($query); | ||||||
| @@ -1130,8 +1039,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 * Save Mx Karma Votes at MapEnd | 	 * Save Mx Karma Votes at MapEnd | ||||||
| 	 */ | 	 */ | ||||||
| 	public function sendMxKarmaVotes(Map $map) { | 	public function sendMxKarmaVotes(Map $map) { | ||||||
| 		if (!$this->maniaControl->getSettingManager() | 		if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED) | ||||||
| 		                        ->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED) |  | ||||||
| 		) { | 		) { | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -113,53 +113,32 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList | |||||||
| 		$this->initTables(); | 		$this->initTables(); | ||||||
|  |  | ||||||
| 		// Settings | 		// Settings | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_TITLE, 'Local Records'); | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_TITLE, 'Local Records'); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_POSX, -139.); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_POSY, 75); | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_POSX, -139.); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_WIDTH, 40.); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_LINESCOUNT, 15); | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_POSY, 75); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_LINEHEIGHT, 4.); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_ENABLE, true); | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_WIDTH, 40.); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NOTIFY_ONLY_DRIVER, false); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NOTIFY_BEST_RECORDS, -1); | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_LINESCOUNT, 15); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_ADJUST_OUTER_BORDER, false); | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_LINEHEIGHT, 4.); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_WIDGET_ENABLE, true); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_NOTIFY_ONLY_DRIVER, false); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_NOTIFY_BEST_RECORDS, -1); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_ADJUST_OUTER_BORDER, false); |  | ||||||
|  |  | ||||||
| 		// Callbacks | 		// Callbacks | ||||||
| 		$this->maniaControl->getTimerManager() | 		$this->maniaControl->getTimerManager()->registerTimerListening($this, 'handle1Second', 1000); | ||||||
| 		                   ->registerTimerListening($this, 'handle1Second', 1000); |  | ||||||
|  |  | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit'); | ||||||
| 		                   ->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINMAP, $this, 'handleMapBegin'); | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'handleSettingChanged'); | ||||||
| 		                   ->registerCallbackListener(Callbacks::BEGINMAP, $this, 'handleMapBegin'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer'); | ||||||
| 		$this->maniaControl->getCallbackManager() |  | ||||||
| 		                   ->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'handleSettingChanged'); |  | ||||||
| 		$this->maniaControl->getCallbackManager() |  | ||||||
| 		                   ->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer'); |  | ||||||
|  |  | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); | ||||||
| 		                   ->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(RecordCallback::CHECKPOINT, $this, 'handleCheckpointCallback'); | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(RecordCallback::LAPFINISH, $this, 'handleLapFinishCallback'); | ||||||
| 		                   ->registerCallbackListener(RecordCallback::CHECKPOINT, $this, 'handleCheckpointCallback'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(RecordCallback::FINISH, $this, 'handleFinishCallback'); | ||||||
| 		$this->maniaControl->getCallbackManager() |  | ||||||
| 		                   ->registerCallbackListener(RecordCallback::LAPFINISH, $this, 'handleLapFinishCallback'); |  | ||||||
| 		$this->maniaControl->getCallbackManager() |  | ||||||
| 		                   ->registerCallbackListener(RecordCallback::FINISH, $this, 'handleFinishCallback'); |  | ||||||
|  |  | ||||||
| 		$this->maniaControl->getCommandManager() | 		$this->maniaControl->getCommandManager()->registerCommandListener(array('recs', 'records'), $this, 'showRecordsList', false, 'Shows a list of Local Records on the current map.'); | ||||||
| 		                   ->registerCommandListener(array('recs', 'records'), $this, 'showRecordsList', false, 'Shows a list of Local Records on the current map.'); | 		$this->maniaControl->getCommandManager()->registerCommandListener('delrec', $this, 'deleteRecord', true, 'Removes a record from the database.'); | ||||||
| 		$this->maniaControl->getCommandManager() |  | ||||||
| 		                   ->registerCommandListener('delrec', $this, 'deleteRecord', true, 'Removes a record from the database.'); |  | ||||||
|  |  | ||||||
| 		$this->updateManialink = true; | 		$this->updateManialink = true; | ||||||
|  |  | ||||||
| @@ -170,8 +149,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList | |||||||
| 	 * Initialize needed database tables | 	 * Initialize needed database tables | ||||||
| 	 */ | 	 */ | ||||||
| 	private function initTables() { | 	private function initTables() { | ||||||
| 		$mysqli = $this->maniaControl->getDatabase() | 		$mysqli = $this->maniaControl->getDatabase()->getMysqli(); | ||||||
| 		                             ->getMysqli(); |  | ||||||
| 		$query  = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_RECORDS . "` ( | 		$query  = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_RECORDS . "` ( | ||||||
| 				`index` int(11) NOT NULL AUTO_INCREMENT, | 				`index` int(11) NOT NULL AUTO_INCREMENT, | ||||||
| 				`mapIndex` int(11) NOT NULL, | 				`mapIndex` int(11) NOT NULL, | ||||||
| @@ -198,8 +176,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList | |||||||
| 	 * @see \ManiaControl\Plugins\Plugin::unload() | 	 * @see \ManiaControl\Plugins\Plugin::unload() | ||||||
| 	 */ | 	 */ | ||||||
| 	public function unload() { | 	public function unload() { | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->hideManialink(self::MLID_RECORDS); | ||||||
| 		                   ->hideManialink(self::MLID_RECORDS); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -218,12 +195,10 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$this->updateManialink = false; | 		$this->updateManialink = false; | ||||||
| 		if ($this->maniaControl->getSettingManager() | 		if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_ENABLE) | ||||||
| 		                       ->getSettingValue($this, self::SETTING_WIDGET_ENABLE) |  | ||||||
| 		) { | 		) { | ||||||
| 			$manialink = $this->buildManialink(); | 			$manialink = $this->buildManialink(); | ||||||
| 			$this->maniaControl->getManialinkManager() | 			$this->maniaControl->getManialinkManager()->sendManialink($manialink); | ||||||
| 			                   ->sendManialink($manialink); |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -233,33 +208,20 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList | |||||||
| 	 * @return string | 	 * @return string | ||||||
| 	 */ | 	 */ | ||||||
| 	private function buildManialink() { | 	private function buildManialink() { | ||||||
| 		$map = $this->maniaControl->getMapManager() | 		$map = $this->maniaControl->getMapManager()->getCurrentMap(); | ||||||
| 		                          ->getCurrentMap(); |  | ||||||
| 		if (!$map) { | 		if (!$map) { | ||||||
| 			return null; | 			return null; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$title        = $this->maniaControl->getSettingManager() | 		$title        = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_TITLE); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_WIDGET_TITLE); | 		$posX         = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_POSX); | ||||||
| 		$posX         = $this->maniaControl->getSettingManager() | 		$posY         = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_POSY); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_WIDGET_POSX); | 		$width        = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_WIDTH); | ||||||
| 		$posY         = $this->maniaControl->getSettingManager() | 		$lines        = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_LINESCOUNT); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_WIDGET_POSY); | 		$lineHeight   = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_LINEHEIGHT); | ||||||
| 		$width        = $this->maniaControl->getSettingManager() | 		$labelStyle   = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultLabelStyle(); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_WIDGET_WIDTH); | 		$quadStyle    = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle(); | ||||||
| 		$lines        = $this->maniaControl->getSettingManager() | 		$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle(); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_WIDGET_LINESCOUNT); |  | ||||||
| 		$lineHeight   = $this->maniaControl->getSettingManager() |  | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_WIDGET_LINEHEIGHT); |  | ||||||
| 		$labelStyle   = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                   ->getStyleManager() |  | ||||||
| 		                                   ->getDefaultLabelStyle(); |  | ||||||
| 		$quadStyle    = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                   ->getStyleManager() |  | ||||||
| 		                                   ->getDefaultQuadStyle(); |  | ||||||
| 		$quadSubstyle = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                   ->getStyleManager() |  | ||||||
| 		                                   ->getDefaultQuadSubstyle(); |  | ||||||
|  |  | ||||||
| 		$records = $this->getLocalRecords($map); | 		$records = $this->getLocalRecords($map); | ||||||
| 		if (!is_array($records)) { | 		if (!is_array($records)) { | ||||||
| @@ -275,8 +237,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList | |||||||
| 		$backgroundQuad = new Quad(); | 		$backgroundQuad = new Quad(); | ||||||
| 		$frame->add($backgroundQuad); | 		$frame->add($backgroundQuad); | ||||||
| 		$backgroundQuad->setVAlign($backgroundQuad::TOP); | 		$backgroundQuad->setVAlign($backgroundQuad::TOP); | ||||||
| 		$adjustOuterBorder = $this->maniaControl->getSettingManager() | 		$adjustOuterBorder = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_ADJUST_OUTER_BORDER); | ||||||
| 		                                        ->getSettingValue($this, self::SETTING_ADJUST_OUTER_BORDER); |  | ||||||
| 		$height            = 7. + ($adjustOuterBorder ? count($records) : $lines) * $lineHeight; | 		$height            = 7. + ($adjustOuterBorder ? count($records) : $lines) * $lineHeight; | ||||||
| 		$backgroundQuad->setSize($width * 1.05, $height); | 		$backgroundQuad->setSize($width * 1.05, $height); | ||||||
| 		$backgroundQuad->setStyles($quadStyle, $quadSubstyle); | 		$backgroundQuad->setStyles($quadStyle, $quadSubstyle); | ||||||
| @@ -347,8 +308,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList | |||||||
| 	 * @return array | 	 * @return array | ||||||
| 	 */ | 	 */ | ||||||
| 	public function getLocalRecords(Map $map, $limit = -1) { | 	public function getLocalRecords(Map $map, $limit = -1) { | ||||||
| 		$mysqli = $this->maniaControl->getDatabase() | 		$mysqli = $this->maniaControl->getDatabase()->getMysqli(); | ||||||
| 		                             ->getMysqli(); |  | ||||||
| 		$limit  = ($limit > 0 ? 'LIMIT ' . $limit : ''); | 		$limit  = ($limit > 0 ? 'LIMIT ' . $limit : ''); | ||||||
| 		$query  = "SELECT * FROM ( | 		$query  = "SELECT * FROM ( | ||||||
| 					SELECT recs.*, @rank := @rank + 1 as `rank` FROM `" . self::TABLE_RECORDS . "` recs, (SELECT @rank := 0) ra | 					SELECT recs.*, @rank := @rank + 1 as `rank` FROM `" . self::TABLE_RECORDS . "` recs, (SELECT @rank := 0) ra | ||||||
| @@ -386,8 +346,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList | |||||||
| 				if ($setting->value) { | 				if ($setting->value) { | ||||||
| 					$this->updateManialink = true; | 					$this->updateManialink = true; | ||||||
| 				} else { | 				} else { | ||||||
| 					$this->maniaControl->getManialinkManager() | 					$this->maniaControl->getManialinkManager()->hideManialink(self::MLID_RECORDS); | ||||||
| 					                   ->hideManialink(self::MLID_RECORDS); |  | ||||||
| 				} | 				} | ||||||
| 				break; | 				break; | ||||||
| 			} | 			} | ||||||
| @@ -432,8 +391,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList | |||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$map = $this->maniaControl->getMapManager() | 		$map = $this->maniaControl->getMapManager()->getCurrentMap(); | ||||||
| 		                          ->getCurrentMap(); |  | ||||||
|  |  | ||||||
| 		$checkpointsString                   = $this->getCheckpoints($callback->player->login); | 		$checkpointsString                   = $this->getCheckpoints($callback->player->login); | ||||||
| 		$this->checkpoints[$callback->login] = array(); | 		$this->checkpoints[$callback->login] = array(); | ||||||
| @@ -449,15 +407,13 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList | |||||||
| 				// Same time | 				// Same time | ||||||
| 				// TODO: respect notify-settings | 				// TODO: respect notify-settings | ||||||
| 				$message = '$<$fff' . $callback->player->nickname . '$> equalized his/her $<$ff0' . $oldRecord->rank . '.$> Local Record: $<$fff' . Formatter::formatTime($oldRecord->time) . '$>!'; | 				$message = '$<$fff' . $callback->player->nickname . '$> equalized his/her $<$ff0' . $oldRecord->rank . '.$> Local Record: $<$fff' . Formatter::formatTime($oldRecord->time) . '$>!'; | ||||||
| 				$this->maniaControl->getChat() | 				$this->maniaControl->getChat()->sendInformation('$3c0' . $message); | ||||||
| 				                   ->sendInformation('$3c0' . $message); |  | ||||||
| 				return; | 				return; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Save time | 		// Save time | ||||||
| 		$mysqli = $this->maniaControl->getDatabase() | 		$mysqli = $this->maniaControl->getDatabase()->getMysqli(); | ||||||
| 		                             ->getMysqli(); |  | ||||||
| 		$query  = "INSERT INTO `" . self::TABLE_RECORDS . "` ( | 		$query  = "INSERT INTO `" . self::TABLE_RECORDS . "` ( | ||||||
| 				`mapIndex`, | 				`mapIndex`, | ||||||
| 				`playerIndex`, | 				`playerIndex`, | ||||||
| @@ -482,10 +438,8 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList | |||||||
| 		$newRecord    = $this->getLocalRecord($map, $callback->player); | 		$newRecord    = $this->getLocalRecord($map, $callback->player); | ||||||
| 		$improvedRank = (!$oldRecord || $newRecord->rank < $oldRecord->rank); | 		$improvedRank = (!$oldRecord || $newRecord->rank < $oldRecord->rank); | ||||||
|  |  | ||||||
| 		$notifyOnlyDriver      = $this->maniaControl->getSettingManager() | 		$notifyOnlyDriver      = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NOTIFY_ONLY_DRIVER); | ||||||
| 		                                            ->getSettingValue($this, self::SETTING_NOTIFY_ONLY_DRIVER); | 		$notifyOnlyBestRecords = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NOTIFY_BEST_RECORDS); | ||||||
| 		$notifyOnlyBestRecords = $this->maniaControl->getSettingManager() |  | ||||||
| 		                                            ->getSettingValue($this, self::SETTING_NOTIFY_BEST_RECORDS); |  | ||||||
|  |  | ||||||
| 		$message = '$3c0'; | 		$message = '$3c0'; | ||||||
| 		if ($notifyOnlyDriver) { | 		if ($notifyOnlyDriver) { | ||||||
| @@ -506,15 +460,12 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if ($notifyOnlyDriver) { | 		if ($notifyOnlyDriver) { | ||||||
| 			$this->maniaControl->getChat() | 			$this->maniaControl->getChat()->sendInformation($message, $callback->player); | ||||||
| 			                   ->sendInformation($message, $callback->player); |  | ||||||
| 		} else if (!$notifyOnlyBestRecords || $newRecord->rank <= $notifyOnlyBestRecords) { | 		} else if (!$notifyOnlyBestRecords || $newRecord->rank <= $notifyOnlyBestRecords) { | ||||||
| 			$this->maniaControl->getChat() | 			$this->maniaControl->getChat()->sendInformation($message); | ||||||
| 			                   ->sendInformation($message); |  | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_LOCALRECORDS_CHANGED, $newRecord); | ||||||
| 		                   ->triggerCallback(self::CB_LOCALRECORDS_CHANGED, $newRecord); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -546,8 +497,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList | |||||||
| 	 * @return mixed | 	 * @return mixed | ||||||
| 	 */ | 	 */ | ||||||
| 	private function getLocalRecord(Map $map, Player $player) { | 	private function getLocalRecord(Map $map, Player $player) { | ||||||
| 		$mysqli = $this->maniaControl->getDatabase() | 		$mysqli = $this->maniaControl->getDatabase()->getMysqli(); | ||||||
| 		                             ->getMysqli(); |  | ||||||
| 		$query  = "SELECT records.* FROM ( | 		$query  = "SELECT records.* FROM ( | ||||||
| 					SELECT recs.*, @rank := @rank + 1 as `rank` FROM `" . self::TABLE_RECORDS . "` recs, (SELECT @rank := 0) ra | 					SELECT recs.*, @rank := @rank + 1 as `rank` FROM `" . self::TABLE_RECORDS . "` recs, (SELECT @rank := 0) ra | ||||||
| 					WHERE recs.`mapIndex` = {$map->index} | 					WHERE recs.`mapIndex` = {$map->index} | ||||||
| @@ -586,8 +536,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList | |||||||
| 		$actionId = $callback[1][2]; | 		$actionId = $callback[1][2]; | ||||||
|  |  | ||||||
| 		$login  = $callback[1][1]; | 		$login  = $callback[1][1]; | ||||||
| 		$player = $this->maniaControl->getPlayerManager() | 		$player = $this->maniaControl->getPlayerManager()->getPlayer($login); | ||||||
| 		                             ->getPlayer($login); |  | ||||||
|  |  | ||||||
| 		if ($actionId === self::ACTION_SHOW_RECORDSLIST) { | 		if ($actionId === self::ACTION_SHOW_RECORDSLIST) { | ||||||
| 			$this->showRecordsList(array(), $player); | 			$this->showRecordsList(array(), $player); | ||||||
| @@ -601,16 +550,11 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList | |||||||
| 	 * @param Player $player | 	 * @param Player $player | ||||||
| 	 */ | 	 */ | ||||||
| 	public function showRecordsList(array $chat, Player $player) { | 	public function showRecordsList(array $chat, Player $player) { | ||||||
| 		$width  = $this->maniaControl->getManialinkManager() | 		$width  = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth(); | ||||||
| 		                             ->getStyleManager() | 		$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight(); | ||||||
| 		                             ->getListWidgetsWidth(); |  | ||||||
| 		$height = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                             ->getStyleManager() |  | ||||||
| 		                             ->getListWidgetsHeight(); |  | ||||||
|  |  | ||||||
| 		// get PlayerList | 		// get PlayerList | ||||||
| 		$records = $this->getLocalRecords($this->maniaControl->getMapManager() | 		$records = $this->getLocalRecords($this->maniaControl->getMapManager()->getCurrentMap()); | ||||||
| 		                                                     ->getCurrentMap()); |  | ||||||
|  |  | ||||||
| 		// create manialink | 		// create manialink | ||||||
| 		$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID); | 		$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID); | ||||||
| @@ -619,9 +563,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList | |||||||
| 		$script->addFeature($paging); | 		$script->addFeature($paging); | ||||||
|  |  | ||||||
| 		// Main frame | 		// Main frame | ||||||
| 		$frame = $this->maniaControl->getManialinkManager() | 		$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging); | ||||||
| 		                            ->getStyleManager() |  | ||||||
| 		                            ->getDefaultListFrame($script, $paging); |  | ||||||
| 		$maniaLink->add($frame); | 		$maniaLink->add($frame); | ||||||
|  |  | ||||||
| 		// Start offsets | 		// Start offsets | ||||||
| @@ -629,9 +571,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList | |||||||
| 		$posY = $height / 2; | 		$posY = $height / 2; | ||||||
|  |  | ||||||
| 		// Predefine Description Label | 		// Predefine Description Label | ||||||
| 		$descriptionLabel = $this->maniaControl->getManialinkManager() | 		$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel(); | ||||||
| 		                                       ->getStyleManager() |  | ||||||
| 		                                       ->getDefaultDescriptionLabel(); |  | ||||||
| 		$frame->add($descriptionLabel); | 		$frame->add($descriptionLabel); | ||||||
|  |  | ||||||
| 		// Headline | 		// Headline | ||||||
| @@ -639,8 +579,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList | |||||||
| 		$frame->add($headFrame); | 		$frame->add($headFrame); | ||||||
| 		$headFrame->setY($posY - 5); | 		$headFrame->setY($posY - 5); | ||||||
| 		$array = array('Rank' => $posX + 5, 'Nickname' => $posX + 18, 'Login' => $posX + 70, 'Time' => $posX + 101); | 		$array = array('Rank' => $posX + 5, 'Nickname' => $posX + 18, 'Login' => $posX + 70, 'Time' => $posX + 101); | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->labelLine($headFrame, $array); | ||||||
| 		                   ->labelLine($headFrame, $array); |  | ||||||
|  |  | ||||||
| 		$index     = 0; | 		$index     = 0; | ||||||
| 		$posY      = $height / 2 - 10; | 		$posY      = $height / 2 - 10; | ||||||
| @@ -669,8 +608,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList | |||||||
| 				$listRecord->nickname = $listRecord->login; | 				$listRecord->nickname = $listRecord->login; | ||||||
| 			} | 			} | ||||||
| 			$array = array($listRecord->rank => $posX + 5, '$fff' . $listRecord->nickname => $posX + 18, $listRecord->login => $posX + 70, Formatter::formatTime($listRecord->time) => $posX + 101); | 			$array = array($listRecord->rank => $posX + 5, '$fff' . $listRecord->nickname => $posX + 18, $listRecord->login => $posX + 70, Formatter::formatTime($listRecord->time) => $posX + 101); | ||||||
| 			$this->maniaControl->getManialinkManager() | 			$this->maniaControl->getManialinkManager()->labelLine($recordFrame, $array); | ||||||
| 			                   ->labelLine($recordFrame, $array); |  | ||||||
|  |  | ||||||
| 			$recordFrame->setY($posY); | 			$recordFrame->setY($posY); | ||||||
|  |  | ||||||
| @@ -679,8 +617,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Render and display xml | 		// Render and display xml | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'PlayerList'); | ||||||
| 		                   ->displayWidget($maniaLink, $player, 'PlayerList'); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -690,33 +627,27 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList | |||||||
| 	 * @param Player $player | 	 * @param Player $player | ||||||
| 	 */ | 	 */ | ||||||
| 	public function deleteRecord(array $chat, Player $player) { | 	public function deleteRecord(array $chat, Player $player) { | ||||||
| 		if (!$this->maniaControl->getAuthenticationManager() | 		if (!$this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MASTERADMIN) | ||||||
| 		                        ->checkRight($player, AuthenticationManager::AUTH_LEVEL_MASTERADMIN) |  | ||||||
| 		) { | 		) { | ||||||
| 			$this->maniaControl->getAuthenticationManager() | 			$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); | ||||||
| 			                   ->sendNotAllowed($player); |  | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$commandParts = explode(' ', $chat[1][2]); | 		$commandParts = explode(' ', $chat[1][2]); | ||||||
| 		if (count($commandParts) < 2) { | 		if (count($commandParts) < 2) { | ||||||
| 			$this->maniaControl->getChat() | 			$this->maniaControl->getChat()->sendUsageInfo('Missing Record ID! (Example: //delrec 3)', $player); | ||||||
| 			                   ->sendUsageInfo('Missing Record ID! (Example: //delrec 3)', $player); |  | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$recordId   = (int)$commandParts[1]; | 		$recordId   = (int)$commandParts[1]; | ||||||
| 		$currentMap = $this->maniaControl->getMapManager() | 		$currentMap = $this->maniaControl->getMapManager()->getCurrentMap(); | ||||||
| 		                                 ->getCurrentMap(); |  | ||||||
| 		$records    = $this->getLocalRecords($currentMap); | 		$records    = $this->getLocalRecords($currentMap); | ||||||
| 		if (count($records) < $recordId) { | 		if (count($records) < $recordId) { | ||||||
| 			$this->maniaControl->getChat() | 			$this->maniaControl->getChat()->sendError('Cannot remove record $<$fff' . $recordId . '$>!', $player); | ||||||
| 			                   ->sendError('Cannot remove record $<$fff' . $recordId . '$>!', $player); |  | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$mysqli = $this->maniaControl->getDatabase() | 		$mysqli = $this->maniaControl->getDatabase()->getMysqli(); | ||||||
| 		                             ->getMysqli(); |  | ||||||
| 		$query  = "DELETE FROM `" . self::TABLE_RECORDS . "` | 		$query  = "DELETE FROM `" . self::TABLE_RECORDS . "` | ||||||
| 				WHERE `mapIndex` = {$currentMap->index} | 				WHERE `mapIndex` = {$currentMap->index} | ||||||
| 				AND `playerIndex` = {$player->index};"; | 				AND `playerIndex` = {$player->index};"; | ||||||
| @@ -726,9 +657,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList | |||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_LOCALRECORDS_CHANGED, null); | ||||||
| 		                   ->triggerCallback(self::CB_LOCALRECORDS_CHANGED, null); | 		$this->maniaControl->getChat()->sendInformation('Record no. $<$fff' . $recordId . '$> has been removed!'); | ||||||
| 		$this->maniaControl->getChat() |  | ||||||
| 		                   ->sendInformation('Record no. $<$fff' . $recordId . '$> has been removed!'); |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -100,32 +100,22 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
|  |  | ||||||
| 		$this->initTables(); | 		$this->initTables(); | ||||||
|  |  | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MIN_HITS_RATIO_RANKING, 100); | ||||||
| 		                   ->initSetting($this, self::SETTING_MIN_HITS_RATIO_RANKING, 100); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MIN_HITS_POINTS_RANKING, 15); | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_MIN_HITS_POINTS_RANKING, 15); |  | ||||||
|  |  | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MIN_REQUIRED_RECORDS, 3); | ||||||
| 		                   ->initSetting($this, self::SETTING_MIN_REQUIRED_RECORDS, 3); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAX_STORED_RECORDS, 50); | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_MAX_STORED_RECORDS, 50); |  | ||||||
|  |  | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_RANKING_TYPE, $this->getRankingsTypeArray()); | ||||||
| 		                   ->initSetting($this, self::SETTING_RANKING_TYPE, $this->getRankingsTypeArray()); |  | ||||||
|  |  | ||||||
| 		// Callbacks | 		// Callbacks | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); | ||||||
| 		                   ->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ENDMAP, $this, 'handleEndMap'); | ||||||
| 		$this->maniaControl->getCallbackManager() |  | ||||||
| 		                   ->registerCallbackListener(Callbacks::ENDMAP, $this, 'handleEndMap'); |  | ||||||
|  |  | ||||||
| 		// Commands | 		// Commands | ||||||
| 		$this->maniaControl->getCommandManager() | 		$this->maniaControl->getCommandManager()->registerCommandListener('rank', $this, 'command_showRank', false, 'Shows your current ServerRank.'); | ||||||
| 		                   ->registerCommandListener('rank', $this, 'command_showRank', false, 'Shows your current ServerRank.'); | 		$this->maniaControl->getCommandManager()->registerCommandListener('nextrank', $this, 'command_nextRank', false, 'Shows the person in front of you in the ServerRanking.'); | ||||||
| 		$this->maniaControl->getCommandManager() | 		$this->maniaControl->getCommandManager()->registerCommandListener(array('topranks', 'top100'), $this, 'command_topRanks', false, 'Shows an overview of the best-ranked 100 players.'); | ||||||
| 		                   ->registerCommandListener('nextrank', $this, 'command_nextRank', false, 'Shows the person in front of you in the ServerRanking.'); |  | ||||||
| 		$this->maniaControl->getCommandManager() |  | ||||||
| 		                   ->registerCommandListener(array('topranks', 'top100'), $this, 'command_topRanks', false, 'Shows an overview of the best-ranked 100 players.'); |  | ||||||
|  |  | ||||||
| 		// TODO: only update records count | 		// TODO: only update records count | ||||||
| 		$this->resetRanks(); | 		$this->resetRanks(); | ||||||
| @@ -138,12 +128,9 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 	 * @return array[] | 	 * @return array[] | ||||||
| 	 */ | 	 */ | ||||||
| 	private function getRankingsTypeArray() { | 	private function getRankingsTypeArray() { | ||||||
| 		$script = $this->maniaControl->getClient() | 		$script = $this->maniaControl->getClient()->getScriptName(); | ||||||
| 		                             ->getScriptName(); |  | ||||||
|  |  | ||||||
| 		if ($this->maniaControl->getMapManager() | 		if ($this->maniaControl->getMapManager()->getCurrentMap()->getGame() === 'tm' | ||||||
| 		                       ->getCurrentMap() |  | ||||||
| 		                       ->getGame() === 'tm' |  | ||||||
| 		) { | 		) { | ||||||
| 			//TODO also add obstacle here as default | 			//TODO also add obstacle here as default | ||||||
| 			return array(self::RANKING_TYPE_RECORDS, self::RANKING_TYPE_POINTS, self::RANKING_TYPE_RATIOS); | 			return array(self::RANKING_TYPE_RECORDS, self::RANKING_TYPE_POINTS, self::RANKING_TYPE_RATIOS); | ||||||
| @@ -158,8 +145,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 	 * Create necessary database tables | 	 * Create necessary database tables | ||||||
| 	 */ | 	 */ | ||||||
| 	private function initTables() { | 	private function initTables() { | ||||||
| 		$mysqli = $this->maniaControl->getDatabase() | 		$mysqli = $this->maniaControl->getDatabase()->getMysqli(); | ||||||
| 		                             ->getMysqli(); |  | ||||||
| 		$query  = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_RANK . "` ( | 		$query  = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_RANK . "` ( | ||||||
| 				`PlayerIndex` int(11) NOT NULL, | 				`PlayerIndex` int(11) NOT NULL, | ||||||
| 				`Rank` int(11) NOT NULL, | 				`Rank` int(11) NOT NULL, | ||||||
| @@ -177,8 +163,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 	 * Resets and rebuilds the Ranking | 	 * Resets and rebuilds the Ranking | ||||||
| 	 */ | 	 */ | ||||||
| 	private function resetRanks() { | 	private function resetRanks() { | ||||||
| 		$mysqli = $this->maniaControl->getDatabase() | 		$mysqli = $this->maniaControl->getDatabase()->getMysqli(); | ||||||
| 		                             ->getMysqli(); |  | ||||||
|  |  | ||||||
| 		// Erase old Average Data | 		// Erase old Average Data | ||||||
| 		$query = "TRUNCATE TABLE `" . self::TABLE_RANK . "`;"; | 		$query = "TRUNCATE TABLE `" . self::TABLE_RANK . "`;"; | ||||||
| @@ -187,20 +172,15 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 			trigger_error($mysqli->error); | 			trigger_error($mysqli->error); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$type = $this->maniaControl->getSettingManager() | 		$type = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_RANKING_TYPE); | ||||||
| 		                           ->getSettingValue($this, self::SETTING_RANKING_TYPE); |  | ||||||
|  |  | ||||||
| 		switch ($type) { | 		switch ($type) { | ||||||
| 			case self::RANKING_TYPE_RATIOS: | 			case self::RANKING_TYPE_RATIOS: | ||||||
| 				$minHits = $this->maniaControl->getSettingManager() | 				$minHits = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MIN_HITS_RATIO_RANKING); | ||||||
| 				                              ->getSettingValue($this, self::SETTING_MIN_HITS_RATIO_RANKING); |  | ||||||
|  |  | ||||||
| 				$hits            = $this->maniaControl->getStatisticManager() | 				$hits            = $this->maniaControl->getStatisticManager()->getStatsRanking(StatisticCollector::STAT_ON_HIT, -1, $minHits); | ||||||
| 				                                      ->getStatsRanking(StatisticCollector::STAT_ON_HIT, -1, $minHits); | 				$killDeathRatios = $this->maniaControl->getStatisticManager()->getStatsRanking(StatisticManager::SPECIAL_STAT_KD_RATIO); | ||||||
| 				$killDeathRatios = $this->maniaControl->getStatisticManager() | 				$accuracies      = $this->maniaControl->getStatisticManager()->getStatsRanking(StatisticManager::SPECIAL_STAT_LASER_ACC); | ||||||
| 				                                      ->getStatsRanking(StatisticManager::SPECIAL_STAT_KD_RATIO); |  | ||||||
| 				$accuracies      = $this->maniaControl->getStatisticManager() |  | ||||||
| 				                                      ->getStatsRanking(StatisticManager::SPECIAL_STAT_LASER_ACC); |  | ||||||
|  |  | ||||||
| 				$ranks = array(); | 				$ranks = array(); | ||||||
| 				foreach ($hits as $login => $hitCount) { | 				foreach ($hits as $login => $hitCount) { | ||||||
| @@ -214,24 +194,19 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
|  |  | ||||||
| 				break; | 				break; | ||||||
| 			case self::RANKING_TYPE_POINTS: | 			case self::RANKING_TYPE_POINTS: | ||||||
| 				$minHits = $this->maniaControl->getSettingManager() | 				$minHits = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MIN_HITS_POINTS_RANKING); | ||||||
| 				                              ->getSettingValue($this, self::SETTING_MIN_HITS_POINTS_RANKING); | 				$ranks   = $this->maniaControl->getStatisticManager()->getStatsRanking(StatisticCollector::STAT_ON_HIT, -1, $minHits); | ||||||
| 				$ranks   = $this->maniaControl->getStatisticManager() |  | ||||||
| 				                              ->getStatsRanking(StatisticCollector::STAT_ON_HIT, -1, $minHits); |  | ||||||
| 				break; | 				break; | ||||||
| 			case self::RANKING_TYPE_RECORDS: | 			case self::RANKING_TYPE_RECORDS: | ||||||
| 				// TODO: verify workable status | 				// TODO: verify workable status | ||||||
| 				/** @var LocalRecordsPlugin $localRecordsPlugin */ | 				/** @var LocalRecordsPlugin $localRecordsPlugin */ | ||||||
| 				$localRecordsPlugin = $this->maniaControl->getPluginManager() | 				$localRecordsPlugin = $this->maniaControl->getPluginManager()->getPlugin(__NAMESPACE__ . '\LocalRecordsPlugin'); | ||||||
| 				                                         ->getPlugin(__NAMESPACE__ . '\LocalRecordsPlugin'); |  | ||||||
| 				if (!$localRecordsPlugin) { | 				if (!$localRecordsPlugin) { | ||||||
| 					return; | 					return; | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 				$requiredRecords = $this->maniaControl->getSettingManager() | 				$requiredRecords = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MIN_REQUIRED_RECORDS); | ||||||
| 				                                      ->getSettingValue($this, self::SETTING_MIN_REQUIRED_RECORDS); | 				$maxRecords      = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAX_STORED_RECORDS); | ||||||
| 				$maxRecords      = $this->maniaControl->getSettingManager() |  | ||||||
| 				                                      ->getSettingValue($this, self::SETTING_MAX_STORED_RECORDS); |  | ||||||
|  |  | ||||||
| 				$query = "SELECT `playerIndex`, COUNT(*) AS `Cnt` | 				$query = "SELECT `playerIndex`, COUNT(*) AS `Cnt` | ||||||
| 						FROM `" . LocalRecordsPlugin::TABLE_RECORDS . "` | 						FROM `" . LocalRecordsPlugin::TABLE_RECORDS . "` | ||||||
| @@ -245,8 +220,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 				} | 				} | ||||||
| 				$result->free_result(); | 				$result->free_result(); | ||||||
|  |  | ||||||
| 				$maps = $this->maniaControl->getMapManager() | 				$maps = $this->maniaControl->getMapManager()->getMaps(); | ||||||
| 				                           ->getMaps(); |  | ||||||
| 				foreach ($maps as $map) { | 				foreach ($maps as $map) { | ||||||
| 					$records = $localRecordsPlugin->getLocalRecords($map, $maxRecords); | 					$records = $localRecordsPlugin->getLocalRecords($map, $maxRecords); | ||||||
|  |  | ||||||
| @@ -321,17 +295,14 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 	public function showRank(Player $player) { | 	public function showRank(Player $player) { | ||||||
| 		$rankObj = $this->getRank($player); | 		$rankObj = $this->getRank($player); | ||||||
|  |  | ||||||
| 		$type = $this->maniaControl->getSettingManager() | 		$type = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_RANKING_TYPE); | ||||||
| 		                           ->getSettingValue($this, self::SETTING_RANKING_TYPE); |  | ||||||
|  |  | ||||||
| 		$message = ''; | 		$message = ''; | ||||||
| 		if ($rankObj) { | 		if ($rankObj) { | ||||||
| 			switch ($type) { | 			switch ($type) { | ||||||
| 				case self::RANKING_TYPE_RATIOS: | 				case self::RANKING_TYPE_RATIOS: | ||||||
| 					$killDeathRatio = $this->maniaControl->getStatisticManager() | 					$killDeathRatio = $this->maniaControl->getStatisticManager()->getStatisticData(StatisticManager::SPECIAL_STAT_KD_RATIO, $player->index); | ||||||
| 					                                     ->getStatisticData(StatisticManager::SPECIAL_STAT_KD_RATIO, $player->index); | 					$accuracy       = $this->maniaControl->getStatisticManager()->getStatisticData(StatisticManager::SPECIAL_STAT_LASER_ACC, $player->index); | ||||||
| 					$accuracy       = $this->maniaControl->getStatisticManager() |  | ||||||
| 					                                     ->getStatisticData(StatisticManager::SPECIAL_STAT_LASER_ACC, $player->index); |  | ||||||
| 					$message        = '$0f3Your Server rank is $<$ff3' . $rankObj->rank . '$> / $<$fff' . $this->recordCount . '$> (K/D: $<$fff' . round($killDeathRatio, 2) . '$> Acc: $<$fff' . round($accuracy * 100) . '%$>)'; | 					$message        = '$0f3Your Server rank is $<$ff3' . $rankObj->rank . '$> / $<$fff' . $this->recordCount . '$> (K/D: $<$fff' . round($killDeathRatio, 2) . '$> Acc: $<$fff' . round($accuracy * 100) . '%$>)'; | ||||||
| 					break; | 					break; | ||||||
| 				case self::RANKING_TYPE_POINTS: | 				case self::RANKING_TYPE_POINTS: | ||||||
| @@ -343,23 +314,19 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 		} else { | 		} else { | ||||||
| 			switch ($type) { | 			switch ($type) { | ||||||
| 				case self::RANKING_TYPE_RATIOS: | 				case self::RANKING_TYPE_RATIOS: | ||||||
| 					$minHits = $this->maniaControl->getSettingManager() | 					$minHits = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MIN_HITS_RATIO_RANKING); | ||||||
| 					                              ->getSettingValue($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...'; | ||||||
| 					break; | 					break; | ||||||
| 				case self::RANKING_TYPE_POINTS: | 				case self::RANKING_TYPE_POINTS: | ||||||
| 					$minPoints = $this->maniaControl->getSettingManager() | 					$minPoints = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MIN_HITS_POINTS_RANKING); | ||||||
| 					                                ->getSettingValue($this, self::SETTING_MIN_HITS_POINTS_RANKING); |  | ||||||
| 					$message   = '$0f3 You must make $<$fff' . $minPoints . '$> Hits on this server before receiving a rank...'; | 					$message   = '$0f3 You must make $<$fff' . $minPoints . '$> Hits on this server before receiving a rank...'; | ||||||
| 					break; | 					break; | ||||||
| 				case self::RANKING_TYPE_RECORDS: | 				case self::RANKING_TYPE_RECORDS: | ||||||
| 					$minRecords = $this->maniaControl->getSettingManager() | 					$minRecords = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MIN_REQUIRED_RECORDS); | ||||||
| 					                                 ->getSettingValue($this, self::SETTING_MIN_REQUIRED_RECORDS); |  | ||||||
| 					$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() | 		$this->maniaControl->getChat()->sendChat($message, $player); | ||||||
| 		                   ->sendChat($message, $player); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -370,8 +337,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 	 */ | 	 */ | ||||||
| 	private function getRank(Player $player) { | 	private function getRank(Player $player) { | ||||||
| 		//TODO setting global from db or local | 		//TODO setting global from db or local | ||||||
| 		$mysqli = $this->maniaControl->getDatabase() | 		$mysqli = $this->maniaControl->getDatabase()->getMysqli(); | ||||||
| 		                             ->getMysqli(); |  | ||||||
|  |  | ||||||
| 		$query  = "SELECT * FROM `" . self::TABLE_RANK . "` | 		$query  = "SELECT * FROM `" . self::TABLE_RANK . "` | ||||||
| 				WHERE `PlayerIndex` = {$player->index};"; | 				WHERE `PlayerIndex` = {$player->index};"; | ||||||
| @@ -404,14 +370,12 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
|  |  | ||||||
| 		if ($rankObject->rank > 1) { | 		if ($rankObject->rank > 1) { | ||||||
| 			$nextRank   = $this->getNextRank($player); | 			$nextRank   = $this->getNextRank($player); | ||||||
| 			$nextPlayer = $this->maniaControl->getPlayerManager() | 			$nextPlayer = $this->maniaControl->getPlayerManager()->getPlayerByIndex($nextRank->playerIndex); | ||||||
| 			                                 ->getPlayerByIndex($nextRank->playerIndex); |  | ||||||
| 			$message    = '$0f3The next better ranked player is $fff' . $nextPlayer->nickname; | 			$message    = '$0f3The next better ranked player is $fff' . $nextPlayer->nickname; | ||||||
| 		} else { | 		} else { | ||||||
| 			$message = '$0f3No better ranked player :-)'; | 			$message = '$0f3No better ranked player :-)'; | ||||||
| 		} | 		} | ||||||
| 		$this->maniaControl->getChat() | 		$this->maniaControl->getChat()->sendChat($message, $player); | ||||||
| 		                   ->sendChat($message, $player); |  | ||||||
|  |  | ||||||
| 		return true; | 		return true; | ||||||
| 	} | 	} | ||||||
| @@ -429,8 +393,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 		} | 		} | ||||||
| 		$nextRank = $rankObject->rank - 1; | 		$nextRank = $rankObject->rank - 1; | ||||||
|  |  | ||||||
| 		$mysqli = $this->maniaControl->getDatabase() | 		$mysqli = $this->maniaControl->getDatabase()->getMysqli(); | ||||||
| 		                             ->getMysqli(); |  | ||||||
| 		$query  = "SELECT * FROM `" . self::TABLE_RANK . "` | 		$query  = "SELECT * FROM `" . self::TABLE_RANK . "` | ||||||
| 				WHERE `Rank` = {$nextRank};"; | 				WHERE `Rank` = {$nextRank};"; | ||||||
| 		$result = $mysqli->query($query); | 		$result = $mysqli->query($query); | ||||||
| @@ -454,8 +417,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 	public function handleEndMap() { | 	public function handleEndMap() { | ||||||
| 		$this->resetRanks(); | 		$this->resetRanks(); | ||||||
|  |  | ||||||
| 		foreach ($this->maniaControl->getPlayerManager() | 		foreach ($this->maniaControl->getPlayerManager()->getPlayers() as $player) { | ||||||
| 		                            ->getPlayers() as $player) { |  | ||||||
| 			if ($player->isFakePlayer()) { | 			if ($player->isFakePlayer()) { | ||||||
| 				continue; | 				continue; | ||||||
| 			} | 			} | ||||||
| @@ -464,8 +426,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Trigger callback | 		// Trigger callback | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_RANK_BUILT); | ||||||
| 		                   ->triggerCallback(self::CB_RANK_BUILT); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -487,8 +448,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 	public function command_nextRank(array $chatCallback, Player $player) { | 	public function command_nextRank(array $chatCallback, Player $player) { | ||||||
| 		if (!$this->showNextRank($player)) { | 		if (!$this->showNextRank($player)) { | ||||||
| 			$message = '$0f3You need to have a ServerRank first!'; | 			$message = '$0f3You need to have a ServerRank first!'; | ||||||
| 			$this->maniaControl->getChat() | 			$this->maniaControl->getChat()->sendChat($message, $player); | ||||||
| 			                   ->sendChat($message, $player); |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -510,20 +470,15 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 	private function showTopRanksList(Player $player) { | 	private function showTopRanksList(Player $player) { | ||||||
| 		$query  = "SELECT * FROM `" . self::TABLE_RANK . "` | 		$query  = "SELECT * FROM `" . self::TABLE_RANK . "` | ||||||
| 				ORDER BY `Rank` ASC LIMIT 0, 100;"; | 				ORDER BY `Rank` ASC LIMIT 0, 100;"; | ||||||
| 		$mysqli = $this->maniaControl->getDatabase() | 		$mysqli = $this->maniaControl->getDatabase()->getMysqli(); | ||||||
| 		                             ->getMysqli(); |  | ||||||
| 		$result = $mysqli->query($query); | 		$result = $mysqli->query($query); | ||||||
| 		if ($mysqli->error) { | 		if ($mysqli->error) { | ||||||
| 			trigger_error($mysqli->error); | 			trigger_error($mysqli->error); | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$width  = $this->maniaControl->getManialinkManager() | 		$width  = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth(); | ||||||
| 		                             ->getStyleManager() | 		$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight(); | ||||||
| 		                             ->getListWidgetsWidth(); |  | ||||||
| 		$height = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                             ->getStyleManager() |  | ||||||
| 		                             ->getListWidgetsHeight(); |  | ||||||
|  |  | ||||||
| 		// create manialink | 		// create manialink | ||||||
| 		$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID); | 		$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID); | ||||||
| @@ -532,9 +487,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 		$script->addFeature($paging); | 		$script->addFeature($paging); | ||||||
|  |  | ||||||
| 		// Main frame | 		// Main frame | ||||||
| 		$frame = $this->maniaControl->getManialinkManager() | 		$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging); | ||||||
| 		                            ->getStyleManager() |  | ||||||
| 		                            ->getDefaultListFrame($script, $paging); |  | ||||||
| 		$maniaLink->add($frame); | 		$maniaLink->add($frame); | ||||||
|  |  | ||||||
| 		// Start offsets | 		// Start offsets | ||||||
| @@ -542,9 +495,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 		$posY = $height / 2; | 		$posY = $height / 2; | ||||||
|  |  | ||||||
| 		//Predefine description Label | 		//Predefine description Label | ||||||
| 		$descriptionLabel = $this->maniaControl->getManialinkManager() | 		$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel(); | ||||||
| 		                                       ->getStyleManager() |  | ||||||
| 		                                       ->getDefaultDescriptionLabel(); |  | ||||||
| 		$frame->add($descriptionLabel); | 		$frame->add($descriptionLabel); | ||||||
|  |  | ||||||
| 		// Headline | 		// Headline | ||||||
| @@ -552,8 +503,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 		$frame->add($headFrame); | 		$frame->add($headFrame); | ||||||
| 		$headFrame->setY($posY - 5); | 		$headFrame->setY($posY - 5); | ||||||
| 		$array = array('$oRank' => $posX + 5, '$oNickname' => $posX + 18, '$oAverage' => $posX + 70); | 		$array = array('$oRank' => $posX + 5, '$oNickname' => $posX + 18, '$oAverage' => $posX + 70); | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->labelLine($headFrame, $array); | ||||||
| 		                   ->labelLine($headFrame, $array); |  | ||||||
|  |  | ||||||
| 		$index = 1; | 		$index = 1; | ||||||
| 		$posY -= 10; | 		$posY -= 10; | ||||||
| @@ -579,19 +529,16 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { | |||||||
| 				$lineQuad->setZ(0.001); | 				$lineQuad->setZ(0.001); | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			$playerObject = $this->maniaControl->getPlayerManager() | 			$playerObject = $this->maniaControl->getPlayerManager()->getPlayerByIndex($rankedPlayer->PlayerIndex); | ||||||
| 			                                   ->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() | 			$this->maniaControl->getManialinkManager()->labelLine($playerFrame, $array); | ||||||
| 			                   ->labelLine($playerFrame, $array); |  | ||||||
|  |  | ||||||
| 			$posY -= 4; | 			$posY -= 4; | ||||||
| 			$index++; | 			$index++; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Render and display xml | 		// Render and display xml | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'TopRanks'); | ||||||
| 		                   ->displayWidget($maniaLink, $player, 'TopRanks'); |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -123,68 +123,40 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 		$this->maniaControl = $maniaControl; | 		$this->maniaControl = $maniaControl; | ||||||
|  |  | ||||||
| 		// Set CustomUI Setting | 		// Set CustomUI Setting | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->getCustomUIManager()->setChallengeInfoVisible(false); | ||||||
| 		                   ->getCustomUIManager() |  | ||||||
| 		                   ->setChallengeInfoVisible(false); |  | ||||||
|  |  | ||||||
| 		// Callbacks | 		// Callbacks | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINMAP, $this, 'handleOnBeginMap'); | ||||||
| 		                   ->registerCallbackListener(Callbacks::BEGINMAP, $this, 'handleOnBeginMap'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ENDMAP, $this, 'handleOnEndMap'); | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); | ||||||
| 		                   ->registerCallbackListener(Callbacks::ENDMAP, $this, 'handleOnEndMap'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'updateWidgets'); | ||||||
| 		$this->maniaControl->getCallbackManager() | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'updateWidgets'); | ||||||
| 		                   ->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'updateSettings'); | ||||||
| 		$this->maniaControl->getCallbackManager() |  | ||||||
| 		                   ->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'updateWidgets'); |  | ||||||
| 		$this->maniaControl->getCallbackManager() |  | ||||||
| 		                   ->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'updateWidgets'); |  | ||||||
| 		$this->maniaControl->getCallbackManager() |  | ||||||
| 		                   ->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'updateSettings'); |  | ||||||
|  |  | ||||||
| 		// Settings | 		// Settings | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED, true); | ||||||
| 		                   ->initSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED, true); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_POSX, 160 - 20); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_POSY, 90 - 4.5); | ||||||
| 		                   ->initSetting($this, self::SETTING_MAP_WIDGET_POSX, 160 - 20); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_WIDTH, 40); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_HEIGHT, 9.); | ||||||
| 		                   ->initSetting($this, self::SETTING_MAP_WIDGET_POSY, 90 - 4.5); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_MAP_WIDGET_WIDTH, 40); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_MAP_WIDGET_HEIGHT, 9.); |  | ||||||
|  |  | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED, true); | ||||||
| 		                   ->initSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED, true); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SERVERINFO_WIDGET_POSX, -160 + 17.5); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SERVERINFO_WIDGET_POSY, 90 - 4.5); | ||||||
| 		                   ->initSetting($this, self::SETTING_SERVERINFO_WIDGET_POSX, -160 + 17.5); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SERVERINFO_WIDGET_WIDTH, 35); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SERVERINFO_WIDGET_HEIGHT, 9.); | ||||||
| 		                   ->initSetting($this, self::SETTING_SERVERINFO_WIDGET_POSY, 90 - 4.5); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_SERVERINFO_WIDGET_WIDTH, 35); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_SERVERINFO_WIDGET_HEIGHT, 9.); |  | ||||||
|  |  | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NEXTMAP_WIDGET_ACTIVATED, true); | ||||||
| 		                   ->initSetting($this, self::SETTING_NEXTMAP_WIDGET_ACTIVATED, true); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NEXTMAP_WIDGET_POSX, 160 - 20); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NEXTMAP_WIDGET_POSY, 90 - 25.5); | ||||||
| 		                   ->initSetting($this, self::SETTING_NEXTMAP_WIDGET_POSX, 160 - 20); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NEXTMAP_WIDGET_WIDTH, 40); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NEXTMAP_WIDGET_HEIGHT, 12.); | ||||||
| 		                   ->initSetting($this, self::SETTING_NEXTMAP_WIDGET_POSY, 90 - 25.5); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_NEXTMAP_WIDGET_WIDTH, 40); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_NEXTMAP_WIDGET_HEIGHT, 12.); |  | ||||||
|  |  | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED, true); | ||||||
| 		                   ->initSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED, true); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_CLOCK_WIDGET_POSX, 160 - 5); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_CLOCK_WIDGET_POSY, 90 - 11); | ||||||
| 		                   ->initSetting($this, self::SETTING_CLOCK_WIDGET_POSX, 160 - 5); | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_CLOCK_WIDGET_WIDTH, 10); | ||||||
| 		$this->maniaControl->getSettingManager() | 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_CLOCK_WIDGET_HEIGHT, 5.5); | ||||||
| 		                   ->initSetting($this, self::SETTING_CLOCK_WIDGET_POSY, 90 - 11); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_CLOCK_WIDGET_WIDTH, 10); |  | ||||||
| 		$this->maniaControl->getSettingManager() |  | ||||||
| 		                   ->initSetting($this, self::SETTING_CLOCK_WIDGET_HEIGHT, 5.5); |  | ||||||
|  |  | ||||||
| 		$this->displayWidgets(); | 		$this->displayWidgets(); | ||||||
|  |  | ||||||
| @@ -196,20 +168,16 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 */ | 	 */ | ||||||
| 	private function displayWidgets() { | 	private function displayWidgets() { | ||||||
| 		// Display Map Widget | 		// Display Map Widget | ||||||
| 		if ($this->maniaControl->getSettingManager() | 		if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_ACTIVATED) | ||||||
| 		                       ->getSettingValue($this, self::SETTING_MAP_WIDGET_ACTIVATED) |  | ||||||
| 		) { | 		) { | ||||||
| 			$this->maniaControl->getClient() | 			$this->maniaControl->getClient()->triggerModeScriptEvent("Siege_SetProgressionLayerPosition", array("160.", "-67.", "0.")); | ||||||
| 			                   ->triggerModeScriptEvent("Siege_SetProgressionLayerPosition", array("160.", "-67.", "0.")); |  | ||||||
| 			$this->displayMapWidget(); | 			$this->displayMapWidget(); | ||||||
| 		} | 		} | ||||||
| 		if ($this->maniaControl->getSettingManager() | 		if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_CLOCK_WIDGET_ACTIVATED) | ||||||
| 		                       ->getSettingValue($this, self::SETTING_CLOCK_WIDGET_ACTIVATED) |  | ||||||
| 		) { | 		) { | ||||||
| 			$this->displayClockWidget(); | 			$this->displayClockWidget(); | ||||||
| 		} | 		} | ||||||
| 		if ($this->maniaControl->getSettingManager() | 		if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED) | ||||||
| 		                       ->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED) |  | ||||||
| 		) { | 		) { | ||||||
| 			$this->displayServerInfoWidget(); | 			$this->displayServerInfoWidget(); | ||||||
| 		} | 		} | ||||||
| @@ -221,20 +189,12 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 * @param string $login | 	 * @param string $login | ||||||
| 	 */ | 	 */ | ||||||
| 	public function displayMapWidget($login = null) { | 	public function displayMapWidget($login = null) { | ||||||
| 		$posX         = $this->maniaControl->getSettingManager() | 		$posX         = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_POSX); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_MAP_WIDGET_POSX); | 		$posY         = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_POSY); | ||||||
| 		$posY         = $this->maniaControl->getSettingManager() | 		$width        = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_WIDTH); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_MAP_WIDGET_POSY); | 		$height       = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_HEIGHT); | ||||||
| 		$width        = $this->maniaControl->getSettingManager() | 		$quadStyle    = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle(); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_MAP_WIDGET_WIDTH); | 		$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle(); | ||||||
| 		$height       = $this->maniaControl->getSettingManager() |  | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_MAP_WIDGET_HEIGHT); |  | ||||||
| 		$quadStyle    = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                   ->getStyleManager() |  | ||||||
| 		                                   ->getDefaultQuadStyle(); |  | ||||||
| 		$quadSubstyle = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                   ->getStyleManager() |  | ||||||
| 		                                   ->getDefaultQuadSubstyle(); |  | ||||||
|  |  | ||||||
| 		$maniaLink = new ManiaLink(self::MLID_MAP_WIDGET); | 		$maniaLink = new ManiaLink(self::MLID_MAP_WIDGET); | ||||||
| 		$script    = new Script(); | 		$script    = new Script(); | ||||||
| @@ -253,8 +213,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 		$backgroundQuad->setStyles($quadStyle, $quadSubstyle); | 		$backgroundQuad->setStyles($quadStyle, $quadSubstyle); | ||||||
| 		$backgroundQuad->addMapInfoFeature(); | 		$backgroundQuad->addMapInfoFeature(); | ||||||
|  |  | ||||||
| 		$map = $this->maniaControl->getMapManager() | 		$map = $this->maniaControl->getMapManager()->getCurrentMap(); | ||||||
| 		                          ->getCurrentMap(); |  | ||||||
|  |  | ||||||
| 		$label = new Label_Text(); | 		$label = new Label_Text(); | ||||||
| 		$frame->add($label); | 		$frame->add($label); | ||||||
| @@ -276,20 +235,15 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 		if (isset($map->mx->pageurl)) { | 		if (isset($map->mx->pageurl)) { | ||||||
| 			$quad = new Quad(); | 			$quad = new Quad(); | ||||||
| 			$frame->add($quad); | 			$frame->add($quad); | ||||||
| 			$quad->setImageFocus($this->maniaControl->getManialinkManager() | 			$quad->setImageFocus($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_MOVER)); | ||||||
| 			                                        ->getIconManager() | 			$quad->setImage($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON)); | ||||||
| 			                                        ->getIcon(IconManager::MX_ICON_MOVER)); |  | ||||||
| 			$quad->setImage($this->maniaControl->getManialinkManager() |  | ||||||
| 			                                   ->getIconManager() |  | ||||||
| 			                                   ->getIcon(IconManager::MX_ICON)); |  | ||||||
| 			$quad->setPosition(-$width / 2 + 4, -1.5, -0.5); | 			$quad->setPosition(-$width / 2 + 4, -1.5, -0.5); | ||||||
| 			$quad->setSize(4, 4); | 			$quad->setSize(4, 4); | ||||||
| 			$quad->setUrl($map->mx->pageurl); | 			$quad->setUrl($map->mx->pageurl); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Send manialink | 		// Send manialink | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->sendManialink($maniaLink, $login); | ||||||
| 		                   ->sendManialink($maniaLink, $login); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -298,20 +252,12 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 * @param bool $login | 	 * @param bool $login | ||||||
| 	 */ | 	 */ | ||||||
| 	public function displayClockWidget($login = false) { | 	public function displayClockWidget($login = false) { | ||||||
| 		$posX         = $this->maniaControl->getSettingManager() | 		$posX         = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_CLOCK_WIDGET_POSX); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_CLOCK_WIDGET_POSX); | 		$posY         = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_CLOCK_WIDGET_POSY); | ||||||
| 		$posY         = $this->maniaControl->getSettingManager() | 		$width        = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_CLOCK_WIDGET_WIDTH); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_CLOCK_WIDGET_POSY); | 		$height       = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_CLOCK_WIDGET_HEIGHT); | ||||||
| 		$width        = $this->maniaControl->getSettingManager() | 		$quadStyle    = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle(); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_CLOCK_WIDGET_WIDTH); | 		$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle(); | ||||||
| 		$height       = $this->maniaControl->getSettingManager() |  | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_CLOCK_WIDGET_HEIGHT); |  | ||||||
| 		$quadStyle    = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                   ->getStyleManager() |  | ||||||
| 		                                   ->getDefaultQuadStyle(); |  | ||||||
| 		$quadSubstyle = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                   ->getStyleManager() |  | ||||||
| 		                                   ->getDefaultQuadSubstyle(); |  | ||||||
|  |  | ||||||
| 		$maniaLink = new ManiaLink(self::MLID_CLOCK_WIDGET); | 		$maniaLink = new ManiaLink(self::MLID_CLOCK_WIDGET); | ||||||
|  |  | ||||||
| @@ -336,8 +282,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 		$label->addClockFeature(false); | 		$label->addClockFeature(false); | ||||||
|  |  | ||||||
| 		// Send manialink | 		// Send manialink | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->sendManialink($maniaLink, $login); | ||||||
| 		                   ->sendManialink($maniaLink, $login); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -346,20 +291,12 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 * @param string $login | 	 * @param string $login | ||||||
| 	 */ | 	 */ | ||||||
| 	public function displayServerInfoWidget($login = null) { | 	public function displayServerInfoWidget($login = null) { | ||||||
| 		$posX         = $this->maniaControl->getSettingManager() | 		$posX         = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_POSX); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_POSX); | 		$posY         = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_POSY); | ||||||
| 		$posY         = $this->maniaControl->getSettingManager() | 		$width        = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_WIDTH); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_POSY); | 		$height       = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_HEIGHT); | ||||||
| 		$width        = $this->maniaControl->getSettingManager() | 		$quadStyle    = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle(); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_WIDTH); | 		$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle(); | ||||||
| 		$height       = $this->maniaControl->getSettingManager() |  | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_HEIGHT); |  | ||||||
| 		$quadStyle    = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                   ->getStyleManager() |  | ||||||
| 		                                   ->getDefaultQuadStyle(); |  | ||||||
| 		$quadSubstyle = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                   ->getStyleManager() |  | ||||||
| 		                                   ->getDefaultQuadSubstyle(); |  | ||||||
|  |  | ||||||
| 		$maniaLink = new ManiaLink(self::MLID_SERVERINFO_WIDGET); | 		$maniaLink = new ManiaLink(self::MLID_SERVERINFO_WIDGET); | ||||||
|  |  | ||||||
| @@ -375,18 +312,13 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 		$backgroundQuad->setSize($width, $height); | 		$backgroundQuad->setSize($width, $height); | ||||||
| 		$backgroundQuad->setStyles($quadStyle, $quadSubstyle); | 		$backgroundQuad->setStyles($quadStyle, $quadSubstyle); | ||||||
|  |  | ||||||
| 		$serverName = $this->maniaControl->getClient() | 		$serverName = $this->maniaControl->getClient()->getServerName(); | ||||||
| 		                                 ->getServerName(); |  | ||||||
|  |  | ||||||
| 		$playerCount = $this->maniaControl->getPlayerManager() | 		$playerCount = $this->maniaControl->getPlayerManager()->getPlayerCount(true); | ||||||
| 		                                  ->getPlayerCount(true); | 		$maxPlayers  = $this->maniaControl->getClient()->getMaxPlayers(); | ||||||
| 		$maxPlayers  = $this->maniaControl->getClient() |  | ||||||
| 		                                  ->getMaxPlayers(); |  | ||||||
|  |  | ||||||
| 		$spectatorCount = $this->maniaControl->getPlayerManager() | 		$spectatorCount = $this->maniaControl->getPlayerManager()->getSpectatorCount(); | ||||||
| 		                                     ->getSpectatorCount(); | 		$maxSpectators  = $this->maniaControl->getClient()->getMaxSpectators(); | ||||||
| 		$maxSpectators  = $this->maniaControl->getClient() |  | ||||||
| 		                                     ->getMaxSpectators(); |  | ||||||
|  |  | ||||||
| 		$label = new Label_Text(); | 		$label = new Label_Text(); | ||||||
| 		$frame->add($label); | 		$frame->add($label); | ||||||
| @@ -438,8 +370,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 		$quad->setManialink('maniacontrol?favorite=' . urlencode($this->maniaControl->getServer()->login)); | 		$quad->setManialink('maniacontrol?favorite=' . urlencode($this->maniaControl->getServer()->login)); | ||||||
|  |  | ||||||
| 		// Send manialink | 		// Send manialink | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->sendManialink($maniaLink, $login); | ||||||
| 		                   ->sendManialink($maniaLink, $login); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -447,8 +378,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 */ | 	 */ | ||||||
| 	public function unload() { | 	public function unload() { | ||||||
| 		//Restore Siege Progression Layer | 		//Restore Siege Progression Layer | ||||||
| 		$this->maniaControl->getClient() | 		$this->maniaControl->getClient()->triggerModeScriptEvent('Siege_SetProgressionLayerPosition', array("160.", "90.", "0.")); | ||||||
| 		                   ->triggerModeScriptEvent('Siege_SetProgressionLayerPosition', array("160.", "90.", "0.")); |  | ||||||
|  |  | ||||||
| 		$this->closeWidget(self::MLID_CLOCK_WIDGET); | 		$this->closeWidget(self::MLID_CLOCK_WIDGET); | ||||||
| 		$this->closeWidget(self::MLID_SERVERINFO_WIDGET); | 		$this->closeWidget(self::MLID_SERVERINFO_WIDGET); | ||||||
| @@ -462,16 +392,14 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 * @param string $widgetId | 	 * @param string $widgetId | ||||||
| 	 */ | 	 */ | ||||||
| 	public function closeWidget($widgetId) { | 	public function closeWidget($widgetId) { | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->hideManialink($widgetId); | ||||||
| 		                   ->hideManialink($widgetId); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * Handle Begin Map Callback | 	 * Handle Begin Map Callback | ||||||
| 	 */ | 	 */ | ||||||
| 	public function handleOnBeginMap() { | 	public function handleOnBeginMap() { | ||||||
| 		if ($this->maniaControl->getSettingManager() | 		if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_ACTIVATED) | ||||||
| 		                       ->getSettingValue($this, self::SETTING_MAP_WIDGET_ACTIVATED) |  | ||||||
| 		) { | 		) { | ||||||
| 			$this->displayMapWidget(); | 			$this->displayMapWidget(); | ||||||
| 		} | 		} | ||||||
| @@ -482,8 +410,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 * Handle End Map Callback | 	 * Handle End Map Callback | ||||||
| 	 */ | 	 */ | ||||||
| 	public function handleOnEndMap() { | 	public function handleOnEndMap() { | ||||||
| 		if ($this->maniaControl->getSettingManager() | 		if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_ACTIVATED) | ||||||
| 		                       ->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_ACTIVATED) |  | ||||||
| 		) { | 		) { | ||||||
| 			$this->displayNextMapWidget(); | 			$this->displayNextMapWidget(); | ||||||
| 		} | 		} | ||||||
| @@ -495,23 +422,13 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 * @param string $login | 	 * @param string $login | ||||||
| 	 */ | 	 */ | ||||||
| 	public function displayNextMapWidget($login = null) { | 	public function displayNextMapWidget($login = null) { | ||||||
| 		$posX         = $this->maniaControl->getSettingManager() | 		$posX         = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_POSX); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_POSX); | 		$posY         = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_POSY); | ||||||
| 		$posY         = $this->maniaControl->getSettingManager() | 		$width        = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_WIDTH); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_POSY); | 		$height       = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_HEIGHT); | ||||||
| 		$width        = $this->maniaControl->getSettingManager() | 		$quadStyle    = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle(); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_WIDTH); | 		$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle(); | ||||||
| 		$height       = $this->maniaControl->getSettingManager() | 		$labelStyle   = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultLabelStyle(); | ||||||
| 		                                   ->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_HEIGHT); |  | ||||||
| 		$quadStyle    = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                   ->getStyleManager() |  | ||||||
| 		                                   ->getDefaultQuadStyle(); |  | ||||||
| 		$quadSubstyle = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                   ->getStyleManager() |  | ||||||
| 		                                   ->getDefaultQuadSubstyle(); |  | ||||||
| 		$labelStyle   = $this->maniaControl->getManialinkManager() |  | ||||||
| 		                                   ->getStyleManager() |  | ||||||
| 		                                   ->getDefaultLabelStyle(); |  | ||||||
|  |  | ||||||
| 		$maniaLink = new ManiaLink(self::MLID_NEXTMAP_WIDGET); | 		$maniaLink = new ManiaLink(self::MLID_NEXTMAP_WIDGET); | ||||||
|  |  | ||||||
| @@ -528,9 +445,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 		$backgroundQuad->setStyles($quadStyle, $quadSubstyle); | 		$backgroundQuad->setStyles($quadStyle, $quadSubstyle); | ||||||
|  |  | ||||||
| 		// Check if the Next Map is a queued Map | 		// Check if the Next Map is a queued Map | ||||||
| 		$queuedMap = $this->maniaControl->getMapManager() | 		$queuedMap = $this->maniaControl->getMapManager()->getMapQueue()->getNextMap(); | ||||||
| 		                                ->getMapQueue() |  | ||||||
| 		                                ->getNextMap(); |  | ||||||
|  |  | ||||||
| 		/** | 		/** | ||||||
| 		 * @var Player $requester | 		 * @var Player $requester | ||||||
| @@ -538,8 +453,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 		$requester = null; | 		$requester = null; | ||||||
| 		// if the nextmap is not a queued map, get it from map info | 		// if the nextmap is not a queued map, get it from map info | ||||||
| 		if (!$queuedMap) { | 		if (!$queuedMap) { | ||||||
| 			$map    = $this->maniaControl->getClient() | 			$map    = $this->maniaControl->getClient()->getNextMapInfo(); | ||||||
| 			                             ->getNextMapInfo(); |  | ||||||
| 			$name   = Formatter::stripDirtyCodes($map->name); | 			$name   = Formatter::stripDirtyCodes($map->name); | ||||||
| 			$author = $map->author; | 			$author = $map->author; | ||||||
| 		} else { | 		} else { | ||||||
| @@ -585,8 +499,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Send manialink | 		// Send manialink | ||||||
| 		$this->maniaControl->getManialinkManager() | 		$this->maniaControl->getManialinkManager()->sendManialink($maniaLink, $login); | ||||||
| 		                   ->sendManialink($maniaLink, $login); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -596,18 +509,15 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 */ | 	 */ | ||||||
| 	public function handlePlayerConnect(Player $player) { | 	public function handlePlayerConnect(Player $player) { | ||||||
| 		// Display Map Widget | 		// Display Map Widget | ||||||
| 		if ($this->maniaControl->getSettingManager() | 		if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_ACTIVATED) | ||||||
| 		                       ->getSettingValue($this, self::SETTING_MAP_WIDGET_ACTIVATED) |  | ||||||
| 		) { | 		) { | ||||||
| 			$this->displayMapWidget($player->login); | 			$this->displayMapWidget($player->login); | ||||||
| 		} | 		} | ||||||
| 		if ($this->maniaControl->getSettingManager() | 		if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_CLOCK_WIDGET_ACTIVATED) | ||||||
| 		                       ->getSettingValue($this, self::SETTING_CLOCK_WIDGET_ACTIVATED) |  | ||||||
| 		) { | 		) { | ||||||
| 			$this->displayClockWidget($player->login); | 			$this->displayClockWidget($player->login); | ||||||
| 		} | 		} | ||||||
| 		if ($this->maniaControl->getSettingManager() | 		if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED) | ||||||
| 		                       ->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED) |  | ||||||
| 		) { | 		) { | ||||||
| 			$this->displayServerInfoWidget(); | 			$this->displayServerInfoWidget(); | ||||||
| 		} | 		} | ||||||
| @@ -628,8 +538,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 * Update Widget on certain callbacks | 	 * Update Widget on certain callbacks | ||||||
| 	 */ | 	 */ | ||||||
| 	public function updateWidgets() { | 	public function updateWidgets() { | ||||||
| 		if ($this->maniaControl->getSettingManager() | 		if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED) | ||||||
| 		                       ->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED) |  | ||||||
| 		) { | 		) { | ||||||
| 			$this->displayServerInfoWidget(); | 			$this->displayServerInfoWidget(); | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -358,8 +358,9 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time | |||||||
|  |  | ||||||
| 			/** @var  Player $playerObj */ | 			/** @var  Player $playerObj */ | ||||||
| 			foreach ($this->maniaControl->playerManager->getPlayers() as $playerObj) { | 			foreach ($this->maniaControl->playerManager->getPlayers() as $playerObj) { | ||||||
| 				if($playerObj->isSpectator) | 				if ($playerObj->isSpectator) { | ||||||
| 					continue; | 					continue; | ||||||
|  | 				} | ||||||
|  |  | ||||||
| 				if (!isset($teams[$playerObj->teamId])) { | 				if (!isset($teams[$playerObj->teamId])) { | ||||||
| 					$teams[$playerObj->teamId] = 1; | 					$teams[$playerObj->teamId] = 1; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user