PocketMine-MP  1.4 - API 1.10.0
 All Classes Namespaces Functions Variables Pages
Generator.php
1 <?php
2 
3 /*
4  *
5  * ____ _ _ __ __ _ __ __ ____
6  * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7  * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8  * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9  * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * @author PocketMine Team
17  * @link http://www.pocketmine.net/
18  *
19  *
20 */
21 
25 namespace pocketmine\level\generator;
26 
28 
29 abstract class Generator{
30  private static $list = [];
31 
32  public static function addGenerator($object, $name){
33  if(is_subclass_of($object, Generator::class) and !isset(Generator::$list[$name = strtolower($name)])){
34  Generator::$list[$name] = $object;
35 
36  return true;
37  }
38 
39  return false;
40  }
41 
42  public static function getGenerator($name){
43  if(isset(Generator::$list[$name = strtolower($name)])){
44  return Generator::$list[$name];
45  }
46 
47  return Normal::class;
48  }
49 
50  public static function getGeneratorName($class){
51  foreach(Generator::$list as $name => $c){
52  if($c === $class){
53  return $name;
54  }
55  }
56 
57  return "unknown";
58  }
59 
60  public abstract function __construct(array $settings = []);
61 
62  public abstract function init(GenerationChunkManager $level, Random $random);
63 
64  public abstract function generateChunk($chunkX, $chunkZ);
65 
66  public abstract function populateChunk($chunkX, $chunkZ);
67 
68  public abstract function getSettings();
69 
70  public abstract function getName();
71 
72  public abstract function getSpawn();
73 }