Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .poggit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ branches:
projects:
WelcomeMessage:
path: ""
icon: "Icon.png"
icon: "Icon.webp"
...
34 changes: 31 additions & 3 deletions DOCS/2.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,42 @@
> - 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 <a href="https://poggit.pmmp.io/p/WelcomeMessage/1.9">Here</a>
> 1. Download the Plugin <a href="https://poggit.pmmp.io/p/WelcomeMessage/2.1">Here</a>
> 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:**
** 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

# 2.1.1:
## 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
> - Daily Cash
>
## How To Install:
> 1. Download the Plugin <a href="https://poggit.pmmp.io/p/WelcomeMessage/2.1.1">Here</a>
> 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**

**Important Changes:**

```$xuid = $player->getXuid();``` Added. If A Player is Not Logged into Xbox Auth Then This will Come out as Empty and The Player will not receive cash.

# 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
cooldogepm/BedrockEconomy
Binary file removed Icon.png
Binary file not shown.
Binary file added Icon.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Simple on the fly customisable welcome message.

## API COMPATIBLE:
- 5.X.X
**Note: Support for API 4.0.0 - 4.25.6 has Been Ended.**

# thanks to the following for helping me construct this plugin:
- <a href="https://github.com/SOF3">SOFe</a>
Expand Down
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: WelcomeMessage
main: skyss0fly\WelcomeMessage\Main
version: 2.1
version: 2.1.1
api: 5.0.0
author: ["skyss0fly", "Inaayat"]
description: A simple welcome message plugin thats customizable
12 changes: 11 additions & 1 deletion resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Btn1: "Rules"

UseFormInsteadOfChat: true
# set to false if you want to use chat instead of form as welcoming..

Whisper: false
# if true and UseFormInsteadOfChat is true then instead of broadcasting the message, it will be whispered to the player
JoinMessage: "{player} Welcome to the Server"
# if the UseFormInsteadOfChat is false then this will show instead of form

Expand All @@ -17,3 +18,12 @@ JoinMessage: "{player} Welcome to the Server"
LeaveMessage: "{player} Has left the server"

LeaveMessageEnabled: true


UseBedrockEconomy: true
DailyAmount: 1000
# Every Join gets you 1000 Cash?

# Do Not touch this:
Cooldown: 1728000
# This is How Many Ticks in a Real Life Day
45 changes: 43 additions & 2 deletions src/skyss0fly/WelcomeMessage/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,50 @@
use pocketmine\event\player\{PlayerJoinEvent, PlayerQuitEvent};
use skyss0fly\WelcomeMessage\Form\{Form, SimpleForm};
use pocketmine\player\Player;
use cooldogepm\BedrockEconomy\api\BedrockEconomyAPI;

class Main extends PluginBase implements Listener {

private $cooldown;

public function onEnable(): void {
$this->saveDefaultConfig();
$this->getServer()->getPluginManager()->registerEvents($this, $this);
$this->cooldown = $this->getConfig()->get("Cooldown");
// Initialise Daily Cooldown
}

public function onPlayerJoin(PlayerJoinEvent $event): void {
$player = $event->getPlayer();
$xuid = $player->getXuid();
// Returns Empty if Player is not Logged into Xbox Auth.

$config = $this->getConfig();
// if ($config->get("UseBedrockEconomy") === true) {
$currentTime = time();
if (isset($this->cooldowns[$player_name]) && $this->cooldowns[$player_name] > $currentTime && !$sender->hasPermission("WelcomeMessage.cooldownbypass")) {
$remainingTime = $this->cooldowns[$player_name] - $currentTime;

return;

} else {
BedrockEconomyAPI::CLOSURE()->add(
xuid: $xuid,
username: $player->getNameExact(),
amount: $this->getConfig()->get("Amount"),
decimals: 0,
onSuccess: static function (): void {
echo 'Balance updated successfully.';
},
onError: static function (SQLException $exception): void {
if ($exception instanceof RecordNotFoundException) {
echo 'Account not found';
return;
}

echo 'An error occurred while updating the balance.';
}
);

if ($config->get("UseFormInsteadOfChat") === true) {
$joinForm = new SimpleForm(function (Player $player, $data) {
Expand All @@ -35,12 +68,20 @@ public function onPlayerJoin(PlayerJoinEvent $event): void {
$joinForm->addButton("§d§lSubmit!");
$player->sendForm($joinForm);
} else {
if ($config->get("Whisper") === false){
$rawMessage = $config->get("JoinMessage");
$message = str_replace("{player}", $player->getName(), $rawMessage);
$this->getServer()->broadcastMessage($message);
}
else {
$rawMessage = $config->get("JoinMessage");
$message = str_replace("{player}", $player->getName(), $rawMessage);
$player->sendMessage($message);

}
}
}
}

public function onPlayerLeave(PlayerQuitEvent $event): void {
$player = $event->getPlayer();
$config = $this->getConfig();
Expand Down