Updated console texts and help

This commit is contained in:
Shoghi Cervantes Pueyo
2013-04-13 19:47:20 +02:00
parent 82d49b0343
commit d157299c7a
11 changed files with 62 additions and 78 deletions

View File

@@ -37,18 +37,17 @@ class BanAPI{
}
public function init(){
console("[INFO] Loading authentication lists...");
$this->whitelist = new Config(DATA_PATH."white-list.txt", CONFIG_LIST);
$this->bannedIPs = new Config(DATA_PATH."banned-ips.txt", CONFIG_LIST);
$this->banned = new Config(DATA_PATH."banned.txt", CONFIG_LIST);
$this->ops = new Config(DATA_PATH."ops.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"));
$this->server->api->console->register("op", "Ops a player", array($this, "commandHandler"));
$this->server->api->console->register("deop", "De-ops a player", array($this, "commandHandler"));
$this->server->api->console->register("sudo", "Run a command as a player", array($this, "commandHandler"));
$this->server->api->console->register("banip", "<add|remove|list|reload> [IP|player]", array($this, "commandHandler"));
$this->server->api->console->register("ban", "<add|remove|list|reload> [username]", array($this, "commandHandler"));
$this->server->api->console->register("kick", "<player> [reason ...]", array($this, "commandHandler"));
$this->server->api->console->register("whitelist", "<on|off|list|add|remove|reload> [username]", array($this, "commandHandler"));
$this->server->api->console->register("op", "<player>", array($this, "commandHandler"));
$this->server->api->console->register("deop", "<player>", array($this, "commandHandler"));
$this->server->api->console->register("sudo", "<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");
@@ -147,7 +146,7 @@ class BanAPI{
break;
case "kick":
if(!isset($params[0])){
$output .= "Usage: /kick <playername> [reason]\n";
$output .= "Usage: /kick <player> [reason ...]\n";
}else{
$name = strtolower(array_shift($params));
$player = $this->server->api->player->get($name);
@@ -199,7 +198,7 @@ class BanAPI{
$this->server->api->setProperty("white-list", false);
break;
default:
$output .= "Usage: /whitelist <on | off | add | remove | reload | list> [username]\n";
$output .= "Usage: /whitelist <on|off|list|add|remove|reload> [username]\n";
break;
}
break;
@@ -232,7 +231,7 @@ class BanAPI{
$output .= "IP ban list: ".implode(", ", $this->bannedIPs->getAll(true))."\n";
break;
default:
$output .= "Usage: /banip <add | remove | list | reload> [IP | Player]\n";
$output .= "Usage: /banip <add|remove|list|reload> [IP|player]\n";
break;
}
break;
@@ -270,7 +269,7 @@ class BanAPI{
$output .= "Ban list: ".implode(", ", $this->banned->getAll(true))."\n";
break;
default:
$output .= "Usage: /ban <add | remove | list | reload> [player]\n";
$output .= "Usage: /ban <add|remove|list|reload> [username]\n";
break;
}
break;

View File

@@ -118,7 +118,7 @@ class BlockAPI{
public function init(){
$this->server->addHandler("block.update", array($this, "updateBlockRemote"), 1);
$this->server->api->console->register("give", "Give items to a player", array($this, "commandHandler"));
$this->server->api->console->register("give", "<player> <item[:damage]> [amount]", array($this, "commandHandler"));
}
public function commandHandler($cmd, $params, $issuer, $alias){
@@ -126,7 +126,7 @@ class BlockAPI{
switch($cmd){
case "give":
if(!isset($params[0]) or !isset($params[1])){
$output .= "Usage: /give <username> <item> [amount] [damage]\n";
$output .= "Usage: /give <player> <item[:damage]> [amount]\n";
break;
}
$player = $this->server->api->player->get($params[0]);

View File

@@ -32,8 +32,8 @@ class ChatAPI{
}
public function init(){
$this->server->api->console->register("tell", "Sends a private message to a player", array($this, "commandHandler"));
$this->server->api->console->register("me", "Broadcast an action", array($this, "commandHandler"));
$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->ban->cmdWhitelist("tell");
$this->server->api->ban->cmdWhitelist("me");
}
@@ -85,7 +85,7 @@ class ChatAPI{
public function broadcast($message){
$this->send(false, $message);
console("[CHAT] ".$message);
console($message);
}
public function sendTo($owner, $text, $player){

View File

@@ -39,13 +39,13 @@ class ConsoleAPI{
$this->event = $this->server->event("server.tick", array($this, "handle"));
$this->loop = new ConsoleLoop;
$this->loop->start();
$this->register("help", "Show available commands", array($this, "defaultCommands"));
$this->register("status", "Show server TPS and memory usage", array($this, "defaultCommands"));
$this->register("difficulty", "Changes server difficulty", array($this, "defaultCommands"));
$this->register("invisible", "Changes server visibility", array($this, "defaultCommands"));
$this->register("say", "Broadcast a message", array($this, "defaultCommands"));
$this->register("save-all", "Save pending changes to disk", array($this, "defaultCommands"));
$this->register("stop", "Stops the server gracefully", array($this, "defaultCommands"));
$this->register("help", "[page|command name]", array($this, "defaultCommands"));
$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->server->api->ban->cmdWhitelist("help");
}
@@ -97,7 +97,7 @@ class ConsoleAPI{
case "difficulty":
$s = trim(array_shift($params));
if($s == "" or (((int) $s) !== 0 and ((int) $s) !== 1)){
$output .= "Usage: /difficulty <0 | 1>\n";
$output .= "Usage: /difficulty <0|1>\n";
break;
}
$this->server->api->setProperty("difficulty", (int) $s);
@@ -120,6 +120,13 @@ class ConsoleAPI{
break;
}
case "help":
if(isset($params[0]) and !is_numeric($params[0])){
$c = trim(strtolower($params[0]));
if(isset($this->help[$c])){
$output .= "Usage: /$c ".$this->help[$c]."\n";
break;
}
}
$max = ceil(count($this->help) / 5);
$page = isset($params[0]) ? min($max - 1, max(0, intval($params[0]) - 1)):0;
$output .= "- Showing help page ". ($page + 1) ." of $max (/help <page>) -\n";
@@ -127,7 +134,7 @@ class ConsoleAPI{
foreach($this->help as $c => $h){
$curpage = (int) ($current / 5);
if($curpage === $page){
$output .= "/$c: ".$h."\n";
$output .= "/$c ".$h."\n";
}elseif($curpage > $page){
break;
}
@@ -167,7 +174,7 @@ class ConsoleAPI{
if($issuer instanceof Player){
console("[INFO] \"".$issuer->username."\" issued server command: $alias /$cmd ".implode(" ", $params));
}else{
console("[INFO] Issued server command: $alias /$cmd ".implode(" ", $params));
console("[INFO] Issued server command: ".ltrim("$alias ")."/$cmd ".implode(" ", $params));
}
if($this->server->api->dhandle("console.command.".$cmd, array("cmd" => $cmd, "parameters" => $params, "issuer" => $issuer, "alias" => $alias)) === false
or $this->server->api->dhandle("console.command", array("cmd" => $cmd, "parameters" => $params, "issuer" => $issuer, "alias" => $alias)) === false){

View File

@@ -34,12 +34,12 @@ class PlayerAPI{
public function init(){
$this->server->addHandler("server.regeneration", array($this, "handle"));
$this->server->addHandler("player.death", array($this, "handle"), 1);
$this->server->api->console->register("list", "Shows connected player list", array($this, "commandHandler"));
$this->server->api->console->register("kill", "Kills a player", array($this, "commandHandler"));
$this->server->api->console->register("gamemode", "Changes the player gamemode", array($this, "commandHandler"));
$this->server->api->console->register("tppos", "Teleports a player to a position", array($this, "commandHandler"));
$this->server->api->console->register("tp", "Teleports a player to another player", array($this, "commandHandler"));
$this->server->api->console->register("lag", "Measure your connection lag", array($this, "commandHandler"));
$this->server->api->console->register("list", "", array($this, "commandHandler"));
$this->server->api->console->register("kill", "<player>", array($this, "commandHandler"));
$this->server->api->console->register("gamemode", "<mode> [player]", array($this, "commandHandler"));
$this->server->api->console->register("tppos", "[target player] <x> <y> <z>", array($this, "commandHandler"));
$this->server->api->console->register("tp", "[target player] <destination player>", array($this, "commandHandler"));
$this->server->api->console->register("lag", "", array($this, "commandHandler"));
$this->server->api->console->alias("suicide", "kill");
$this->server->api->ban->cmdWhitelist("list");
$this->server->api->ban->cmdWhitelist("lag");

View File

@@ -58,7 +58,7 @@ class PluginAPI extends stdClass{
$info = strstr($content, "*/", true);
$content = substr(strstr($content, "*/"),2);
if(preg_match_all('#([a-zA-Z0-9\-_]*)=([^\r\n]*)#u', $info, $matches) == 0){ //false or 0 matches
console("[ERROR] [PluginAPI] Failed parsing of ".basename($file));
console("[ERROR] Failed parsing of ".basename($file));
return false;
}
$info = array();
@@ -82,28 +82,28 @@ class PluginAPI extends stdClass{
$info["class"] = trim(strtolower($info["class"]));
}
if(!isset($info["name"]) or !isset($info["version"]) or !isset($info["class"]) or !isset($info["author"])){
console("[ERROR] [PluginAPI] Failed parsing of ".basename($file));
console("[ERROR] Failed parsing of ".basename($file));
return false;
}
console("[INFO] [PluginAPI] Loading plugin \"\x1b[32m".$info["name"]."\x1b[0m\" \x1b[35m".$info["version"]." \x1b[0mby \x1b[36m".$info["author"]."\x1b[0m");
console("[INFO] Loading plugin \"\x1b[32m".$info["name"]."\x1b[0m\" \x1b[35m".$info["version"]." \x1b[0mby \x1b[36m".$info["author"]."\x1b[0m");
if(class_exists($info["class"])){
console("[ERROR] [PluginAPI] Failed loading plugin: class exists");
console("[ERROR] Failed loading plugin: class already exists");
return false;
}
if(eval($info["code"]) === false or !class_exists($info["class"])){
console("[ERROR] [PluginAPI] Failed loading plugin: evaluation error");
console("[ERROR] Failed loading plugin: evaluation error");
return false;
}
$className = $info["class"];
$apiversion = array_map("intval", explode(",", (string) $info["apiversion"]));
if(!in_array((string) CURRENT_API_VERSION, $apiversion)){
console("[WARNING] [PluginAPI] Plugin \"".$info["name"]."\" may not be compatible with the API (".$info["apiversion"]." != ".CURRENT_API_VERSION.")! It can crash or corrupt the server!");
console("[WARNING] Plugin \"".$info["name"]."\" may not be compatible with the API (".$info["apiversion"]." != ".CURRENT_API_VERSION.")! It can crash or corrupt the server!");
}
$object = new $className($this->server->api, false);
if(!($object instanceof Plugin)){
console("[ERROR] [PluginAPI] Plugin \"\x1b[36m".$info["name"]."\x1b[0m\" doesn't use the Plugin Interface");
console("[ERROR] Plugin \"\x1b[36m".$info["name"]."\x1b[0m\" doesn't use the Plugin Interface");
if(method_exists($object, "__destruct")){
$object->__destruct();
}
@@ -172,7 +172,6 @@ class PluginAPI extends stdClass{
}
public function loadAll(){
console("[INFO] Loading Plugins...");
$dir = dir(DATA_PATH."plugins/");
while(false !== ($file = $dir->read())){
if($file{0} !== "."){
@@ -185,6 +184,7 @@ class PluginAPI extends stdClass{
}
public function initAll(){
console("[INFO] Starting plugins...");
foreach($this->plugins as $p){
$p[0]->init(); //ARGHHH!!! Plugin loading randomly fails!!
}

View File

@@ -52,8 +52,7 @@ class ServerAPI{
@mkdir(DATA_PATH."players/", 0755);
@mkdir(DATA_PATH."worlds/", 0755);
@mkdir(DATA_PATH."plugins/", 0755);
console("[INFO] Starting ServerAPI server handler...");
file_put_contents(DATA_PATH."logs/packets.log", "");
console("[INFO] \x1b[33;1mPocketMine-MP ".MAJOR_VERSION.", LGPL License", true, true, 0);
if(!file_exists(DATA_PATH."logs/test.bin.log") or md5_file(DATA_PATH."logs/test.bin.log") !== TEST_MD5){
console("[NOTICE] Executing tests...");
console("[INFO] OS: ".PHP_OS.", ".Utils::getOS());
@@ -89,7 +88,7 @@ class ServerAPI{
}
}
console("[DEBUG] Loading server.properties...", true, true, 2);
console("[INFO] Loading properties...");
$this->config = new Config(DATA_PATH . "server.properties", CONFIG_PROPERTIES, array(
"server-name" => "Minecraft Server",
"description" => "Server made using PocketMine-MP",
@@ -213,8 +212,6 @@ class ServerAPI{
$this->loadProperties();
$this->server->loadMap();
console("[INFO] Loading default APIs");
$this->loadAPI("console", "ConsoleAPI");
$this->loadAPI("level", "LevelAPI");
$this->loadAPI("block", "BlockAPI");
@@ -254,7 +251,7 @@ class ServerAPI{
}
public function sendUsage(){
console("[INTERNAL] Sending usage data...", true, true, 3);
console("[DEBUG] Sending usage data...", true, true, 2);
$plist = "";
foreach($this->plugin->getList() as $p){
$plist .= str_replace(array(";", ":"), "", $p["name"]).":".str_replace(array(";", ":"), "", $p["version"]).";";
@@ -289,7 +286,7 @@ class ServerAPI{
$value = array("M" => 1, "G" => 1024);
$real = ((int) substr($memory, 0, -1)) * $value[substr($memory, -1)];
if($real < 128){
console("[ERROR] PocketMine doesn't work right with less than 128MB of RAM", true, true, 0);
console("[WARNING] PocketMine-MP doesn't work right with less than 128MB of RAM", true, true, 0);
}
@ini_set("memory_limit", $memory);
}else{
@@ -398,7 +395,7 @@ class ServerAPI{
if($level["LevelName"] == ""){
$level["LevelName"] = "world".time();
}
console("[DEBUG] Importing map \"".$level["LevelName"]."\" gamemode ".$level["GameType"]." with seed ".$level["RandomSeed"], true, true, 2);
console("[DEBUG] Importing level \"".$level["LevelName"]."\" gamemode ".$level["GameType"]." with seed ".$level["RandomSeed"], true, true, 2);
unset($level["Player"]);
$lvName = $level["LevelName"]."/";
@mkdir(DATA_PATH."worlds/".$lvName, 0755);
@@ -428,7 +425,7 @@ class ServerAPI{
$this->server->spawn = array("x" => $level["SpawnX"], "y" => $level["SpawnY"], "z" => $level["SpawnZ"]);
$this->writeProperties();
}
console("[INFO] Map \"".$level["LevelName"]."\" importing done!");
console("[INFO] Level \"".$level["LevelName"]."\" importing done!");
unset($level, $entities, $nbt);
return true;
}
@@ -510,7 +507,7 @@ class ServerAPI{
}
$this->$name = new $class();
$this->apiList[] = $this->$name;
console("[".($internal === true ? "DEBUG":"INFO")."] API \x1b[36m".$name."\x1b[0m [\x1b[30;1m".$class."\x1b[0m] loaded", true, true, ($internal === true ? 2:1));
console("[".($internal === true ? "INTERNAL":"DEBUG")."] API \x1b[36m".$name."\x1b[0m [\x1b[30;1m".$class."\x1b[0m] loaded", true, true, ($internal === true ? 2:1));
}
}

View File

@@ -38,7 +38,7 @@ class TimeAPI{
}
public function init(){
$this->server->api->console->register("time", "Manages server time", array($this, "commandHandler"));
$this->server->api->console->register("time", "<check|set|add> [time]", array($this, "commandHandler"));
}
public function commandHandler($cmd, $params, $issuer, $alias){
@@ -69,7 +69,7 @@ class TimeAPI{
$this->night();
break;
default:
$output .= "Usage: /time <check | set | add | sunrise | day | sunset | night> [time]\n";
$output .= "Usage: /time <check|set|add> [time]\n";
break;
}
break;