Last active
August 29, 2015 14:26
-
-
Save Lesmiscore/b1cac2c8c66077856842 to your computer and use it in GitHub Desktop.
Templates for making a plugin for PocketMine-MP
This file contains 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 | |
/*This file is Public Domain. You can use it at anywhere!*/ | |
namespace nao20010128nao; | |
use pocketmine\command\Command; | |
use pocketmine\command\CommandSender; | |
use pocketmine\command\ConsoleCommandSender; | |
use pocketmine\command\PluginIdentifiableCommand; | |
use pocketmine\Player; | |
use pocketmine\utils\TextFormat; | |
use pocketmine\plugin\PluginBase; | |
class CmdNameCommand extends Command implements PluginIdentifiableCommand | |
{ | |
public function __construct(PluginBase $plugin, $name, $description) | |
{ | |
$this->plugin = $plugin; | |
parent::__construct($name, $description); | |
} | |
private function checkPermission(CommandSender $sender){ | |
if(!($sender->isOp() or $sender->hasPermission("plugin.permission"))){ | |
$sender->sendMessage(TextFormat::RED . "You don't have permission to use this command."); | |
return false; | |
} | |
return true; | |
} | |
public function execute(CommandSender $sender, $label, array $args) | |
{ | |
if(!isset($args[0]) or !isset($args[1])) | |
{ | |
if(!$this->checkPermission($sender)) return true; | |
$sender->sendMessage(TextFormat::GREEN . "[Plugin Name] Usage here"); | |
return false; | |
} | |
//Write the content here | |
return false; | |
} | |
public function getPlugin(){ | |
return $this->plugin; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Replace them to use:
"nao20010128nao" at line 3
The namespace for your plugin.
"CmdName" at line 11
Command name(e.g. List)
"plugin.permission" at line 20
The permission that you speficied in plugin.yml.
"Plugin Name" at line 32
Your plugin name.
"Usage here" at line 32
Usage of the command.
Enjoy making commands!
This file is Public Domain!