Hi, im working on a pocketmine plugin which is called: MyHelper (Will be submitted to pocketmine when done) it would allows users to customized /helper command with their own custom message. They will be able to add anything like where user's can buy vip for their server.. ect All of that will be able to edit on the Config.yml While i was running it to make sure no errors are found , so far there was not, but i registered a command and it doesn't work (when i run /helper on the local server). Please help i've added some pictures if you wanna help and point me out some mistakes. MyHelper.php PHP: <?php########################## MyHelper Was Created By: Andre_The_Gamer########################## ===================================namespace Andre;######################### EVERYTHING THE PLUGIN WILL USED.######################use pocketmine\Server;use pocketmine\event\server\ServerCommandEvent;use pocketmine\command\defaults\HelpCommand;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\plugin\PluginBase;use pocketmine\command\PluginCommand;use pocketmine\plugin\PluginLogger;use pocketmine\utils\Config;use pocketmine\event\player\PlayerLoginEvent;use pocketmine\command\defaults\KickCommand;use pocketmine\command\CommandSender;use pocketmine\command\CommandReader;use pocketmine\event\player;use pocketmine\event\player\PlayerPreLoginEvent;use pocketmine\event\player\PlayerQuitEvent;use pocketmine\command\CommandExecutor;use pocketmine\event\player\PlayerChatEvent;use pocketmine\event\Listener;use pocketmine\network\protocol\LevelEventPacket;use pocketmine\utils\TextFormat;use pocketmine\command\Command;########################################################################## Basic Start Up Things###################################class MyHelper extends PluginBase{ public function onEnable(){ $this->config = (new Config($this->getDataFolder()."config.yml", Config::YAML))->getAll(); $this->saveDefaultConfig(); $this->reloadConfig(); $this->getConfig()->getAll(); } public function onDisable(){ $this->getLogger()->info("onDisable() MyHelper Is Disable");}public function onCommand(CommandSender $sender, Command $command, $label, array $args){ $commandName = $command->getName(); if($commandName === "helper"){ // Doesn't work when i try /help In local server $sender->sendMessage(" Testing"); // This will get line1 from config :p , But i've haven't work on it yet. return true; } return false; }} Config.yml: PHP: ############################# MY HELPER ############################## - Custom /helper command with custom message# Made By: Andre_The_Gamer // Do Not Modify Without My Permission! :D# Website: www.insanepe.net######## No Permission MessageNo-Permission: You don't have permission to use this command# ===== Messages ===== #line1: +=My Helper=+line2: Add Anything hereline3: Add Anything hereline4: Add Anything hereline5: Add Anything hereline6: Add Anything hereline7: Add Anything hereline8: Add Anything hereline9: += <> <> =+ Plugin.yml: PHP: name: MyHelpermain: Andre\MyHelperversion: 1.0.0api: 1.0.0author: Andre_The_Gamerdescrption: Set your own custom help pagewebsite: https://www.insanepe.netCommands: helper: description: show the help page to user permission: myhelper.usePermissions: myhelper.use: default: true description: allows player to use the /helper command I started with this project today. xD This plugin will be useful for all server's owner cause they will be able to customized the /helper command. I just need help to register the /helper command and ill be good to do.
Firstly the command would be /helper and not/help. Secondly, it wouldn't display the messages to the players as, you haven't linked the configs to sendMessage(). So basically, when you would do /helper, it would send: Testing, and you forgot to register events. so in public function onEnable(), please add: PHP: $this->getServer()->getPluginManager()->registerEvents($this, $this);
I know., i didn't link the comfig. But when i do /helper (In local server) it would send: Testing" but it didn't
I recommend, that you firstly make a command without using the concept of configs, so you can get a understand of how the commands work. Example of a simple command that sends player a message: PHP: public function onCommand(CommandSender $sender, Command $command, $label, array $args){ $cmd = strtolower($command->getName()); if($cmd === "h"){ $sender->sendMessage("Welcome " . $sender->getName() . " !"); $sender->sendMessage("Please use the warps"); return true; }return false}
Why? There's no event being used, why register them? You should add "usage" to the command in the plugin.yml.
do 'permissions' instead of 'Permissions' and 'Commands' to - 'commands' Dont wanna be mean, but you have bad coding style, practise more
Thanks, but my codding style is alright. It's not messy . Look before you judge Ok, it works. Thanks alot. Im gonna start working on config now.. Thanks alot
This is good coding style: https://github.com/PurePlugins/PurePerms/blob/master/src/_64FF00/PurePerms/PurePerms.php
plugin.yml Code: name: MyHelper api: 1.0.0 version: 1.0.0 main: Andre\MyHelper description: 'Useless plugin :)' commands: helper usage: '/helper' permission: myhelper.command.helper permissions: myhelper.*: default: false description: '' children: myhelper.command.* default: false description: '' children: myhelper.command.helper default: true description: '' MyHelper.php PHP: <?phpnamespace Andre;use pocketmine\plugin\PluginBase;use pocketmine\Player;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\utils\TextFormat;class MyHelper extends PluginBase { public function onLoad() { $this->getLogger()->info('['.$this->getDescription()->getName().'] Loading...'); } public function onEnable() { $this->saveDefaultConfig(); $this->getLogger()->info(TextFormat::GREEN.'Activated.'); } public function onDisable() { $this->getLogger()->info(TextFormat::GREEN.'Deactivated.'); } /** * @param CommandSender $sender * @param Command $command * @param string $label * @param array $args * * @return bool */ public function onCommand(CommandSender $sender, Command $command, $label, array $args) { if(strtolower($command->getName()) === 'helper'){ if(!$sender instanceof Player){ $sender->sendMessage('Run this command in-game'); return true; } foreach($this->getConfig()->get('content') as $i => $msg) { $sender->sendMessage($msg); } } } } config.yml Code: --- content: - 'Line 1' - 'Line 2' - 'Line 3' - 'And so on' ...
Thanks, everyone that helped "MyHelper" Is done and has been submitetd to pocketmine. Thanks for helping. i hope it get's accepted!