Coder Social home page Coder Social logo

nidplays / customalerts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from evolsoft/customalerts

0.0 1.0 0.0 76 KB

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

License: MIT License

PHP 100.00%

customalerts's Introduction

start2

CustomAlerts

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

Category

PocketMine-MP plugins

Requirements

PocketMine-MP Alpha_1.5 API 1.12.0

Overview

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

EvolSoft Website: http://www.evolsoft.tk

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

To prevent bugs, delete all old plugin data if you are updating CustomAlerts.

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]

What is included?

In the ZIP file you will find:
- CustomAlerts_v1.6.phar : CustomAlerts Plugin + API
- CustomAlertsExample_v1.2.zip : Example Plugin source code

Commands:

/customalerts - CustomAlerts commands

To-Do:

- Bug fix (if bugs will be found)

Documentation

For Users:

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

Colors:

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

Special:

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

Configuration (config.yml):

---
#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
  # - {PLAYER}: Show player name
  # - {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
  # - {PLAYER}: Show player name
  # - {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
  # - {PLAYER}: Show player name
  # - {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
  # - {PLAYER}: Show player name
  # - {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

Permissions:

  • customalerts.* - CustomAlerts permissions.
  • customalerts.help - CustomAlerts command Help permission.
  • customalerts.info - CustomAlerts command Info permission.
  • customalerts.reload - CustomAlerts command Reload permission.

For Developers

Basic Tutorial:

1. Define the plugin dependency in plugin.yml (you can check if CustomAlerts is installed in different ways):

depend: [CustomAlerts]

2. Include CustomAlerts API and CustomAlerts Events in your php code:

//PocketMine Event Listener
use pocketmine\event\Listener;
//CustomAlerts API
use CustomAlerts\CustomAlerts;
//CustomAlerts Events
use CustomAlerts\Events\CustomAlertsJoinEvent;

3. Create the class:

class Example extends PluginBase implements Listener {
}

4. Check if CustomAlerts API is compatible (insert this code in onEnable() function)

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):

public function onCAJoinEvent(CustomAlertsJoinEvent $event){
  CustomAlerts::getAPI()->setJoinMessage("Example Join message: " . $event->getPlayer()->getName());
}

6. Call the API function:

CustomAlerts::getAPI()->api_function();

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

CustomAlerts API Events:

CustomAlertsDeathEvent:

This event is handled when a player dies.

Event functions are:

Get Player:
Player getPlayer()

Description:
Get death event player.
Return:
The death event player

Get Cause:
EntityDamageEvent|null getCause()

Description:
Get death event cause.
Return:
The death event cause

CustomAlertsFullServerKickEvent:

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

Event functions are:

Get Player:
Player getPlayer()

Description:
Get event player.
Return:
The event player (instance of pocketmine\Player)

CustomAlertsJoinEvent:

This event is handled when a player joins.

Event functions are:

Get Player:
Player getPlayer()

Description:
Get join event player.
Return:
The join event player (instance of pocketmine\Player)

Get default PocketMine join message:
string getPocketMineJoinMessage()

Description:
Get default PocketMine join message.
Return:
The default PocketMine join message

CustomAlertsMotdUpdateEvent:

This event is handled when the motd is updated

Event functions are:

Get default PocketMine Motd:
string getPocketMineMotd()

Description:
Get default PocketMine Motd.
Return:
The default PocketMine Motd

CustomAlertsOutdatedClientKickEvent:

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

Event functions are:

Get Player:
Player getPlayer()

Description:
Get event player.
Return:
The event player (instance of pocketmine\Player)

CustomAlertsOutdatedServerKickEvent:

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

Event functions are:

Get Player:
Player getPlayer()

Description:
Get event player.
Return:
The event player (instance of pocketmine\Player)

CustomAlertsQuitEvent:

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

Event functions are:

Get Player:
Player getPlayer()

Description:
Get quit event player.
Return:
The quit event player (instance of pocketmine\Player)

Get default PocketMine quit message:
string getPocketMineQuitMessage()

Description:
Get default PocketMine quit message.
Return:
The default PocketMine quit message

CustomAlertsWhitelistKickEvent:

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

Event functions are:

Get Player:
Player getPlayer()

Description:
Get event player.
Return:
The event player (instance of pocketmine\Player)

CustomAlertsWorldChangeEvent:

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

Event functions are:

Get Player:
Player getPlayer()

Description:
Get world change event player.
Return:
The world change event player (instance of pocketmine\Player)

Get Origin Level:
Level getOrigin()

Description:
Get origin level.
Return:
The origin level (instance of pocketmine\Level)

Get Target Level:
Level getTarget()

Description:
Get target level.
Return:
The target level (instance of pocketmine\Level)

CustomAlerts API Functions:

Get Version:
string getVersion()

Description:
Get CustomAlerts plugin version
Return:
plugin version

Get API Version:
string getAPIVersion()

Description:
Get the CustomAlerts API version.
Return:
plugin API version

Check if motd message is custom:
boolean isMotdCustom()

Description:
Check if motd message is custom.
Return:
boolean

Get default motd message:
string getDefaultMotdMessage()

Description:
Get default motd message.
Return:
string the default motd message

Get current motd message:
string getMotdMessage()

Description:
Get current motd message.
Return:
string the current motd message

Set current motd message:
function setMotdMessage($message)

Description:
Set current motd message.
Parameters:
$message

