Show captcha at login, if active.

This commit is contained in:
asofold 2012-10-01 05:50:37 +02:00
parent 90e32942cb
commit 152b68f5b4

View File

@ -8,6 +8,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerLoginEvent.Result;
@ -204,6 +205,20 @@ public class ChatListener implements Listener, INotifyReload {
if (noPwnage.isEnabled(player) && noPwnage.checkLogin(player))
event.disallow(Result.KICK_OTHER, cc.noPwnageReloginKickMessage);
}
@EventHandler(
priority = EventPriority.MONITOR)
public void onPlayerJoin(final PlayerJoinEvent event) {
final Player player = event.getPlayer();
final ChatConfig cc = ChatConfig.getConfig(player);
final ChatData data = ChatData.getData(player);
if (captcha.isEnabled(player) && captcha.shouldCheckCaptcha(cc, data)){
// shouldCheckCaptcha: only if really enabled.
// Later: add check for cc.captchaOnLogin or so.
// TODO: maybe schedule this to coma after other plugins messages.
captcha.sendNewCaptcha(player, cc, data);
}
}
@Override
public void onReload() {