Hi! I have been working on a BanCID plugin recently.. I am not very sure about the issue with the plugin. The plugin is suppose to can a players CID when I do /bancid <name> and stores into a YAML file and checks it when the player joins even with a different Username or IP. Any help would be appreciated! Thanks Code: PHP: <?phpnamespace BCID;use pocketmine\Server;use pocketmine\Player;use pocketmine\utils\Config;use pocketmine\plugin\PluginBase;use pocketmine\event\Listener;use pocketmine\command\Command;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\command\CommandSender;class Main extends PluginBase implements Listener { public function onEnable() { if(!is_dir($this->getDataFolder())) { @mkdir($this->getDataFolder()); } //$this->saveResource("clientBan.yml"); $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->clientBan = new Config($this->getDataFolder() . "clientBan.yml", Config::YAML, array()); } public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) { switch($cmd->getName()) { case "bancid": if($sender->hasPermission("bancid")) { if(isset($args[0])) { $name = $args[0]; $pl = $this->getServer()->getPlayer($args[0]); if($pl instanceof Player) { $this->clientBan->set(strtolower($pl->getName()), $pl->getClientId()); $this->clientBan->save(); //$pl->setBanned(true); $pl->kick("You have been banned", false); $sender->sendMessage("You have successfully CID banned $name!"); } else { $sender->sendMessage($args[0] . " isn't online!"); } } else { $sender->sendMessage("Usage: /bancid {name}"); } } else { $sender->sendMessage("You have no permission to use this command!"); } return true; case "pardoncid": if($sender->hasPermission("pardoncid")) { if(isset($args[0])) { if($this->clientBan->exists($name = strtolower($args[0]))) { $this->clientBan->remove($name); $this->clientBan->save(); $sender->sendMessage("You have CID pardoned $name!"); } else { $sender->sendMessage($args[0] . " doesn't exist!"); } } else { $sender->sendMessage("Usage: /pardoncid {name}"); } } else { $sender->sendMessage("You have no permission to use this command!"); } return true; } } public function onJoin(PlayerJoinEvent $e) { $cid = $e->getPlayer()->getClientId(); $name = strtolower($e->getPlayer()->getName()); //if($this->clientBan->exists(strtolower($name))) { if($cid == $this->clientBan->getAll()) { $e->getPlayer()->kick("You have been CID banned!"); //$e->getPlayer()->setBanned(true); //} } } public function onDisable() { $this->clientBan->save(); }} GitHub SRC: https://github.com/RTGNetworkkk/BanCID
PHP: public function onJoin(PlayerJoinEvent $e) { $cid = $e->getPlayer()->getClientId(); $name = strtolower($e->getPlayer()->getName()); //if($this->clientBan->exists(strtolower($name))) { if($cid == $this->clientBan->get($name)) { //You need to get the value associated with the player name $e->getPlayer()->kick("You have been CID banned!"); //$e->getPlayer()->setBanned(true); //} } } Try that
While i don't consider creating a BanCID plugin yourself is necessary, there are too many out there already. You need to iterate through your list and check for any player having the clientid https://github.com/robske110/BanWarn/blob/master/English/src/robske_110/BanWarn/Main.php#L44-L58
PocketMine doesn't have bancid feature yet so i have to stop hackers by a plugin like this. I'll take a look at BanWarn. Thanks