Inheritance: extends AttachableThreadedLogger
Ejemplo n.º 1
0
 public function run()
 {
     if ($this->readline) {
         readline_callback_handler_install("CS> ", [$this, "readline_callback"]);
         $this->logger->setConsoleCallback("readline_redisplay");
     }
     while (!$this->shutdown) {
         $r = [$this->stdin];
         $w = null;
         $e = null;
         if (stream_select($r, $w, $e, 0, 200000) > 0) {
             // PHP on Windows sucks
             if (feof($this->stdin)) {
                 if (Utils::getOS() == "win") {
                     $this->stdin = fopen("php://stdin", "r");
                     if (!is_resource($this->stdin)) {
                         break;
                     }
                 } else {
                     break;
                 }
             }
             $this->readLine();
         }
     }
     if ($this->readline) {
         $this->logger->setConsoleCallback(null);
         readline_callback_handler_remove();
     }
 }
Ejemplo n.º 2
0
 public static function log($logger, $flag, $msg, $timeout = 5)
 {
     if (isset(self::$msgs[$flag])) {
         if (microtime(true) - self::$msgs[$flag] < $timeout) {
             return;
         }
     }
     self::$msgs[$flag] = microtime(true);
     if ($logger instanceof \Logger) {
         $logger->notice($msg);
     } else {
         MainLogger::getLogger()->notice($msg);
     }
 }
 public function handleDataPacket(DataPacket $pk)
 {
     $this->logger->debug("Received packet " . $pk::NETWORK_ID . " from {$this->serverIp}:{$this->port}");
     switch ($pk::NETWORK_ID) {
         case Info::INFORMATION_PACKET:
             /** @var InformationPacket $pk */
             switch ($pk->type) {
                 case InformationPacket::TYPE_LOGIN:
                     if ($pk->message == InformationPacket::INFO_LOGIN_SUCCESS) {
                         $this->logger->info("Login success to {$this->serverIp}:{$this->port}");
                         $this->verified = true;
                     } elseif ($pk->message == InformationPacket::INFO_LOGIN_FAILED) {
                         $this->logger->info("Login failed to {$this->serverIp}:{$this->port}");
                     }
                     break;
                 case InformationPacket::TYPE_CLIENT_DATA:
                     $this->clientData = json_decode($pk->message, true);
                     $this->lastRecvInfo = microtime();
                     break;
             }
             break;
         case Info::PLAYER_LOGIN_PACKET:
             /** @var PlayerLoginPacket $pk */
             $player = new Player($this->synLibInterface, mt_rand(0, PHP_INT_MAX), $pk->address, $pk->port);
             $player->setUniqueId($pk->uuid);
             $this->server->addPlayer(spl_object_hash($player), $player);
             $this->players[$pk->uuid->toBinary()] = $player;
             $player->handleLoginPacket($pk);
             break;
         case Info::REDIRECT_PACKET:
             /** @var RedirectPacket $pk */
             if (isset($this->players[$uuid = $pk->uuid->toBinary()])) {
                 $pk = $this->getPacket($pk->mcpeBuffer);
                 $pk->decode();
                 $this->players[$uuid]->handleDataPacket($pk);
             }
             break;
         case Info::PLAYER_LOGOUT_PACKET:
             /** @var PlayerLogoutPacket $pk */
             if (isset($this->players[$uuid = $pk->uuid->toBinary()])) {
                 $this->players[$uuid]->setConnected(false);
                 $this->players[$uuid]->close("", $pk->reason);
                 $this->removePlayer($this->players[$uuid]);
             }
             break;
     }
 }
Ejemplo n.º 4
0
 public function __construct()
 {
     // load recipes from src/pocketmine/recipes.json
     $recipes = new Config(Server::getInstance()->getFilePath() . "src/pocketmine/resources/recipes.json", Config::JSON, []);
     MainLogger::getLogger()->info("Loading recipes...");
     foreach ($recipes->getAll() as $recipe) {
         switch ($recipe["Type"]) {
             case 0:
                 // TODO: handle multiple result items
                 if (count($recipe["Result"]) == 1) {
                     $first = $recipe["Result"][0];
                     $result = new ShapelessRecipe(Item::get($first["ID"], $first["Damage"], $first["Count"]));
                     foreach ($recipe["Ingredients"] as $ingredient) {
                         $result->addIngredient(Item::get($ingredient["ID"], $ingredient["Damage"], $ingredient["Count"]));
                     }
                     $this->registerRecipe($result);
                 }
                 break;
             case 1:
                 // TODO: handle multiple result items
                 if (count($recipe["Result"]) == 1) {
                     $first = $recipe["Result"][0];
                     $result = new ShapedRecipe(Item::get($first["ID"], $first["Damage"], $first["Count"]), $recipe["Height"], $recipe["Width"]);
                     $shape = array_chunk($recipe["Ingredients"], $recipe["Width"]);
                     foreach ($shape as $y => $row) {
                         foreach ($row as $x => $ingredient) {
                             $result->addIngredient($x, $y, Item::get($ingredient["ID"], $ingredient["Damage"] < 0 ? null : $ingredient["Damage"], $ingredient["Count"]));
                         }
                     }
                     $this->registerRecipe($result);
                 }
                 break;
             case 2:
                 $result = $recipe["Result"];
                 $resultItem = Item::get($result["ID"], $result["Damage"], $result["Count"]);
                 $this->registerRecipe(new FurnaceRecipe($resultItem, Item::get($recipe["Ingredients"], 0, 1)));
                 break;
             case 3:
                 $result = $recipe["Result"];
                 $resultItem = Item::get($result["ID"], $result["Damage"], $result["Count"]);
                 $this->registerRecipe(new FurnaceRecipe($resultItem, Item::get($recipe["Ingredients"]["ID"], $recipe["Ingredients"]["Damage"], 1)));
                 break;
             default:
                 break;
         }
     }
 }
Ejemplo n.º 5
0
 public function parseInfo()
 {
     $this->seek(0);
     if (fread($this->fp, 3) !== "PMF") {
         return false;
     }
     $this->version = ord($this->read(1));
     switch ($this->version) {
         case 0x1:
             $this->type = ord($this->read(1));
             break;
         default:
             MainLogger::getLogger()->alert("Tried loading non-supported PMF version " . $this->version . " on file " . $this->file);
             return false;
     }
     return true;
 }
