PocketMine-MP 5.37.1 git-cef37e7835c666594588f957a47b27d521c6a58e
Loading...
Searching...
No Matches
CommandParameter.php
1<?php
2
3/*
4 * This file is part of BedrockProtocol.
5 * Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
6 *
7 * BedrockProtocol is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 */
12
13declare(strict_types=1);
14
15namespace pocketmine\network\mcpe\protocol\types\command;
16
18 public const FLAG_FORCE_COLLAPSE_ENUM = 0x1;
19 public const FLAG_HAS_ENUM_CONSTRAINT = 0x2;
20
21 public string $paramName;
22 public int $paramType;
23 public bool $isOptional;
24 public int $flags = 0; //shows enum name if 1, always zero except for in /gamerule command
25 public CommandHardEnum|CommandSoftEnum|null $enum = null;
26 public ?string $postfix = null;
27
28 private static function baseline(string $name, int $type, int $flags, bool $optional) : self{
29 $result = new self;
30 $result->paramName = $name;
31 $result->paramType = $type;
32 $result->flags = $flags;
33 $result->isOptional = $optional;
34 return $result;
35 }
36
37 public static function standard(string $name, int $type, int $flags = 0, bool $optional = false) : self{
38 return self::baseline($name, $type, $flags, $optional);
39 }
40
41 public static function postfixed(string $name, string $postfix, int $flags = 0, bool $optional = false) : self{
42 $result = self::baseline($name, 0, $flags, $optional);
43 $result->postfix = $postfix;
44 return $result;
45 }
46
47 public static function enum(string $name, CommandHardEnum $enum, int $flags, bool $optional = false) : self{
48 $result = self::baseline($name, 0, $flags, $optional);
49 $result->enum = $enum;
50 return $result;
51 }
52
53 public static function softEnum(string $name, CommandSoftEnum $enum, int $flags, bool $optional = false) : self{
54 $result = self::baseline($name, 0, $flags, $optional);
55 $result->enum = $enum;
56 return $result;
57 }
58
62 public static function allFields(string $paramName, int $paramType, bool $isOptional, int $flags, CommandHardEnum|CommandSoftEnum|null $enum, ?string $postfix) : self{
63 $result = new self;
64 $result->paramName = $paramName;
65 $result->paramType = $paramType;
66 $result->isOptional = $isOptional;
67 $result->flags = $flags;
68 $result->enum = $enum;
69 $result->postfix = $postfix;
70 return $result;
71 }
72}
static allFields(string $paramName, int $paramType, bool $isOptional, int $flags, CommandHardEnum|CommandSoftEnum|null $enum, ?string $postfix)