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

show item id ingame

Comments in 'Plugin Development' started by mariusbjornor, Aug 5, 2015.

  1. mariusbjornor
    Offline

    mariusbjornor Active Member

    Joined:
    Jan 6, 2015
    Posts:
    109
    Minecraft User:
    MariusB
    Is there a plugin for this or would it be possible to make an easy plugin for show item id when choosing a item for hotbar?

    Im would really appriciate a plugin that shows item id next to item name when you select it for hotbar. That would make my life and probably some others life much easyer when making shops etc.. Takes ages when you need to look up ids on computer etc..
  2. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Not Possible to show item id next to name but it's possible to send popup with id:
    PHP:
    public function onItemHeld(PlayerItemHeldEvent $event){
    $item $event->getItem();
    $player $event->getPlayer();
    if(
    $player->isOp()){ // Lets make it for ops only to not bother other players
    $player->sendPopup($item->getId()." "2);
    return 
    true;
    }
    }
    mariusbjornor likes this.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    1. Use hasPermission instead of isOp
    2. Use (string) instead of ." " to convert an integer into a string.
    3. Just send the name with the ID.
    CraftYourBukkit and hoyinm14mc like this.
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    1. isOp() and done, hasPermission() and register permission.
    2. I was thinking about putting name after id. But as he asked only id i deleted $item->getName().
    3. '2.'
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    isOp is not customizable.
    He wants the ID beside the name. So send them together.
  6. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PHP:
    public function onItemHeld(PlayerItemHeldEvent $event){
    $item $event->getItem();
    $player $event->getPlayer();
    if(
    $player->hasPermission('item.info')){ // Added permissions
    $player->sendPopup($item->getName()."  ".$item->getId().":".$item->getDamage()." x".$item->getCount(), 2); // More info about item that is held
    return true;
    }
    }
    plugin.yml:
    Code:
    permissions:
     items.info:
      default: OP
      description: " "
    
    Last edited: Aug 5, 2015
  7. Asparanc
    Offline

    Asparanc Active Member

    Joined:
    Feb 20, 2015
    Posts:
    210
    Minecraft User:
    Asparanc
    Something wrong :

    Code:
    Error: syntax error, unexpected 'public function onItemHeld' (T_STRING), expecting function (T_FUNCTION)
    File: /Aventcube-Server-master/src/AventCube/Main
    Line: 482
    Type: E_PARSE
    
    THIS CRASH WAS CAUSED BY A PLUGIN
    
    Code:
    [473]    
    [474]     public function onBlockPlace(BlockPlaceEvent $event){
    [475]         $player = $event->getPlayer()->getName();
    [476] if ($this->login[$player]<2){
    [477] $event->setCancelled(true);
    [478] }
    [479]     }
    [480]    
    [481]    
    [482]     public function onItemHeld(PlayerItemHeldEvent $event){
    [483] $item = $event->getItem();
    [484] $player = $event->getPlayer();
    [485] if($player->isOp()){ // Lets make it for ops only to not bother other players
    [486] $player->sendPopup($item->getId()." ", 2);
    [487] return true;
    [488] }
    [489] }
    [490]
    [491] 
  8. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Please rewrite code by hand it sometimes happens of copy and paste and use my last posted code
  9. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PHP:
     $sender->sendMessage("[Iditem]You are holding $inHandname ID $inHandid meta $inHandmeta");
    Dumb message
  10. Achak
    Offline

    Achak New Member

    Joined:
    Feb 14, 2015
    Posts:
    32
    Minecraft User:
    Achak_Adhay
    I had this posted then deleted it thinking it wasn't what you where asking for. And it isn't. But you said you wanted it so you wouldn't have to look up item ID's on your computer. This plugin will give you the item ID, name, and meta of the item in the players hand.

    command: /iditem
    https://forums.pocketmine.net/threads/iditem-plugin.10069/#post-103207

    sorry for blowing up your alerts

    If you think that message is dumb, check the message if you put in an argument. I have to update the argument message to just give the regular message even if they put in an argument. I mean, that is the point of the plugin.
    Unless you meant because...and Thanks
    PHP:
      $inHanditem $sender->getInventory()->getItemInHand();
      
    $sender->sendMessage("[Iditem] You are holding ".$inHanditem->getName()." ID ".$inHanditem->getId()." meta ".$inHanditem->getDamage());
    Last edited: Aug 5, 2015
  11. mariusbjornor
    Offline

    mariusbjornor Active Member

    Joined:
    Jan 6, 2015
    Posts:
    109
    Minecraft User:
    MariusB
    It doesnt seem to work..
    Permission added to pureperms too..
  12. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Then use edit this line
    PHP:
    if($player->hasPermission('item.info')){
    to
    PHP:
    if($player->isOp()){ // @PEMapModder dislike xD
  13. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    I see my problem i registered permission "items.info" but i'm checking for "item.info"
    change plugin.yml:
    Code:
    permissions:
     item.info:
       default: OP
       description: " "
    
    And ignore my post above :D
  14. mariusbjornor
    Offline

    mariusbjornor Active Member

    Joined:
    Jan 6, 2015
    Posts:
    109
    Minecraft User:
    MariusB
    Changed... but still it wont show ID next to name when i swape between items on hotbar..

    use pocketmine\plugin\PluginBase;
    use pocketmine\event\player\PlayerItemHeldEvent as HoldEvent;
    use pocketmine\Player;

    do i need any else?
  15. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    register listener add
    PHP:
    use pocketmine\event\Listener;
    and register Listener onEnable()
    PHP:
    public function onEnable(){
    $this->getServer()->getPluginManager()->registerEvents($this$this);
    }
  16. mariusbjornor
    Offline

    mariusbjornor Active Member

    Joined:
    Jan 6, 2015
    Posts:
    109
    Minecraft User:
    MariusB
    This appeared in console now..

    [Server thread/NOTICE]: RuntimeException: "Argument 1 passed to pocketmine\plugin\PluginManager::registerEvents() must implement interface pocketmine\event\Listener, instance of MariusB\ItemID\main given, called in /home/mariusbjornor/MinecraftTestServer/plugins/ItemID/src/MariusB/ItemID/main.php on line 12 and defined" (E_RECOVERABLE_ERROR) in "/src/pocketmine/plugin/PluginManager" at line 698
  17. Achak
    Offline

    Achak New Member

    Joined:
    Feb 14, 2015
    Posts:
    32
    Minecraft User:
    Achak_Adhay
    does it need a
    PHP:
    use pocketmine\item\Item;

    ?
    Primus likes this.
  18. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Change
    PHP:
    class Main extends implements Listener{

    }
    And change your class name to ucfirst()! // set first letter to Capital
  19. mariusbjornor
    Offline

    mariusbjornor Active Member

    Joined:
    Jan 6, 2015
    Posts:
    109
    Minecraft User:
    MariusB
    Line12:

    $this->getServer()->getPluginManager()->registerEvents($this, $this);
  20. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Send full code and i will correct!

Share This Page

Advertisement