diff --git a/.gitignore b/.gitignore index 74241ef..bec544e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,6 @@ !Beu/MoreModesTools.php !Beu/SimpleChatColorer.php !Beu/SimpleSkinsRemover.php +!Beu/BeuDonationButton.php !TFH !TFH/* diff --git a/Beu/BeuDonationButton.php b/Beu/BeuDonationButton.php new file mode 100644 index 0000000..6448e43 --- /dev/null +++ b/Beu/BeuDonationButton.php @@ -0,0 +1,172 @@ +maniaControl = $maniaControl; + + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_ISANEVENT, True, 'Display the message at the 3rd person'); + + $this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); + $this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'updateSettings'); + + $this->generateManialink(); + $this->maniaControl->getManialinkManager()->sendManialink($this->manialink); + } + + /** + * Handle when a player connects + * + * @param Player $player + */ + public function handlePlayerConnect(Player $player) { + $this->maniaControl->getManialinkManager()->sendManialink($this->manialink,$player->login); + } + + public function updateSettings(Setting $setting = null) { + $this->generateManialink(); + $this->maniaControl->getManialinkManager()->sendManialink($this->manialink); + } + + private function generateManialink() { + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_ISANEVENT)) { + $message = "This server is hosted for free by Beu. You can support him by sending a donation"; + } else { + $message = "Support me and my work by sending a donation \$f00♥"; + } + + $this->manialink = << + + + + + + + EOD; + + } + + /** + * Unload the plugin and its Resources + */ + public function unload() { + $this->maniaControl->getManialinkManager()->hideManialink("XmlRpcUI_BeuDonationButton"); + } +}