Ejemplo n.º 6
0
 public function query($msg, $fetch, ...$args)
 {
     foreach ($args as &$arg) {
         if (is_string($arg)) {
             $arg = "'" . $this->mysqli->escape_string($arg) . "'";
         } else {
             $arg = "{$arg}";
         }
     }
     if (count($args) > 0) {
         try {
             if ($fetch !== 3) {
                 $result = $this->mysqli->query($query = sprintf($msg, ...$args));
             } else {
                 return sprintf($msg, ...$args);
             }
         } catch (\RuntimeException $e) {
             MainLogger::getLogger()->alert($e->getTraceAsString());
             MainLogger::getLogger()->alert("Query: " . TextFormat::YELLOW . $msg);
             MainLogger::getLogger()->alert("Args: " . var_export($args, true));
             return null;
         }
     } else {
         $result = $this->mysqli->query($query = $msg);
         // to make it faster
     }
     if ($result === false) {
         $server = Server::getInstance();
         $server->getLogger()->warning("Query failed! Query:");
         $server->getLogger()->warning($query);
         $server->getLogger()->warning("Message: " . $this->mysqli->error);
     }
     if ($result instanceof \mysqli_result) {
         if ($fetch === self::ASSOC) {
             return $result->fetch_assoc();
         } elseif ($fetch === self::ALL) {
             return $result->fetch_all(MYSQLI_ASSOC);
         }
         return $result;
     }
     return $result;
 }
