Skip to content

Commit

Permalink
Added login reminder
Browse files Browse the repository at this point in the history
  • Loading branch information
PEMapModder committed Jan 21, 2016
1 parent f64f6d4 commit 4695a6b
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ Features
- [x] Server-customized messages
- [x] Extensive audit logging
- [ ] An extensive API (W.I.P.)

Entry script
===
Open this phar directly with PHP binaries to automatically extract the config files.
Binary file modified compile/HereAuth_Dev.phar
Binary file not shown.
2 changes: 1 addition & 1 deletion compile/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"major": 1,
"minor": 0
},
"nextBuild": 83
"nextBuild": 84
}
13 changes: 13 additions & 0 deletions resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@ MultiSesCtrl:
# This won't block the message if it contains anything other than the pssword, including spaces.
BlockPasswordChat: true

# Send chat/tip/popup to remind player to register/login
RemindLogin:
# Messages to send to players
Message:
Register: Please register by typing password into chat
Login: Please login by typing password into chat
# Type of message.
# Options: chat, popup, tip
Type: popup
# Frequency interval, in seconds, of how often to send the message
# Value is rounded down to 0.05 second
Interval: 0.5

# Force players to register before playing
ForceRegister:
# If this is set to false, players have to execute /register to register.
Expand Down
56 changes: 56 additions & 0 deletions src/HereAuth/Task/RemindLoginTask.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/

namespace HereAuth\Task;

use HereAuth\HereAuth;
use pocketmine\scheduler\PluginTask;

class RemindLoginTask extends PluginTask{
/** @type HereAuth $main */
private $main;

public function __construct(HereAuth $main){
parent::__construct($this->main = $main);
$period = (int) ($main->getConfig()->getNested("RemindLogin.Interval", 0.5) * 20);
$main->getServer()->getScheduler()->scheduleDelayedRepeatingTask($this, $period, $period);
}

public function onRun($currentTick){
$reg = $this->main->getConfig()->getNested("RemindLogin.Message.Register", "Register please");
$log = $this->main->getConfig()->getNested("RemindLogin.Message.Login", "Login please");
$method = $this->main->getConfig()->getNested("RemindLogin.Type", "popup");
if($method === "chat"){
$fx = "sendMessage";
}elseif($method === "tip"){
$fx = "sendTip";
}else{
$fx = "sendPopup";
}
foreach($this->main->getUsers() as $user){
if($user->isRegistering()){
$user->getPlayer()->$fx($reg);
}elseif($user->isLoggingIn()){
$user->getPlayer()->$fx($log);
}
}
}
}

0 comments on commit 4695a6b

Please sign in to comment.