From 653b6b55a9ab44d24e9402d0a253b3d394c62908 Mon Sep 17 00:00:00 2001 From: TheDiamondYT1 Date: Thu, 27 Apr 2017 16:38:51 +0100 Subject: [PATCH 01/11] Added title command and API for resetting title duration --- src/pocketmine/Player.php | 20 +++- src/pocketmine/command/SimpleCommandMap.php | 4 +- .../command/defaults/TitleCommand.php | 102 ++++++++++++++++++ .../permission/DefaultPermissions.php | 1 + 4 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 src/pocketmine/command/defaults/TitleCommand.php diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index c7674a53f..191400cab 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -3439,11 +3439,20 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade public function addTitle(string $title, string $subtitle = "", int $fadeIn = -1, int $stay = -1, int $fadeOut = -1){ $this->setTitleDuration($fadeIn, $stay, $fadeOut); if($subtitle !== ""){ - $this->sendTitleText($subtitle, SetTitlePacket::TYPE_SET_SUBTITLE); + $this->addSubTitle($subtitle); } $this->sendTitleText($title, SetTitlePacket::TYPE_SET_TITLE); } + /** + * Sets the subtitle message, without sending a title. + * + * @param string $subtitle + */ + public function addSubTitle(string $subtitle){ + $this->sendTitleText($subtitle, SetTitlePacket::TYPE_SET_SUBTITLE); + } + /** * Adds small text to the user's screen. * @@ -3462,6 +3471,15 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->dataPacket($pk); } + /** + * Resets the title duration settings. + */ + public function resetTitles(){ + $pk = new SetTitlePacket(); + $pk->type = SetTitlePacket::TYPE_RESET_TITLE; + $this->dataPacket($pk); + } + /** * Sets the title duration. * diff --git a/src/pocketmine/command/SimpleCommandMap.php b/src/pocketmine/command/SimpleCommandMap.php index ae959c8ad..9d934bede 100644 --- a/src/pocketmine/command/SimpleCommandMap.php +++ b/src/pocketmine/command/SimpleCommandMap.php @@ -57,6 +57,7 @@ use pocketmine\command\defaults\TeleportCommand; use pocketmine\command\defaults\TellCommand; use pocketmine\command\defaults\TimeCommand; use pocketmine\command\defaults\TimingsCommand; +use pocketmine\command\defaults\TitleCommand; use pocketmine\command\defaults\TransferServerCommand; use pocketmine\command\defaults\VanillaCommand; use pocketmine\command\defaults\VersionCommand; @@ -115,6 +116,7 @@ class SimpleCommandMap implements CommandMap{ $this->register("pocketmine", new TeleportCommand("tp")); $this->register("pocketmine", new TimeCommand("time")); $this->register("pocketmine", new TimingsCommand("timings")); + $this->register("pocketmine", new TitleCommand("title")); $this->register("pocketmine", new ReloadCommand("reload")); $this->register("pocketmine", new TransferServerCommand("transferserver")); @@ -302,4 +304,4 @@ class SimpleCommandMap implements CommandMap{ } -} \ No newline at end of file +} diff --git a/src/pocketmine/command/defaults/TitleCommand.php b/src/pocketmine/command/defaults/TitleCommand.php new file mode 100644 index 000000000..1b4314722 --- /dev/null +++ b/src/pocketmine/command/defaults/TitleCommand.php @@ -0,0 +1,102 @@ +setPermission("pocketmine.command.title"); + } + + public function execute(CommandSender $sender, $currentAlias, array $args){ + if(!$this->testPermission($sender)){ + return true; + } + + if(count($args) < 2){ + $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage])); + return true; + } + + $player = $sender->getServer()->getPlayer($args[0]); + if($player === null){ + $sender->sendMessage(new TranslationContainer("commands.generic.player.notFound")); + return true; + } + + switch($args[1]){ + case "clear": + $player->removeTitles(); + break; + case "reset": + $player->resetTitles(); + break; + case "title": + if(count($args) < 3){ + $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage])); + return false; + } + + $player->addTitle(implode(" ", array_slice($args, 2))); + break; + case "subtitle": + if(count($args) < 3){ + $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage])); + return false; + } + + $player->addSubTitle(implode(" ", array_slice($args, 2))); + break; + case "actionbar": + if(count($args) < 3){ + $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage])); + return false; + } + + $player->addActionBarMessage(implode(" ", array_slice($args, 2))); + break; + case "times": + if(count($args) < 4){ + $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage])); + return false; + } + + $player->setTitleDuration($this->getInteger($sender, $args[2]), $this->getInteger($sender, $args[3]), $this->getInteger($sender, $args[4])); + break; + default: + $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage])); + return false; + } + + $sender->sendMessage(new TranslationContainer("commands.title.success")); + } +} diff --git a/src/pocketmine/permission/DefaultPermissions.php b/src/pocketmine/permission/DefaultPermissions.php index 079db04ff..10852f80a 100644 --- a/src/pocketmine/permission/DefaultPermissions.php +++ b/src/pocketmine/permission/DefaultPermissions.php @@ -124,6 +124,7 @@ abstract class DefaultPermissions{ self::registerPermission(new Permission(self::ROOT . ".command.spawnpoint", "Allows the user to change player's spawnpoint", Permission::DEFAULT_OP), $commands); self::registerPermission(new Permission(self::ROOT . ".command.setworldspawn", "Allows the user to change the world spawn", Permission::DEFAULT_OP), $commands); self::registerPermission(new Permission(self::ROOT . ".command.transferserver", "Allows the user to transfer self to another server", Permission::DEFAULT_OP), $commands); + self::registerPermission(new Permission(self::ROOT . ".command.title", "Allows the user to send a title to the specified player", Permission::DEFAULT_OP), $commands); $commands->recalculatePermissibles(); From b542277ecaa5b274581a54fac01f6748c9cd0094 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 28 Apr 2017 16:53:05 +0100 Subject: [PATCH 02/11] Disable memory limit before performing a mem dump Fix memory dumps not completing due to exhausting available memory --- src/pocketmine/MemoryManager.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pocketmine/MemoryManager.php b/src/pocketmine/MemoryManager.php index b7e149b2a..40b2728d9 100644 --- a/src/pocketmine/MemoryManager.php +++ b/src/pocketmine/MemoryManager.php @@ -214,6 +214,8 @@ class MemoryManager{ } public function dumpServerMemory($outputFolder, $maxNesting, $maxStringSize){ + $hardLimit = ini_get('memory_limit'); + ini_set('memory_limit', -1); gc_disable(); if(!file_exists($outputFolder)){ @@ -300,6 +302,7 @@ class MemoryManager{ echo "[Dump] Finished!\n"; + ini_set('memory_limit', $hardLimit); gc_enable(); } From a22306d4181bf0237cf278e41ee1511186c2bc48 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 28 Apr 2017 18:43:36 +0100 Subject: [PATCH 03/11] Fixed static property refcount bug --- src/pocketmine/MemoryManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/MemoryManager.php b/src/pocketmine/MemoryManager.php index 40b2728d9..fab57d0f4 100644 --- a/src/pocketmine/MemoryManager.php +++ b/src/pocketmine/MemoryManager.php @@ -276,7 +276,7 @@ class MemoryManager{ fwrite($obData, "$hash@$className: " . json_encode($info, JSON_UNESCAPED_SLASHES) . "\n"); - if(!isset($objects["staticProperties"][$className])){ + if(!isset($staticProperties[$className])){ $staticProperties[$className] = []; foreach($reflection->getProperties() as $property){ if(!$property->isStatic() or $property->getDeclaringClass()->getName() !== $className){ From 1266f8f1aafe66b56d0767da7c964fbe347145b1 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 29 Apr 2017 12:07:29 +0100 Subject: [PATCH 04/11] Fixed static properties not being dumped if an instance of the class was not referenced by Server --- src/pocketmine/MemoryManager.php | 40 ++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/src/pocketmine/MemoryManager.php b/src/pocketmine/MemoryManager.php index fab57d0f4..114a841e1 100644 --- a/src/pocketmine/MemoryManager.php +++ b/src/pocketmine/MemoryManager.php @@ -234,6 +234,30 @@ class MemoryManager{ $refCounts = []; + $staticCount = 0; + foreach($this->server->getLoader()->getClasses() as $className){ + $reflection = new \ReflectionClass($className); + $staticProperties[$className] = []; + foreach($reflection->getProperties() as $property){ + if(!$property->isStatic() or $property->getDeclaringClass()->getName() !== $className){ + continue; + } + + if(!$property->isPublic()){ + $property->setAccessible(true); + } + + $staticCount++; + $this->continueDump($property->getValue(), $staticProperties[$className][$property->getName()], $objects, $refCounts, 0, $maxNesting, $maxStringSize); + } + + if(count($staticProperties[$className]) === 0){ + unset($staticProperties[$className]); + } + } + + echo "[Dump] Wrote $staticCount static properties\n"; + $this->continueDump($this->server, $data, $objects, $refCounts, 0, $maxNesting, $maxStringSize); do{ @@ -275,25 +299,11 @@ class MemoryManager{ } fwrite($obData, "$hash@$className: " . json_encode($info, JSON_UNESCAPED_SLASHES) . "\n"); - - if(!isset($staticProperties[$className])){ - $staticProperties[$className] = []; - foreach($reflection->getProperties() as $property){ - if(!$property->isStatic() or $property->getDeclaringClass()->getName() !== $className){ - continue; - } - - if(!$property->isPublic()){ - $property->setAccessible(true); - } - $this->continueDump($property->getValue($object), $staticProperties[$className][$property->getName()], $objects, $refCounts, 0, $maxNesting, $maxStringSize); - } - } } echo "[Dump] Wrote " . count($objects) . " objects\n"; }while($continue); - + fclose($obData); file_put_contents($outputFolder . "/staticProperties.js", json_encode($staticProperties, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); From de359a2bce48e4eb044f7cd2bddc14f735e10f11 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 29 Apr 2017 18:03:45 +0100 Subject: [PATCH 05/11] Fixed a microscopic Command TimingsHandler memory leak This reduces memory usage of an idling server by about 20kb. Definitely worth the time. --- src/pocketmine/command/Command.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/command/Command.php b/src/pocketmine/command/Command.php index 189a3b03b..38f562abb 100644 --- a/src/pocketmine/command/Command.php +++ b/src/pocketmine/command/Command.php @@ -79,11 +79,11 @@ abstract class Command{ */ public function __construct($name, $description = "", $usageMessage = null, array $aliases = []){ $this->commandData = self::generateDefaultData(); - $this->name = $this->nextLabel = $this->label = $name; + $this->name = $name; + $this->setLabel($name); $this->setDescription($description); $this->usageMessage = $usageMessage === null ? "/" . $name : $usageMessage; $this->setAliases($aliases); - $this->timings = new TimingsHandler("** Command: " . $name); } /** @@ -208,6 +208,9 @@ abstract class Command{ public function setLabel($name){ $this->nextLabel = $name; if(!$this->isRegistered()){ + if($this->timings instanceof TimingsHandler){ + $this->timings->remove(); + } $this->timings = new TimingsHandler("** Command: " . $name); $this->label = $name; From 971703a618066c06b41b45cfd3cbdf246375b52d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 29 Apr 2017 19:12:46 +0100 Subject: [PATCH 06/11] Dump object counts when dumping memory --- src/pocketmine/MemoryManager.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/pocketmine/MemoryManager.php b/src/pocketmine/MemoryManager.php index 114a841e1..8b291dd9c 100644 --- a/src/pocketmine/MemoryManager.php +++ b/src/pocketmine/MemoryManager.php @@ -234,6 +234,8 @@ class MemoryManager{ $refCounts = []; + $instanceCounts = []; + $staticCount = 0; foreach($this->server->getLoader()->getClasses() as $className){ $reflection = new \ReflectionClass($className); @@ -269,6 +271,11 @@ class MemoryManager{ $continue = true; $className = get_class($object); + if(!isset($instanceCounts[$className])){ + $instanceCounts[$className] = 1; + }else{ + $instanceCounts[$className]++; + } $objects[$hash] = true; @@ -310,6 +317,9 @@ class MemoryManager{ file_put_contents($outputFolder . "/serverEntry.js", json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); file_put_contents($outputFolder . "/referenceCounts.js", json_encode($refCounts, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); + arsort($instanceCounts, SORT_NUMERIC); + file_put_contents($outputFolder . "/instanceCounts.js", json_encode($instanceCounts, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); + echo "[Dump] Finished!\n"; ini_set('memory_limit', $hardLimit); From 0a52e210db934080290f80e82b433b270a5a88c9 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 30 Apr 2017 15:59:53 +0100 Subject: [PATCH 07/11] Fixed crash when crashing while generating a crashdump due to crashing --- src/pocketmine/Server.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index f9c6477d5..b8e38a28d 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -2081,7 +2081,8 @@ class Server{ try{ $dump = new CrashDump($this); }catch(\Throwable $e){ - $this->logger->critical($this->getLanguage()->translateString("pocketmine.crash.error", $e->getMessage())); + $this->logger->logException($e); + $this->logger->critical($this->getLanguage()->translateString("pocketmine.crash.error", [$e->getMessage()])); return; } From 6d90f91be0bb6ed5508fbe72f55d08cd5ba78598 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 30 Apr 2017 16:22:50 +0100 Subject: [PATCH 08/11] Fixed crashes while crashing related to plugins --- src/pocketmine/CrashDump.php | 3 ++- src/pocketmine/Server.php | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pocketmine/CrashDump.php b/src/pocketmine/CrashDump.php index 5bfc6b569..b727d2afb 100644 --- a/src/pocketmine/CrashDump.php +++ b/src/pocketmine/CrashDump.php @@ -24,6 +24,7 @@ namespace pocketmine; use pocketmine\network\mcpe\protocol\ProtocolInfo; use pocketmine\plugin\PluginBase; use pocketmine\plugin\PluginLoadOrder; +use pocketmine\plugin\PluginManager; use pocketmine\utils\Utils; use pocketmine\utils\VersionString; use raklib\RakLib; @@ -86,7 +87,7 @@ class CrashDump{ } private function pluginsData(){ - if(class_exists("pocketmine\\plugin\\PluginManager", false)){ + if($this->server->getPluginManager() instanceof PluginManager){ $this->addLine(); $this->addLine("Loaded plugins:"); $this->data["plugins"] = []; diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index b8e38a28d..55072d40c 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -1937,8 +1937,10 @@ class Server{ UPnP::RemovePortForward($this->getPort()); } - $this->getLogger()->debug("Disabling all plugins"); - $this->pluginManager->disablePlugins(); + if($this->pluginManager instanceof PluginManager){ + $this->getLogger()->debug("Disabling all plugins"); + $this->pluginManager->disablePlugins(); + } foreach($this->players as $player){ $player->close($player->getLeaveMessage(), $this->getProperty("settings.shutdown-message", "Server closed")); From f889bf9cf56ea8284fefa55c3011fc4b66591ef6 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 2 May 2017 11:18:32 +0100 Subject: [PATCH 09/11] Fixed player list self-duplication --- src/pocketmine/Server.php | 3 --- src/pocketmine/utils/BinaryStream.php | 12 ++++++++++-- src/pocketmine/utils/UUID.php | 11 +++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index 55072d40c..086150fbc 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -2199,9 +2199,6 @@ class Server{ $pk = new PlayerListPacket(); $pk->type = PlayerListPacket::TYPE_ADD; foreach($this->playerList as $player){ - if($p === $player){ - continue; //fixes duplicates - } $pk->entries[] = [$player->getUniqueId(), $player->getId(), $player->getDisplayName(), $player->getSkinId(), $player->getSkinData()]; } diff --git a/src/pocketmine/utils/BinaryStream.php b/src/pocketmine/utils/BinaryStream.php index 156ce4523..5fc671f4b 100644 --- a/src/pocketmine/utils/BinaryStream.php +++ b/src/pocketmine/utils/BinaryStream.php @@ -177,11 +177,19 @@ class BinaryStream extends \stdClass{ } public function getUUID(){ - return UUID::fromBinary($this->get(16)); + //This is actually two little-endian longs: UUID Most followed by UUID Least + $part1 = $this->getLInt(); + $part0 = $this->getLInt(); + $part3 = $this->getLInt(); + $part2 = $this->getLInt(); + return new UUID($part0, $part1, $part2, $part3); } public function putUUID(UUID $uuid){ - $this->put($uuid->toBinary()); + $this->putLInt($uuid->getPart(1)); + $this->putLInt($uuid->getPart(0)); + $this->putLInt($uuid->getPart(3)); + $this->putLInt($uuid->getPart(2)); } public function getSlot(){ diff --git a/src/pocketmine/utils/UUID.php b/src/pocketmine/utils/UUID.php index 552ea3376..3b6118257 100644 --- a/src/pocketmine/utils/UUID.php +++ b/src/pocketmine/utils/UUID.php @@ -102,4 +102,15 @@ class UUID{ public function __toString(){ return $this->toString(); } + + public function getPart(int $partNumber){ + if($partNumber < 0 or $partNumber > 3){ + throw new \InvalidArgumentException("Invalid UUID part index $partNumber"); + } + return $this->parts[$partNumber]; + } + + public function getParts() : array{ + return $this->parts; + } } \ No newline at end of file From 966e4bf8a1940ba54f145408c105f003f5ab5db3 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 2 May 2017 19:37:35 +0100 Subject: [PATCH 10/11] Added name field to crashdump data --- src/pocketmine/CrashDump.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/CrashDump.php b/src/pocketmine/CrashDump.php index b727d2afb..45504df64 100644 --- a/src/pocketmine/CrashDump.php +++ b/src/pocketmine/CrashDump.php @@ -225,6 +225,7 @@ class CrashDump{ private function generalData(){ $version = new VersionString(); $this->data["general"] = []; + $this->data["general"]["name"] = $this->server->getName(); $this->data["general"]["version"] = $version->get(false); $this->data["general"]["build"] = $version->getBuild(); $this->data["general"]["protocol"] = ProtocolInfo::CURRENT_PROTOCOL; @@ -236,7 +237,7 @@ class CrashDump{ $this->data["general"]["zend"] = zend_version(); $this->data["general"]["php_os"] = PHP_OS; $this->data["general"]["os"] = Utils::getOS(); - $this->addLine("PocketMine-MP version: " . $version->get(false) . " #" . $version->getBuild() . " [Protocol " . ProtocolInfo::CURRENT_PROTOCOL . "; API " . API_VERSION . "]"); + $this->addLine($this->server->getName() . " version: " . $version->get(false) . " #" . $version->getBuild() . " [Protocol " . ProtocolInfo::CURRENT_PROTOCOL . "; API " . API_VERSION . "]"); $this->addLine("Git commit: " . GIT_COMMIT); $this->addLine("uname -a: " . php_uname("a")); $this->addLine("PHP Version: " . phpversion()); From eaef2bd16985dcbe56643a47b181d16545de393b Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 4 May 2017 12:19:50 +0100 Subject: [PATCH 11/11] Fixed some inspections --- src/pocketmine/Player.php | 1 - src/pocketmine/command/Command.php | 5 ----- src/pocketmine/command/defaults/EffectCommand.php | 1 - src/pocketmine/command/defaults/TitleCommand.php | 4 ++-- src/pocketmine/level/format/io/region/McRegion.php | 1 - src/pocketmine/level/format/io/region/RegionLoader.php | 1 - src/pocketmine/network/mcpe/NetworkSession.php | 1 - src/pocketmine/network/mcpe/protocol/DropItemPacket.php | 2 ++ 8 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 191400cab..62d1a36e3 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -184,7 +184,6 @@ use pocketmine\network\mcpe\protocol\StopSoundPacket; use pocketmine\network\mcpe\protocol\TakeItemEntityPacket; use pocketmine\network\mcpe\protocol\TextPacket; use pocketmine\network\mcpe\protocol\TransferPacket; -use pocketmine\network\mcpe\protocol\UnknownPacket; use pocketmine\network\mcpe\protocol\UpdateAttributesPacket; use pocketmine\network\mcpe\protocol\UpdateBlockPacket; use pocketmine\network\mcpe\protocol\UpdateTradePacket; diff --git a/src/pocketmine/command/Command.php b/src/pocketmine/command/Command.php index 38f562abb..0795665ac 100644 --- a/src/pocketmine/command/Command.php +++ b/src/pocketmine/command/Command.php @@ -46,11 +46,6 @@ abstract class Command{ /** @var string */ private $label; - /** - * @var string[] - */ - private $aliases = []; - /** * @var string[] */ diff --git a/src/pocketmine/command/defaults/EffectCommand.php b/src/pocketmine/command/defaults/EffectCommand.php index 76e761b38..559d5576a 100644 --- a/src/pocketmine/command/defaults/EffectCommand.php +++ b/src/pocketmine/command/defaults/EffectCommand.php @@ -75,7 +75,6 @@ class EffectCommand extends VanillaCommand{ return true; } - $duration = 300; $amplification = 0; if(count($args) >= 3){ diff --git a/src/pocketmine/command/defaults/TitleCommand.php b/src/pocketmine/command/defaults/TitleCommand.php index 1b4314722..68423c842 100644 --- a/src/pocketmine/command/defaults/TitleCommand.php +++ b/src/pocketmine/command/defaults/TitleCommand.php @@ -23,8 +23,6 @@ namespace pocketmine\command\defaults; use pocketmine\command\CommandSender; use pocketmine\event\TranslationContainer; -use pocketmine\plugin\Plugin; -use pocketmine\utils\TextFormat; class TitleCommand extends VanillaCommand{ @@ -98,5 +96,7 @@ class TitleCommand extends VanillaCommand{ } $sender->sendMessage(new TranslationContainer("commands.title.success")); + + return true; } } diff --git a/src/pocketmine/level/format/io/region/McRegion.php b/src/pocketmine/level/format/io/region/McRegion.php index b8fe71378..5d9e29758 100644 --- a/src/pocketmine/level/format/io/region/McRegion.php +++ b/src/pocketmine/level/format/io/region/McRegion.php @@ -30,7 +30,6 @@ use pocketmine\level\format\io\ChunkUtils; use pocketmine\level\format\SubChunk; use pocketmine\level\generator\Generator; use pocketmine\level\Level; -use pocketmine\level\LevelException; use pocketmine\nbt\NBT; use pocketmine\nbt\tag\{ ByteArrayTag, ByteTag, CompoundTag, IntArrayTag, IntTag, ListTag, LongTag, StringTag diff --git a/src/pocketmine/level/format/io/region/RegionLoader.php b/src/pocketmine/level/format/io/region/RegionLoader.php index c76278364..c98a2a34b 100644 --- a/src/pocketmine/level/format/io/region/RegionLoader.php +++ b/src/pocketmine/level/format/io/region/RegionLoader.php @@ -25,7 +25,6 @@ namespace pocketmine\level\format\io\region; use pocketmine\level\format\Chunk; use pocketmine\level\format\io\ChunkException; -use pocketmine\level\LevelException; use pocketmine\utils\Binary; use pocketmine\utils\MainLogger; diff --git a/src/pocketmine/network/mcpe/NetworkSession.php b/src/pocketmine/network/mcpe/NetworkSession.php index 959823e1c..6bde53d41 100644 --- a/src/pocketmine/network/mcpe/NetworkSession.php +++ b/src/pocketmine/network/mcpe/NetworkSession.php @@ -103,7 +103,6 @@ use pocketmine\network\mcpe\protocol\StopSoundPacket; use pocketmine\network\mcpe\protocol\TakeItemEntityPacket; use pocketmine\network\mcpe\protocol\TextPacket; use pocketmine\network\mcpe\protocol\TransferPacket; -use pocketmine\network\mcpe\protocol\UnknownPacket; use pocketmine\network\mcpe\protocol\UpdateAttributesPacket; use pocketmine\network\mcpe\protocol\UpdateBlockPacket; use pocketmine\network\mcpe\protocol\UpdateTradePacket; diff --git a/src/pocketmine/network/mcpe/protocol/DropItemPacket.php b/src/pocketmine/network/mcpe/protocol/DropItemPacket.php index 98fff9df9..be25e0c7b 100644 --- a/src/pocketmine/network/mcpe/protocol/DropItemPacket.php +++ b/src/pocketmine/network/mcpe/protocol/DropItemPacket.php @@ -24,12 +24,14 @@ namespace pocketmine\network\mcpe\protocol; #include +use pocketmine\item\Item; use pocketmine\network\mcpe\NetworkSession; class DropItemPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::DROP_ITEM_PACKET; public $type; + /** @var Item */ public $item; public function decode(){