Ejemplo n.º 7
0
 \ini_set("display_errors", 1);
 \ini_set("display_startup_errors", 1);
 \ini_set("default_charset", "utf-8");
 \ini_set("memory_limit", -1);
 \define("pocketmine\\START_TIME", \microtime(\true));
 $opts = \getopt("", ["data:", "plugins:", "no-wizard", "enable-profiler"]);
 \define("pocketmine\\DATA", isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR);
 \define("pocketmine\\PLUGIN_PATH", isset($opts["plugins"]) ? $opts["plugins"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR);
 Terminal::init();
 \define("pocketmine\\ANSI", Terminal::hasFormattingCodes());
 if (!\file_exists(\pocketmine\DATA)) {
     \mkdir(\pocketmine\DATA, 0777, \true);
 }
 //Logger has a dependency on timezone, so we'll set it to UTC until we can get the actual timezone.
 \date_default_timezone_set("UTC");
 $logger = new MainLogger(\pocketmine\DATA . "server.log", \pocketmine\ANSI);
 if (!\ini_get("date.timezone")) {
     if ($timezone = detect_system_timezone() and \date_default_timezone_set($timezone)) {
         //Success! Timezone has already been set and validated in the if statement.
         //This here is just for redundancy just in case some program wants to read timezone data from the ini.
         \ini_set("date.timezone", $timezone);
     } else {
         //If system timezone detection fails or timezone is an invalid value.
         if ($response = Utils::getURL("http://ip-api.com/json") and $ip_geolocation_data = \json_decode($response, \true) and $ip_geolocation_data['status'] != 'fail' and \date_default_timezone_set($ip_geolocation_data['timezone'])) {
             //Again, for redundancy.
             \ini_set("date.timezone", $ip_geolocation_data['timezone']);
         } else {
             \ini_set("date.timezone", "UTC");
             \date_default_timezone_set("UTC");
             $logger->warning("Timezone could not be automatically determined. An incorrect timezone will result in incorrect timestamps on console logs. It has been set to \"UTC\" by default. You can change it on the php.ini file.");
         }
Ejemplo n.º 8
0
 /**
  * @param Plugin $plugin
  */
 public function disablePlugin(Plugin $plugin)
 {
     if ($plugin instanceof PluginBase and $plugin->isEnabled()) {
         MainLogger::getLogger()->info("Disabling " . $plugin->getDescription()->getFullName());
         Server::getInstance()->getPluginManager()->callEvent(new PluginDisableEvent($plugin));
         $plugin->setEnabled(false);
     }
 }
Ejemplo n.º 9
0
 /**
  * Send to the subscriber a message
  * @param string $msg a string message, could be formatted in the sprintf() method
  * @param string ...$args arguments to be formatted in sprintf()
  * @return void
  */
 public function tell($msg, ...$args)
 {
     try {
         MainLogger::getLogger()->info(sprintf($msg, ...$args));
     } catch (\RuntimeException $e) {
         var_dump($msg, $args, $e);
     }
 }
Ejemplo n.º 10
0
 public function readChunk($x, $z, $generate = true, $forward = false)
 {
     $index = self::getChunkOffset($x, $z);
     if ($index < 0 or $index >= 4096) {
         //Regenerate chunk due to corruption
         $this->locationTable[$index][0] = 0;
         $this->locationTable[$index][1] = 1;
     }
     if (!$this->isChunkGenerated($index)) {
         if ($generate === true) {
             //Allocate space
             $this->locationTable[$index][0] = ++$this->lastSector;
             $this->locationTable[$index][1] = 1;
             fseek($this->filePointer, $this->locationTable[$index][0] << 12);
             fwrite($this->filePointer, str_pad(Binary::writeInt(-1) . chr(self::COMPRESSION_ZLIB), 4096, "", STR_PAD_RIGHT));
             $this->writeLocationIndex($index);
         } else {
             return false;
         }
     }
     fseek($this->filePointer, $this->locationTable[$index][0] << 12);
     $length = Binary::readInt(fread($this->filePointer, 4));
     $compression = ord(fgetc($this->filePointer));
     if ($length <= 0) {
         //Not yet generated
         $this->generateChunk($x, $z);
         fseek($this->filePointer, $this->locationTable[$index][0] << 12);
         $length = Binary::readInt(fread($this->filePointer, 4));
         $compression = ord(fgetc($this->filePointer));
     }
     if ($length > $this->locationTable[$index][1] << 12) {
         //Invalid chunk, bigger than defined number of sectors
         MainLogger::getLogger()->error("Corrupted chunk detected");
         $this->locationTable[$index][1] = $length >> 12;
         $this->writeLocationIndex($index);
     } elseif ($compression !== self::COMPRESSION_ZLIB and $compression !== self::COMPRESSION_GZIP) {
         MainLogger::getLogger()->error("Invalid compression type");
         return false;
     }
     $chunk = Chunk::fromBinary(fread($this->filePointer, $length - 1), $this->levelProvider);
     if ($chunk instanceof Chunk) {
         return $chunk;
     } elseif ($forward === false) {
         MainLogger::getLogger()->error("Corrupted chunk detected");
         $this->generateChunk($x, $z);
         return $this->readChunk($x, $z, $generate, true);
     } else {
         return null;
     }
 }
Ejemplo n.º 11
0
 /**
  * @param string $str
  *
  * @return BanEntry
  */
 public static function fromString($str)
 {
     if (strlen($str) < 2) {
         return null;
     } else {
         $str = explode("|", trim($str));
         $entry = new BanEntry(trim(array_shift($str)));
         if (count($str) > 0) {
             $datetime = \DateTime::createFromFormat(self::$format, array_shift($str));
             if (!$datetime instanceof \DateTime) {
                 MainLogger::getLogger()->alert("Error parsing date for BanEntry for player \"" . $entry->getName() . "\", the format may be invalid!");
                 return $entry;
             }
             $entry->setCreated($datetime);
             if (count($str) > 0) {
                 $entry->setSource(trim(array_shift($str)));
                 if (count($str) > 0) {
                     $expire = trim(array_shift($str));
                     if (strtolower($expire) !== "forever" and strlen($expire) > 0) {
                         $entry->setExpires(\DateTime::createFromFormat(self::$format, $expire));
                     }
                     if (count($str) > 0) {
                         $entry->setReason(trim(array_shift($str)));
                     }
                 }
             }
         }
         return $entry;
     }
 }
Ejemplo n.º 12
0
 /**
  * @param string $message
  */
 public function sendMessage($message)
 {
     if ($message instanceof TextContainer) {
         $message = $this->getServer()->getLanguage()->translate($message);
     } else {
         $message = $this->getServer()->getLanguage()->translateString($message);
     }
     foreach (explode("\n", trim($message)) as $line) {
         MainLogger::getLogger()->info($line);
     }
 }
Ejemplo n.º 13
0
 public function loadChunk($X, $Z)
 {
     if ($this->isChunkLoaded($X, $Z)) {
         return true;
     }
     $index = self::getIndex($X, $Z);
     $path = $this->getChunkPath($X, $Z);
     if (!file_exists($path)) {
         if ($this->generateChunk($X, $Z) === false) {
             return false;
         }
         if ($this->isGenerating === 0) {
             $this->populateChunk($X, $Z);
         }
         return true;
     }
     $chunk = file_get_contents($path);
     if ($chunk === false) {
         return false;
     }
     $chunk = zlib_decode($chunk);
     $offset = 0;
     $this->chunkInfo[$index] = [0 => ord($chunk[0]), 1 => Binary::readInt(substr($chunk, 1, 4))];
     $offset += 5;
     $len = Binary::readInt(substr($chunk, $offset, 4));
     $offset += 4;
     $nbt = new NBT(NBT::BIG_ENDIAN);
     $nbt->read(substr($chunk, $offset, $len));
     $this->chunkInfo[$index][2] = $nbt->getData();
     $offset += $len;
     $this->chunks[$index] = [];
     $this->chunkChange[$index] = [-1 => false];
     $this->chunkInfo[$index][3] = substr($chunk, $offset, 256);
     //Biome data
     $offset += 256;
     for ($Y = 0; $Y < 8; ++$Y) {
         if (($this->chunkInfo[$index][0] & 1 << $Y) !== 0) {
             // 4096 + 2048 + 2048, Block Data, Meta, Light
             if (strlen($this->chunks[$index][$Y] = substr($chunk, $offset, 8192)) < 8192) {
                 MainLogger::getLogger()->notice("Empty corrupt chunk detected [{$X},{$Z},:{$Y}], recovering contents");
                 $this->fillMiniChunk($X, $Z, $Y);
             }
             $offset += 8192;
         } else {
             $this->chunks[$index][$Y] = false;
         }
     }
     if ($this->isGenerating === 0 and !$this->isPopulated($X, $Z)) {
         $this->populateChunk($X, $Z);
     }
     return true;
 }
Ejemplo n.º 14
0
 public function onDisable()
 {
     MainLogger::getLogger()->info(TextFormat::LIGHT_PURPLE . "AntiFly disabled.");
 }
Ejemplo n.º 15
0
 /**
  * @param Player $player
  * @param mixed[]|null $loginData
  * @return bool
  */
 public function newSession(Player $player, $loginData = null)
 {
     if ($loginData === null) {
         $player->sendMessage(Phrases::VAR_wait . "Welcome to Legion PE! Please wait while we are preparing to register an account for you.");
         new NewUserQuery($this, $player);
         return false;
     }
     try {
         $this->sessions[$player->getId()] = $this->createSession($player, $loginData);
         return true;
     } catch (\Exception $e) {
         $this->getLogger()->error("An error occurred while trying to initialize session for player {$player->getName()}: ");
         MainLogger::getLogger()->logException($e);
         return false;
     }
 }
Ejemplo n.º 16
0
 public function save($flag = \true)
 {
     $this->removeExpired();
     $fp = @\fopen($this->file, "w");
     if (\is_resource($fp)) {
         if ($flag === \true) {
             \fwrite($fp, "# Updated " . \strftime("%x %H:%M", \time()) . " by " . Server::getInstance()->getName() . " " . Server::getInstance()->getPocketMineVersion() . "\n");
             \fwrite($fp, "# victim name | ban date | banned by | banned until | reason\n\n");
         }
         foreach ($this->list as $entry) {
             \fwrite($fp, $entry->getString() . "\n");
         }
         \fclose($fp);
     } else {
         MainLogger::getLogger()->error("Could not save ban list");
     }
 }
 public function readChunk($x, $z)
 {
     $index = self::getChunkOffset($x, $z);
     if ($index < 0 or $index >= 4096) {
         return \null;
     }
     $this->lastUsed = \time();
     if (!$this->isChunkGenerated($index)) {
         return \null;
     }
     \fseek($this->filePointer, $this->locationTable[$index][0] << 12);
     $length = \unpack("N", \fread($this->filePointer, 4))[1] << 32 >> 32;
     $compression = \ord(\fgetc($this->filePointer));
     if ($length <= 0 or $length > self::MAX_SECTOR_LENGTH) {
         //Not yet generated / corrupted
         if ($length >= self::MAX_SECTOR_LENGTH) {
             $this->locationTable[$index][0] = ++$this->lastSector;
             $this->locationTable[$index][1] = 1;
             MainLogger::getLogger()->error("Corrupted chunk header detected");
         }
         return \null;
     }
     if ($length > $this->locationTable[$index][1] << 12) {
         //Invalid chunk, bigger than defined number of sectors
         MainLogger::getLogger()->error("Corrupted bigger chunk detected");
         $this->locationTable[$index][1] = $length >> 12;
         $this->writeLocationIndex($index);
     } elseif ($compression !== self::COMPRESSION_ZLIB and $compression !== self::COMPRESSION_GZIP) {
         MainLogger::getLogger()->error("Invalid compression type");
         return \null;
     }
     $chunk = $this->unserializeChunk(\fread($this->filePointer, $length - 1));
     if ($chunk instanceof FullChunk) {
         return $chunk;
     } else {
         MainLogger::getLogger()->error("Corrupted chunk detected");
         return \null;
     }
 }
Ejemplo n.º 18
0
 public function run()
 {
     while ($this->stop !== true) {
         $this->synchronized(function () {
             $this->wait(2000);
         });
         $r = [$socket = $this->socket];
         $w = null;
         $e = null;
         if (socket_select($r, $w, $e, 0) === 1) {
             if (($client = socket_accept($this->socket)) !== false) {
                 socket_set_block($client);
                 socket_set_option($client, SOL_SOCKET, SO_KEEPALIVE, 1);
                 $done = false;
                 for ($n = 0; $n < $this->maxClients; ++$n) {
                     if ($this->{"client" . $n} === null) {
                         $this->{"client" . $n} = $client;
                         $this->{"status" . $n} = 0;
                         $this->{"timeout" . $n} = microtime(true) + 5;
                         $done = true;
                         break;
                     }
                 }
                 if ($done === false) {
                     @socket_close($client);
                 }
             }
         }
         for ($n = 0; $n < $this->maxClients; ++$n) {
             $client =& $this->{"client" . $n};
             if ($client !== null) {
                 if ($this->{"status" . $n} !== -1 and $this->stop !== true) {
                     if ($this->{"status" . $n} === 0 and $this->{"timeout" . $n} < microtime(true)) {
                         //Timeout
                         $this->{"status" . $n} = -1;
                         continue;
                     }
                     $p = $this->readPacket($client, $size, $requestID, $packetType, $payload);
                     if ($p === false) {
                         $this->{"status" . $n} = -1;
                         continue;
                     } elseif ($p === null) {
                         continue;
                     }
                     switch ($packetType) {
                         case 9:
                             //Protocol check
                             if ($this->{"status" . $n} !== 1) {
                                 $this->{"status" . $n} = -1;
                                 continue;
                             }
                             $this->writePacket($client, $requestID, 0, RCON::PROTOCOL_VERSION);
                             $this->response = "";
                             if ($payload == RCON::PROTOCOL_VERSION) {
                                 $this->logger->setSendMsg(true);
                             }
                             //GeniRCON output
                             break;
                         case 4:
                             //Logger
                             if ($this->{"status" . $n} !== 1) {
                                 $this->{"status" . $n} = -1;
                                 continue;
                             }
                             $this->writePacket($client, $requestID, 0, str_replace("\n", "\r\n", trim($this->logger->getMessages())));
                             $this->response = "";
                             break;
                         case 3:
                             //Login
                             if ($this->{"status" . $n} !== 0) {
                                 $this->{"status" . $n} = -1;
                                 continue;
                             }
                             if ($payload === $this->password) {
                                 socket_getpeername($client, $addr, $port);
                                 $this->response = "[INFO] Successful Rcon connection from: /{$addr}:{$port}";
                                 $this->response = "";
                                 $this->writePacket($client, $requestID, 2, "");
                                 $this->{"status" . $n} = 1;
                             } else {
                                 $this->{"status" . $n} = -1;
                                 $this->writePacket($client, -1, 2, "");
                                 continue;
                             }
                             break;
                         case 2:
                             //Command
                             if ($this->{"status" . $n} !== 1) {
                                 $this->{"status" . $n} = -1;
                                 continue;
                             }
                             if (strlen($payload) > 0) {
                                 $this->cmd = ltrim($payload);
                                 $this->synchronized(function () {
                                     $this->waiting = true;
                                     $this->wait();
                                 });
                                 $this->waiting = false;
                                 $this->writePacket($client, $requestID, 0, str_replace("\n", "\r\n", trim($this->response)));
                                 $this->response = "";
                                 $this->cmd = "";
                             }
                             break;
                     }
                 } else {
                     @socket_set_option($client, SOL_SOCKET, SO_LINGER, ["l_onoff" => 1, "l_linger" => 1]);
                     @socket_shutdown($client, 2);
                     @socket_set_block($client);
                     @socket_read($client, 1);
                     @socket_close($client);
                     $this->{"status" . $n} = 0;
                     $this->{"client" . $n} = null;
                 }
             }
         }
     }
     unset($this->socket, $this->cmd, $this->response, $this->stop);
     exit(0);
 }
 /**
  * @param string $message
  */
 public function sendMessage($message)
 {
     foreach (\explode("\n", \trim($message)) as $line) {
         MainLogger::getLogger()->info($line);
     }
 }
Ejemplo n.º 20
0
 public function import()
 {
     if (file_exists($this->path . "tileEntities.dat")) {
         //OldPM
         $level = unserialize(file_get_contents($this->path . "level.dat"));
         MainLogger::getLogger()->info("Importing OldPM level \"" . $level["LevelName"] . "\" to PMF format");
         $entities = new Config($this->path . "entities.yml", Config::YAML, unserialize(file_get_contents($this->path . "entities.dat")));
         $entities->save();
         $tiles = new Config($this->path . "tiles.yml", Config::YAML, unserialize(file_get_contents($this->path . "tileEntities.dat")));
         $tiles->save();
     } elseif (file_exists($this->path . "chunks.dat") and file_exists($this->path . "level.dat")) {
         //Pocket
         $nbt = new NBT(NBT::LITTLE_ENDIAN);
         $nbt->read(substr(file_get_contents($this->path . "level.dat"), 8));
         $level = $nbt->getData();
         if ($level["LevelName"] == "") {
             $level["LevelName"] = "world" . time();
         }
         MainLogger::getLogger()->info("Importing Pocket level \"" . $level->LevelName . "\" to PMF format");
         unset($level->Player);
         $nbt->read(substr(file_get_contents($this->path . "entities.dat"), 12));
         $entities = $nbt->getData();
         if (!isset($entities->TileEntities)) {
             $entities->TileEntities = [];
         }
         $tiles = $entities->TileEntities;
         $entities = $entities->Entities;
         $entities = new Config($this->path . "entities.yml", Config::YAML, $entities);
         $entities->save();
         $tiles = new Config($this->path . "tiles.yml", Config::YAML, $tiles);
         $tiles->save();
     } else {
         return false;
     }
     $pmf = new LevelFormat($this->path . "level.pmf", ["name" => $level->LevelName, "seed" => $level->RandomSeed, "time" => $level->Time, "spawnX" => $level->SpawnX, "spawnY" => $level->SpawnY, "spawnZ" => $level->SpawnZ, "height" => 8, "generator" => "default", "generatorSettings" => "", "extra" => ""]);
     $chunks = new PocketChunkParser();
     $chunks->loadFile($this->path . "chunks.dat");
     $chunks->loadMap();
     for ($Z = 0; $Z < 16; ++$Z) {
         for ($X = 0; $X < 16; ++$X) {
             $chunk = [0 => "", 1 => "", 2 => "", 3 => "", 4 => "", 5 => "", 6 => "", 7 => ""];
             $pmf->initCleanChunk($X, $Z);
             for ($z = 0; $z < 16; ++$z) {
                 for ($x = 0; $x < 16; ++$x) {
                     $block = $chunks->getChunkColumn($X, $Z, $x, $z, 0);
                     $meta = $chunks->getChunkColumn($X, $Z, $x, $z, 1);
                     for ($Y = 0; $Y < 8; ++$Y) {
                         $chunk[$Y] .= substr($block, $Y << 4, 16);
                         $chunk[$Y] .= substr($meta, $Y << 3, 8);
                         $chunk[$Y] .= "";
                     }
                 }
             }
             foreach ($chunk as $Y => $data) {
                 $pmf->setMiniChunk($X, $Z, $Y, $data);
             }
             $pmf->setPopulated($X, $Z);
             $pmf->saveChunk($X, $Z);
         }
         MainLogger::getLogger()->notice("Importing level " . ceil(($Z + 1) / 0.16) . "%");
     }
     $chunks->map = null;
     $chunks = null;
     @unlink($this->path . "level.dat");
     @unlink($this->path . "level.dat_old");
     @unlink($this->path . "player.dat");
     @unlink($this->path . "entities.dat");
     @unlink($this->path . "chunks.dat");
     @unlink($this->path . "chunks.dat.gz");
     @unlink($this->path . "tiles.dat");
     unset($chunks, $level, $entities, $tiles, $nbt);
     return true;
 }
Ejemplo n.º 21
0
 public function readChunk($x, $z, $generate = true, $forward = false)
 {
     $index = self::getChunkOffset($x, $z);
     if ($index < 0 or $index >= 4096) {
         return null;
     }
     $this->lastUsed = time();
     if (!$this->isChunkGenerated($index)) {
         if ($generate === true) {
             //Allocate space
             $this->locationTable[$index][0] = ++$this->lastSector;
             $this->locationTable[$index][1] = 1;
             fseek($this->filePointer, $this->locationTable[$index][0] << 12);
             fwrite($this->filePointer, str_pad(pack("N", 0) . chr(self::COMPRESSION_ZLIB), 4096, "", STR_PAD_RIGHT));
             $this->writeLocationIndex($index);
         } else {
             return null;
         }
     }
     fseek($this->filePointer, $this->locationTable[$index][0] << 12);
     $length = PHP_INT_SIZE === 8 ? unpack("N", fread($this->filePointer, 4))[1] << 32 >> 32 : unpack("N", fread($this->filePointer, 4))[1];
     $compression = ord(fgetc($this->filePointer));
     if ($length <= 0 or $length > self::MAX_SECTOR_LENGTH) {
         //Not yet generated / corrupted
         if ($length >= self::MAX_SECTOR_LENGTH) {
             $this->locationTable[$index][0] = ++$this->lastSector;
             $this->locationTable[$index][1] = 1;
             MainLogger::getLogger()->error("Corrupted chunk header detected");
         }
         $this->generateChunk($x, $z);
         fseek($this->filePointer, $this->locationTable[$index][0] << 12);
         $length = PHP_INT_SIZE === 8 ? unpack("N", fread($this->filePointer, 4))[1] << 32 >> 32 : unpack("N", fread($this->filePointer, 4))[1];
         $compression = ord(fgetc($this->filePointer));
     }
     if ($length > $this->locationTable[$index][1] << 12) {
         //Invalid chunk, bigger than defined number of sectors
         MainLogger::getLogger()->error("Corrupted bigger chunk detected");
         $this->locationTable[$index][1] = $length >> 12;
         $this->writeLocationIndex($index);
     } elseif ($compression !== self::COMPRESSION_ZLIB and $compression !== self::COMPRESSION_GZIP) {
         MainLogger::getLogger()->error("Invalid compression type");
         return null;
     }
     $chunk = Chunk::fromBinary(fread($this->filePointer, $length - 1), $this->levelProvider);
     if ($chunk instanceof Chunk) {
         return $chunk;
     } elseif ($forward === false) {
         MainLogger::getLogger()->error("Corrupted chunk detected");
         $this->generateChunk($x, $z);
         return $this->readChunk($x, $z, $generate, true);
     } else {
         return null;
     }
 }
Ejemplo n.º 22
0
 /**
  * @param $content
  */
 private function parseProperties($content)
 {
     if (preg_match_all('/([a-zA-Z0-9\\-_\\.]*)=([^\\r\\n]*)/u', $content, $matches) > 0) {
         //false or 0 matches
         foreach ($matches[1] as $i => $k) {
             $v = trim($matches[2][$i]);
             switch (strtolower($v)) {
                 case "on":
                 case "true":
                 case "yes":
                     $v = true;
                     break;
                 case "off":
                 case "false":
                 case "no":
                     $v = false;
                     break;
             }
             if (isset($this->config[$k])) {
                 MainLogger::getLogger()->debug("[Config] Repeated property " . $k . " on file " . $this->file);
             }
             $this->config[$k] = $v;
         }
     }
 }
Ejemplo n.º 23
0
 public function __construct(bool $useJson = false)
 {
     $this->registerBrewingStand();
     if ($useJson) {
         // load recipes from src/pocketmine/recipes.json
         $recipes = new Config(Server::getInstance()->getFilePath() . "src/pocketmine/resources/recipes.json", Config::JSON, []);
         MainLogger::getLogger()->Info("Loading recipes...");
         foreach ($recipes->getAll() as $recipe) {
             switch ($recipe["Type"]) {
                 case 0:
                     // TODO: handle multiple result items
                     if (count($recipe["Result"]) == 1) {
                         $first = $recipe["Result"][0];
                         $result = new ShapelessRecipe(Item::get($first["ID"], $first["Damage"], $first["Count"]));
                         foreach ($recipe["Ingredients"] as $ingredient) {
                             $result->addIngredient(Item::get($ingredient["ID"], $ingredient["Damage"], $ingredient["Count"]));
                         }
                         $this->registerRecipe($result);
                     }
                     break;
                 case 1:
                     // TODO: handle multiple result items
                     if (count($recipe["Result"]) == 1) {
                         $first = $recipe["Result"][0];
                         $result = new ShapedRecipeFromJson(Item::get($first["ID"], $first["Damage"], $first["Count"]), $recipe["Height"], $recipe["Width"]);
                         $shape = array_chunk($recipe["Ingredients"], $recipe["Width"]);
                         foreach ($shape as $y => $row) {
                             foreach ($row as $x => $ingredient) {
                                 $result->addIngredient($x, $y, Item::get($ingredient["ID"], $ingredient["Damage"] < 0 ? null : $ingredient["Damage"], $ingredient["Count"]));
                             }
                         }
                         $this->registerRecipe($result);
                     }
                     break;
                 case 2:
                     $result = $recipe["Result"];
                     $resultItem = Item::get($result["ID"], $result["Damage"], $result["Count"]);
                     $this->registerRecipe(new FurnaceRecipe($resultItem, Item::get($recipe["Ingredients"], 0, 1)));
                     break;
                 case 3:
                     $result = $recipe["Result"];
                     $resultItem = Item::get($result["ID"], $result["Damage"], $result["Count"]);
                     $this->registerRecipe(new FurnaceRecipe($resultItem, Item::get($recipe["Ingredients"]["ID"], $recipe["Ingredients"]["Damage"], 1)));
                     break;
                 default:
                     break;
             }
         }
     } else {
         $this->registerStonecutter();
         $this->registerFurnace();
         $this->registerDyes();
         $this->registerIngots();
         $this->registerTools();
         $this->registerWeapons();
         $this->registerArmor();
         $this->registerFood();
         $this->registerBrewingStand();
         $this->registerRecipe((new ShapedRecipe(Item::get(Item::CLAY_BLOCK, 0, 1), "X"))->setIngredient("X", Item::get(Item::CLAY, 0, 4)));
         $this->registerRecipe((new ShapedRecipe(Item::get(Item::WORKBENCH, 0, 1), "XX", "XX"))->setIngredient("X", Item::get(Item::WOODEN_PLANK, null)));
         $this->registerRecipe((new ShapedRecipe(Item::get(Item::GLOWSTONE_BLOCK, 0, 1), "XX", "XX"))->setIngredient("X", Item::get(Item::GLOWSTONE_DUST, 0, 4)));
         $this->registerRecipe((new ShapedRecipe(Item::get(Item::LIT_PUMPKIN, 0, 1), "X ", "Y "))->setIngredient("X", Item::get(Item::PUMPKIN, 0, 1))->setIngredient("Y", Item::get(Item::TORCH, 0, 1)));
         $this->registerRecipe((new ShapedRecipe(Item::get(Item::SNOW_BLOCK, 0, 1), "XX", "XX"))->setIngredient("X", Item::get(Item::SNOWBALL)));
         $this->registerRecipe((new ShapedRecipe(Item::get(Item::SNOW_LAYER, 0, 6), "X"))->setIngredient("X", Item::get(Item::SNOW_BLOCK, 0, 3)));
         $this->registerRecipe((new ShapedRecipe(Item::get(Item::STICK, 0, 4), "X ", "X "))->setIngredient("X", Item::get(Item::WOODEN_PLANK, null)));
         $this->registerRecipe((new ShapedRecipe(Item::get(Item::STONECUTTER, 0, 1), "XX", "XX"))->setIngredient("X", Item::get(Item::COBBLESTONE)));
         $this->registerRecipe((new ShapedRecipe(Item::get(Item::WOODEN_PLANK, Planks::OAK, 4), "X"))->setIngredient("X", Item::get(Item::WOOD, Wood::OAK, 1)));
         $this->registerRecipe((new ShapedRecipe(Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 4), "X"))->setIngredient("X", Item::get(Item::WOOD, Wood::SPRUCE, 1)));
         $this->registerRecipe((new ShapedRecipe(Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 4), "X"))->setIngredient("X", Item::get(Item::WOOD, Wood::BIRCH, 1)));
         $this->registerRecipe((new ShapedRecipe(Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 4), "X"))->setIngredient("X", Item::get(Item::WOOD, Wood::JUNGLE, 1)));
         $this->registerRecipe((new ShapedRecipe(Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 4), "X"))->setIngredient("X", Item::get(Item::WOOD2, Wood2::ACACIA, 1)));
         $this->registerRecipe((new ShapedRecipe(Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 4), "X"))->setIngredient("X", Item::get(Item::WOOD2, Wood2::DARK_OAK, 1)));
         $this->registerRecipe((new ShapedRecipe(Item::get(Item::WOOL, 0, 1), "XX", "XX"))->setIngredient("X", Item::get(Item::STRING, 0, 4)));
         $this->registerRecipe((new ShapedRecipe(Item::get(Item::TORCH, 0, 4), "C ", "S"))->setIngredient("C", Item::get(Item::COAL, 0, 1))->setIngredient("S", Item::get(Item::STICK, 0, 1)));
         $this->registerRecipe((new ShapedRecipe(Item::get(Item::TORCH, 0, 4), "C ", "S"))->setIngredient("C", Item::get(Item::COAL, 1, 1))->setIngredient("S", Item::get(Item::STICK, 0, 1)));
         $this->registerRecipe((new ShapedRecipe(Item::get(Item::SUGAR, 0, 1), "S"))->setIngredient("S", Item::get(Item::SUGARCANE, 0, 1)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::BED, 0, 1), "WWW", "PPP"))->setIngredient("W", Item::get(Item::WOOL, null, 3))->setIngredient("P", Item::get(Item::WOODEN_PLANK, null, 3)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::CHEST, 0, 1), "PPP", "P P", "PPP"))->setIngredient("P", Item::get(Item::WOODEN_PLANK, null, 8)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, 0, 3), "PSP", "PSP"))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::OAK, 4)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, Planks::SPRUCE, 3), "PSP", "PSP"))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 4)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, Planks::BIRCH, 3), "PSP", "PSP"))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 4)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, Planks::JUNGLE, 3), "PSP", "PSP"))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 4)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, Planks::ACACIA, 3), "PSP", "PSP"))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 4)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, Planks::DARK_OAK, 3), "PSP", "PSP"))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 4)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE, 0, 1), "SPS", "SPS"))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::OAK, 2)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE_SPRUCE, 0, 1), "SPS", "SPS"))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 2)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE_BIRCH, 0, 1), "SPS", "SPS"))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 2)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE_JUNGLE, 0, 1), "SPS", "SPS"))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 2)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE_DARK_OAK, 0, 1), "SPS", "SPS"))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 2)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE_ACACIA, 0, 1), "SPS", "SPS"))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 2)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FURNACE, 0, 1), "CCC", "C C", "CCC"))->setIngredient("C", Item::get(Item::COBBLESTONE, 0, 8)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::GLASS_PANE, 0, 16), "GGG", "GGG"))->setIngredient("G", Item::get(Item::GLASS, 0, 6)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::LADDER, 0, 2), "S S", "SSS", "S S"))->setIngredient("S", Item::get(Item::STICK, 0, 7)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::NETHER_REACTOR, 0, 1), "IDI", "IDI", "IDI"))->setIngredient("D", Item::get(Item::DIAMOND, 0, 3))->setIngredient("I", Item::get(Item::IRON_INGOT, 0, 6)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::TRAPDOOR, 0, 2), "PPP", "PPP"))->setIngredient("P", Item::get(Item::WOODEN_PLANK, null, 6)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOODEN_DOOR, 0, 1), "PP", "PP", "PP"))->setIngredient("P", Item::get(Item::WOODEN_PLANK, null, 6)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::BIRCH_DOOR, 0, 1), "PP", "PP", "PP"))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 6)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::SPRUCE_DOOR, 0, 1), "PP", "PP", "PP"))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 6)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::JUNGLE_DOOR, 0, 1), "PP", "PP", "PP"))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 6)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::ACACIA_DOOR, 0, 1), "PP", "PP", "PP"))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 6)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::DARK_OAK_DOOR, 0, 1), "PP", "PP", "PP"))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 6)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOODEN_STAIRS, 0, 4), "  P", " PP", "PPP"))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::OAK, 6)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOOD_SLAB, Planks::OAK, 6), "PPP"))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::OAK, 3)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::SPRUCE_WOOD_STAIRS, 0, 4), "  P", " PP", "PPP"))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 6)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOOD_SLAB, Planks::SPRUCE, 6), "PPP"))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 3)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::BIRCH_WOOD_STAIRS, 0, 4), "  P", " PP", "PPP"))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 6)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOOD_SLAB, Planks::BIRCH, 6), "PPP"))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 3)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::JUNGLE_WOOD_STAIRS, 0, 4), "P", "PP", "PPP"))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 6)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOOD_SLAB, Planks::JUNGLE, 6), "PPP"))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 3)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::ACACIA_WOOD_STAIRS, 0, 4), "  P", " PP", "PPP"))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 6)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOOD_SLAB, Planks::ACACIA, 6), "PPP"))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 3)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::DARK_OAK_WOOD_STAIRS, 0, 4), "  P", " PP", "PPP"))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 6)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOOD_SLAB, Planks::DARK_OAK, 6), "PPP"))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 3)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::BUCKET, 0, 1), "I I", " I"))->setIngredient("I", Item::get(Item::IRON_INGOT, 0, 3)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::CLOCK, 0, 1), " G", "GR", " G"))->setIngredient("G", Item::get(Item::GOLD_INGOT, 0, 4))->setIngredient("R", Item::get(Item::REDSTONE_DUST, 0, 1)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::COMPASS, 0, 1), " I ", "IRI", " I"))->setIngredient("I", Item::get(Item::IRON_INGOT, 0, 4))->setIngredient("R", Item::get(Item::REDSTONE_DUST, 0, 1)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::TNT, 0, 1), "GSG", "SGS", "GSG"))->setIngredient("G", Item::get(Item::GUNPOWDER, 0, 5))->setIngredient("S", Item::get(Item::SAND, null, 4)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::BOWL, 0, 4), "P P", " P"))->setIngredient("P", Item::get(Item::WOODEN_PLANKS, null, 3)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::MINECART, 0, 1), "I I", "III"))->setIngredient("I", Item::get(Item::IRON_INGOT, 0, 5)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::BOOK, 0, 1), "P P", " P "))->setIngredient("P", Item::get(Item::PAPER, 0, 3)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::BOOKSHELF, 0, 1), "PBP", "PBP", "PBP"))->setIngredient("P", Item::get(Item::WOODEN_PLANK, null, 6))->setIngredient("B", Item::get(Item::BOOK, 0, 3)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::PAINTING, 0, 1), "SSS", "SWS", "SSS"))->setIngredient("S", Item::get(Item::STICK, 0, 8))->setIngredient("W", Item::get(Item::WOOL, null, 1)));
         $this->registerRecipe((new ShapedRecipe(Item::get(Item::PAPER, 0, 3), "SS", "S"))->setIngredient("S", Item::get(Item::SUGARCANE, 0, 3)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::SIGN, 0, 3), "PPP", "PPP", " S"))->setIngredient("S", Item::get(Item::STICK, 0, 1))->setIngredient("P", Item::get(Item::WOODEN_PLANKS, null, 6)));
         //TODO: check if it gives one sign or three
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::IRON_BARS, 0, 16), "III", "III", "III"))->setIngredient("I", Item::get(Item::IRON_INGOT, 0, 9)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::GLASS_BOTTLE, 0, 3), "G G", " G ", "   "))->setIngredient("G", Item::get(Item::GLASS, 0, 3)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOODEN_PRESSURE_PLATE, 0, 1), "   ", "   ", "XX "))->setIngredient("X", Item::get(Item::WOODEN_PLANK, null, 2)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::HEAVY_WEIGHTED_PRESSURE_PLATE, 0, 1), "   ", "XX ", "   "))->setIngredient("X", Item::get(Item::IRON_INGOT, 0, 2)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::LIGHT_WEIGHTED_PRESSURE_PLATE, 0, 1), "   ", "XX ", "   "))->setIngredient("X", Item::get(Item::GOLD_INGOT, 0, 2)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::STONE_PRESSURE_PLATE, 0, 1), "   ", "XX ", "   "))->setIngredient("X", Item::get(Item::STONE, 0, 2)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::INACTIVE_REDSTONE_LAMP, 0, 1), " R ", "RGR", " R "))->setIngredient("R", Item::get(Item::REDSTONE, 0, 4))->setIngredient("G", Item::get(Item::GLOWSTONE_BLOCK, 0, 1)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::REDSTONE_TORCH, 0, 1), "   ", " R ", " S "))->setIngredient("R", Item::get(Item::REDSTONE, 0, 1))->setIngredient("S", Item::get(Item::STICK, 0, 1)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOODEN_BUTTON, 0, 1), "   ", " X ", "   "))->setIngredient("X", Item::get(Item::WOODEN_PLANK, null, 1)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::STONE_BUTTON, 0, 1), "   ", " X ", "   "))->setIngredient("X", Item::get(Item::COBBLESTONE, 0, 1)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::LEVER, 0, 1), "   ", " X ", " Y "))->setIngredient("X", Item::get(Item::STICK, 0, 1))->setIngredient("Y", Item::get(Item::COBBLESTONE, 0, 1)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::COBBLESTONE_STAIRS, 0, 4), "P  ", "PP ", "PPP"))->setIngredient("P", Item::get(Item::COBBLESTONE, 0, 6)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::STONE_BRICK_STAIRS, 0, 4), "P  ", "PP ", "PPP"))->setIngredient("P", Item::get(Item::STONE_BRICK, 0, 6)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::SLAB, 0, 6), "   ", "PPP"))->setIngredient("P", Item::get(Item::STONE, '', 3)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::SLAB, 5, 6), "   ", "PPP"))->setIngredient("P", Item::get(Item::STONE_BRICK, '', 3)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::STONE_BRICK, 3, 1), "   ", "PP "))->setIngredient("P", Item::get(Item::SLAB, 5, 2)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::SLAB, 1, 6), "   ", "PPP"))->setIngredient("P", Item::get(Item::SANDSTONE, 0, 3)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::SANDSTONE, 1, 1), "   ", "PP "))->setIngredient("P", Item::get(Item::SLAB, 1, 2)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::STONE_BRICK, 0, 4), "XX ", "XX "))->setIngredient("X", Item::get(Item::STONE, '', 4)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::QUARTZ_BLOCK, 0, 1), "XX ", "XX "))->setIngredient("X", Item::get(Item::QUARTZ, 0, 4)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::BRICK_STAIRS, 0, 4), "P  ", "PP ", "PPP"))->setIngredient("P", Item::get(Item::BRICKS_BLOCK, 0, 6)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::BRICKS_BLOCK, 0, 1), "XX ", "XX "))->setIngredient("X", Item::get(Item::BRICK, 0, 4)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::SLAB, 4, 6), "   ", "PPP"))->setIngredient("P", Item::get(Item::BRICKS_BLOCK, 0, 3)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::QUARTZ_BLOCK, 1, 1), "   ", "PP "))->setIngredient("P", Item::get(Item::SLAB, 6, 2)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::SLAB, 3, 6), "   ", "PPP"))->setIngredient("P", Item::get(Item::COBBLESTONE, 0, 3)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::COBBLESTONE, 0, 1), "   ", "PP "))->setIngredient("P", Item::get(Item::SLAB, 3, 2)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::COBBLESTONE_WALL, 0, 6), "PPP", "PPP"))->setIngredient("P", Item::get(Item::COBBLESTONE, 0, 6)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::COBBLESTONE_WALL, 1, 6), "PPP", "PPP"))->setIngredient("P", Item::get(Item::MOSS_STONE, 0, 6)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::NETHER_BRICKS, 0, 1), "XX ", "XX "))->setIngredient("X", Item::get(Item::NETHER_BRICK, 0, 4)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::NETHER_BRICKS_STAIRS, 0, 4), "XXX", "XXX"))->setIngredient("X", Item::get(Item::NETHER_BRICKS, 0, 6)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::QUARTZ_BLOCK, 2, 2), "   ", "PP "))->setIngredient("P", Item::get(Item::QUARTZ_BLOCK, 0, 2)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::SLAB, 6, 6), "   ", "PPP"))->setIngredient("P", Item::get(Item::QUARTZ_BLOCK, 0, 3)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::SANDSTONE_STAIRS, 0, 4), "P  ", "PP ", "PPP"))->setIngredient("P", Item::get(Item::SANDSTONE, 0, 6)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::SANDSTONE, 0, 1), "XX ", "XX "))->setIngredient("X", Item::get(Item::SAND, 0, 4)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::SANDSTONE, 2, 4), "XX ", "XX "))->setIngredient("X", Item::get(Item::SANDSTONE, 0, 4)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::STONE, Stone::POLISHED_GRANITE, 4), "XX ", "XX "))->setIngredient("X", Item::get(Item::STONE, Stone::GRANITE, 4)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::STONE, Stone::POLISHED_DIORITE, 4), "XX ", "XX "))->setIngredient("X", Item::get(Item::STONE, Stone::DIORITE, 4)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::STONE, Stone::POLISHED_ANDESITE, 4), "XX ", "XX "))->setIngredient("X", Item::get(Item::STONE, Stone::ANDESITE, 4)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::STONE_BRICK, 1, 1), "   ", " Y ", " X "))->setIngredient("X", Item::get(Item::STONE_BRICK, 0, 1))->setIngredient("Y", Item::get(Item::VINES, 0, 1)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::STONE, Stone::GRANITE, 1), "   ", " Y ", " X "))->setIngredient("X", Item::get(Item::STONE, Stone::DIORITE, 1))->setIngredient("Y", Item::get(Item::QUARTZ, 0, 1)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::STONE, Stone::DIORITE, 2), "YY ", "XX ", "   "))->setIngredient("X", Item::get(Item::COBBLESTONE, 0, 2))->setIngredient("Y", Item::get(Item::QUARTZ, 0, 2)));
         $this->registerRecipe((new BigShapedRecipe(Item::get(Item::STONE, Stone::ANDESITE, 2), "   ", " Y ", " X "))->setIngredient("X", Item::get(Item::COBBLESTONE, 0, 1))->setIngredient("Y", Item::get(Item::STONE, Stone::DIORITE, 1)));
     }
 }