From 24c6cca66474d7fc900a618f8e12267bc74eaa4c Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Wed, 14 Jan 2015 17:23:16 +0100 Subject: [PATCH] Updated RakLib, fixed help message not showing command, added documentation to Plugin->getResource() --- src/pocketmine/Server.php | 2 +- .../command/defaults/HelpCommand.php | 10 ++++---- src/pocketmine/network/RakLibInterface.php | 2 +- src/pocketmine/plugin/PluginBase.php | 1 + src/pocketmine/scheduler/AsyncPool.php | 4 +--- src/pocketmine/utils/MainLogger.php | 23 ++++++++++++------- src/raklib | 2 +- 7 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index e246cdf4b..cd9c7b714 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -683,7 +683,7 @@ class Server{ $result = $this->getPlayerExact($name); if($result === null){ - return new OfflinePlayer($this, $name); + $result = new OfflinePlayer($this, $name); } return $result; diff --git a/src/pocketmine/command/defaults/HelpCommand.php b/src/pocketmine/command/defaults/HelpCommand.php index 43f62f8ec..a26d951a8 100644 --- a/src/pocketmine/command/defaults/HelpCommand.php +++ b/src/pocketmine/command/defaults/HelpCommand.php @@ -87,11 +87,11 @@ class HelpCommand extends VanillaCommand{ return true; }else{ - if(($command = $sender->getServer()->getCommandMap()->getCommand(strtolower($command))) instanceof Command){ - if($command->testPermissionSilent($sender)){ - $message = TextFormat::YELLOW . "--------- " . TextFormat::WHITE . " Help: /" . $command->getName() . TextFormat::YELLOW . " ---------\n"; - $message .= TextFormat::GOLD . "Description: " . TextFormat::WHITE . $command->getDescription() . "\n"; - $message .= TextFormat::GOLD . "Usage: " . TextFormat::WHITE . implode("\n" . TextFormat::WHITE, explode("\n", $command->getUsage())) . "\n"; + if(($cmd = $sender->getServer()->getCommandMap()->getCommand(strtolower($command))) instanceof Command){ + if($cmd->testPermissionSilent($sender)){ + $message = TextFormat::YELLOW . "--------- " . TextFormat::WHITE . " Help: /" . $cmd->getName() . TextFormat::YELLOW . " ---------\n"; + $message .= TextFormat::GOLD . "Description: " . TextFormat::WHITE . $cmd->getDescription() . "\n"; + $message .= TextFormat::GOLD . "Usage: " . TextFormat::WHITE . implode("\n" . TextFormat::WHITE, explode("\n", $cmd->getUsage())) . "\n"; $sender->sendMessage($message); return true; diff --git a/src/pocketmine/network/RakLibInterface.php b/src/pocketmine/network/RakLibInterface.php index a1a700ab6..824b45fd7 100644 --- a/src/pocketmine/network/RakLibInterface.php +++ b/src/pocketmine/network/RakLibInterface.php @@ -134,7 +134,7 @@ class RakLibInterface implements ServerInstance, SourceInterface{ }else{ $info = $this->rakLib->getTerminationInfo(); $this->server->removeInterface($this); - \ExceptionHandler::handler(E_ERROR, "RakLib Thread crashed [".$info["scope"]."]" . (isset($info["message"]) ? $info["message"] : ""), $info["file"], $info["line"]); + \ExceptionHandler::handler(E_ERROR, "RakLib Thread crashed [".$info["scope"]."]: " . (isset($info["message"]) ? $info["message"] : ""), $info["file"], $info["line"]); } } diff --git a/src/pocketmine/plugin/PluginBase.php b/src/pocketmine/plugin/PluginBase.php index 5295b71c8..a928fe840 100644 --- a/src/pocketmine/plugin/PluginBase.php +++ b/src/pocketmine/plugin/PluginBase.php @@ -171,6 +171,7 @@ abstract class PluginBase implements Plugin{ /** * Gets an embedded resource on the plugin file. + * WARNING: You must close the resource given using fclose() * * @param string $filename * diff --git a/src/pocketmine/scheduler/AsyncPool.php b/src/pocketmine/scheduler/AsyncPool.php index 4eea79b73..35917dfd9 100644 --- a/src/pocketmine/scheduler/AsyncPool.php +++ b/src/pocketmine/scheduler/AsyncPool.php @@ -101,9 +101,7 @@ class AsyncPool{ $task->onCompletion($this->server); - $this->workerUsage[$this->taskWorkers[$task->getTaskId()]]--; - unset($this->tasks[$task->getTaskId()]); - unset($this->taskWorkers[$task->getTaskId()]); + $this->removeTask($task); }elseif($task->isTerminated()){ $info = $task->getTerminationInfo(); $this->removeTask($task); diff --git a/src/pocketmine/utils/MainLogger.php b/src/pocketmine/utils/MainLogger.php index 515373566..16163267d 100644 --- a/src/pocketmine/utils/MainLogger.php +++ b/src/pocketmine/utils/MainLogger.php @@ -194,6 +194,9 @@ class MainLogger extends \AttachableThreadedLogger{ } $this->logStream .= date("Y-m-d", $now) . " " . $cleanMessage; + $this->synchronized(function(){ + $this->notify(); + }); } public function run(){ @@ -204,17 +207,21 @@ class MainLogger extends \AttachableThreadedLogger{ } while($this->shutdown === false){ - if(strlen($this->logStream) >= 4096){ - $this->lock(); - $chunks = strlen($this->logStream) >> 12; - $chunk = substr($this->logStream, 0, $chunks << 12); - $this->logStream = substr($this->logStream, $chunks << 12); - $this->unlock(); - fwrite($this->logResource, $chunk); + if($this->logStream !== ""){ + $this->synchronized(function(){ + $this->lock(); + $chunk = $this->logStream; + $this->logStream = ""; + $this->unlock(); + fwrite($this->logResource, $chunk); + }); }else{ - usleep(250000); //sleep for 0.25 seconds + $this->synchronized(function(){ + $this->wait(250000); + }); } } + if(strlen($this->logStream) > 0){ fwrite($this->logResource, $this->logStream); } diff --git a/src/raklib b/src/raklib index 2faa3d242..e33ec9852 160000 --- a/src/raklib +++ b/src/raklib @@ -1 +1 @@ -Subproject commit 2faa3d242c09aba253dc3f3e2a861e91906ac2f9 +Subproject commit e33ec9852b6d4635ca3edb59951674ac1cefe0d4