Last active
June 13, 2016 19:37
-
-
Save ifvictr/f1c0f1b11b97450c776b1f8dff32f690 to your computer and use it in GitHub Desktop.
OAAT for PocketMine-MP.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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