mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-03 18:42:37 +00:00
Better Console Alias
This commit is contained in:
parent
967a929723
commit
90c8ac1461
@ -47,6 +47,10 @@ class BanAPI{
|
||||
$this->server->api->console->register("whitelist", "Manages White-listing", array($this, "commandHandler"));
|
||||
$this->server->api->console->register("op", "Ops a player", array($this, "commandHandler"));
|
||||
$this->server->api->console->register("deop", "Deops a player", array($this, "commandHandler"));
|
||||
$this->server->api->console->alias("ban-ip", "banip add");
|
||||
$this->server->api->console->alias("banlist", "ban list");
|
||||
$this->server->api->console->alias("pardon", "ban remove");
|
||||
$this->server->api->console->alias("pardon-ip", "banip remove");
|
||||
$this->server->addHandler("console.command", array($this, "opCheck"), 1);
|
||||
}
|
||||
|
||||
|
@ -26,10 +26,11 @@ the Free Software Foundation, either version 3 of the License, or
|
||||
*/
|
||||
|
||||
class ConsoleAPI{
|
||||
private $loop, $server, $event, $help, $cmds;
|
||||
private $loop, $server, $event, $help, $cmds, $alias;
|
||||
function __construct(PocketMinecraftServer $server){
|
||||
$this->help = array();
|
||||
$this->cmds = array();
|
||||
$this->alias = array();
|
||||
$this->server = $server;
|
||||
$this->last = microtime(true);
|
||||
}
|
||||
@ -143,10 +144,7 @@ class ConsoleAPI{
|
||||
}
|
||||
|
||||
public function alias($alias, $cmd){
|
||||
if(!isset($this->cmds[$cmd])){
|
||||
return false;
|
||||
}
|
||||
$this->cmds[strtolower(trim($alias))] = &$this->cmds[$cmd];
|
||||
$this->alias[strtolower(trim($alias))] = trim($cmd);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -163,6 +161,10 @@ class ConsoleAPI{
|
||||
if($line != ""){
|
||||
$params = explode(" ", $line);
|
||||
$cmd = strtolower(array_shift($params));
|
||||
if(isset($this->alias[$cmd])){
|
||||
$this->run($this->alias[$cmd] . " " .implode(" ", $params), $issuer);
|
||||
return;
|
||||
}
|
||||
if($issuer instanceof Player){
|
||||
console("[INFO] \"".$issuer->username."\" issued server command: /$cmd ".implode(" ", $params));
|
||||
}else{
|
||||
@ -179,11 +181,11 @@ class ConsoleAPI{
|
||||
}
|
||||
}
|
||||
if($output != "" and ($issuer instanceof Player)){
|
||||
$issuer->sendChat($output);
|
||||
}elseif($output != ""){
|
||||
$mes = explode("\n", $output);
|
||||
$issuer->sendChat(trim($output));
|
||||
}elseif($output != "" and $issuer === "console"){
|
||||
$mes = explode("\n", trim($output));
|
||||
foreach($mes as $m){
|
||||
console($m);
|
||||
console("[CMD] ".$m);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user