diff --git a/DOCS/1.7.md b/DOCS/1.7.md new file mode 100644 index 0000000..484222d --- /dev/null +++ b/DOCS/1.7.md @@ -0,0 +1,12 @@ +# Documentation on Welcome Message + +## Features in this Version: +> - Customisable: +> > Prefix, Message, ServerName + +## How To Install: +> 1. Download the Plugin Here +> 2. Put the Plugin in your Plugins Folder +> 3. Restart/Start/Stop & Start your Server +> 4. go to `plugin_data -> WelcomeMessage -> Config.yml` and Edit the values to how you like it +**Done** diff --git a/DOCS/1.8.md b/DOCS/1.8.md new file mode 100644 index 0000000..91d7300 --- /dev/null +++ b/DOCS/1.8.md @@ -0,0 +1,12 @@ +# Documentation on Welcome Message + +## Features in this Version: +> - Customisable: +> > Prefix, Message, ServerName, Whisper Or Broadcast + +## How To Install: +> 1. Download the Plugin Here +> 2. Put the Plugin in your Plugins Folder +> 3. Restart/Start/Stop & Start your Server +> 4. go to `plugin_data -> WelcomeMessage -> Config.yml` and Edit the values to how you like it +**Done** diff --git a/DOCS/1.9.md b/DOCS/1.9.md new file mode 100644 index 0000000..c82f963 --- /dev/null +++ b/DOCS/1.9.md @@ -0,0 +1,18 @@ +# Documentation on Welcome Message + +## Features in this Version: +> - Customisable: +> > Prefix, Message, ServerName Customisable In a Form + +## How To Install: +> 1. Download the Plugin Here +> 2. Put the Plugin in your Plugins Folder +> 3. Restart/Start/Stop & Start your Server +> 4. go to `plugin_data -> WelcomeMessage -> Config.yml` and Edit the values to how you like it +> +**Done** + +# Disclaimer +** if you have a previous version of this plugin you must delete the config in `plugin_data -> WelcomeMessage -> config.yml` and delete the prexesisting plugin phar file, then reinstall the plugin for it to work!** +** Required Dependencies:** +jojoe77777/FormAPI diff --git a/DOCS/2.1.md b/DOCS/2.1.md new file mode 100644 index 0000000..84d78a5 --- /dev/null +++ b/DOCS/2.1.md @@ -0,0 +1,20 @@ +# Documentation on Welcome Message + +## Features in this Version: +> - Customisable Prefix, +> - Customisable Message, +> - Customisable ServerName Customisable In a Form, +> - The Ability to chose to have a leave message and if you want the welcome message in a form or chat + +## How To Install: +> 1. Download the Plugin Here +> 2. Put the Plugin in your Plugins Folder +> 3. Restart/Start/Stop & Start your Server +> 4. go to `plugin_data -> WelcomeMessage -> Config.yml` and Edit the values to how you like it +> +**Done** + +# Disclaimer +** if you have a previous version of this plugin you must delete the config in `plugin_data -> WelcomeMessage -> config.yml` and delete the prexesisting plugin phar file, then reinstall the plugin for it to work!** +** Required Dependencies:** +jojoe77777/FormAPI diff --git a/DOCS/index.md b/DOCS/index.md new file mode 100644 index 0000000..8cb9351 --- /dev/null +++ b/DOCS/index.md @@ -0,0 +1,12 @@ +# Documentation for WelcomeMessage + +> Click Here For Documentation on V1.7
+> Click Here For Documentation on V1.8
+> Click Here For Documentation on V1.9
+ Click Here For Documentation on V1.21
+ +# Current Versions In Development: +**V1.22** +introduction of rules tab + +# Development Has Been slowed due to me no longer having as much time to develop. diff --git a/README.md b/README.md index c055f46..0faeea1 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Simple on the fly customisable welcome message. - 5.X.X # thanks to the following for helping me construct this plugin: +- ZalgoDev - SOFe - Inaayat - RuzBenzy (kinda, just gave like 1 suggestion) @@ -25,3 +26,6 @@ Simple on the fly customisable welcome message. https://poggit.pmmp.io/p/WelcomeMessage

