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

Wrong

Comments in 'Plugin Development' started by XxD7omGamer, Jan 17, 2016.

  1. XxD7omGamer
    Offline

    XxD7omGamer New Member

    Joined:
    Jun 28, 2015
    Posts:
    38
    Minecraft User:
    XxD7omGamer
    What's wrong
    This code it's doesn't work
    PHP:
        public function Item(PlayerItemHeldEvent $event){
            
    $player $event->getPlayer();      
            
    $it $event->getItem()->getID();      
            if(
    $it == 288){      
                
    $player->setNameTag("§b§lLegend§cPvP §7| §r§e".$player->getName());
            }
        }
    Last edited: Jan 17, 2016
  2. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    You've only have 2 closing }
  3. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    Sorry, misread.
    Vaivez66 likes this.
  4. HotFireyDeath
    Offline

    HotFireyDeath Notable Member Plugin Developer

    Joined:
    Mar 19, 2015
    Posts:
    328
    Plugins:
    1
    Minecraft User:
    HotFireyDeath
    Try getId() instead of getID().
    Also, try === since they are of the same type.
    applqpak and Vaivez66 like this.
  5. XxD7omGamer
    Offline

    XxD7omGamer New Member

    Joined:
    Jun 28, 2015
    Posts:
    38
    Minecraft User:
    XxD7omGamer
    This ?
    PHP:
    public function Item(PlayerItemHeldEvent $event){
            
    $player $event->getPlayer();      
            
    $it $event->getItem()->getID();      
            if(
    $it == getId()->288){      
                
    $player->setNameTag("§b§lLegend§cPvP §7| §r§e".$player->getName());
            }
        }
  6. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    What @HotFireyDeath meant is
    PHP:
    public function Item(PlayerItemHeldEvent $event){
        
    $player $event->getPlayer();
        
    $it $event->getItem()->getId(); //here
        
    if($it === 288){ //here
            
    $player->setNameTag("§b§lLegend§cPvP §7| §r§e".$player->getName());
        }
    }
  7. XxD7omGamer
    Offline

    XxD7omGamer New Member

    Joined:
    Jun 28, 2015
    Posts:
    38
    Minecraft User:
    XxD7omGamer
    Thanks i love you !
  8. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Instead of 288 you should use Item::THE_ITEM_YOU_WANT
    HotFireyDeath and PEMapModder like this.
  9. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    That's the same.. Item::ITEMHERE returns the ID.
    Vaivez66 likes this.
  10. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    What if the ID's will change in future? Will you change all ID's in all your plugins? Instead of using a static one use this method.
    @PEMapModder
    PEMapModder likes this.
  11. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Ugh, misread it. I somehow thought you mean change Item::ITEM to the ID..

Share This Page

Advertisement