How to fix. PHP: case "Godz": if($sender->hasPermission("tag.Godz") || $sender->isOp()){ $pperms = $this->getServer()->getPluginManager()->getPlugin("PurePerms"); $prefix = "§6God§r"; $this->pureChat->setPrefix($prefix, $sender); $sender->sendMessage("You change your Tag to §eGodz"); }else{ if(!$sender->hasPermission("tag.Godz")); $sender->sendMessage("§8[§4!§8]§7You dont have this tag.") ; } break; } } } } } } return true; }} Here the error PHP: [03:33:54] [Server thread/CRITICAL]: Error: "Call to a member function setPrefix() on null" (EXCEPTION) in "plugins/phar_Tag_o9c7lGyfvQpIsR2.phar/src/Alan/Tag/Main" at line 70
Like @KielKing said, we cant see where its defined. If its defined by getting plugin via server ( ` $server->getPluginManager()->getPlugin('PluginName ` ) if the plugin does not exits it will return null, also your getting PurePerms for no use in that section... I would assume you meant to get PureChat and use that, if so i would check if its null before doing anything (as said above).
PHP: <?phpnamespace Alan\Tag;use pocketmine\event\player\PlayerDeathEvent;use pocketmine\event\entity\EntityDeathEvent;use pocketmine\utils\Config;use _64FF00\PureChat\PureChat;use pocketmine\utils\TextFormat;use pocketmine\event\Listener;use pocketmine\Player;use pocketmine\plugin\PluginBase;use pocketmine\Server;use pocketmine\event\block\BlockBreakEvent;use pocketmine\event\block\BlockPlaceEvent;use pocketmine\utils\TextFormat as TF;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\level\Position;use pocketmine\command\ConsoleCommandSender;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\event\entity\EntityDamageByEntityEvent;class Main extends PluginBase implements Listener{ private $pureChat = null; ########################################################################### ########################### IMPORTANT THINGS ################################# ########################################################################### public function onEnable(){ $this->getLogger()->info("Tag by Alan now enabled!"); } public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool { if(strtolower($command->getName()) === "tag") { if(count($args) < 1) { $sender->sendMessage(TF::GRAY . "§7Usage:§e/tag <list|use>"); return true; } if(isset($args[0])) { switch($args[0]) { case "list": $sender->sendMessage(TF::GRAY . "•Available Tag•"); $sender->sendMessage(TF::GRAY . "•Godz"); return true; break; default: $sender->sendMessage(TextFormat::RED . "Usage: /tag <list|use>"); return true; break; case "use": if (count($args) < 2) { $sender->sendMessage(TextFormat::RED . "Usage: /tag use <tag name>"); return true; } if($sender->hasPermission("tag.command") || $sender->isOp()){ if(isset($args[1])) { switch($args[1]) { case "Godz": if($sender->hasPermission("tag.Godz") || $sender->isOp()){ $pperms = $this->getServer()->getPluginManager()->getPlugin("PurePerms"); $prefix = "§6God§r"; $this->pureChat->setPrefix($sender, $prefix, $this->pureChat->getConfig()->get("enable-multiworld-chat") ? $player->getLevel()->getName() : null); $sender->sendMessage("You change your Tag to §eGodz"); }else{ if(!$sender->hasPermission("tag.Godz")); $sender->sendMessage("§8[§4!§8]§7You dont have this tag.") ; } break; } } } } } } return true; }}