How Can Get Item id from item name

Discussion in 'Plugin Help' started by ResooTR43, Jul 5, 2021.

  1. ResooTR43

    ResooTR43 Spider

    I want to get the id of the item from the item name. For example, the sign says Stone. I want to get the id of this item by pulling this text from the sign. i make SignShop. how can I do?
  2. Axon

    Axon Zombie

    You can use the ItemFactory static function FromString() to get the Item's Id.
    Example accepted formats:
    • diamond_pickaxe:5
    • minecraft:string
    • 351:4 (lapis lazuli ID:meta)
    If multiple item instances are to be created, their identifiers must be comma-separated, for example: diamond_pickaxe,wooden_shovel:18,iron_ingot

    pocketmine\item\ItemFactory::fromString("minecraft:diamond_pickaxe")->getId() // Get's the item then get's the item's id.
    Agent likes this.
  3. ResooTR43

    ResooTR43 Spider

    but this can cause some problems. I don't want it to say "diamond_pickaxe" on the sign. I want it to say "Diamond Pickaxe"
    Line0 - [SignShop]
    Line1 - Diamond Pickaxe
    Line2 - 1 Piece
    Line3 - 100 Dolars
    I want it that way
  4. Axon

    Axon Zombie

    You can use str_replace() to change the space to underscore, then lowercase the string
    Agent and NTT like this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.