Supposing that both are classes, add a content to "Command.php" and create new class instance on Main.php I suppose that you're trying to add a command in Command.php, so simply extend Command (you should use the PocketMine Command class with an aliase, both cannot have the same name) and add all the command stuff. You can register a command class in the main file with: PHP: $this->getServer()->getCommandMap()->register("command", new Command());
We cannot explain everything of PHP to you, this is the PocketMine forum, not a PHP one. Please learn PHP before you start with PocketMine plugins.
This is my main.php: PHP: <?phpnamespace test;use pocketmine\plugin\PluginBase;use pocketmine\event\Listener;use pocketmine\command\CommandSender;use pocketmine\command\Command;use pocketmine\command\CommandExecutor;use pocketmine\command\ConsoleCommandSender;use pocketmine\item\Item;use pocketmine\Player;use pocketmine\Server;use pockemine\inventory\Inventory;use pocketmine\event\player\PlayerJoinEvent;class main extends PluginBase implements Listener{ public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getLogger()->info("plugin testowy został załadowany"); } } And test.php: PHP: <?phpnamespace test;use pocketmine\plugin\PluginBase;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\event\block\BlockBreakEvent;use pocketmine\event\player\PlayerJoinEvent;use test\main;use pocketmine\Player;class test extends PluginBase implements Listener{ public function __construct(main $plugin){ $this->plugin = $plugin; } public function onJoin(PlayerJoinEvent $event){ $player = $event->getPlayer(); $player->sendMessage("TESTSSSSSTSTSTST"); }} But this plugin not work
But i have error when i'm register the command: Code: [Server] Fatal error: Call to undefined function test\new TestCommand() in myzip:///storage/sdcard0/PocketMine/plugins/test.zip#src/test/Main.php on line 16 [Server] [12:59:08] [EMERGENCY]: An unrecoverable error has occurred and the server has crashed. Creating a crash dump [Server] [12:59:08] [EMERGENCY]: Please upload the "/storage/sdcard0/PocketMine/CrashDump_Fri_May_27-12.59.08-UTC_2016.log" file to the Crash Archive and submit the link to the Bug Reporting page. Give as much info as you can. My Main class PHP: <?phpnamespace test;use pocketmine\plugin\PluginBase;use pocketmine\event\Listener;use pocketmine\Server;use pocketmine\command\Command;use pocketmine\command\CommandExecutor;use test\command\TestCommand;class Main extends PluginBase implements Listener{ public function onEnable(){ $this->getCommand('test')->setExecutor(new TestCommand()); $this->getServer()->getPluginManager()->registerEvents(new EventListener($this), $this); $this->getServer()->getPluginManager()->registerEvents(new TestCommand($this), $this); $this->getLogger()->info("plugin testowy został załadowany"); } } And TestCommand: PHP: <?phpnamespace test\command;use pocketmine\command\CommandSender;use pocketmine\command\Command;use pocketmine\command\CommandExecutor;use pocketmine\Player;use pocketmine\Server;use test\Main;use pocketmine\event\Listener;use pocketmine\plugin\PluginBase;use pocketmine\event\player\PlayerJoinEvent;class TestCommand implements CommandExecutor{ public function __construct(Main $plugin){ $this->plugin = $plugin; } public function onCommand(CommandSender $sender, Command $command, $label, array $args){ $name = $sender->getPlayer()->getName(); if(strtolower($command->getName('test'))) { if(empty($args)) { $sender->sendMessage("test"); return true; } if($args[0] == "test1") { } if($args[0] == "test2") { } } if($args[0] == "test3") { } } }
If you want register an event in only one class you should use registerEvent method instead registerEvents.
How to create a new file in Windows: http://windows.microsoft.com/en-hk/windows-vista/create-a-new-file This answers your question if you are on Windows, right?
but what is the creation of the file to the plugin ? and a so-so already advised , I used __construct
And what is the reason of creating a file for the plugin? If you just want to have another file in the plugin, the link I sent you already explains how. Can you first explain why you want to create multiple files?
but I ask you to do a few classes in the plugin and you give me a guide on how to do a new file in windows ... !
Oh right. In the new file add this: PHP: <?phpclass Clazz{} New class added. Happy? If you can't even explain what you want a new class for, how can we answer you?