I've downloaded and successfully added the devoots plugin to my minecraft-pe server. Now I want to convert and downloaded plugin in php format to an phar file. From what I understand I need to use the makeplugin command. Only it says: Invalid plugin name, check the name case. What am I doing wrong? I tried to place the plugin in: minecraft/plugins minecraft/plugins/devtools minecraft/src/plugins
A plugin for PocketMine requires more than just a single php file. It requires a plugin.yml file with the required information written in, along with a special folder structure. The plugin you downloaded is most likely an extremely outdated plugin for the old PocketMine API. May I ask what plugin it was, and where you downloaded it from?
I'm completely new in this and just started setting up an server for my kids. This is the file: PHP: <?phpclass DisableTNT implements Plugin{ private $api; public function __construct(ServerAPI $api, $server = false){ $this->api = $api; } public function init(){ $this->api->addHandler("player.block.action", array($this, "handle"), 15); //Priority higher that API $this->api->addHandler("player.equipment.change", array($this, "handle"), 15); } public function __destruct(){ } public function handle(&$data, $event){ switch($event){ case "player.equipment.change": if($data["block"] === 46){ $this->api->player->getByEID($data["eid"])->eventHandler("[DisableTNT] By DemonKingz", "server.chat"); $data["block"] = 0; $data["meta"] = 0; } break; case "player.block.action": if($data["block"] === 46){ //no u won't $data["block"] = 0; //wtf it's a secret LOL $data["meta"] = 0; } break; } }} I'll RTFM first about creating plugins. Creating an plugin.yml seems pretty straight foreward. I'll give that an try. Thanks for the help. This sets me in the right direction.
So far I did not learn anything. I just found this on the internet and tried it. Thanks to you guys I already saw this. I will be fun to learn php and convert the one I have to the new api. I already know several languages and scripts. So this won't be a big problem. And this seems like a fun small plugin to start with.
If you want a really quick start you might want to try and create a script plugin: It might help you to get past the current mess with getting a devtools phar. PHP: <?php/** * @name YourPluginName * @main authorName\PluginName\MainClassName * @version 0.0.1 * @api 3.0.0-ALPHA3 * @description Much description. * @author authorName */namespace authorName\PluginName{ use robske_110\SPC\ScriptPluginCommands; use robske_110\Utils\Utils; use pocketmine\event\Listener; use pocketmine\plugin\PluginBase; use pocketmine\command\Command; use pocketmine\command\CommandSender; class PacketLogger extends PluginBase implements Listener{ public function onLoad(){ $id = ScriptPluginCommands::initFor($this); ScriptPluginCommands::addCommand($id, [ 'name' => 'exampleCmd0', 'description' => 'somedesc', 'permission' => 'op', //Op only 'usage' => 'usage' ]); ScriptPluginCommands::addCommand($id, [ 'name' => 'exampleCmd1', 'description' => 'ouputs sth to console', 'permission' => 'op', //Op only 'usage' => 'usage' ]); $this->getServer()->getCommandMap()->registerAll($this->getDescription()->getName(), ScriptPluginCommands::getCommands($id)); } public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this, $this); } public function onDisable(){ //Disable code } public function onCommand(CommandSender $sender, Command $command, $label, array $args){ switch($command->getName()){ case "exampleCmd0": //blah return true; break; case "exampleCmd0": $this->getLogger()->info("much test"); return true; break; } } }}/** LIBARIES */namespace robske_110\SPC{ use pocketmine\command\PluginCommand; use pocketmine\Plugin\Plugin; use robske_110\Utils\Utils; /** * @author robske_110 * @version 0.1.2-php7 */ abstract class ScriptPluginCommands{ private static $plugins; public static function initFor(Plugin $plugin) : int { self::$plugins[] = [$plugin]; return count(self::$plugins) - 1; } public static function addCommand(int $id, array $data){ if(!isset(self::$plugins[$id])){ Utils::critical("addCommand() has been called with an unkown ID!"); } $cmd = new PluginCommand($data["name"], self::$plugins[$id][0]); if(isset($data["description"])){ $cmd->setDescription($data["description"]); } if(isset($data["usage"])){ $cmd->setUsage($data["usage"]); } if(isset($data["permission"])){ $cmd->setPermission($data["permission"]); } if(isset($data["aliases"]) && is_array($data["aliases"])){ $aliases = []; foreach($data["aliases"] as $alias){ $aliases[] = $alias; } $cmd->setAliases($aliases); } self::$plugins[$id][1][] = $cmd; } public static function getCommands(int $id) : array { if(!isset(self::$plugins[$id])){ Utils::critical("getCommands() has been called with an unkown ID!"); } return self::$plugins[$id][1]; } }}
Thanks guys. I've succesfully made my first plugin. I'll add the funcionallity I need and put it on my server. Thanks for all the help.