Skip to content

Instantly share code, notes, and snippets.

@ifvictr
Last active June 13, 2016 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ifvictr/f1c0f1b11b97450c776b1f8dff32f690 to your computer and use it in GitHub Desktop.
Save ifvictr/f1c0f1b11b97450c776b1f8dff32f690 to your computer and use it in GitHub Desktop.
OAAT for PocketMine-MP.
<?php
/**
* @name OAAT
* @main oaat\OAAT
* @version 1.0.0
* @api 1.12.0
* @load POSTWORLD
* @author Gamecrafter
* @description Only one user with this name can join.
* @link https://gist.github.com/Gamecrafter/f1c0f1b11b97450c776b1f8dff32f690
*/
namespace oaat{
use pocketmine\event\player\PlayerPreLoginEvent;
use pocketmine\event\Listener;
use pocketmine\plugin\PluginBase;
class OAAT extends PluginBase implements Listener{
public function onEnable(){
$this->getServer()->getPluginManager()->registerEvents($this, $this);
}
/**
* @param PlayerPreLoginEvent $event
* @priority MONITOR
* @ignoreCancelled true
*/
public function onPlayerPreLogin(PlayerPreLoginEvent $event){
$name = $event->getPlayer()->getName();
if($this->getServer()->getPlayer($name)){
$event->setCancelled(true);
$event->setKickMessage("Someone with the name \"$name\" is already online.");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment