Hi, I have been working on this plugin. There were no errors produced on Console but the plugin just doesn't load at all. Please correct me, if there's an issue. Thanks PHP: - AFKSystem.php -<?php/** * All rights reserved RTGNetworkkk * GitHub: https://github.com/RTGNetworkkk * Author: InspectorGadget*/namespace RTG\AFK;use pocketmine\Player;use pocketmine\Server;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\plugin\PluginBase;use pocketmine\event\Listener;use pocketmine\event\Cancellable;use pocketmine\event\player\PlayerDropItemEvent;use pocketmine\event\player\PlayerMoveEvent;use pocketmine\event\player\PlayerDamageEvent;use pocketmine\event\player\PlayerDeathEvent;use pocketmine\event\player\PlayerChatEvent;class AFKSystem extends PluginBase implements Listener { public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->saveResource("afklist.txt"); $this->cfg = new Config($this->getDataFolder() . "afklist.txt"); } public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) { switch(strtolower($cmd->getName())) { case "afkmode": if($sender instanceof Player) { if($sender->hasPermission("afk.command")) { if(isset($args[0])) { switch(strtolower($args[0])) { case "on": $n = $sender->getName(); if($this->cfg->get($n) === false) { $this->cfg->save(); $this->broadcastMessage("§d[Server] [] $n is now AFK!"); } return true; break; case "off": $n = $sender->getName(); if($this->cfg->get($n) === true) { $this->cfg->remove($n); $this->cfg->save(); $this->broadcastMessage("§d[Server] [] $n is no longer AFK!"); } return true; break; } } else { $sender->sendMessage("Usage: /afkmode < on | off >"); } } else { $sender->sendMessage("§cYou have no permission to use this command!"); } } else { $sender->sendMessage("Only in-game!"); } return true; break; public function onMove(PlayerMoveEvent $e) { $n = $e->getPlayer()->getName(); if($this->cfg->get($n) === true) { $e->getPlayer()->sendPopup("§c[AFK] Please do /afk to leave AFK Mode!"); $this->setCancelled(); } } public function onHurt(PlayerDamageEvent $e) { $n = $e->getPlayer()->getName(); if($this->cfg->get($n) === true) { $this->setCancelled(); } } public function onDrop(PlayerDropItemEvent $e) { $n = $e->getPlayer()->getName(); if($this->cfg->get($n) === true) { $this->setCancelled(); } } public function onDeath(PlayerDeathEvent $e) { $n = $e->getPlayer()->getName(); if($this->cfg->get($n) === true) { $this->setCancelled(); } } public function onChat(PlayerChatEvent $e) { $n = $e->getPlayer()->getName(); if($this->cfg->get($n) === true) { $e->getPlayer()->sendMessage("[] Please do /afk to turn off AFK Mode!"); $this->setCancelled(); } } public function onJoin(PlayerJoinEvent $e) { $n = $e->getPlayer()->getName(); if($this->cfg->get($n) === true) { $this->cfg->remove($n); $this->cfg->save(); $e->getPlayer()->sendMessage("You are no longer AFK!"); } } public function onDisable() { } } PHP: - plugin.yml -name: AFKSystemversion: 1.0.0main: RTG\AFK\AFKSystemapi: [2.0.0, 2.1.0, 3.0.0]author: InspectorGadgetcommands: afkmode: usage: "/afkmode" permission: afk.command description: "Toggles AFK!"permissions: afk.command: default: op
If you are extending a class as listener, you need to register it as the event listener class. PHP: public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this, $this);}
If it doesn't load at all your problem isn't the code (that seems like to be ok) but may depend on how are you trying to load it (is it a phar?) and what's your folder structure.
Didn't see that oops.. Your code seems fine, there's nothing wrong. Is plugin.yml and the src folder in the same directory?
It's a good idea to push the whole code structure onto GitHub via Git. In this way we can see how the whole plugin looks like.