PocketMine-MP 5.15.1 git-be6754494fdbbb9dd57c058ba0e33a4a78c4581f
PaintingMotive.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
22declare(strict_types=1);
23
24namespace pocketmine\entity\object;
25
27 private static bool $initialized = false;
28
30 protected static array $motives = [];
31
32 public static function init() : void{
33 self::$initialized = true;
34 foreach([
35 new PaintingMotive(1, 1, "Alban"),
36 new PaintingMotive(1, 1, "Aztec"),
37 new PaintingMotive(1, 1, "Aztec2"),
38 new PaintingMotive(1, 1, "Bomb"),
39 new PaintingMotive(1, 1, "Kebab"),
40 new PaintingMotive(1, 1, "Plant"),
41 new PaintingMotive(1, 1, "Wasteland"),
42 new PaintingMotive(1, 2, "Graham"),
43 new PaintingMotive(1, 2, "Wanderer"),
44 new PaintingMotive(2, 1, "Courbet"),
45 new PaintingMotive(2, 1, "Creebet"),
46 new PaintingMotive(2, 1, "Pool"),
47 new PaintingMotive(2, 1, "Sea"),
48 new PaintingMotive(2, 1, "Sunset"),
49 new PaintingMotive(2, 2, "Bust"),
50 new PaintingMotive(2, 2, "Earth"),
51 new PaintingMotive(2, 2, "Fire"),
52 new PaintingMotive(2, 2, "Match"),
53 new PaintingMotive(2, 2, "SkullAndRoses"),
54 new PaintingMotive(2, 2, "Stage"),
55 new PaintingMotive(2, 2, "Void"),
56 new PaintingMotive(2, 2, "Water"),
57 new PaintingMotive(2, 2, "Wind"),
58 new PaintingMotive(2, 2, "Wither"),
59 new PaintingMotive(4, 2, "Fighters"),
60 new PaintingMotive(4, 3, "DonkeyKong"),
61 new PaintingMotive(4, 3, "Skeleton"),
62 new PaintingMotive(4, 4, "BurningSkull"),
63 new PaintingMotive(4, 4, "Pigscene"),
64 new PaintingMotive(4, 4, "Pointer")
65 ] as $motive){
66 self::registerMotive($motive);
67 }
68 }
69
70 public static function registerMotive(PaintingMotive $motive) : void{
71 if(!self::$initialized){
72 self::init();
73 }
74 self::$motives[$motive->getName()] = $motive;
75 }
76
77 public static function getMotiveByName(string $name) : ?PaintingMotive{
78 if(!self::$initialized){
79 self::init();
80 }
81 return self::$motives[$name] ?? null;
82 }
83
87 public static function getAll() : array{
88 if(!self::$initialized){
89 self::init();
90 }
91 return self::$motives;
92 }
93
94 public function __construct(
95 protected int $width,
96 protected int $height,
97 protected string $name
98 ){}
99
100 public function getName() : string{
101 return $this->name;
102 }
103
104 public function getWidth() : int{
105 return $this->width;
106 }
107
108 public function getHeight() : int{
109 return $this->height;
110 }
111
112 public function __toString() : string{
113 return "PaintingMotive(name: " . $this->getName() . ", height: " . $this->getHeight() . ", width: " . $this->getWidth() . ")";
114 }
115}