mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 01:09:44 +00:00
allow use of any iterable for enum initialization
this allows possible use of generators
This commit is contained in:
parent
44b7239847
commit
a6395c9ac7
@ -57,7 +57,7 @@ final class DyeColor{
|
|||||||
/** @var DyeColor[] */
|
/** @var DyeColor[] */
|
||||||
private static $numericIdMap = [];
|
private static $numericIdMap = [];
|
||||||
|
|
||||||
protected static function setup() : array{
|
protected static function setup() : iterable{
|
||||||
return [
|
return [
|
||||||
new DyeColor("white", "White", 0, new Color(0xf0, 0xf0, 0xf0)),
|
new DyeColor("white", "White", 0, new Color(0xf0, 0xf0, 0xf0)),
|
||||||
new DyeColor("orange", "Orange", 1, new Color(0xf9, 0x80, 0x1d)),
|
new DyeColor("orange", "Orange", 1, new Color(0xf9, 0x80, 0x1d)),
|
||||||
|
@ -46,7 +46,7 @@ final class SkullType{
|
|||||||
/** @var SkullType[] */
|
/** @var SkullType[] */
|
||||||
private static $numericIdMap = [];
|
private static $numericIdMap = [];
|
||||||
|
|
||||||
protected static function setup() : array{
|
protected static function setup() : iterable{
|
||||||
return [
|
return [
|
||||||
new SkullType("skeleton", "Skeleton Skull", 0),
|
new SkullType("skeleton", "Skeleton Skull", 0),
|
||||||
new SkullType("wither_skeleton", "Wither Skeleton Skull", 1),
|
new SkullType("wither_skeleton", "Wither Skeleton Skull", 1),
|
||||||
|
@ -37,7 +37,7 @@ use pocketmine\utils\EnumTrait;
|
|||||||
final class SlabType{
|
final class SlabType{
|
||||||
use EnumTrait;
|
use EnumTrait;
|
||||||
|
|
||||||
protected static function setup() : array{
|
protected static function setup() : iterable{
|
||||||
return [
|
return [
|
||||||
new self("bottom"),
|
new self("bottom"),
|
||||||
new self("top"),
|
new self("top"),
|
||||||
|
@ -46,7 +46,7 @@ final class TreeType{
|
|||||||
/** @var TreeType[] */
|
/** @var TreeType[] */
|
||||||
private static $numericIdMap = [];
|
private static $numericIdMap = [];
|
||||||
|
|
||||||
protected static function setup() : array{
|
protected static function setup() : iterable{
|
||||||
return [
|
return [
|
||||||
new TreeType("oak", "Oak", 0),
|
new TreeType("oak", "Oak", 0),
|
||||||
new TreeType("spruce", "Spruce", 1),
|
new TreeType("spruce", "Spruce", 1),
|
||||||
|
@ -37,7 +37,7 @@ use pocketmine\utils\EnumTrait;
|
|||||||
final class ItemUseResult{
|
final class ItemUseResult{
|
||||||
use EnumTrait;
|
use EnumTrait;
|
||||||
|
|
||||||
protected static function setup() : array{
|
protected static function setup() : iterable{
|
||||||
return [
|
return [
|
||||||
new self("none"),
|
new self("none"),
|
||||||
new self("fail"),
|
new self("fail"),
|
||||||
|
@ -47,7 +47,7 @@ final class GameMode{
|
|||||||
/** @var self[] */
|
/** @var self[] */
|
||||||
protected static $magicNumberMap = [];
|
protected static $magicNumberMap = [];
|
||||||
|
|
||||||
protected static function setup() : array{
|
protected static function setup() : iterable{
|
||||||
return [
|
return [
|
||||||
new self("survival", 0, "Survival", "gameMode.survival", ["s", "0"]),
|
new self("survival", 0, "Survival", "gameMode.survival", ["s", "0"]),
|
||||||
new self("creative", 1, "Creative", "gameMode.creative", ["c", "1"]),
|
new self("creative", 1, "Creative", "gameMode.creative", ["c", "1"]),
|
||||||
|
@ -36,7 +36,7 @@ use pocketmine\utils\EnumTrait;
|
|||||||
final class PluginLoadOrder{
|
final class PluginLoadOrder{
|
||||||
use EnumTrait;
|
use EnumTrait;
|
||||||
|
|
||||||
protected static function setup() : array{
|
protected static function setup() : iterable{
|
||||||
return [
|
return [
|
||||||
new self("startup"),
|
new self("startup"),
|
||||||
new self("postworld")
|
new self("postworld")
|
||||||
|
@ -54,9 +54,9 @@ trait EnumTrait{
|
|||||||
*
|
*
|
||||||
* (This ought to be private, but traits suck too much for that.)
|
* (This ought to be private, but traits suck too much for that.)
|
||||||
*
|
*
|
||||||
* @return self[]
|
* @return self[]|iterable
|
||||||
*/
|
*/
|
||||||
abstract protected static function setup() : array;
|
abstract protected static function setup() : iterable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal Lazy-inits the enum if necessary.
|
* @internal Lazy-inits the enum if necessary.
|
||||||
|
@ -41,7 +41,7 @@ class NoteInstrument{
|
|||||||
__construct as Enum___construct;
|
__construct as Enum___construct;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function setup() : array{
|
protected static function setup() : iterable{
|
||||||
return [
|
return [
|
||||||
new self("piano", 0),
|
new self("piano", 0),
|
||||||
new self("bass_drum", 1),
|
new self("bass_drum", 1),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user