CustomiesDevs / Customies

A PocketMine-MP plugin that implements support for custom blocks, items and entities.
MIT License
107 stars 48 forks source link

Null ☠️ #121

Open GabBiswajit opened 4 months ago

GabBiswajit commented 4 months ago

While attempting to register an emerald chestplate item using the CustomiesItemFactory class, the following code snippet is used:

register = CustomiesItemFactory::getInstance()->registerItem(Emerald_Chestplate::class, "armorsapi:emerald_chestplate", "emerald_chestplate");

Subsequently, an attempt is made to parse the string "emerald_chestplate" into an item using the StringToItemParser class. However, this operation is returning null.

Please address this issue. Thank you! 🥲

GabBiswajit commented 4 months ago

I use $item->getVanillaName() and i get emerald_chestplate so vanilla name use in StringToItemParser that's why i set emerald_chestplate if I need to use armorsapi:emerald_chestplate than can you tell how i get it ?

ShadowMikado commented 4 months ago

HI, you can use StringToItemParser::getInstance()->registerAlias()

GabBiswajit commented 2 months ago

@ShadowMikado it's work like this : ?


$name = $item->getVanillaName();
StringToItemParser::getInstance()->registerAlias($name);
ShadowMikado commented 2 months ago
public function registerAlias(string $existing, string $alias) : void{

https://github.com/pmmp/PocketMine-MP/blob/50e2c469a547a16a23b2dc691e70a51d34e29395/src/utils/StringToTParser.php#L64