Skip to content
This repository has been archived by the owner on Jul 11, 2018. It is now read-only.

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandroliu committed Apr 18, 2015
1 parent 7e72108 commit 943bfcf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion SimpleAuthHelper/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
main: aliuly\helper\Main
api: 1.10.0
load: POSTWORLD
depend: [SimpleAuth]

name: SimpleAuthHelper
description: Simplifies the way people authenticate to servers
version: 1.1.0-dev
version: 1.2.0
author: aliuly

17 changes: 10 additions & 7 deletions SimpleAuthHelper/src/aliuly/helper/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public function onPlayerQuit(PlayerQuitEvent $ev) {
if (isset($this->pwds[$n])) unset($this->pwds[$n]);
}
public function onPlayerJoin(PlayerJoinEvent $ev) {
if ($this->cfg["login-timeout"] == 0) return;
$n = $ev->getPlayer()->getName();
$this->getServer()->getScheduler()->scheduleDelayedTask(new CallbackTask([$this,"checkTimeout"],[$n]),$this->cfg["login-timeout"]*20);
}
Expand Down Expand Up @@ -107,13 +108,15 @@ public function onPlayerCmd(PlayerCommandPreprocessEvent $ev) {
}
return;
}
if (isset($this->pwds[$n])) {
++$this->pwds[$n];
} else {
$this->pwds[$n] = 0;
}
$ev->setMessage("/login ".$ev->getMessage());
$this->getServer()->getScheduler()->scheduleDelayedTask(new CallbackTask([$this,"checkLoginCount"],[$n]),5);
if ($this->cfg["max-attempts"] > 0) {
if (isset($this->pwds[$n])) {
++$this->pwds[$n];
} else {
$this->pwds[$n] = 1;
}
$this->getServer()->getScheduler()->scheduleDelayedTask(new CallbackTask([$this,"checkLoginCount"],[$n]),5);
}
return;
}
public function checkTimeout($n) {
Expand All @@ -131,7 +134,7 @@ public function checkLoginCount($n) {
$pl = $this->getServer()->getPlayer($n);
if ($pl && !$this->auth->isPlayerAuthenticated($pl)) {
echo __METHOD__.",".__LINE__."($n)\n"; //##DEBUG;
if ($this->pwds[$n] > $this->cfg["max-attempts"]) {
if ($this->pwds[$n] >= $this->cfg["max-attempts"]) {
echo __METHOD__.",".__LINE__."($n)\n"; //##DEBUG;
$pl->kick($this->cfg["messages"]["too many logins"]);
unset($this->pwds[$n]);
Expand Down

0 comments on commit 943bfcf

Please sign in to comment.