<repo_name>EvolSoft/CustomAlerts<file_sep>/CustomAlerts/src/CustomAlerts/Commands/Commands.php
<?php

namespace CustomAlerts\Commands;

use pocketmine\command\Command;
use CustomAlerts\CustomAlerts;
use pocketmine\command\CommandSender;
use pocketmine\utils\TextFormat;

Class Commands extends Command{

    private $plugin;

    public function __construct(CustomAlerts $plugin)
    {
        parent::__construct("customalerts", "CustomAlerts commands.", null, ["calerts"]);
        $this->plugin = $plugin;

    }

    public function execute(CommandSender $sender, string $commandLabel, array $args)
    {
        if(isset($args[0])){
            switch(strtolower($args[0])){
                case "help":
                    if($sender->hasPermission("customalerts.help")){
						$sender->sendMessage(TextFormat::colorize("&b-- &aAvailable Commands &b--"));
						$sender->sendMessage(TextFormat::colorize("&d/calerts help &b-&a Show help about this plugin"));
						$sender->sendMessage(TextFormat::colorize("&d/calerts info &b-&a Show info about this plugin"));
						$sender->sendMessage(TextFormat::colorize("&d/calerts reload &b-&a Reload the config"));
					}else{
						$sender->sendMessage(TextFormat::colorize("&cYou don't have permissions to use this command"));
					}
                break;
                case "info":
                    if($sender->hasPermission("customalerts.info")){
			            $sender->sendMessage(TextFormat::colorize(CustomAlerts::PREFIX . "&aCustomAlerts &dv" . $this->plugin->getDescription()->getVersion() . "&a developed by &dEvolSoft §r§aand updated by §dKanekiLeChomeur "));
			            $sender->sendMessage(TextFormat::colorize(CustomAlerts::PREFIX . "&aWebsite &d" . $this->plugin->getDescription()->getWebsite()));
			        }else{
						$sender->sendMessage(TextFormat::colorize("&cYou don't have permissions to use this command"));
					}
                break;
                case "reload":
                    if($sender->hasPermission("customalerts.reload")){
			            $this->plugin->reloadConfig();
			            $this->plugin->cfg = $this->plugin->getConfig()->getAll();
			            $sender->sendMessage(TextFormat::colorize(CustomAlerts::PREFIX . "&aConfiguration Reloaded."));
			        }else{
						$sender->sendMessage(TextFormat::colorize("&cYou don't have permissions to use this command"));
					}
                break;
                default:
                if($sender->hasPermission("customalerts")){
                    $sender->sendMessage(TextFormat::colorize(CustomAlerts::PREFIX . "&cSubcommand &a" . $args[0] . " &cnot found. Use &a/calerts help &cto show available commands"));
                }else{
                    $sender->sendMessage(TextFormat::colorize("&cYou don't have permissions to use this command"));	
                }
                break;
            }
        }else{
            if($sender->hasPermission("customalerts")){
                $sender->sendMessage(TextFormat::colorize(CustomAlerts::PREFIX . "&cUse &a/calerts help &cto show available commands"));
            }else{
                $sender->sendMessage(TextFormat::colorize("&cYou don't have permissions to use this command"));	
            }
        }
    }

}
<file_sep>/README.md
![start2](https://cloud.githubusercontent.com/assets/10303538/6315586/9463fa5c-ba06-11e4-8f30-ce7d8219c27d.png)

# CustomAlerts

Customize or hide alerts (join/leave messages, whitelist messages, outdated server/client messages, etc...) plugin for PocketMine-MP

[![Download!](https://user-images.githubusercontent.com/10297075/101246002-cb046780-3710-11eb-950f-ba06934b8138.png)](http://gestyy.com/er3sEQ)

## Category

PocketMine-MP plugins

## Requirements

PocketMine-MP API 4.0.0

## Overview

**CustomAlerts** lets you customize or hide all PocketMine alerts (join/leave messages, whitelist messages, outdated server/client messages, etc...)

**EvolSoft Website:** *Downed*

***This Plugin uses the New API. You can't install it on old versions of PocketMine.***

With CustomAlerts you can customize or hide whitelist kick messages, outdated server/client messages, join/leave messages, first join messages, death messages, world change messages... (read documentation)

**Features**

- Customize or hide join, quit and death messages
- Add first join and world change messages
- Customize Motd ***(from MCPE 0.11.0)***
- Customize Outdated Server/Client kick messages ***(from MCPE 0.11.0 BUILD 11)***
- Customize Whitelist kick messages ***(from MCPE 0.11.0 BUILD 11)***
- Customize Full Server kick messages ***(from MCPE 0.11.0 BUILD 11) [Please keep in mind that if you have VIP or additional slots on your server you MUST disable this feature from config]***
- Customize Death messages ***(There a problem for the moment due to PocketMine-MP 4)***

**What is included?**

In the ZIP file you will find:<br>
*- CustomAlerts_v2.phar : CustomAlerts Plugin + API*<br>
*- CustomAlertsExample_v1.5.zip : Example Plugin source code*<br>

**Commands:**

***/customalerts*** *- CustomAlerts commands*

## Donate

Please support the development of this plugin with a small donation by clicking [:dollar: here](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=<EMAIL>&lc=US&item_name=KanekiLeChomeur&no_note=0&cn=&curency_code=EUR&bn=PP-DonationsBF:btn_donateCC_LG.gif:NonHosted). 
Your small donation will help me paying web hosting, domains, buying programs (such as IDEs, debuggers, etc...) and new hardware to improve software development. Thank you :smile:

## Documentation

**Text format (Available on PocketMine console and on MCPE since v0.11.0):**

**Colors:**

Black ("&0");<br>
Dark Blue ("&1");<br>
Dark Green ("&2");<br>
Dark Aqua ("&3");<br>
Dark Red ("&4");<br>
Dark Purple ("&5");<br>
Gold ("&6");<br>
Gray ("&7");<br>
Dark Gray ("&8");<br>
Blue ("&9");<br>
Green ("&a");<br>
Aqua ("&b");<br>
Red ("&c");<br>
Light Purple ("&d");<br>
Yellow ("&e");<br>
White ("&f");<br>

**Special:**

Obfuscated ("&k");<br>
Bold ("&l");<br>
Strikethrough ("&m");<br>
Underline ("&n");<br>
Italic ("&o");<br>
Reset ("&r");<br>

**Configuration (config.yml):**

```yaml
---
#REMEMBER THAT IF YOU USE CustomAlerts EXTENSIONS, MESSAGES MAY NOT FOLLOW THE DEFAULT CONFIG
#Date/Time format (replaced in {TIME}). For format codes read http://php.net/manual/en/datetime.formats.php
datetime-format: "H:i:s"
#Server Motd message settings (available from MCPE 0.11.0 and later)
Motd:
  #Motd update timeout
  update-timeout: 1
  #Show custom Motd
  custom: true
  #Motd message
  #Available Tags:
  # - {MAXPLAYERS}: Show the maximum number of players supported by the server
  # - {TIME}: Show current time
  # - {TOTALPLAYERS}: Show the number of all online players
  message: "&e[{TIME}] &aWelcome to your server! &n&b[{MAXPLAYERS}/{TOTALPLAYERS}]"
#Outdated Client message (available from MCPE 0.11.0 BUILD 11 and later)
OutdatedClient:
  #Show custom Outdated Client message
  custom: true
  #Outdated Client message
  #Available Tags:
  # - {MAXPLAYERS}: Show the maximum number of players supported by the server
  # - {TIME}: Show current time
  # - {TOTALPLAYERS}: Show the number of all online players
  message: "&cYour MCPE client is outdated!"
#Outdated Server message (available from MCPE 0.11.0 BUILD 11 and later)
OutdatedServer:
  #Show custom Outdated Server message
  custom: true
  #Outdated Server message
  #Available Tags:
  # - {MAXPLAYERS}: Show the maximum number of players supported by the server
  # - {TIME}: Show current time
  # - {TOTALPLAYERS}: Show the number of all online players
  message: "&cOops! Server outdated!"
#Whitelisted Server message (available from MCPE 0.11.0 BUILD 11 and later)
WhitelistedServer:
  #Show custom Whitelisted Server message
  custom: true
  #Whitelisted Server message
  #Available Tags:
  # - {MAXPLAYERS}: Show the maximum number of players supported by the server
  # - {TIME}: Show current time
  # - {TOTALPLAYERS}: Show the number of all online players
  message: "&c&oThis Server is whitelisted!"
#Full Server message (available from MCPE 0.11.0 BUILD 11 and later)
FullServer:
  #Show custom Full Server message
  custom: true
  #Available Tags:
  # - {MAXPLAYERS}: Show the maximum number of players supported by the server
  # - {TIME}: Show current time
  # - {TOTALPLAYERS}: Show the number of all online players
  message: "&e{PLAYER}&b, The Server is full &c[{TOTALPLAYERS}/{MAXPLAYERS}]&b!\n&l&dTry to join later :)"
#First Join message settings
FirstJoin:
  #Enable First Join message
  enable: true
  #First Join message
  #Available Tags:
  # - {MAXPLAYERS}: Show the maximum number of players supported by the server
  # - {PLAYER}: Show player name
  # - {TIME}: Show current time
  # - {TOTALPLAYERS}: Show the number of all online players
  message: "&2[{TIME}] &a{PLAYER}&d joined the game for the first time."
#Join message settings
Join:
  #Hide Join message
  hide: false
  #Show custom Join message 
  custom: true
  #Join message
  #Available Tags:
  # - {MAXPLAYERS}: Show the maximum number of players supported by the server
  # - {PLAYER}: Show player name
  # - {TIME}: Show current time
  # - {TOTALPLAYERS}: Show the number of all online players
  message: "&2[{TIME}] &a{PLAYER}&e joined the game."
#Quit message settings
Quit:
  #Hide Quit message
  hide: true
  #Show custom Quit message 
  custom: false
  #Quit message
  #Available Tags:
  # - {MAXPLAYERS}: Show the maximum number of players supported by the server
  # - {PLAYER}: Show player name
  # - {TIME}: Show current time
  # - {TOTALPLAYERS}: Show the number of all online players
  message: "&4[{TIME}] &c{PLAYER}&e has left the game"
#World Change message settings
WorldChange:
  #Enable World Change message
  enable: true
  #World Change message
  #Available Tags:
  # - {MAXPLAYERS}: Show the maximum number of players supported by the server
  # - {ORIGIN}: Show origin world name
  # - {PLAYER}: Show player name
  # - {TARGET}: Show target world name
  # - {TIME}: Show current time
  # - {TOTALPLAYERS}: Show the number of all online players
  message: "&2[{TIME}] &a{PLAYER}&e moved from &c{ORIGIN}&e to &a{TARGET}"
#Death message settings
Death:
  #Hide deafult Death message
  hide: false
  #Show custom default Death message
  custom: true
  #Default Death message
  #Available Tags:
  # - {MAXPLAYERS}: Show the maximum number of players supported by the server
  # - {PLAYER}: Show player name
  # - {TIME}: Show current time
  # - {TOTALPLAYERS}: Show the number of all online players
  message: "&c{PLAYER} died"
  #Death by contact message
  death-contact-message:
    #Hide Death by contact message
    hide: false
    #Show custom Death by contact message
    custom: true
    #Death by contact message
    #Available Tags:
    # - {BLOCK}: The name of the block which killed the player
    # - {MAXPLAYERS}: Show the maximum number of players supported by the server
    # - {PLAYER}: Show player name
    # - {TIME}: Show current time
    # - {TOTALPLAYERS}: Show the number of all online players
    message: "&cOops! {PLAYER} was killed by {BLOCK}"
  #Death by entity message (players and mobs)
  kill-message:
    #Hide Death by entity message
    hide: false
    #Show custom Death by entity message
    custom: true
    #Death by entity message
    # - {KILLER}: The name of the killer entity
    # - {MAXPLAYERS}: Show the maximum number of players supported by the server
    # - {PLAYER}: Show player name
    # - {TIME}: Show current time
    # - {TOTALPLAYERS}: Show the number of all online players
    message: "&9{PLAYER} &ewas killed by &c{KILLER}"
  #Death by projectile message
  death-projectile-message:
    #Hide Death by projectile message
    hide: false
    #Show custom Death by projectile message
    custom: true
    #Death by projectile message
    # - {KILLER}: The name of the killer entity
    # - {MAXPLAYERS}: Show the maximum number of players supported by the server
    # - {PLAYER}: Show player name
    # - {TIME}: Show current time
    # - {TOTALPLAYERS}: Show the number of all online players
    message: "&c{PLAYER} was killed by {KILLER} by arrow"
  #Death by suffocation message
  death-suffocation-message:
    #Hide Death by suffocation message
    hide: false
    #Show custom Death by suffocation message
    custom: true
    #Death by suffocation message
    # - {MAXPLAYERS}: Show the maximum number of players supported by the server
    # - {PLAYER}: Show player name
    # - {TIME}: Show current time
    # - {TOTALPLAYERS}: Show the number of all online players
    message: "&c{PLAYER} suffocated"
  #Death by fall message
  death-fall-message:
    #Hide Death by fall message
    hide: false
    #Show custom Death by fall message
    custom: true
    #Death by fall message
    # - {MAXPLAYERS}: Show the maximum number of players supported by the server
    # - {PLAYER}: Show player name
    # - {TIME}: Show current time
    # - {TOTALPLAYERS}: Show the number of all online players
    message: "&c{PLAYER} fell from a high place"
  #Death by fire message
  death-fire-message:
    #Hide Death by fire message
    hide: false
    #Show custom Death by fire message
    custom: true
    #Death by fire message
    # - {MAXPLAYERS}: Show the maximum number of players supported by the server
    # - {PLAYER}: Show player name
    # - {TIME}: Show current time
    # - {TOTALPLAYERS}: Show the number of all online players
    message: "&c{PLAYER} went up in flames"
  #Death on fire message
  death-on-fire-message:
    #Hide Death on fire message
    hide: false
    #Show custom Death on fire message
    custom: true
    #Death on fire message
    # - {MAXPLAYERS}: Show the maximum number of players supported by the server
    # - {PLAYER}: Show player name
    # - {TIME}: Show current time
    # - {TOTALPLAYERS}: Show the number of all online players
    message: "&c{PLAYER} burned"
  #Death by lava message
  death-lava-message:
    #Hide Death by lava message
    hide: false
    #Show custom Death by lava message
    custom: true
    #Death by lava message
    # - {MAXPLAYERS}: Show the maximum number of players supported by the server
    # - {PLAYER}: Show player name
    # - {TIME}: Show current time
    # - {TOTALPLAYERS}: Show the number of all online players
    message: "&c{PLAYER} tried to swim in lava"
  #Death by drowning message
  death-drowning-message:
    #Hide Death by drowning message
    hide: false
    #Show custom Death by drowning message
    custom: true
    #Death by drowning message
    # - {MAXPLAYERS}: Show the maximum number of players supported by the server
    # - {PLAYER}: Show player name
    # - {TIME}: Show current time
    # - {TOTALPLAYERS}: Show the number of all online players
    message: "&c{PLAYER} drowned"
  #Death by explosion message
  death-explosion-message:
    #Hide Death by explosion message
    hide: false
    #Show custom Death by explosion message
    custom: true
    #Death by explosion message
    # - {MAXPLAYERS}: Show the maximum number of players supported by the server
    # - {PLAYER}: Show player name
    # - {TIME}: Show current time
    # - {TOTALPLAYERS}: Show the number of all online players
    message: "&c{PLAYER} exploded"
  #Death by void message
  death-void-message:
    #Hide Death by void message
    hide: false
    #Show custom Death by void message
    custom: true
    #Death by void message
    # - {MAXPLAYERS}: Show the maximum number of players supported by the server
    # - {PLAYER}: Show player name
    # - {TIME}: Show current time
    # - {TOTALPLAYERS}: Show the number of all online players
    message: "&c{PLAYER} fell into the void"
  #Death by suicide message
  death-suicide-message:
    #Hide Death by suicide message
    hide: false
    #Show custom Death by suicide message
    custom: true
    #Death by suicide message
    # - {MAXPLAYERS}: Show the maximum number of players supported by the server
    # - {PLAYER}: Show player name
    # - {TIME}: Show current time
    # - {TOTALPLAYERS}: Show the number of all online players
    message: "&c{PLAYER} committed suicide"
  #Death magic message
  death-magic-message:
    #Hide Death magic message
    hide: false
    #Show custom Death magic message
    custom: true
    #Death magic message
    # - {MAXPLAYERS}: Show the maximum number of players supported by the server
    # - {PLAYER}: Show player name
    # - {TIME}: Show current time
    # - {TOTALPLAYERS}: Show the number of all online players
    message: "&c{PLAYER} was killed by a spell"
```

**Commands:**

***/customalerts*** *- CustomAlerts commands* **Not usable for the moment**
<br><br>
**Permissions:**
<br>
- <dd><i><b>customalerts.*</b> - CustomAlerts permissions.</i></dd>
- <dd><i><b>customalerts.help</b> - CustomAlerts command Help permission.</i></dd>
- <dd><i><b>customalerts.info</b> - CustomAlerts command Info permission.</i></dd>
- <dd><i><b>customalerts.reload</b> - CustomAlerts command Reload permission.</i></dd>

## API

Almost all our plugins have API access to widely extend their features.

**Basic Tutorial:**

*1. Define the plugin dependency in plugin.yml (you can check if CustomAlerts is installed in different ways):*
```yaml
depend: [CustomAlerts]
```
*2. Include CustomAlerts API and CustomAlerts Events in your php code:*
```php
//PocketMine Event Listener
use pocketmine\event\Listener;
//CustomAlerts API
use CustomAlerts\CustomAlerts;
//CustomAlerts Events
use CustomAlerts\Events\CustomAlertsJoinEvent;
```
*3. Create the class:*
```php
class Example extends PluginBase implements Listener {
}
```
*4. Check if CustomAlerts API is compatible (insert this code in onEnable():void function)*
```php
if(CustomAlerts::getAPI()->getAPIVersion() == "(used API version)"){
            //API compatible
            //Register Events
            $this->getServer()->getPluginManager()->registerEvents($this, $this);
        }else{
            //API not compatible
            $this->getPluginLoader()->disablePlugin($this);
        }
  }
```
*5. Handle a CustomAlerts event (in this tutorial we will handle the CustomAlertsJoinEvent):*
```php
public function onCAJoinEvent(CustomAlertsJoinEvent $event){
  $event->setMessage("Example Join message: " . $event->getPlayer()->getName());
}
```
*6. Access the API by doing:*
```php
CustomAlerts::getAPI()->api_function();
```

***A full plugin example using CustomAlerts API and CustomAlerts Events is included in the ZIP file.***

**CustomAlerts API Events:**

Each CustomAlerts event has two global functions:

###### Set Message:

```php
setMessage($message);
```

**Description:**<br>
Set event message.<br>
**Parameters:**<br>
*$message*

###### Get Message:

```php
getMessage();
```

**Description:**<br>
Get event message.<br>
**Return:**<br>
*string*

###### CustomAlertsDeathEvent:

This event is handled when a player dies.

Event functions are:

###### Get Player:

```php
Player getPlayer()
```
**Description:**<br>
Get death event player.<br>
**Return:**<br>
The death event player

###### Get Cause:

```php
EntityDamageEvent|null getCause()
```
**Description:**<br>
Get death event cause.<br>
**Return:**<br>
The death event cause

###### CustomAlertsFullServerKickEvent:

This event is handled when a player is kicked due to full server.

Event functions are:

###### Get NetworkSession:

```php
NetworkSession getOrigin()
```
**Description:**<br>
Get event NetworkSession.<br>
**Return:**<br>
The event NetworkSession (instance of pocketmine\Player)

###### CustomAlertsJoinEvent:

This event is handled when a player joins.

Event functions are:

###### Get Player:

```php
Player getPlayer()
```
**Description:**<br>
Get join event player.<br>
**Return:**<br>
The join event player (instance of pocketmine\player\Player)

###### Get default PocketMine join message:

```php
string getPocketMineJoinMessage()
```
**Description:**<br>
Get default PocketMine join message.<br>
**Return:**<br>
The default PocketMine join message

###### CustomAlertsMotdUpdateEvent:

This event is handled when the motd is updated

Event functions are:

###### Get default PocketMine Motd:

```php
string getPocketMineMotd()
```
**Description:**<br>
Get default PocketMine Motd.<br>
**Return:**<br>
The default PocketMine Motd

###### CustomAlertsOutdatedClientKickEvent:

This event is handled when a player is kicked due to outdated client.

Event functions are:

###### Get NetworkSession:

```php
NetworkSession getOrigin()
```
**Description:**<br>
Get event NetworkSession.<br>
**Return:**<br>
The event NetworkSession (instance of pocketmine\network\mcpe\NetworkSession)

###### CustomAlertsOutdatedServerKickEvent:

This event is handled when a player is kicked due to outdated server.

Event functions are:

###### Get NetworkSession:

```php
NetworkSession getOrigin()
```
**Description:**<br>
Get event player.<br>
**Return:**<br>
The event NetworkSession (instance of pocketmine\network\mcpe\NetworkSession)

###### CustomAlertsQuitEvent:

This event is handled when a player quits. It must be declared:

Event functions are:

###### Get Player:

```php
Player getPlayer()
```
**Description:**<br>
Get quit event player.<br>
**Return:**<br>
The quit event player (instance of pocketmine\player\Player)

###### Get default PocketMine quit message:

```php
string getPocketMineQuitMessage()
```
**Description:**<br>
Get default PocketMine quit message.<br>
**Return:**<br>
The default PocketMine quit message

###### CustomAlertsWhitelistKickEvent:

This event is handled when a player is kicked due to whitelisted server.

Event functions are:

###### Get Player:

```php
PlayerInfo getPlayerInfo()
```
**Description:**<br>
Get event player.<br>
**Return:**<br>
The event PlayerInfo (instance of pocketmine\player\PlayerInfo)

###### CustomAlertsWorldChangeEvent:

This event is handled when a player changes world. It must be declared:

Event functions are:

###### Get Player:

```php
Player getPlayer()
```
**Description:**<br>
Get world change event player.<br>
**Return:**<br>
The world change event player (instance of pocketmine\player\Player)

###### Get Origin World:

```php
World getFrom()
```
**Description:**<br>
Get origin world.<br>
**Return:**<br>
The origin world (instance of pocketmine\world\World)

###### Get Target World:

```php
World getTarget()
```
**Description:**<br>
Get target world.<br>
**Return:**<br>
The target world (instance of pocketmine\world\World)

**CustomAlerts API Functions:**

###### Get Version:
```php
string getVersion()
```
**Description:**<br>
Get CustomAlerts plugin version.<br>
**Return:**<br>
plugin version

###### Get API Version:
```php
string getAPIVersion()
```
**Description:**<br>
Get the CustomAlerts API version.<br>
**Return:**<br>
plugin API version

###### Check if motd message is custom:
```php
boolean isMotdCustom()
```
**Description:**<br>
Check if motd message is custom.<br>
**Return:**<br>
*bool*

###### Get default motd message:
```php
string getMotdMessage()
```
**Description:**<br>
Get motd message.<br>
**Return:**<br>
*string*

###### Check if outdated client message is custom:
```php
boolean isOutdatedClientMessageCustom()
```
**Description:**<br>
Check if outdated client message is custom.<br>
**Return:**<br>
*bool*

###### Get outdated client message:
```php
string getOutdatedClientMessage()
```
**Description:**<br>
Get outdated client message.<br>
**Parameters:**<br>
**Return:**<br>
*string*

###### Check if outdated server message is custom:
```php
boolean isOutdatedServerMessageCustom()
```
**Description:**<br>
Check if outdated server message is custom.<br>
**Return:**<br>
*bool*

###### Get outdated server message:
```php
string getOutdatedServerMessage()
```
**Description:**<br>
Get outdated server message.<br>
**Parameters:**<br>
**Return:**<br>
*string*

###### Check if whitelist message is custom:
```php
boolean isWhitelistMessageCustom()
```
**Description:**<br>
Check if whitelist message is custom.<br>
**Return:**<br>
*bool*

###### Get whitelist message:
```php
string getWhitelistMessage()
```
**Description:**<br>
Get whitelist message.<br>
**Parameters:**<br>
**Return:**<br>
*string*

###### Check if full server message is custom:
```php
boolean isFullServerMessageCustom()
```
**Description:**<br>
Check if full server message is custom.<br>
**Return:**<br>
*bool*

###### Get full server message:
```php
string getFullServerMessage()
```
**Description:**<br>
Get full server message.<br>
**Parameters:**<br>
*$player* the current player<br>
**Return:**<br>
*string*

###### Check if first join message is enabled:
```php
boolean isFirstJoinMessageEnabled()
```
**Description:**<br>
Check if first join message is enabled.<br>
**Return:**<br>
*bool*

###### Get first join message:
```php
string getFirstJoinMessage(Player $player)
```
**Description:**<br>
Get first join message.<br>
**Parameters:**<br>
*$player* the current player<br>
**Return:**<br>
*string*

###### Check if join message is custom:
```php
boolean isJoinMessageCustom()
```
**Description:**<br>
Check if join message is custom.<br>
**Return:**<br>
*bool*

###### Check if join message is hidden:
```php
boolean isJoinMessageHidden()
```
**Description:**<br>
Check if join message is hidden.<br>
**Return:**<br>
*bool*

###### Get join message:
```php
string getJoinMessage(Player $player)
```
**Description:**<br>
Get join message.<br>
**Parameters:**<br>
*$player* the current player<br>
**Return:**<br>
*string*

###### Check if quit message is custom:
```php
boolean isQuitMessageCustom()
```
**Description:**<br>
Check if quit message is custom.<br>
**Return:**<br>
*bool*

###### Check if quit message is hidden:
```php
boolean isQuitMessageHidden()
```
**Description:**<br>
Check if quit message is hidden.<br>
**Return:**<br>
*bool*

###### Get quit message:
```php
string getQuitMessage(Player $player)
```
**Description:**<br>
Get quit message.<br>
**Parameters:**<br>
*$player* the current player<br>
**Return:**<br>
*string*

###### Check if world change message is enabled:
```php
boolean isWorldChangeMessageEnabled()
```
**Description:**<br>
Check if world change message is enabled.<br>
**Return:**<br>
*bool*

###### Get world change message:
```php
string getWorldChangeMessage(Player $player, World $origin, World $target)
```
**Description:**<br>
Get default world change message.<br>
**Parameters:**<br>
*$player* the current player<br>
*$origin* the origin level<br>
*$target* the target level<br>
**Return:**<br>
*string*

###### Check if death messages are custom:
```php
boolean isDeathMessageCustom($cause = null)
```
**Description:**<br>
Check if death messages are custom.<br>
**Parameters:**<br>
*$cause* Check message by cause<br>
**Return:**<br>
*boolean*

###### Check if death messages are hidden:
```php
boolean isDeathMessageHidden($cause = null)
```
**Description:**<br>
Check if death messages are hidden.<br>
**Parameters:**<br>
*$cause* Check message by cause<br>
**Return:**<br>
*bool*

###### Get death message for the specified cause:
```php
string getDeathMessage(Player $player, $cause = null)
```
**Description:**<br>
Get default death message related to the specified cause.<br>
**Parameters:**<br>
*$player* the current player<br>
*$cause* the cause of death (instanceof EntityDamageEvent). If it's null, the function will return the default death message
**Return:**<br>
*string*
<file_sep>/CustomAlerts/src/CustomAlerts/Events/CustomAlertsWhitelistKickEvent.php
<?php

/*
 * CustomAlerts v2.0 by EvolSoft
 * Developer: Flavius12
 * Website: https://www.evolsoft.tk
 * Copyright (C) 2014-2018 EvolSoft
 * Licensed under MIT (https://github.com/EvolSoft/CustomAlerts/blob/master/LICENSE)
 */

namespace CustomAlerts\Events;

use pocketmine\player\PlayerInfo;

class CustomAlertsWhitelistKickEvent extends CustomAlertsEvent {
	
	public static $handlerList = null;
	
	/** @var PlayerInfo $player */
	private $player;
	
	/**
	 * @param PlayerInfo $player
	 */
	public function __construct(?PlayerInfo $player){
		$this->player = $player;
	}

	/**
	 * Get whitelist kick event player
	 * 
	 * @return PlayerInfo
	 */
	public function getPlayerInfo() : ?PlayerInfo {
		return $this->player;
	}
}
<file_sep>/CustomAlerts/src/CustomAlerts/Events/CustomAlertsMotdUpdateEvent.php
<?php

/*
 * CustomAlerts v2.0 by EvolSoft
 * Developer: Flavius12
 * Website: https://www.evolsoft.tk
 * Copyright (C) 2014-2018 EvolSoft
 * Licensed under MIT (https://github.com/EvolSoft/CustomAlerts/blob/master/LICENSE)
 */

namespace CustomAlerts\Events;

class CustomAlertsMotdUpdateEvent extends CustomAlertsEvent {
	
	public static $handlerList = null;

	public function __construct(){}
}<file_sep>/CustomAlertsExample/src/CustomAlertsExample/CustomAlertsExample.php
<?php

/*
 * This is an Example Plugin with CustomAlerts API implementation
 * This plugin will show an example join message using CustomAlerts API and Events
 */

namespace CustomAlertsExample;

use pocketmine\event\Listener;
use pocketmine\plugin\PluginBase;
use pocketmine\utils\TextFormat;

//CustomAlerts API Call
use CustomAlerts\CustomAlerts;
use CustomAlerts\Events\CustomAlertsJoinEvent;

class CustomAlertsExample extends PluginBase implements Listener {
    
    public function onEnable(){
    	if(CustomAlerts::getAPI()->getAPIVersion() == "2.0"){ //Checking API version. Important for API Functions Calls
    		$this->getLogger()->info(TextFormat::GREEN . "Example Plugin using CustomAlerts (API v2.0)");
    		$this->getServer()->getPluginManager()->registerEvents($this, $this);
    	}else{
    		$this->getLogger()->alert(TextFormat::RED . "Plugin disabled. Please use CustomAlerts (API v2.0)");
    		$this->getPluginLoader()->disablePlugin($this);
    	}
    }
    
    public function onCAJoinEvent(CustomAlertsJoinEvent $event){
        $event->setMessage("Example Join Message: " . $event->getPlayer()->getName());
    }
}<file_sep>/CustomAlerts/src/CustomAlerts/Events/CustomAlertsEvent.php
<?php

/*
 * CustomAlerts v2.0 by EvolSoft
 * Developer: Flavius12
 * Website: https://www.evolsoft.tk
 * Copyright (C) 2014-2018 EvolSoft
 * Licensed under MIT (https://github.com/EvolSoft/CustomAlerts/blob/master/LICENSE)
 */

namespace CustomAlerts\Events;

use pocketmine\event\plugin\PluginEvent;

abstract class CustomAlertsEvent extends PluginEvent {
    
    /** @var string */
    private $message;
    
    /**
     * Get event message
     * 
     * @return string
     */
    public function getMessage(){
        return $this->message;
    }
    
    /**
     * Set event message
     * 
     * @param string $message
     */
    public function setMessage($message){
        $this->message = $message;
    }
}<file_sep>/CustomAlerts/src/CustomAlerts/EventListener.php
<?php

/*
 * CustomAlerts v2.0 by EvolSoft
 * Developer: Flavius12
 * Website: https://www.evolsoft.tk
 * Copyright (C) 2014-2018 EvolSoft
 * Licensed under MIT (https://github.com/EvolSoft/CustomAlerts/blob/master/LICENSE)
 */

namespace CustomAlerts;

use pocketmine\event\Listener;
use pocketmine\event\player\PlayerDeathEvent;
use pocketmine\event\player\PlayerJoinEvent;
use pocketmine\event\player\PlayerPreLoginEvent;
use pocketmine\event\player\PlayerQuitEvent;
use pocketmine\event\server\DataPacketReceiveEvent;
use pocketmine\network\mcpe\protocol\LoginPacket;
use pocketmine\network\mcpe\protocol\ProtocolInfo;
use pocketmine\player\Player;
use pocketmine\event\server\QueryRegenerateEvent;
use pocketmine\Server;
use pocketmine\network\mcpe\NetworkSession;
use CustomAlerts\Events\CustomAlertsDeathEvent;
use CustomAlerts\Events\CustomAlertsFullServerKickEvent;
use CustomAlerts\Events\CustomAlertsJoinEvent;
use CustomAlerts\Events\CustomAlertsOutdatedClientKickEvent;
use CustomAlerts\Events\CustomAlertsOutdatedServerKickEvent;
use CustomAlerts\Events\CustomAlertsQuitEvent;
use CustomAlerts\Events\CustomAlertsWhitelistKickEvent;
use CustomAlerts\Events\CustomAlertsWorldChangeEvent;
use pocketmine\event\entity\EntityTeleportEvent;

class EventListener implements Listener {

	private $plugin;
	
	public function __construct(CustomAlerts $plugin){
        $this->plugin = $plugin;
    }
    
    /**
     * @param DataPacketReceiveEvent $event
     *
     * @priority HIGHEST
     */
    public function onReceivePacket(DataPacketReceiveEvent $event){
	    $origin = $event->getOrigin();
    	$packet = $event->getPacket();
    	if($packet instanceof LoginPacket){
    	    if($packet->protocol < ProtocolInfo::CURRENT_PROTOCOL){
    	        //Outdated Client message
    	        $cevent = new CustomAlertsOutdatedClientKickEvent($origin);
    	        if($this->plugin->isOutdatedClientMessageCustom()){
    	            $cevent->setMessage($this->plugin->getOutdatedClientMessage());
    	        }
    	        $cevent->call();
    	        if($cevent->getMessage() != ""){
					$origin->disconnect($cevent->getMessage());
    	            $event->cancel();
    	            return;
    	        }
    	    }else if($packet->protocol > ProtocolInfo::CURRENT_PROTOCOL){
    	        //Outdated Server message
    	        $cevent = new CustomAlertsOutdatedServerKickEvent($origin);
    	        if($this->plugin->isOutdatedServerMessageCustom()){
    	            $cevent->setMessage($this->plugin->getOutdatedServerMessage());
    	        }
    	        $cevent->call();
    	        if($cevent->getMessage() != ""){
    	            $origin->disconnect($cevent->getMessage());
    	            $event->cancel();
    	            return;
    	        }
    	    }
			if(count($this->plugin->getServer()->getOnlinePlayers()) >= $this->plugin->getServer()->getMaxPlayers() || count($this->plugin->getServer()->getOnlinePlayers()) - 1 > $this->plugin->getServer()->getMaxPlayers()){
			$ev = new CustomAlertsFullServerKickEvent($origin);
			
			if($this->plugin->isFullServerMessageCustom()){
				$ev->setMessage($this->plugin->getFullServerMessage());
			}

    		$ev->call();
    		if($ev->getMessage() != ""){
    			$origin->disconnect($ev->getMessage());
    			return;
    		}
			}
    	}
    }
    
    /**
     * @param PlayerPreLoginEvent $event
     *
     * @priority HIGHEST
     */
    public function onPlayerPreLogin(PlayerPreLoginEvent $event){
    	$player = $event->getPlayerInfo();
    	if(count($this->plugin->getServer()->getOnlinePlayers()) - 1 < $this->plugin->getServer()->getMaxPlayers()){
    	    //Whitelist Message
    		if(!$this->plugin->getServer()->isWhitelisted($player->getUsername())){
    		    $cevent = new CustomAlertsWhitelistKickEvent($player);
    			if($this->plugin->isWhitelistMessageCustom()){
    				$cevent->setMessage($this->plugin->getWhitelistMessage($player));
    			}
    			$cevent->call();
    			if($cevent->getMessage() != ""){
    				$event->setKickReason(PlayerPreLoginEvent::KICK_REASON_SERVER_WHITELISTED, $cevent->getMessage());
    				return;
    			}
    		}
    	}else{
			
    	}
    }
    
    /**
     * @param PlayerJoinEvent $event
     *
     * @priority HIGHEST
     */
    public function onPlayerJoin(PlayerJoinEvent $event){
    	$player = $event->getPlayer();
    	//Motd Update
    	$this->plugin->updateMotd();
    	//Join Message
    	$cevent = new CustomAlertsJoinEvent($player);
    	if(!$player->hasPlayedBefore() && $this->plugin->isFirstJoinMessageEnabled()){
    		$cevent->setMessage($this->plugin->getFirstJoinMessage($player));
    	}else if($this->plugin->isJoinMessageHidden()){
    	    $cevent->setMessage("");
    	}else if($this->plugin->isJoinMessageCustom()){
    	    $cevent->setMessage($this->plugin->getJoinMessage($player));
    	}else{
    	    $cevent->setMessage($event->getJoinMessage());
    	}
    	$cevent->call();
    	$event->setJoinMessage($cevent->getMessage());
    }
    
    /**
     * @param PlayerQuitEvent $event
     *
     * @priority HIGHEST
     */
    public function onPlayerQuit(PlayerQuitEvent $event){
    	 $player = $event->getPlayer();
    	 //Motd Update
    	 $this->plugin->updateMotd();
    	 //Quit Message
    	 $cevent = new CustomAlertsQuitEvent($player);
    	 if($this->plugin->isQuitMessageHidden()){
    	     $cevent->setMessage("");
    	 }else if($this->plugin->isQuitMessageCustom()){
    	     $cevent->setMessage($this->plugin->getQuitMessage($player));
    	 }else{
    	     $cevent->setMessage($event->getQuitMessage());
    	 }
    	 $cevent->call();
    	 $event->setQuitMessage($cevent->getMessage());
    }
    
    /**
     * @param EntityTeleportEvent $event
     *
     * @priority HIGHEST
     */
    public function onWorldChange(EntityTeleportEvent $event){
    	
		$from = $event->getFrom()->getWorld();
		$to = $event->getTo()->getWorld();
		$player = $event->getEntity();
    	if($from->getDisplayName() !== $to->getDisplayName()){
			$cevent = new CustomAlertsWorldChangeEvent($player, $from, $to);
    		if($this->plugin->isWorldChangeMessageEnabled()){
    			$cevent->setMessage($this->plugin->getWorldChangeMessage($player, $from, $to));
    		}else{
    		    $cevent->setMessage("");
    		}
    	    $cevent->call();
    		if($cevent->getMessage() != ""){
    			Server::getInstance()->broadcastMessage($cevent->getMessage());
    		}
		}
    }
    
    
    /**
     * @param PlayerDeathEvent $event
     *
     * @priority HIGHEST
     */
    public function onPlayerDeath(PlayerDeathEvent $event){
    	$player = $event->getEntity();
    	if($player instanceof Player){
    	    $cause = $player->getLastDamageCause();
    	    $cevent = new CustomAlertsDeathEvent($player, $cause);
    		if($this->plugin->isDeathMessageHidden($cause)){
    			$cevent->setMessage("");
    		}else if($this->plugin->isDeathMessageCustom($cause)){
    		    $cevent->setMessage($this->plugin->getDeathMessage($player, $cause));
    		}else{
    		    $cevent->setMessage($event->getDeathMessage());
    		}
    	    $cevent->call();
    		$event->setDeathMessage($cevent->getMessage());
    	}
    }
}
<file_sep>/CustomAlerts/src/CustomAlerts/Events/CustomAlertsWorldChangeEvent.php
<?php

/*
 * CustomAlerts v2.0 by EvolSoft
 * Developer: Flavius12
 * Website: https://www.evolsoft.tk
 * Copyright (C) 2014-2018 EvolSoft
 * Licensed under MIT (https://github.com/EvolSoft/CustomAlerts/blob/master/LICENSE)
 */

namespace CustomAlerts\Events;

use pocketmine\player\Player;
use pocketmine\world\World;

class CustomAlertsWorldChangeEvent extends CustomAlertsEvent {
	
	public static $handlerList = null;
	
	/** @var Player $player */
	private $player;
	
	/** @var World $origin */
	private $origin;
	
	/** @var World $target */
	private $target;
	
	/**
	 * @param Player $player
	 * @param World $origin
	 * @param World $target
	 */
	public function __construct(Player $player, World $origin, World $target){
		$this->player = $player;
		$this->origin = $origin;
		$this->target = $target;
	}
	
	/**
	 * Get world change event player
	 *
	 * @return Player
	 */
	public function getPlayer() : Player {
		return $this->player;
	}
	
	/**
	 * Get origin level
	 *
	 * @return World
	 */
	public function getOrigin() : World {
		return $this->origin;
	}
	
	/**
	 * Get target level
	 *
	 * @return World
	 */
	public function getTarget() : World {
		return $this->target;
	}
}
<file_sep>/CustomAlerts/src/CustomAlerts/CustomAlerts.php
<?php

/*
 * CustomAlerts v2.0 by EvolSoft
 * Developer: Flavius12
 * Website: https://www.evolsoft.tk
 * Copyright (C) 2014-2018 EvolSoft
 * Licensed under MIT (https://github.com/EvolSoft/CustomAlerts/blob/master/LICENSE)
 */

namespace CustomAlerts;

use pocketmine\player\Player;
use pocketmine\entity\Living;
use pocketmine\event\entity\EntityDamageByBlockEvent;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\level\Level;
use pocketmine\plugin\PluginBase;
use pocketmine\utils\TextFormat;

use CustomAlerts\Commands\Commands;
use CustomAlerts\Events\CustomAlertsMotdUpdateEvent;
use pocketmine\command\PluginCommand;
use pocketmine\entity\projectile\Projectile;
use pocketmine\event\entity\EntityDamageByEntityEvent;
use pocketmine\event\entity\ProjectileHitEntityEvent;
use pocketmine\player\Player as PlayerPlayer;
use pocketmine\player\PlayerInfo;
use pocketmine\world\World;

class CustomAlerts extends PluginBase {
    
	/** @var string */
	const PREFIX = "&b[&aCustom&cAlerts&b] ";
	
	/** @var string */
	const API_VERSION = "2.0";
	
	private $cfg;
	
	/** @var CustomAlerts $instance */
	private static $instance = null;
	
	public function onLoad():void{
	    if(!self::$instance instanceof CustomAlerts){
	        self::$instance = $this;
	    }
	}
	
    public function onEnable():void{
    	@mkdir($this->getDataFolder());
    	$this->saveDefaultConfig();
    	$this->cfg = $this->getConfig()->getAll();
        $this->getServer()->getCommandMap()->register("customalerts", new Commands($this));
    	$this->getServer()->getPluginManager()->registerEvents(new EventListener($this), $this);
    	$this->getScheduler()->scheduleRepeatingTask(new MotdTask($this), 20);
    }
    
    /**
     * Replace variables inside a string
     * 
     * @param string $str
     * @param array $vars
     * 
     * @return string
     */
    public function replaceVars($str, array $vars){
        foreach($vars as $key => $value){
            $str = str_replace("{" . $key . "}", $value, $str);
        }
        return $str;
    }
    
    //API Functions
    
    /**
     * Get CustomAlerts API
     *
     * @return CustomAlerts
     */
    public static function getAPI(){
        return self::$instance;
    }
    
    /**
     * Get CustomAlerts version
     * 
     * @return string
     */
    public function getVersion(){
    	return $this->getVersion();
    }
    
    /**
     * Get CustomAlerts API version
     *
     * @return string
     */
    public function getAPIVersion(){
    	return self::API_VERSION;
    }
    
    /**
     * Check if motd is custom
     * 
     * @return bool
     */
    public function isMotdCustom() : bool {
    	return $this->cfg["Motd"]["custom"];
    }
    
    /**
     * Get motd message
     *
     * @return string
     */
    public function getMotdMessage(){
        return TextFormat::colorize($this->replaceVars($this->cfg["Motd"]["message"], array(
            "MAXPLAYERS" => $this->getServer()->getMaxPlayers(),
            "TOTALPLAYERS" => count($this->getServer()->getOnlinePlayers()),
            "TIME" => date($this->cfg["datetime-format"]))));
    }
    
    public function updateMotd(){
        $cevent = new CustomAlertsMotdUpdateEvent();
        if($this->isMotdCustom()){
            $cevent->setMessage($this->getMotdMessage());
        }else{
            $cevent->setMessage($this->getServer()->getMotd());
        }
        $cevent->call();
        $this->getServer()->getNetwork()->setName($cevent->getMessage());
    }
    
    /**
     * Check if outdated client message is custom
     *
     * @return bool
     */
    public function isOutdatedClientMessageCustom() : bool {
    	return $this->cfg["OutdatedClient"]["custom"];
    }
    
    /**
     * Get outdated client message
     *
     * @return string
     */
    public function getOutdatedClientMessage(){
        return TextFormat::colorize($this->replaceVars($this->cfg["OutdatedClient"]["message"], array(
            "MAXPLAYERS" => $this->getServer()->getMaxPlayers(),
            "TOTALPLAYERS" => count($this->getServer()->getOnlinePlayers()),
            "TIME" => date($this->cfg["datetime-format"]))));
    }
    
    /**
     * Check if outdated server message is custom
     *
     * @return bool
     */
    public function isOutdatedServerMessageCustom() : bool {
    	return $this->cfg["OutdatedServer"]["custom"];
    }
    
    /**
     * Get outdated server message
     * 
     *
     * @return string
     */
    public function getOutdatedServerMessage(){
        return TextFormat::colorize($this->replaceVars($this->cfg["OutdatedServer"]["message"], array(
            "MAXPLAYERS" => $this->getServer()->getMaxPlayers(),
            "TOTALPLAYERS" => count($this->getServer()->getOnlinePlayers()),
            "TIME" => date($this->cfg["datetime-format"]))));
    }
    
    /**
     * Check if whitelist message is custom
     *
     * @return bool
     */
    public function isWhitelistMessageCustom() : bool {
    	return $this->cfg["WhitelistedServer"]["custom"];
    }
    
    /**
     * Get whitelist message
     *
     * @return string
     */
    public function getWhitelistMessage(){
        return TextFormat::colorize($this->replaceVars($this->cfg["WhitelistedServer"]["message"], array(
            "MAXPLAYERS" => $this->getServer()->getMaxPlayers(),
            "TOTALPLAYERS" => count($this->getServer()->getOnlinePlayers()),
            "TIME" => date($this->cfg["datetime-format"]))));
    }
    
    /**
     * Check if full server message is custom
     *
     * @return bool
     */
    public function isFullServerMessageCustom() : bool {
    	$cfg = $this->getConfig()->getAll();
    	return $cfg["FullServer"]["custom"];
    }
    
    /**
     * Get full server message
     * 
     *
     * @return string
     */
    public function getFullServerMessage(){
        return TextFormat::colorize($this->replaceVars($this->cfg["FullServer"]["message"], array(
            "MAXPLAYERS" => $this->getServer()->getMaxPlayers(),
            "TOTALPLAYERS" => count($this->getServer()->getOnlinePlayers()),
            "TIME" => date($this->cfg["datetime-format"]))));
    }
    
    /**
     * Check if first join message is enabled
     * 
     * @return bool
     */
    public function isFirstJoinMessageEnabled() : bool {
    	return $this->cfg["FirstJoin"]["enable"];
    }

    /**
     * Get first join message
     * 
     * @param Player $player
     * 
     * @return string
     */
    public function getFirstJoinMessage(Player $player){
        return TextFormat::colorize($this->replaceVars($this->cfg["FirstJoin"]["message"], array(
            "PLAYER" => $player->getName(),
            "MAXPLAYERS" => $this->getServer()->getMaxPlayers(),
            "TOTALPLAYERS" => count($this->getServer()->getOnlinePlayers()),
            "TIME" => date($this->cfg["datetime-format"]))));
    }
    
    /**
     * Check if join message is custom
     * 
     * @return bool
     */
    public function isJoinMessageCustom() : bool {
    	return $this->cfg["Join"]["custom"];
    }
    
    /**
     * Check if join message is hidden
     *
     * @return bool
     */
    public function isJoinMessageHidden() : bool {
    	return $this->cfg["Join"]["hide"];
    }
    
    /**
     * Get join message
     * 
     * @param Player $player
     * 
     * @return string
     */
    public function getJoinMessage(Player $player){
        return TextFormat::colorize($this->replaceVars($this->cfg["Join"]["message"], array(
            "PLAYER" => $player->getName(),
            "MAXPLAYERS" => $this->getServer()->getMaxPlayers(),
            "TOTALPLAYERS" => count($this->getServer()->getOnlinePlayers()),
            "TIME" => date($this->cfg["datetime-format"]))));
    }
    
    /**
     * Check if quit message is custom
     *
     * @return bool
     */
    public function isQuitMessageCustom(){
    	return $this->cfg["Quit"]["custom"];
    }
    
    /**
     * Check if quit message is hidden
     *
     * @return bool
     */
    public function isQuitMessageHidden(){
    	return $this->cfg["Quit"]["hide"];
    }
    
    /**
     * Get default quit message
     * 
     * @param Player $player
     * 
     * @return string
     */
    public function getQuitMessage(Player $player){
        return TextFormat::colorize($this->replaceVars($this->cfg["Quit"]["message"], array(
            "PLAYER" => $player->getName(),
            "MAXPLAYERS" => $this->getServer()->getMaxPlayers(),
            "TOTALPLAYERS" => count($this->getServer()->getOnlinePlayers()),
            "TIME" => date($this->cfg["datetime-format"]))));
    }
    
    /**
     * Check if world change message is enabled
     *
     * @return bool
     */
    public function isWorldChangeMessageEnabled(){
    	return $this->cfg["WorldChange"]["enable"];
    }
    
    /**
     * Get world change message
     *
     * @param Player $player
     * @param World $origin
     * @param World $target
     *
     * @return string
     */
    public function getWorldChangeMessage(Player $player, World $origin, World $target){
        return TextFormat::colorize($this->replaceVars($this->cfg["WorldChange"]["message"], array(
    	    "ORIGIN" => $origin->getDisplayName(),
    	    "TARGET" => $target->getDisplayName(),
    	    "PLAYER" => $player->getName(),
    	    "MAXPLAYERS" => $this->getServer()->getMaxPlayers(),
    	    "TOTALPLAYERS" => count($this->getServer()->getOnlinePlayers()),
    	    "TIME" => date($this->cfg["datetime-format"]))));
    }
    
    /**
     * Check if death messages are custom
     * 
     *
     * @return bool
     */
    public function isDeathMessageCustom(?EntityDamageEvent $cause = null){
        if(!$cause){
            return $this->cfg["Death"]["custom"];
        }
        switch($cause->getCause()){
            case EntityDamageEvent::CAUSE_CONTACT:
                return $this->cfg["Death"]["death-contact-message"]["custom"];
            case EntityDamageEvent::CAUSE_ENTITY_ATTACK:
                return $this->cfg["Death"]["kill-message"]["custom"];
            case EntityDamageEvent::CAUSE_PROJECTILE:
                return $this->cfg["Death"]["death-projectile-message"]["custom"];
            case EntityDamageEvent::CAUSE_SUFFOCATION:
                return $this->cfg["Death"]["death-suffocation-message"]["custom"];
            case EntityDamageEvent::CAUSE_FALL:
                return $this->cfg["Death"]["death-fall-message"]["custom"];
            case EntityDamageEvent::CAUSE_FIRE:
                return $this->cfg["Death"]["death-fire-message"]["custom"];
            case EntityDamageEvent::CAUSE_FIRE_TICK:
                return $this->cfg["Death"]["death-on-fire-message"]["custom"];
            case EntityDamageEvent::CAUSE_LAVA:
                return $this->cfg["Death"]["death-lava-message"]["custom"];
            case EntityDamageEvent::CAUSE_DROWNING:
                return $this->cfg["Death"]["death-drowning-message"]["custom"];
            case EntityDamageEvent::CAUSE_ENTITY_EXPLOSION:
            case EntityDamageEvent::CAUSE_BLOCK_EXPLOSION:
                return $this->cfg["Death"]["death-explosion-message"]["custom"];
            case EntityDamageEvent::CAUSE_VOID:
                return $this->cfg["Death"]["death-void-message"]["custom"];
            case EntityDamageEvent::CAUSE_SUICIDE:
                return $this->cfg["Death"]["death-suicide-message"]["custom"];
            case EntityDamageEvent::CAUSE_MAGIC:
                return $this->cfg["Death"]["death-magic-message"]["custom"];
            default:
                return $this->cfg["Death"]["custom"];
        }
    }
    
    /**
     * Check if death messages are hidden
     * 
     * @param EntityDamageEvent $cause
     *
     * @return bool
     */
    public function isDeathMessageHidden(EntityDamageEvent $cause = null){
        if(!$cause){
            return $this->cfg["Death"]["hide"];
        }
        switch($cause->getCause()){
            case EntityDamageEvent::CAUSE_CONTACT:
                return $this->cfg["Death"]["death-contact-message"]["hide"];
            case EntityDamageEvent::CAUSE_ENTITY_ATTACK:
                return $this->cfg["Death"]["kill-message"]["hide"];
            case EntityDamageEvent::CAUSE_PROJECTILE:
                return $this->cfg["Death"]["death-projectile-message"]["hide"];
            case EntityDamageEvent::CAUSE_SUFFOCATION:
                return $this->cfg["Death"]["death-suffocation-message"]["hide"];
            case EntityDamageEvent::CAUSE_FALL:
                return $this->cfg["Death"]["death-fall-message"]["hide"];
            case EntityDamageEvent::CAUSE_FIRE:
                return $this->cfg["Death"]["death-fire-message"]["hide"];
            case EntityDamageEvent::CAUSE_FIRE_TICK:
                return $this->cfg["Death"]["death-on-fire-message"]["hide"];
            case EntityDamageEvent::CAUSE_LAVA:
                return $this->cfg["Death"]["death-lava-message"]["hide"];
            case EntityDamageEvent::CAUSE_DROWNING:
                return $this->cfg["Death"]["death-drowning-message"]["hide"];
            case EntityDamageEvent::CAUSE_ENTITY_EXPLOSION:
            case EntityDamageEvent::CAUSE_BLOCK_EXPLOSION:
                return $this->cfg["Death"]["death-explosion-message"]["hide"];
            case EntityDamageEvent::CAUSE_VOID:
                return $this->cfg["Death"]["death-void-message"]["hide"];
            case EntityDamageEvent::CAUSE_SUICIDE:
                return $this->cfg["Death"]["death-suicide-message"]["hide"];
            case EntityDamageEvent::CAUSE_MAGIC:
                return $this->cfg["Death"]["death-magic-message"]["hide"];
            default:
                return $this->cfg["Death"]["hide"];
        }
    }
    
    /**
     * Get death message related to the specified cause
     *
     * @param Player $player
     * @param EntityDamageEvent $cause
     *
     * @return string
     */
    public function getDeathMessage(Player $player, EntityDamageEvent $cause = null){
        $array = array(
            "PLAYER" => $player->getName(),
            "MAXPLAYERS" => $this->getServer()->getMaxPlayers(),
            "TOTALPLAYERS" => count($this->getServer()->getOnlinePlayers()),
            "TIME" => date($this->cfg["datetime-format"]));
        if(!$cause){
            $message = $this->cfg["Death"]["message"];
        }else{
            switch($cause->getCause()){
                case EntityDamageEvent::CAUSE_CONTACT:
                    $message = $this->cfg["Death"]["death-contact-message"]["message"];
                    if($cause instanceof EntityDamageByBlockEvent){
                        $array["BLOCK"] = $cause->getDamager()->getName();
                        break;
                    }
                    $array["BLOCK"] = "Unknown";
                    break;
                case EntityDamageEvent::CAUSE_ENTITY_ATTACK:
                    $message = $this->cfg["Death"]["kill-message"]["message"];
                    if($cause instanceof EntityDamageByEntityEvent){
                        $killer = $cause->getDamager();
                        if($killer instanceof Living){
                            $array["KILLER"] = $killer->getName();
                            break;
                        }
                    }
                    $array["KILLER"] = "Unknown";
                    break;
                case EntityDamageEvent::CAUSE_PROJECTILE:
                    $message = $this->cfg["Death"]["death-projectile-message"]["message"];
                    if($cause instanceof ProjectileHitEntityEvent){
                        $projectile = $cause->getEntity();
                        if($projectile instanceof Projectile){
                            $killer = $projectile->getOwningEntity();
                            if($killer instanceof Living){
                                $array["KILLER"] = $killer->getName();
                                break;
                            }
                        }
                    }
                    $array["KILLER"] = "Unknown";
                    break;
                case EntityDamageEvent::CAUSE_SUFFOCATION:
                    $message = $this->cfg["Death"]["death-suffocation-message"]["message"];
                    break;
                case EntityDamageEvent::CAUSE_FALL:
                    $message = $this->cfg["Death"]["death-fall-message"]["message"];
                    break;
                case EntityDamageEvent::CAUSE_FIRE:
                    $message = $this->cfg["Death"]["death-fire-message"]["message"];
                    break;
                case EntityDamageEvent::CAUSE_FIRE_TICK:
                    $message = $this->cfg["Death"]["death-on-fire-message"]["message"];
                    break;
                case EntityDamageEvent::CAUSE_LAVA:
                    $message = $this->cfg["Death"]["death-lava-message"]["message"];
                    break;
                case EntityDamageEvent::CAUSE_DROWNING:
                    $message = $this->cfg["Death"]["death-drowning-message"]["message"];
                    break;
                case EntityDamageEvent::CAUSE_ENTITY_EXPLOSION:
                case EntityDamageEvent::CAUSE_BLOCK_EXPLOSION:
                    $message = $this->cfg["Death"]["death-explosion-message"]["message"];
                    break;
                case EntityDamageEvent::CAUSE_VOID:
                    $message = $this->cfg["Death"]["death-void-message"]["message"];
                    break;
                case EntityDamageEvent::CAUSE_SUICIDE:
                    $message = $this->cfg["Death"]["death-suicide-message"]["message"];
                    break;
                case EntityDamageEvent::CAUSE_MAGIC:
                    $message = $this->cfg["Death"]["death-magic-message"]["message"];
                    break;
                default:
                    $message = $this->cfg["Death"]["message"];
                    break;
            }
        }
        return TextFormat::colorize($this->replaceVars($message, $array));
    }
}
<file_sep>/CustomAlerts/src/CustomAlerts/MotdTask.php
<?php

/*
 * CustomAlerts v2.0 by EvolSoft
 * Developer: Flavius12
 * Website: https://www.evolsoft.tk
 * Copyright (C) 2014-2018 EvolSoft
 * Licensed under MIT (https://github.com/EvolSoft/CustomAlerts/blob/master/LICENSE)
 */

namespace CustomAlerts;

use pocketmine\scheduler\Task;

class MotdTask extends Task {
    
    /** @var CustomAlerts */
    private $plugin;
	
    public function __construct(CustomAlerts $plugin){
      $this->plugin = $plugin;
    }
    
    public function onRun() : void{
        CustomAlerts::getAPI()->updateMotd();
    }

    public function getPlugin(){
        return $this->plugin;
    }
}
<file_sep>/CustomAlerts/src/CustomAlerts/Events/CustomAlertsFullServerKickEvent.php
<?php

/*
 * CustomAlerts v2.0 by EvolSoft
 * Developer: Flavius12
 * Website: https://www.evolsoft.tk
 * Copyright (C) 2014-2018 EvolSoft
 * Licensed under MIT (https://github.com/EvolSoft/CustomAlerts/blob/master/LICENSE)
 */

namespace CustomAlerts\Events;

use pocketmine\network\mcpe\NetworkSession;

class CustomAlertsFullServerKickEvent extends CustomAlertsEvent{
	
	public static $handlerList = null;
	
	/** @var NetworkSession $origin */
	private $origin;
	
	/**
	 * @param NetworkSession $origin
	 */
	public function __construct(NetworkSession $origin){
		$this->origin = $origin;
	}

	/**
	 * Get full server kick event player
	 * 
	 * @return NetworkSession
	 */
	public function getPlayerInfo() : NetworkSession {
		return $this->origin;
	}
}
<file_sep>/CustomAlerts/src/CustomAlerts/Events/CustomAlertsOutdatedClientKickEvent.php
<?php

/*
 * CustomAlerts v2.0 by EvolSoft
 * Developer: Flavius12
 * Website: https://www.evolsoft.tk
 * Copyright (C) 2014-2018 EvolSoft
 * Licensed under MIT (https://github.com/EvolSoft/CustomAlerts/blob/master/LICENSE)
 */

namespace CustomAlerts\Events;

use pocketmine\network\mcpe\NetworkSession;
use pocketmine\player\Player;

class CustomAlertsOutdatedClientKickEvent extends CustomAlertsEvent {
	
	public static $handlerList = null;
	
	/** @var NetworkSession $origin */
	private $origin;
	
	/**
	 * @param NetworkSession $origin
	 */
	public function __construct(?NetworkSession $origin){
		$this->origin = $origin;
	}

	/**
	 * Get outdated client kick event player
	 * 
	 * @return NetworkSession
	 */
	public function getOrigin() : ?NetworkSession {
		return $this->origin;
	}
}