^^ Download the Latest Flavour of WelcomeMessage ^^ + + + diff --git a/plugin.yml b/plugin.yml index 4224dfc..8b7e564 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: WelcomeMessage -main: skyss0fly\welcomemessage\Main -version: 1.8 -api: 5.0.0 +main: skyss0fly\WelcomeMessage\Main +version: 2.2 +api: 6.0.0 author: ["skyss0fly", "Inaayat"] description: A simple welcome message plugin thats customizable diff --git a/resources/config.yml b/resources/config.yml index ed3b000..dc6d1bb 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -1,10 +1,19 @@ #config +Form-Title: "Welcome!" +Submit-Msg: "Submit" +Form-Content: "Welcome" +Btn1: "Rules" -# Use {player} for the player name -# Use & for color +UseFormInsteadOfChat: true +# set to false if you want to use chat instead of form as welcoming.. -Prefix: "&l&o&cName" -Message: "&aWelcome to our server, {player}! &cWe hope you enjoy your stay at " -ServerName: "&cName" +JoinMessage: "{player} Welcome to the Server" +# if the UseFormInsteadOfChat is false then this will show instead of form -BroadcastToServer: true + +# Leave Message Values: +# {player} - gives player name + +LeaveMessage: "{player} Has left the server" + +LeaveMessageEnabled: true diff --git a/src/skyss0fly/WelcomeMessage/Form/Form.php b/src/skyss0fly/WelcomeMessage/Form/Form.php new file mode 100644 index 0000000..0476b6d --- /dev/null +++ b/src/skyss0fly/WelcomeMessage/Form/Form.php @@ -0,0 +1,56 @@ +callable = $callable; + } + + /** + * @deprecated + * @see Player::sendForm() + * + * @param Player $sender + */ + public function sendToPlayer(Player $sender) : void { + $sender->sendForm($this); + } + + public function getCallable() : ?callable { + return $this->callable; + } + + public function setCallable(?callable $callable) { + $this->callable = $callable; + } + + public function handleResponse(Player $sender, $data) : void { + $this->processData($data); + $callable = $this->getCallable(); + if($callable !== null) { + $callable($sender, $data); + } + } + + public function processData(mixed &$data) : void { + } + + public function jsonSerialize():mixed{ + return $this->data; + } +} diff --git a/src/skyss0fly/WelcomeMessage/Form/SimpleForm.php b/src/skyss0fly/WelcomeMessage/Form/SimpleForm.php new file mode 100644 index 0000000..4b95250 --- /dev/null +++ b/src/skyss0fly/WelcomeMessage/Form/SimpleForm.php @@ -0,0 +1,76 @@ +data["type"] = "form"; + $this->data["title"] = ""; + $this->data["content"] = $this->content; + $this->data["buttons"] = []; + } + + public function processData(mixed &$data): void { + $data = $this->labelMap[$data] ?? null; + } + + /** + * @param string $title + */ + public function setTitle(string $title) : void { + $this->data["title"] = $title; + } + + /** + * @return string + */ + public function getTitle() : string { + return $this->data["title"]; + } + + /** + * @return string + */ + public function getContent() : string { + return $this->data["content"]; + } + + /** + * @param string $content + */ + public function setContent(string $content) : void { + $this->data["content"] = $content; + } + + /** + * @param string $text + * @param int $imageType + * @param string $imagePath + * @param string $label + */ + public function addButton(string $text, int $imageType = -1, string $imagePath = "", ?string $label = null) : void { + $content = ["text" => $text]; + if($imageType !== -1) { + $content["image"]["type"] = $imageType === 0 ? "path" : "url"; + $content["image"]["data"] = $imagePath; + } + $this->data["buttons"][] = $content; + $this->labelMap[] = $label ?? count($this->labelMap); + } + +} diff --git a/src/skyss0fly/WelcomeMessage/Main.php b/src/skyss0fly/WelcomeMessage/Main.php new file mode 100644 index 0000000..10f53fc --- /dev/null +++ b/src/skyss0fly/WelcomeMessage/Main.php @@ -0,0 +1,60 @@ +saveDefaultConfig(); + $this->getServer()->getPluginManager()->registerEvents($this, $this); + } + + public function onPlayerJoin(PlayerJoinEvent $event): void { + $player = $event->getPlayer(); + $config = $this->getConfig(); + + if ($config->get("UseFormInsteadOfChat") === true) { + $joinForm = new SimpleForm(function (Player $player, $data) { + if ($data !== null) { + $submitMessage = $this->getConfig()->get("Submit-Msg"); + $player->sendMessage($submitMessage); + } + }); + + $formTitle = $config->get("Form-Title"); + $formContent = $config->get("Form-Content"); + + $joinForm->setTitle($formTitle); + $joinForm->setContent($formContent); + $joinForm->addButton("§d§lSubmit!"); + $player->sendForm($joinForm); + } else { + $rawMessage = $config->get("JoinMessage"); + $message = str_replace("{player}", $player->getName(), $rawMessage); + $this->getServer()->broadcastMessage($message); + } + } + + public function onPlayerLeave(PlayerQuitEvent $event): void { + $player = $event->getPlayer(); + $config = $this->getConfig(); + $leaveMessageEnabled = $config->get("LeaveMessageEnabled"); + + if ($leaveMessageEnabled === true) { + $rawMessage = $config->get("LeaveMessage"); + $message = str_replace("{player}", $player->getName(), $rawMessage); + $this->getServer()->broadcastMessage($message); + } elseif ($leaveMessageEnabled === false) { + // No action required + } else { + $this->getLogger()->error("Invalid value for 'LeaveMessageEnabled'. Disabling plugin to protect the server."); + $this->getServer()->getPluginManager()->disablePlugin($this); + } + } +} diff --git a/src/skyss0fly/welcomemessage/Main.php b/src/skyss0fly/welcomemessage/Main.php deleted file mode 100644 index a3652a0..0000000 --- a/src/skyss0fly/welcomemessage/Main.php +++ /dev/null @@ -1,34 +0,0 @@ -saveDefaultConfig(); - $this->getServer()->getPluginManager()->registerEvents($this, $this); - } - - public function onPlayerJoin(PlayerJoinEvent $event) { - $player = $event->getPlayer(); - $servername = $this->getConfig()->get("ServerName"); - $prefix = $this->getConfig()->get("Prefix"); - $message = $this->getConfig()->get("Message"); - $broadcasttoserver = $this->getConfig()->get("BroadcastToServer"); - $message = str_replace("{player}", $player->getName(), $message); - $prefix = str_replace("&", "§", $prefix); - $servername = str_replace("&", "§", $servername); - $message = str_replace("&", "§", $message); - $message = $prefix . ": " . $message . $servername; -if ($broadcasttoserver === true) { - $this->getServer()->broadcastMessage($message); -} -else { - $player->sendMessage($message); -} - } -}