Check if outdated client message is custom:
boolean isOutdatedClientMessageCustom()

Description:
Check if outdated client message is custom.
Return:
boolean

Get default outdated client message:
string getDefaultOutdatedClientMessage(Player $player)

Description:
Get default outdated client message.
Parameters:
$player the current player
Return:
string the default outdated client message

Get current outdated client message:
string getOutdatedClientMessage()

Description:
Get current outdated client message.
Return:
string the current outdated client message

Set current outdated client message:
function setOutdatedClientMessage($message)

Description:
Set current outdated client message.
Parameters:
$message

Check if outdated server message is custom:
boolean isOutdatedServerMessageCustom()

Description:
Check if outdated server message is custom.
Return:
boolean

Get default outdated server message:
string getDefaultOutdatedServerMessage(Player $player)

Description:
Get default outdated server message.
Parameters:
$player the current player
Return:
string the default outdated server message

Get current outdated server message:
string getOutdatedServerMessage()

Description:
Get current outdated server message.
Return:
string the current outdated server message

Set current outdated server message:
function setOutdatedServerMessage($message)

Description:
Set current outdated server message.
Parameters:
$message

Check if whitelist message is custom:
boolean isWhitelistMessageCustom()

Description:
Check if whitelist message is custom.
Return:
boolean

Get default whitelist message:
string getDefaultWhitelistMessage(Player $player)

Description:
Get default whitelist message.
Parameters:
$player the current player
Return:
string the default whitelist message

Get current whitelist message:
string getWhitelistMessage()

Description:
Get current whitelist message.
Return:
string the current whitelist message

Set current whitelist message:
function setWhitelistMessage($message)

Description:
Set current whitelist message.
Parameters:
$message

Check if full server message is custom:
boolean isFullServerMessageCustom()

Description:
Check if full server message is custom.
Return:
boolean

Get default full server message:
string getDefaultFullServerMessage(Player $player)

Description:
Get default full server message.
Parameters:
$player the current player
Return:
string the default full server message

Get current full server message:
string getFullServerMessage()

Description:
Get current full server message.
Return:
string the current full server message

Set current full server message:
function setFullServerMessage($message)

Description:
Set current full server message.
Parameters:
$message

Check if default first join message is enabled:
boolean isDefaultFirstJoinMessageEnabled()

Description:
Check if default first join message is enabled.
Return:
boolean

Get default first join message:
string getDefaultFirstJoinMessage(Player $player)

Description:
Get default first join message.
Parameters:
$player the current player
Return:
string the default first join message

Check if a player has joined for the first time:
boolean hasJoinedFirstTime(Player $player)

Description:
Check if a player has joined for the first time.
Parameters:
$player
Return:
boolean

Check if default join message is custom:
boolean isDefaultJoinMessageCustom()

Description:
Check if default join message is custom.
Return:
boolean

Check if default join message is hidden:
boolean isDefaultJoinMessageHidden()

Description:
Check if default join message is hidden.
Return:
boolean

Get default join message:
string getDefaultJoinMessage(Player $player)

Description:
Get default join message.
Parameters:
$player the current player
Return:
string the default join message

Get current join message:
string getJoinMessage()

Description:
Get current join message.
Return:
string the current join message

Set current join message:
function setJoinMessage($message)

Description:
Set current join message.
Parameters:
$message

Check if default quit message is custom:
boolean isDefaultQuitMessageCustom()

Description:
Check if default quit message is custom.
Return:
boolean

Check if default quit message is hidden:
boolean isDefaultQuitMessageHidden()

Description:
Check if default quit message is hidden.
Return:
boolean

Get default quit message:
string getDefaultQuitMessage(Player $player)

Description:
Get default quit message.
Parameters:
$player the current player
Return:
string the default quit message

Get current quit message:
string getQuitMessage()

Description:
Get current quit message.
Return:
string the current quit message

Set current quit message:
function setQuitMessage($message)

Description:
Set current quit message.
Parameters:
$message

Check if default world change message is enabled:
boolean isDefaultWorldChangeMessageEnabled()

Description:
Check if default world change message is enabled.
Return:
boolean

Get default world change message:
string getDefaultWorldChangeMessage(Player $player, Level $origin, Level $target)

Description:
Get default world change message.
Parameters:
$player the current player
$origin the origin level
$target the target level
Return:
string the default world change message

Get current world change message:
string getWorldChangeMessage()

Description:
Get current world change message.
Return:
string the current world change message

Set current world change message:
function setWorldChangeMessage($message)

Description:
Set current world change message.
Parameters:
$message

Check if default death messages are custom:
boolean isDefaultDeathMessageCustom($cause = null)

Description:
Check if default death messages are custom.
Parameters:
$cause Check message by cause
Return:
boolean

Check if default death messages are hidden:
boolean isDefaultDeathMessageHidden($cause = null)

Description:
Check if default death messages are hidden
Parameters:
$cause Check message by cause
Return:
boolean

Get default death message related to the specified cause:
string getDefaultDeathMessage(Player $player, $cause = null)

Description:
Get default death message related to the specified cause.
Parameters:
$player the current player
$cause the cause of death (instanceof EntityDamageEvent). If it's null, the function will return the default death message Return:
string the default death message related to the specified cause

Get current death message:
string getDeathMessage()

Description:
Get current death message.
Return:
string the current death message

Set current death message:
function setDeathMessage($message)

Description:
Set current death message.
Parameters:
$message

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.