/**
* @param PlayerPreLoginEvent $login
* @priority HIGH
* @ignoreCancelled true
*/
public function onPlayerPreconnect(PlayerPreLoginEvent $login)
{
$name = strtolower($login->getPlayer()->getName());
if (in_array($name, ["pocketmine", "console", "server", "rcon", "legionpe", "botbot", "fakeclient", "pocketbot"])) {
$login->setCancelled();
$login->setKickMessage("Bad username");
} else {
$reason = $this->getMain()->getMySQLi()->query("SELECT msg FROM ipbans WHERE %s LIKE ip AND %d<(unix_timestamp(creation)+length);", MysqlConnection::ASSOC, $login->getPlayer()->getAddress(), time());
if (is_array($reason)) {
$login->setCancelled();
$login->setKickMessage("You are IP-banned! Reason: " . (isset($reason["msg"]) ? $reason["msg"] : "no reason specified :("));
}
if (($old = $this->getMain()->getServer()->getPlayerExact($name)) instanceof Player) {
// if has name collision
if ($old->getAddress() !== ($ip = $login->getPlayer()->getAddress())) {
// if IP is different
if (substr($ip, 0, 8) !== "192.168." and $ip !== "119.247.51.252") {
// if new IP isn't local and isn't PEMapModder's IP address (yes I am making it for myself)
$login->setCancelled();
$login->setKickMessage("Player already online with differnet IP");
}
}
}
}
}