Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IP ban check #45

Open
wants to merge 1 commit into
base: api/pm5
Choose a base branch
from

Conversation

UnknownNull
Copy link
Contributor

No description provided.

@@ -168,5 +168,12 @@ public function onLogin(PlayerLoginEvent $event) : void {
$player->kick($reason);
$event->cancel();
}
if (BetterBan::isBannedIp($player->getNetworkSession()->getIp())) {
Copy link
Contributor

@xqwtxon xqwtxon Apr 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use proper indentation. Please fix your coding standards as follows to poggit rules.

$pl = BetterBan::getInstance();
$entry = $pl->useMySQL() ? $pl->getMySQLIpBans()->getEntry($player->getNetworkSession()->getIp()) : $pl->getServer()->getNameBans()->getEntry($player->getName());
$reason = str_replace(["{source}", "{expires}", "{reason}", "{line}"], [$entry->getSource(), $entry->getExpires() !== null ? BetterBan::getInstance()->toPrettyFormat($entry->getExpires(), BetterBan::getInstance()->getConfig("use-legacy-format", false)) : "Never", $entry->getReason(), "\n"], BetterBan::getInstance()->getConfig()->get("you-are-banned-ip-logout"));
$player->kick($reason);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this to PlayerPreLoginEvent, kick player by using PlayerPreLoginEvent->setKickFlag(), Just to improve the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants