mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Merge branch 'master' of https://github.com/shoghicp/PocketMine-MP
This commit is contained in:
commit
937888a655
@ -41,11 +41,28 @@ class BanAPI{
|
||||
$this->banned = new Config(FILE_PATH."banned.txt", CONFIG_LIST);
|
||||
$this->server->api->console->register("banip", "Manages IP Banning", array($this, "commandHandler"));
|
||||
$this->server->api->console->register("ban", "Manages Bannning", array($this, "commandHandler"));
|
||||
$this->server->api->console->register("kick", "Kicks a player", array($this, "commandHandler"));
|
||||
$this->server->api->console->register("whitelist", "Manages White-listing", array($this, "commandHandler"));
|
||||
}
|
||||
|
||||
public function commandHandler($cmd, $params){
|
||||
switch($cmd){
|
||||
case "kick":
|
||||
if(!isset($params[0])){
|
||||
console("[INFO] Usage: /kick <playername> [reason]");
|
||||
}else{
|
||||
$name = array_shift($params);
|
||||
$player = $this->server->api->player->get($name);
|
||||
if($player === false){
|
||||
console("[ERROR] Player \"".$name."\" does not exist");
|
||||
}else{
|
||||
$reason = implode(" ", $params);
|
||||
$reason = $reason == "" ? "No reason":$reason;
|
||||
$player->close("You have been kicked: ".$reason);
|
||||
console("[INFO] Player \"".$player->username."\" has been kicked: $reason");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "whitelist":
|
||||
$p = strtolower(array_shift($params));
|
||||
switch($p){
|
||||
|
@ -87,11 +87,6 @@ class ConsoleAPI{
|
||||
console("[INFO] Stopping the server...");
|
||||
$this->server->close();
|
||||
break;
|
||||
/*case "restart":
|
||||
console("[INFO] Restarting the server...");
|
||||
$this->server->api->restart = true;
|
||||
$this->server->close();
|
||||
break;*/
|
||||
case "gamemode":
|
||||
$s = trim(array_shift($params));
|
||||
if($s == "" or (((int) $s) !== 0 and ((int) $s) !== 1)){
|
||||
@ -122,12 +117,6 @@ class ConsoleAPI{
|
||||
case "save-all":
|
||||
$this->server->save();
|
||||
break;
|
||||
case "block":
|
||||
foreach($this->server->clients as $client){
|
||||
$b = $this->server->map->getBlock(round($client->entity->position["x"] - 0.5), round($client->entity->position["y"] - 1), round($client->entity->position["z"] - 0.5));
|
||||
console("[INFO] EID ".$client->eid." is over block ".$b[0].":".$b[1]);
|
||||
}
|
||||
break;
|
||||
case "help":
|
||||
case "?":
|
||||
console("[INFO] /help: Show available commands");
|
||||
@ -150,7 +139,11 @@ class ConsoleAPI{
|
||||
}
|
||||
|
||||
public function alias($alias, $cmd){
|
||||
if(!isset($this->cmds[$cmd])){
|
||||
return false;
|
||||
}
|
||||
$this->cmds[strtolower(trim($alias))] = &$this->cmds[$cmd];
|
||||
return true;
|
||||
}
|
||||
|
||||
public function register($cmd, $help, $callback){
|
||||
@ -161,21 +154,25 @@ class ConsoleAPI{
|
||||
$this->cmds[$cmd] = $callback;
|
||||
$this->help[$cmd] = $help;
|
||||
}
|
||||
|
||||
public function run($line = ""){
|
||||
if($line != ""){
|
||||
$params = explode(" ", $line);
|
||||
$cmd = strtolower(array_shift($params));
|
||||
console("[INFO] Issued server command: /$cmd ".implode(" ", $params));
|
||||
if(isset($this->cmds[$cmd]) and is_callable($this->cmds[$cmd])){
|
||||
call_user_func($this->cmds[$cmd], $cmd, $params);
|
||||
}elseif($this->server->api->dhandle("api.console.command", array("cmd" => $cmd, "params" => $params)) !== false){
|
||||
$this->defaultCommands($cmd, $params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function handle($time){
|
||||
if($this->loop->line !== false){
|
||||
$line = trim($this->loop->line);
|
||||
$this->loop->line = false;
|
||||
if($line !== ""){
|
||||
$params = explode(" ", $line);
|
||||
$cmd = strtolower(array_shift($params));
|
||||
console("[INFO] Issued server command: /$cmd ".implode(" ", $params));
|
||||
if(isset($this->cmds[$cmd]) and is_callable($this->cmds[$cmd])){
|
||||
call_user_func($this->cmds[$cmd], $cmd, $params);
|
||||
}elseif($this->server->api->dhandle("api.console.command", array("cmd" => $cmd, "params" => $params)) !== false){
|
||||
$this->defaultCommands($cmd, $params);
|
||||
}
|
||||
}
|
||||
$this->run($line);
|
||||
}else{
|
||||
$this->loop->notify();
|
||||
}
|
||||
|
@ -421,9 +421,7 @@ class PocketMinecraftServer{
|
||||
$this->custom["times_".$CID] = 0;
|
||||
}
|
||||
$ln = 15;
|
||||
if(strlen($this->description) === 0){
|
||||
$this->description = "";
|
||||
}
|
||||
$this->description .= " ";
|
||||
$txt = substr($this->description, $this->custom["times_".$CID], $ln);
|
||||
$txt .= substr($this->description, 0, $ln - strlen($txt));
|
||||
$this->send(0x1c, array(
|
||||
|
Loading…
x
Reference in New Issue
Block a user