Error 22.09 16:54:39 [Server] INFO Fatal error: Declaration of KnockbackM\Main:nCommand(KnockbackM\Command $cmd, KnockbackM\CommandSender $sender, array $args, $label) must be compatible with pocketmine\command\CommandExecutor:nCommand(pocketmine\command\CommandSender $sender, pocketmine\command\Command $command, string $label, array $args): bool in /plugins/KnockbackM/src/KnockbackM/Main.php on line 12 LINE 12 = PHP: class Main extends PluginBase implements Listener{ Code PHP: <?phpnamespace KnockbackM;use pocketmine\event\Event;use pocketmine\event\entity\EntityDamageByEntityEvent;use pocketmine\event\entity\EntityDamageEvent;use pocketmine\Server;use pocketmine\Player;use pocketmine\plugin\PluginBase;use pocketmine\event\Listener;class Main extends PluginBase implements Listener{ public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this,$this); } public $knockback = 0.4; public function onCommand(Command $cmd, CommandSender $sender, array $args, $label) { if($cmd->getName() == "kb") { $event->setKnockback($args[0]); $sender->sendMessage("Knockback Set!"); } } public function onDamage(EntityDamageEvent $event) { if($event instanceof EntityDamageByEntityEvent){ $event->setKnockback(1.0); } }}
learn to read error and also RTFD https://forums.pmmp.io/threads/updating-a-plugin-to-work-with-different-apis-the-manual-way.3647/
Sorry, like I said im new to this. This is my first real plugin. Didnt know that I didnt just have to change api in plugin.yml. Thanks
cheers, either ways you should try google it first or learn to read the error that would help you out
Read the thread Thunder gave you. Beginners should understand it. If you don't, here's how to fix it: Find the line in your code: PHP: public function onCommand(Command $cmd, CommandSender $sender, array $args, $label) It must be compatible with: PHP: public function onCommand(pocketmine\command\CommandSender $sender, pocketmine\command\Command $cmd, string $label, array $args): bool That means, your line needs to exactly look like this (if you used the use keyword on the CommandSender and Command class, you can remove the pocketmine\command\ in-front of those). Look here to get an idea.