isCreativeItem() public static method

public static isCreativeItem ( Item $item ) : boolean
$item Item
return boolean
Example #1
0
 public function registerItem($id, $class)
 {
     Item::$list[$id] = $class;
     if (Item::isCreativeItem($item = new $class())) {
         Item::addCreativeItem($item);
     }
 }
 public function registerBlock($id, $class)
 {
     Block::$list[$id] = $class;
     if ($id < 255) {
         Item::$list[$id] = $class;
         if (!Item::isCreativeItem($item = Item::get($id))) {
             Item::addCreativeItem($item);
         }
     }
     for ($data = 0; $data < 16; ++$data) {
         Block::$fullList[$id << 4 | $data] = new $class($data);
     }
 }
Example #3
0
 public function onEnable()
 {
     $path = $this->getServer()->getDataPath() . "plugins/EntityManager/";
     if (!is_dir($path)) {
         mkdir($path);
     }
     $getData = function ($ar, $key, $default) {
         $vars = explode(".", $key);
         $base = array_shift($vars);
         if (!isset($ar[$base])) {
             return $default;
         }
         $base = $ar[$base];
         while (count($vars) > 0) {
             $baseKey = array_shift($vars);
             if (!is_array($base) or !isset($base[$baseKey])) {
                 return $default;
             }
             $base = $base[$baseKey];
         }
         return $base;
     };
     $data = [];
     if (file_exists($path . "config.yml")) {
         $data = yaml_parse($this->yaml($path . "config.yml"));
     }
     self::$data = ["entity" => ["maximum" => $getData($data, "entity.maximum", 50), "explode" => $getData($data, "entity.explode", true)], "spawn" => ["rand" => $getData($data, "spawn.rand", "1/5"), "tick" => $getData($data, "spawn.tick", 150)], "autospawn" => ["turn-on" => $getData($data, "autospawn.turn-on", $getData($data, "spawn.auto", true)), "radius" => $getData($data, "autospawn.radius", $getData($data, "spawn.radius", 25))]];
     file_put_contents($path . "config.yml", yaml_emit(self::$data, YAML_UTF8_ENCODING));
     if (file_exists($path . "SpawnerData.yml")) {
         self::$spawn = yaml_parse($this->yaml($path . "SpawnerData.yml"));
         unlink($path . "SpawnerData.yml");
     } elseif (file_exists($path . "spawner.yml")) {
         self::$spawn = yaml_parse($this->yaml($path . "spawner.yml"));
     } else {
         self::$spawn = [];
         file_put_contents($path . "spawner.yml", yaml_emit([], YAML_UTF8_ENCODING));
     }
     if (file_exists($path . "drops.yml")) {
         self::$drops = yaml_parse($this->yaml($path . "drops.yml"));
     } else {
         self::$drops = [Zombie::NETWORK_ID => [], Creeper::NETWORK_ID => []];
         file_put_contents($path . "drops.yml", yaml_emit([], YAML_UTF8_ENCODING));
     }
     foreach (self::$knownEntities as $id => $name) {
         if (!is_numeric($id)) {
             continue;
         }
         $item = Item::get(Item::SPAWN_EGG, $id);
         if (!Item::isCreativeItem($item)) {
             Item::addCreativeItem($item);
         }
     }
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     $this->getServer()->getLogger()->info(TextFormat::GOLD . "[EntityManager]Plugin has been enabled");
     $this->getServer()->getScheduler()->scheduleRepeatingTask(new UpdateEntityTask($this), 1);
     $this->getServer()->getScheduler()->scheduleRepeatingTask(new SpawnEntityTask($this), $this->getData("spawn.tick"));
 }