mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-20 15:41:33 +00:00
Limited RCON threads to one and added a auth timeout
This commit is contained in:
@@ -99,7 +99,7 @@ class BanAPI{
|
||||
if($this->server->api->handle("console.check", $data) === true or $this->isOp($data["issuer"]->iusername)){
|
||||
return true;
|
||||
}
|
||||
}elseif($data["issuer"] === "console"){
|
||||
}elseif($data["issuer"] === "console" or $data["issuer"] === "rcon"){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@@ -34,6 +34,7 @@ class ChatAPI{
|
||||
public function init(){
|
||||
$this->server->api->console->register("tell", "<player> <private message ...>", array($this, "commandHandler"));
|
||||
$this->server->api->console->register("me", "<action ...>", array($this, "commandHandler"));
|
||||
$this->server->api->console->register("say", "<message ...>", array($this, "commandHandler"));
|
||||
$this->server->api->ban->cmdWhitelist("tell");
|
||||
$this->server->api->ban->cmdWhitelist("me");
|
||||
}
|
||||
@@ -41,9 +42,22 @@ class ChatAPI{
|
||||
public function commandHandler($cmd, $params, $issuer, $alias){
|
||||
$output = "";
|
||||
switch($cmd){
|
||||
case "say":
|
||||
$s = implode(" ", $params);
|
||||
if(trim($s) == ""){
|
||||
$output .= "Usage: /say <message>\n";
|
||||
break;
|
||||
}
|
||||
$sender = ($issuer instanceof Player) ? "Server":ucfirst($issuer);
|
||||
$this->server->api->chat->broadcast("[$sender] ".$s);
|
||||
break;
|
||||
case "me":
|
||||
if(!($issuer instanceof Player)){
|
||||
$sender = "Console";
|
||||
if($issuer === "rcon"){
|
||||
$sender = "Rcon";
|
||||
}else{
|
||||
$sender = "Console";
|
||||
}
|
||||
}else{
|
||||
$sender = $issuer->username;
|
||||
}
|
||||
@@ -55,7 +69,7 @@ class ChatAPI{
|
||||
break;
|
||||
}
|
||||
if(!($issuer instanceof Player)){
|
||||
$sender = "Console";
|
||||
$sender = ucfirst($issuer);
|
||||
}else{
|
||||
$sender = $issuer->username;
|
||||
}
|
||||
@@ -65,7 +79,7 @@ class ChatAPI{
|
||||
$target = $target->username;
|
||||
}else{
|
||||
$target = strtolower($n);
|
||||
if($target === "server" or $target === "console"){
|
||||
if($target === "server" or $target === "console" or $target === "rcon"){
|
||||
$target = "Console";
|
||||
}else{
|
||||
$output .= "Usage: /$cmd <player> <message>\n";
|
||||
@@ -74,7 +88,7 @@ class ChatAPI{
|
||||
}
|
||||
$mes = implode(" ", $params);
|
||||
$output .= "[me -> ".$target."] ".$mes."\n";
|
||||
if($target !== "Console"){
|
||||
if($target !== "Console" and $target !== "Rcon"){
|
||||
$this->sendTo(false, "[".$sender." -> me] ".$mes, $target);
|
||||
}
|
||||
console("[INFO] [".$sender." -> ".$target."] ".$mes);
|
||||
|
@@ -42,7 +42,6 @@ class ConsoleAPI{
|
||||
$this->register("status", "", array($this, "defaultCommands"));
|
||||
$this->register("difficulty", "<0|1>", array($this, "defaultCommands"));
|
||||
$this->register("invisible", "<on|off>", array($this, "defaultCommands"));
|
||||
$this->register("say", "<message ...>", array($this, "defaultCommands"));
|
||||
$this->register("save-all", "", array($this, "defaultCommands"));
|
||||
$this->register("stop", "", array($this, "defaultCommands"));
|
||||
$this->register("defaultgamemode", "<mode>", array($this, "defaultCommands"));
|
||||
@@ -128,20 +127,12 @@ class ConsoleAPI{
|
||||
$this->server->api->setProperty("difficulty", (int) $s);
|
||||
$output .= "Difficulty changed to ".$this->server->difficulty."\n";
|
||||
break;
|
||||
case "say":
|
||||
$s = implode(" ", $params);
|
||||
if(trim($s) == ""){
|
||||
$output .= "Usage: /say <message>\n";
|
||||
break;
|
||||
}
|
||||
$this->server->api->chat->broadcast("[Server] ".$s);
|
||||
break;
|
||||
case "save-all":
|
||||
$this->server->save();
|
||||
break;
|
||||
|
||||
case "?":
|
||||
if($issuer !== "console"){
|
||||
if($issuer !== "console" and $issuer !== "rcon"){
|
||||
break;
|
||||
}
|
||||
case "help":
|
||||
|
Reference in New Issue
Block a user