getGeneratorName() public static method

public static getGeneratorName ( $class )
Esempio n. 1
0
 public function onSCommand(CommandSender $c, Command $cc, $scmd, $data, array $args)
 {
     if (count($args) < 1 || count($args) > 4) {
         return false;
     }
     $world = array_shift($args);
     if ($this->owner->getServer()->isLevelGenerated($world)) {
         $c->sendMessage(TextFormat::RED . mc::_("[MW] A world named %1% already exists", $world));
         return true;
     }
     $seed = null;
     $generator = null;
     $opts = [];
     if (isset($args[0])) {
         $seed = intval($args[0]);
     }
     if (isset($args[1])) {
         $generator = Generator::getGenerator($args[1]);
         if (strtolower($args[1]) != Generator::getGeneratorName($generator)) {
             $c->sendMessage(TextFormat::RED . mc::_("[MW] Unknown generator %1%", $args[1]));
             return true;
         }
         $c->sendMessage(TextFormat::GREEN . mc::_("[MW] Using %1%", Generator::getGeneratorName($generator)));
     }
     if (isset($args[2])) {
         $opts = ["preset" => $args[2]];
     }
     $this->owner->getServer()->broadcastMessage(mc::_("[MW] Creating level %1%... (Expect Lag)", $world));
     $this->owner->getServer()->generateLevel($world, $seed, $generator, $opts);
     $this->owner->getServer()->loadLevel($world);
     return true;
 }
Esempio n. 2
0
 public static function generate($path, $name, $seed, $generator, array $options = [])
 {
     @mkdir($path, 0777, true);
     @mkdir($path . "/region", 0777);
     //TODO, add extra details
     $levelData = new Compound("Data", ["hardcore" => new Byte("hardcore", 0), "initialized" => new Byte("initialized", 1), "GameType" => new Int("GameType", 0), "generatorVersion" => new Int("generatorVersion", 1), "SpawnX" => new Int("SpawnX", 128), "SpawnY" => new Int("SpawnY", 70), "SpawnZ" => new Int("SpawnZ", 128), "version" => new Int("version", 19133), "DayTime" => new Int("DayTime", 0), "LastPlayed" => new Long("LastPlayed", microtime(true) * 1000), "RandomSeed" => new Long("RandomSeed", $seed), "SizeOnDisk" => new Long("SizeOnDisk", 0), "Time" => new Long("Time", 0), "generatorName" => new String("generatorName", Generator::getGeneratorName($generator)), "generatorOptions" => new String("generatorOptions", isset($options["preset"]) ? $options["preset"] : ""), "LevelName" => new String("LevelName", $name), "GameRules" => new Compound("GameRules", [])]);
     $nbt = new NBT(NBT::BIG_ENDIAN);
     $nbt->setData(new Compound(null, ["Data" => $levelData]));
     $buffer = $nbt->writeCompressed();
     @file_put_contents($path . "level.dat", $buffer);
 }
Esempio n. 3
0
 public static function generate($path, $name, $seed, $generator, array $options = [])
 {
     if (!file_exists($path)) {
         mkdir($path, 0777, true);
     }
     if (!file_exists($path . "/db")) {
         mkdir($path . "/db", 0777, true);
     }
     //TODO, add extra details
     $levelData = new Compound("", ["hardcore" => new Byte("hardcore", 0), "initialized" => new Byte("initialized", 1), "GameType" => new Int("GameType", 0), "generatorVersion" => new Int("generatorVersion", 1), "SpawnX" => new Int("SpawnX", 128), "SpawnY" => new Int("SpawnY", 70), "SpawnZ" => new Int("SpawnZ", 128), "version" => new Int("version", 19133), "DayTime" => new Int("DayTime", 0), "LastPlayed" => new Long("LastPlayed", microtime(true) * 1000), "RandomSeed" => new Long("RandomSeed", $seed), "SizeOnDisk" => new Long("SizeOnDisk", 0), "Time" => new Long("Time", 0), "RainTime" => new Int("RainTime", 0), "Raining" => new String("Raining", false), "ThunderTime" => new Int("ThunderTime", 0), "Thundering" => new String("Thundering", false), "generatorName" => new String("generatorName", Generator::getGeneratorName($generator)), "generatorOptions" => new String("generatorOptions", isset($options["preset"]) ? $options["preset"] : ""), "LevelName" => new String("LevelName", $name), "GameRules" => new Compound("GameRules", [])]);
     $nbt = new NBT(NBT::LITTLE_ENDIAN);
     $nbt->setData($levelData);
     $buffer = $nbt->write();
     file_put_contents($path . "level.dat", Binary::writeLInt(3) . Binary::writeLInt(strlen($buffer)) . $buffer);
     $db = new \LevelDB($path . "/db");
     $db->close();
 }