While I realize that PlayerBanEvents aren't real, I would like to know how to program the equivalent of one. How can I tell when a player is banned or unbanned?
Well, we can code a work around Here is what I came up with in 5 minutes PHP: public function onPlayerCommand(PlayerCommandPreprocessEvent $event){ $player= $event->getPlayer(); $message = $event->getMessage(); $command = substr($message, 1); $args = explode(" ", $command); if($args[0] === "ban-ip" or $args[0] === "ban"){ //commands if (substr($message, 0, 1) === '/') { //Double check to make sure its a command. $event->getPlayer()->sendMessage("- xFlare stoped this command with magic."); $event->setCancelled(true); return true;
That works for the ban command, but I also want to catch when a plugin calls the Player::setBanned() method. No, he had it right. You can check if a player is banned by calling the Player::isBanned() method.