I'm new to this and don't know how it works... I want my commands.php to link with main.php but I don't know how.
I suggest learning what a constructor does and when it should be used before worrying about it. You can read a bit about it from php.net. I assume your commands.php and main.php are supposed to be instances of Command and PluginBase, respectively? Show what you've tried so far.
PHP: Main.php<?phpnamespace Kaz;use pocketmine\plugin\PluginBase;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\block\Block;use pocketmine\tile\Tile;use pocketmine\command\CommandSender;use pocketmine\command\Command;use pocketmine\event\block\BlockBreakEvent;use pocketmine\event\block\BlockPlaceEvent;use pocketmine\event\Listener;use pocketmine\Server;use pocketmine\Player;use pocketmine\event\entity\EntityDamageEvent;use Kaz\Tasks\MyTask;use pocketmine\utils\TextFormat as TF;use pocketmine\inventory\Inventory;use pocketmine\item\Item;use pocketmine\math\Vector3;use pocketmine\command\ConsoleCommandSender;use pocketmine\scheduler\PluginTask;use pocketmine\event\player\PlayerInteractEvent;use pocketmine\level\format\Chunk;use pocketmine\level\Level;use Kaz\Commands;class Main extends PluginBase implements Listener{ private $commands; public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getLogger()->info("§aKaz was enabled"); } public function onDisable() { $this->getLogger()->info("§cKaz was disabled"); }} Commands.php PHP: <?phpnamespace Kaz;use Kaz\Main;use pocketmine\event\Listener;class Commands implements Listener{ private $plugin; public function __construct(Main $plugin) { $this->plugin = $plugin; } public function onCommand(CommandSender $sender, Command $command, $label, array $args) { switch ($command->getName()) { case "kaz": $sender->sendMessage("§cCommands:\n§6-§7 /gmc\n§6-§7 /gms\n§6-§7 /awesome"); return true;
I suggest looking at this tutorial over Plugin Commands. There are several ways to use commands in plugins, but you're a little off the mark. You don't need a Listener interface for commands. You can extend PluginCommand or Command in a second class, or, as shown in the thread above, you can handle commands with your main class. I strongly suggest using that method, as it is much simpler. Other than that, you don't typically need to have 2 classes that implement the Listener interface, as one will do. If you were going to use a non-main class as the listener, you would need to use PluginManager->registerEvents with an instance of that class as the first parameter. The second parameter is fine.