I tried to set the default group from pureperm when a player is a config, but it comes an error. Here is my Code with that i tried to set the Chatformat: PHP: $event->setFormat(PurePerms::getDefaultGroup()); Here is the error: Code: [Server] [Server] Deprecated: Non-static method _64FF00\PurePerms\PurePerms::getDefaultGroup() should not be called statically in /storage/emulated/0/PocketMine/plugins/Nick/src/UniverseNick/JonasGehtMitte/Nick.php on line 181 [Server] [PocketMine] [13:11:16] CRITICAL> Could not execute task UniverseNick\JonasGehtMitte\Refresh: Using $this when not in object context [Server] [PocketMine] [13:11:16] CRITICAL> Error: "Using $this when not in object context" (EXCEPTION) in "/PurePerms.phar/src/_64FF00/PurePerms/PurePerms" at line 332
getDefaultGroup is not a static method, so that should be PHP: $event->setFormat($server->getPluginManager()->getPlugin("PurePerms")->getDefaultGroup()); assume $server is an instance of \pocketmine\Server You may want to read further on static methods at https://secure.php.net/manual/en/language.oop5.static.php.
PHP: $event->setFormat($server->getPluginManager()->getPlugin("PurePerms")->getUserDataMgr()->getGroup($event->getPlayer()));
When i use this then comes an error. The -> behind the getPlugin() have i deleted. And i have wrote in my Plugin use pocketmine\IPlayer; Code: [Server] [PocketMine] [09:03:59] CRITICAL> "Could not pass event 'pocketmine\event\player\PlayerChatEvent' to 'Nick v1.0.1': Argument 1 passed to _64FF00\PurePerms\data\UserDataManager::getGroup() must implement interface pocketmine\IPlayer, string given, called in /storage/emulated/0/PocketMine/plugins/Nick/src/UniverseNick/JonasGehtMitte/Nick.php on line 168 on UniverseNick\JonasGehtMitte\Nick [Server] [PocketMine] [09:03:59] CRITICAL> TypeError: "Argument 1 passed to _64FF00\PurePerms\data\UserDataManager::getGroup() must implement interface pocketmine\IPlayer, string given, called in /storage/emulated/0/PocketMine/plugins/Nick/src/UniverseNick/JonasGehtMitte/Nick.php on line 168" (EXCEPTION) in "/PurePerms.phar/src/_64FF00/PurePerms/data/UserDataManager" at line 56
Read the error. It's soo clear. Here, let me rephrase the error. You provided argument 1 for getGroup() as a string while it should've actually been IPlayer::class.
So? PHP: $this->getServer()->getPluginManager()->getPlugin("PurePerms")->getUserDataMgr()->getGroup();
getOfflinePlayer() returns IPlayer. I wouldn't recommend using getPlayer() or getPlayerExact() as it would return Player(which implements IPlayer) only if the player was online. And we don't know what $nick is.
Code: [Server] [PocketMine] [16:59:08] CRITICAL> "Could not pass event 'pocketmine\event\player\PlayerChatEvent' to 'Nick v1.0.1': Argument 1 passed to _64FF00\PurePerms\PurePerms::setGroup() must implement interface pocketmine\IPlayer, string given, called in /storage/emulated/0/PocketMine/plugins/Nick/src/UniverseNick/JonasGehtMitte/Nick.php on line 168 on UniverseNick\JonasGehtMitte\Nick [Server] [PocketMine] [16:59:08] CRITICAL> TypeError: "Argument 1 passed to _64FF00\PurePerms\PurePerms::setGroup() must implement interface pocketmine\IPlayer, string given, called in /storage/emulated/0/PocketMine/plugins/Nick/src/UniverseNick/JonasGehtMitte/Nick.php on line 168" (EXCEPTION) in "/PurePerms.phar/src/_64FF00/PurePerms/PurePerms" at line 659 [Server] [PocketMine] [16:59:08] INFO> [Developer] Guest | Serus Haralain > a
It was answered. getOfflinePlayer() doesn't mean you can't get an online player. If the player is online, getOfflinePlayer() returns the online player.