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

Help with popup message

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

  1. mariusbjornor
    Offline

    mariusbjornor Active Member

    Joined:
    Jan 6, 2015
    Posts:
    112
    Minecraft User:
    MariusB
    I got a simple plugin that shows ItemID in popup when changing between items in hotbar. Only problem is that i cant get it to show everytime i tap same item. It just shows the first time and i need to tap another item first before the same item will show ID again.. It shows item name everytime i tap it but my custom popup with ID shows only at first tap..

    Is there someone that can help adding something to my code that make the custom popup show every time i tap the item?
    And please add so that ID shows with meta too...

    PHP:
    public function onItemHeld(PlayerItemHeldEvent $event){
    $item $event->getItem();
    $player $event->getPlayer();
    if(
    $player->hasPermission('item.info')){
    $player->sendPopup($item->getName()." ┬žeID: ".$item->getId().":".$item->getDamage(), 2);
    return 
    true;
    }
    }
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Make a scheduled task and let the popup show constantly. Otherwise, no it's not possible.
    mariusbjornor and jojoe77777 like this.
  3. mariusbjornor
    Offline

    mariusbjornor Active Member

    Joined:
    Jan 6, 2015
    Posts:
    112
    Minecraft User:
    MariusB
    Would it be possible for you to help implement my codes for a scheduled task?
  4. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,747
    Minecraft User:
    Legoboy0215
    In the Main file:
    PHP:
    $this->getServer()->getScheduler()->scheduleRepeatingTask(new PopupTask($this), 30);
    Create a file called 'PopupTask.php':
    PHP:
    <?php

    namespace Blah-Blah;

    use 
    pocketmine\scheduler\PluginTask;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\Player;

    class 
    TimerTask extends PluginTask{

        public function 
    __construct(Main $plugin){
           
    parent::__construct($plugin);
        }

        public function 
    onRun($currentTick){
            
    //Code you want to run here...
        
    }
    }
    mariusbjornor and Xenturio like this.
  5. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,747
    Minecraft User:
    Legoboy0215
    Then if they switch an item stop the task.

Share This Page

Advertisement