Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Custom Item Names

Comments in 'Plugin Development' started by ImagicalGamer, Mar 23, 2016.

  1. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    This is my current code:
    PHP:
            public function playerItemHeld(PlayerItemHeldEvent $event){
            
    $item $event->getItem();
            
    $player $event->getPlayer();
            if (
    $item instanceof Item){
                switch (
    $item->getId()){
                    case 
    378ETC...
    Do I add $item->setCustomName(NAME)? And would it look like this?
    PHP:
            public function playerItemHeld(PlayerItemHeldEvent $event){
            
    $item $event->getItem();
            
    $player $event->getPlayer();
            if (
    $item instanceof Item){
                    
    $item->setCustomName(TextFormat::GREEN "NAME");
                switch (
    $item->getId()){
                    case 
    378ETC....
    Last edited: Mar 23, 2016
  2. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    So I tried that and it's not changing the name. I could send a tip or a PopUp but there are still a few hundred milliseconds before that would happen and you would see the item's name.
  3. TheDeibo
    Offline

    TheDeibo Notable Member Plugin Developer

    Joined:
    Sep 8, 2014
    Posts:
    692
    Plugins:
    1
    Minecraft User:
    TheDeibo
  4. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    PHP:
    $item $event->getItem()->getId();

  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    He is using the Item object here. Why should he getId()? Please don't post if you don't understand what you are talking about.

Share This Page

Advertisement