Skip to content

Instantly share code, notes, and snippets.

@jojoe77777 jojoe77777/FormExample.php Secret

Created Aug 5, 2017
What would you like to do?
FormAPI example use
* @name FormExample
* @main jojoe77777\FormExample\Main
* @api 3.0.0-ALPHA7
* @version 1.0.0
* @author jojoe77777
namespace jojoe77777\FormExample;
use pocketmine\event\Listener;
use pocketmine\event\player\PlayerCommandPreprocessEvent;
use pocketmine\Player;
use pocketmine\plugin\PluginBase;
class Main extends PluginBase implements Listener {
public function onEnable(){
$this->getServer()->getPluginManager()->registerEvents($this, $this);
public function onCommandPreProcess(PlayerCommandPreprocessEvent $ev){
$msg = $ev->getMessage();
if($msg === "ban"){
public function displayBanForm(Player $player){
$api = $this->getServer()->getPluginManager()->getPlugin("FormAPI");
if($api === null){
$form = $api->createCustomForm(function(Player $player, array $data){
list($name, $reason, $silent) = $data;
$player->getServer()->getNameBans()->addBan($name, $reason);
$player->getServer()->broadcastMessage("§a{$name}§c has been banned by §a{$player->getName()}§c for §d{$reason}§a.");
$form->setTitle("Ban Player");
$form->addInput("Player name");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.