Player is instanceof CommandSender

This commit is contained in:
Shoghi Cervantes
2014-03-31 02:53:37 +02:00
parent 5bb909adf1
commit 2b8df410d1
4 changed files with 475 additions and 5 deletions

View File

@ -44,6 +44,7 @@ use PocketMine\Network\Query\QueryHandler;
use PocketMine\Network\Query\QueryPacket;
use PocketMine\Network\ThreadedHandler;
use PocketMine\Network\UPnP\UPnP;
use PocketMine\Permission\BanList;
use PocketMine\Permission\DefaultPermissions;
use PocketMine\Plugin\Plugin;
use PocketMine\Plugin\PluginLoadOrder;
@ -61,6 +62,18 @@ class Server{
/** @var Server */
private static $instance = null;
/** @var BanList */
private $banByName = null;
/** @var BanList */
private $banByIP = null;
/** @var Config */
private $operators = null;
/** @var Config */
private $whitelist = null;
/** @var bool */
private $isRunning = true;
@ -477,6 +490,92 @@ class Server{
}
}
/**
* @return BanList
*/
public function getNameBans(){
return $this->banByName;
}
/**
* @return BanList
*/
public function getIPBans(){
return $this->banByIP;
}
/**
* @param string $name
*/
public function addOp($name){
$this->operators->set(strtolower($name), true);
if(($player = Player::get($name, false, false)) instanceof Player){
$player->recalculatePermissions();
}
}
/**
* @param string $name
*/
public function removeOp($name){
$this->operators->remove(strtolower($name));
if(($player = Player::get($name, false, false)) instanceof Player){
$player->recalculatePermissions();
}
}
/**
* @param string $name
*/
public function addWhitelist($name){
$this->whitelist->set(strtolower($name), true);
}
/**
* @param string $name
*/
public function removeWhitelist($name){
$this->whitelist->remove(strtolower($name));
}
/**
* @param string $name
*
* @return bool
*/
public function isWhitelisted($name){
return !$this->hasWhitelist() or $this->operators->exists($name, true) or $this->whitelist->exists($name, true);
}
/**
* @param string $name
*
* @return bool
*/
public function isOp($name){
return $this->operators->exists($name, true);
}
/**
* @return Config
*/
public function getWhitelisted(){
return $this->whitelist;
}
/**
* @return Config
*/
public function getOPs(){
return $this->operators;
}
public function reloadWhitelist(){
$this->whitelist->reload();
}
/**
* @return Server
*/
@ -501,6 +600,14 @@ class Server{
@mkdir($this->dataPath . "players/", 0777);
@mkdir($this->pluginPath, 0777);
$this->operators = new Config($this->dataPath . "ops.txt", Config::ENUM);
$this->whitelist = new Config($this->dataPath . "whitelist.txt", Config::ENUM);
if(file_exists($this->dataPath . "banned.txt") and !file_exists($this->dataPath . "banned-players.txt")){
@rename($this->dataPath . "banned.txt", $this->dataPath . "banned-players.txt");
}
$this->banByName = new BanList($this->dataPath . "banned-players.txt");
$this->banByIP = new BanList($this->dataPath . "banned-ips.txt");
$this->tickScheduler = new TickScheduler(20);
$this->scheduler = new ServerScheduler();
$this->console = new CommandReader();