fixed plugin unload method

This commit is contained in:
Steffen Schröder 2013-12-31 15:08:51 +01:00
parent fe3ca728bc
commit 07818a4ba9

View File

@ -19,13 +19,15 @@ class ChatMessagePlugin implements CommandListener, Plugin {
const PLUGIN_VERSION = 0.1; const PLUGIN_VERSION = 0.1;
const PLUGIN_NAME = 'ChatMessagePlugin'; const PLUGIN_NAME = 'ChatMessagePlugin';
const PLUGIN_AUTHOR = 'kremsy'; const PLUGIN_AUTHOR = 'kremsy';
const SETTING_AFK_FORCE_SPEC = 'AFK command forces spec'; const SETTING_AFK_FORCE_SPEC = 'AFK command forces spec';
/** /**
* Private properties * Private properties
*/ */
/** @var maniaControl $maniaControl */ /**
*
* @var maniaControl $maniaControl
*/
private $maniaControl = null; private $maniaControl = null;
/** /**
@ -66,13 +68,13 @@ class ChatMessagePlugin implements CommandListener, Plugin {
* Unload the plugin and its resources * Unload the plugin and its resources
*/ */
public function unload() { public function unload() {
$this->maniaControl->callbackManager->unregisterCallbackListener($this); $this->maniaControl->commandManager->unregisterCommandListener($this);
unset($this->maniaControl); unset($this->maniaControl);
} }
/** /**
* Builds a chat message starting with the player's nickname, can used to express emotions * Builds a chat message starting with the player's nickname, can used to express emotions
*
* @param array $chat * @param array $chat
* @param Player $player * @param Player $player
*/ */
@ -85,16 +87,17 @@ class ChatMessagePlugin implements CommandListener, Plugin {
/** /**
* Hello Message * Hello Message
*
* @param array $chat * @param array $chat
* @param Player $player * @param Player $player
*/ */
public function chat_hi(array $chat, Player $player) { public function chat_hi(array $chat, Player $player) {
$command = explode(" ", $chat[1][2]); $command = explode(" ", $chat[1][2]);
if (isset($command[1])) { if (isset($command[1])) {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iHello $z$<' . $this->getTarget($command[1]) . '$>$i!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iHello $z$<' . $this->getTarget($command[1]) . '$>$i!';
}else{ }
else {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iHello All!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iHello All!';
} }
// TODO why not italic? // TODO why not italic?
@ -103,6 +106,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
/** /**
* Bye Message * Bye Message
*
* @param array $chat * @param array $chat
* @param Player $player * @param Player $player
*/ */
@ -111,16 +115,17 @@ class ChatMessagePlugin implements CommandListener, Plugin {
if (isset($command[1])) { if (isset($command[1])) {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iBye $z$<' . $this->getTarget($command[1]) . '$>$i!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iBye $z$<' . $this->getTarget($command[1]) . '$>$i!';
}else{ }
else {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iI have to go... Bye All!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iI have to go... Bye All!';
} }
$this->maniaControl->chat->sendChat($msg, null, false); $this->maniaControl->chat->sendChat($msg, null, false);
} }
/** /**
* Thx Message * Thx Message
*
* @param array $chat * @param array $chat
* @param Player $player * @param Player $player
*/ */
@ -129,7 +134,8 @@ class ChatMessagePlugin implements CommandListener, Plugin {
if (isset($command[1])) { if (isset($command[1])) {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iThanks $z$<' . $this->getTarget($command[1]) . '$>$i!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iThanks $z$<' . $this->getTarget($command[1]) . '$>$i!';
}else{ }
else {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iThanks All!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iThanks All!';
} }
@ -138,6 +144,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
/** /**
* Good Game Message * Good Game Message
*
* @param array $chat * @param array $chat
* @param Player $player * @param Player $player
*/ */
@ -146,7 +153,8 @@ class ChatMessagePlugin implements CommandListener, Plugin {
if (isset($command[1])) { if (isset($command[1])) {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Game $z$<' . $this->getTarget($command[1]) . '$>$i!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Game $z$<' . $this->getTarget($command[1]) . '$>$i!';
}else{ }
else {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Game All!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Game All!';
} }
@ -155,6 +163,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
/** /**
* Good Luck Message * Good Luck Message
*
* @param array $chat * @param array $chat
* @param Player $player * @param Player $player
*/ */
@ -163,7 +172,8 @@ class ChatMessagePlugin implements CommandListener, Plugin {
if (isset($command[1])) { if (isset($command[1])) {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Luck $z$<' . $this->getTarget($command[1]) . '$>$i!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Luck $z$<' . $this->getTarget($command[1]) . '$>$i!';
}else{ }
else {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Luck All!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Luck All!';
} }
@ -172,6 +182,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
/** /**
* Have Fun Message * Have Fun Message
*
* @param array $chat * @param array $chat
* @param Player $player * @param Player $player
*/ */
@ -180,7 +191,8 @@ class ChatMessagePlugin implements CommandListener, Plugin {
if (isset($command[1])) { if (isset($command[1])) {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iHave Fun $z$<' . $this->getTarget($command[1]) . '$>$i!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iHave Fun $z$<' . $this->getTarget($command[1]) . '$>$i!';
}else{ }
else {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iHave Fun All!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iHave Fun All!';
} }
@ -189,6 +201,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
/** /**
* Good Luck and Have Fun Message * Good Luck and Have Fun Message
*
* @param array $chat * @param array $chat
* @param Player $player * @param Player $player
*/ */
@ -197,7 +210,8 @@ class ChatMessagePlugin implements CommandListener, Plugin {
if (isset($command[1])) { if (isset($command[1])) {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Luck and Have Fun $z$<' . $this->getTarget($command[1]) . '$>$i!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Luck and Have Fun $z$<' . $this->getTarget($command[1]) . '$>$i!';
}else{ }
else {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Luck and Have Fun All!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Luck and Have Fun All!';
} }
@ -206,6 +220,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
/** /**
* Nice Shot Message * Nice Shot Message
*
* @param array $chat * @param array $chat
* @param Player $player * @param Player $player
*/ */
@ -214,7 +229,8 @@ class ChatMessagePlugin implements CommandListener, Plugin {
if (isset($command[1])) { if (isset($command[1])) {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iNice Shot $z$<' . $this->getTarget($command[1]) . '$>$i!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iNice Shot $z$<' . $this->getTarget($command[1]) . '$>$i!';
}else{ }
else {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iNice Shot!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iNice Shot!';
} }
@ -223,6 +239,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
/** /**
* Nice one Message * Nice one Message
*
* @param array $chat * @param array $chat
* @param Player $player * @param Player $player
*/ */
@ -231,7 +248,8 @@ class ChatMessagePlugin implements CommandListener, Plugin {
if (isset($command[1])) { if (isset($command[1])) {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iNice One $z$<' . $this->getTarget($command[1]) . '$>$i!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iNice One $z$<' . $this->getTarget($command[1]) . '$>$i!';
}else{ }
else {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iNice One!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iNice One!';
} }
@ -240,6 +258,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
/** /**
* Lol! Message * Lol! Message
*
* @param array $chat * @param array $chat
* @param Player $player * @param Player $player
*/ */
@ -250,6 +269,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
/** /**
* LooOOooL! Message * LooOOooL! Message
*
* @param array $chat * @param array $chat
* @param Player $player * @param Player $player
*/ */
@ -260,6 +280,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
/** /**
* Be right back Message * Be right back Message
*
* @param array $chat * @param array $chat
* @param Player $player * @param Player $player
*/ */
@ -270,6 +291,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
/** /**
* Bad game for me Message * Bad game for me Message
*
* @param array $chat * @param array $chat
* @param Player $player * @param Player $player
*/ */
@ -280,6 +302,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
/** /**
* Leave the server with an Bootme Message * Leave the server with an Bootme Message
*
* @param array $chat * @param array $chat
* @param Player $player * @param Player $player
*/ */
@ -297,6 +320,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
/** /**
* Leave the server with an Ragequit * Leave the server with an Ragequit
*
* @param array $chat * @param array $chat
* @param Player $player * @param Player $player
*/ */
@ -312,9 +336,9 @@ class ChatMessagePlugin implements CommandListener, Plugin {
} }
} }
/** /**
* Afk Message and force player to spec * Afk Message and force player to spec
*
* @param array $chat * @param array $chat
* @param Player $player * @param Player $player
*/ */
@ -336,7 +360,9 @@ class ChatMessagePlugin implements CommandListener, Plugin {
} }
/** /**
* Checks if a Player is in the PlayerList and returns the nickname if he is, can be called per login, pid or nickname or lj for (last joined) * Checks if a Player is in the PlayerList and returns the nickname if he is, can be called per login, pid or nickname or lj for
* (last joined)
*
* @param $login * @param $login
* @return mixed * @return mixed
*/ */
@ -350,8 +376,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
$pid++; $pid++;
} }
if($login == 'lj') if ($login == 'lj') return $player->nickname;
return $player->nickname;
return $login; return $login;
} }
@ -400,5 +425,4 @@ class ChatMessagePlugin implements CommandListener, Plugin {
public static function getDescription() { public static function getDescription() {
return null; return null;
} }
} }