mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-30 23:29:54 +00:00
Added Command Permissions Whitelist
This commit is contained in:
parent
3f10e11ddf
commit
6dfe348767
@ -31,6 +31,7 @@ class BanAPI{
|
|||||||
private $banned;
|
private $banned;
|
||||||
private $ops;
|
private $ops;
|
||||||
private $bannedIPs;
|
private $bannedIPs;
|
||||||
|
private $cmdWL = array();
|
||||||
function __construct(PocketMinecraftServer $server){
|
function __construct(PocketMinecraftServer $server){
|
||||||
$this->server = $server;
|
$this->server = $server;
|
||||||
}
|
}
|
||||||
@ -52,11 +53,16 @@ class BanAPI{
|
|||||||
$this->server->api->console->alias("banlist", "ban list");
|
$this->server->api->console->alias("banlist", "ban list");
|
||||||
$this->server->api->console->alias("pardon", "ban remove");
|
$this->server->api->console->alias("pardon", "ban remove");
|
||||||
$this->server->api->console->alias("pardon-ip", "banip remove");
|
$this->server->api->console->alias("pardon-ip", "banip remove");
|
||||||
$this->server->addHandler("console.command", array($this, "opCheck"), 1);
|
$this->server->addHandler("console.command", array($this, "permissionsCheck"), 1);
|
||||||
|
$this->cmdWhitelist("help");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function cmdWhitelist($cmd){
|
||||||
|
$this->cmdWhitelist[strtolower(trim($cmd))] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isOp($username){
|
public function isOp($username){
|
||||||
if($this->server->api->dhandle("api.op.check", $username) === true){
|
if($this->server->api->dhandle("op.check", $username) === true){
|
||||||
return true;
|
return true;
|
||||||
}elseif($this->ops->exists($username)){
|
}elseif($this->ops->exists($username)){
|
||||||
return true;
|
return true;
|
||||||
@ -64,16 +70,14 @@ class BanAPI{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function opCheck($data, $event){
|
public function permissionsCheck($data, $event){
|
||||||
$whitelist = array(
|
|
||||||
"help",
|
if(isset($this->cmdWhitelist[$data["cmd"]])){
|
||||||
);
|
|
||||||
if(in_array($data["cmd"], $whitelist, true)){
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($data["issuer"] instanceof Player){
|
if($data["issuer"] instanceof Player){
|
||||||
if($this->isOp($data["issuer"]->username)){
|
if($this->server->api->handle("console.check", $data) === true or $this->isOp($data["issuer"]->username)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}elseif($data["issuer"] === "console"){
|
}elseif($data["issuer"] === "console"){
|
||||||
|
@ -30,6 +30,7 @@ class Deprecation{
|
|||||||
public static $events = array(
|
public static $events = array(
|
||||||
"world.block.change" => "block.change",
|
"world.block.change" => "block.change",
|
||||||
"block.drop" => "item.drop",
|
"block.drop" => "item.drop",
|
||||||
|
"api.op.check" => "op.check",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user