I'm coding a plugin, but isn't working at all. Please help me fix and explain my mistakes (I want to learn too). I'm not getting any errors. PHP: <?phpnamespace WinterBuild7074\NoCrafting;use pocketmine\command\CommandSender;use pocketmine\command\Command;use pocketmine\event\Listener;use pocketmine\plugin\PluginBase;use pocketmine\event\player\PlayerInteractEvent;use pocketmine\Server;use pocketmine\Player;class Main extends PluginBase implements Listener { public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->saveDefaultConfig(); } public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) { switch($cmd->getName()) { case "nocrafting": case "disablecrafting": case "turnoffcrafting": if($sender->hasPermission("nocrafting.tools")) { if(isset($args[0])) { if(strtolower($args[0]) === "add" || strtolower($args[0]) === "remove") { if(isset($args[1])) { $level = $args[1]; if($this->getServer()->isLevelGenerated($level)) { if($args[0] === "add") { $disablecrafting = $this->getConfig()->get("DisableCrafting"); $disablecrafting[] = $level; $this->getConfig()->set("DisableCrafting", $disablecrafting); } else { $disablecrafting = $this->getConfig()->get("DisableCrafting"); if(in_array($level, $disablecrafting)) { $pos = array_search($level, $disablecrafting); unset($disablecrafting[$pos]); $this->getConfig()->set("DisableCrafting", $disablecrafting); } else { $sender->sendMessage("§cCannot remove world from config because that world isn't in the §oDisableCrafting§r§c list."); } } } else { $sender->sendMessage("§cWorld doesn't exist."); } } else { $sender->sendMessage("§cUsage: /" . $label . " <add|remove> <worldName>"); } } else { $sender->sendMessage("§cUsage: /" . $label . " <add|remove> <worldName>"); } } else { $sender->sendMessage("§cUsage: /" . $label . " <add|remove> <worldName>"); } } break; case "getworldname": if($sender->hasPermission("nocrafting.world")) { $playerlevel = $sender->getLevel()->getName(); $sender->sendMessage("§aName of world: §o" . $playerlevel); } break; } } public function onTouch(PlayerInteractEvent $event) { $block = $event->getBlock(); $player = $event->getPlayer(); $blocklevel = $block->getLevel()->getName(); $blockedcrafting = $this->getConfig()->get("BlockedCrafting"); $opcrafting = $this->getConfig()->get("OPCrafting"); if(strtolower($opcrafting) === "true") { if(!$player->hasPermission("nocrafting.op")) { if($block->getId() === 58) { if(in_array($blocklevel, $blockedcrafting)) { $event->setCancelled(); } } } } else { if($block->getId() === 58) { if(in_array($blocklevel, $blockedcrafting)) { $event->setCancelled(); } } } }}
Are you sure your code is even being executed? Use var_dump(). Anyway, I found a possible fault in your code. You forgot to save the config after modifying it.