PocketMine-MP 5.21.2 git-a6534ecbbbcf369264567d27e5ed70f7f5be9816
Loading...
Searching...
No Matches
pocketmine\item\LegacyStringToItemParser Class Reference
+ Collaboration diagram for pocketmine\item\LegacyStringToItemParser:

Public Member Functions

 __construct (private ItemDataUpgrader $itemDataUpgrader, private ItemDeserializer $itemDeserializer)
 
 addMapping (string $alias, string $id)
 
 getMappings ()
 
 parse (string $input)
 

Protected Member Functions

 reprocess (string $input)
 

Detailed Description

Deprecated
See also
StringToItemParser

This class replaces the functionality that used to be provided by ItemFactory::fromString(), but in a more dynamic way. Avoid using this wherever possible. Unless you need to parse item strings containing meta (e.g. "dye:4", "351:4") or item IDs (e.g. "351"), you should prefer the newer StringToItemParser, which is much more user-friendly, more flexible, and also supports registering custom aliases for any item in any state.

WARNING: This class does NOT support items added during or after PocketMine-MP 5.0.0. Use StringToItemParser for modern items.

Definition at line 56 of file LegacyStringToItemParser.php.

Constructor & Destructor Documentation

◆ __construct()

pocketmine\item\LegacyStringToItemParser::__construct ( private ItemDataUpgrader $itemDataUpgrader,
private ItemDeserializer $itemDeserializer )

Definition at line 84 of file LegacyStringToItemParser.php.

Member Function Documentation

◆ addMapping()

pocketmine\item\LegacyStringToItemParser::addMapping ( string $alias,
string $id )

Definition at line 89 of file LegacyStringToItemParser.php.

◆ getMappings()

pocketmine\item\LegacyStringToItemParser::getMappings ( )
Returns
string[] @phpstan-return array<string, string>

Definition at line 97 of file LegacyStringToItemParser.php.

◆ parse()

pocketmine\item\LegacyStringToItemParser::parse ( string $input)

Tries to parse the specified string into Item types.

Example accepted formats:

  • diamond_pickaxe:5
  • minecraft:string
  • 351:4 (lapis lazuli ID:meta)
Exceptions
LegacyStringToItemParserExceptionif the given string cannot be parsed as an item identifier

Definition at line 111 of file LegacyStringToItemParser.php.

◆ reprocess()

pocketmine\item\LegacyStringToItemParser::reprocess ( string $input)
protected

Definition at line 142 of file LegacyStringToItemParser.php.


The documentation for this class was generated from the following file: