1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

People can take the item from an item frame?!

Discussion in 'Help' started by rektpixel, Jan 23, 2017.

  1. rektpixel

    rektpixel Baby Zombie

    Messages:
    186
    I noticed with pocketmine players can take an item from a item frame even if the area has been protected. (i used plugin iProtect to protect) does anyone know a way to stop players from taking items from item frames? an alternative protection plugin? I couldn't find a working one
     
  2. xBeastMode

    xBeastMode Shog Chips

    Messages:
    0
    I believe there are no plugins that can protect item frames from dropping items yet. When an item is taken from an item frame the client does not send a block event packet, it sends an item frame drop item packet, most protection plugins only protect when a player breaks, places, or interacts [with] a block.
     
  3. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
  4. rektpixel

    rektpixel Baby Zombie

    Messages:
    186
  5. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    There is an event called. DataPacketRecieveEvent. I know it's nothing you should use, but if you have no option beside modifying the core, you can consider using it.
    There is always a last resort. Again this is very hacky, but should work. Might break even WITHOUT an api version change.
    Currently working on a small plugin for this.
    In the meantime here is a small concept:
    PHP:
    /**
      * @license GPLv3
      * @author robske_110
      * NO WARRANTY
      */
    use pocketmine\event\server\DataPacketReceiveEvent;
    use 
    pocketmine\network\protocol\ItemFrameDropItemPacket;
    use 
    pocketmine\math\Vector3;
     
    public function 
    onItemFrameDropPacket(DataPacketReceiveEvent $event){
        
    $packet $event->getPacket();
        if(
    $packet instanceof ItemFrameDropItemPacket){
            
    $player $event->getPlayer();
            
    $level $player->getLevel();
            
    $vec3 = new Vector3($packet->x$packet->y$packet->z);
            
    #do checks using all that data
            #and if it is invalid do
            
    $event->setCancelled();
        }
    }
     
  6. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    It is possible to stop the removal of the item by stopping the server from handling the packet but it isn't very reliable and is considered hacky. It may work for now but as @robske_110 (Tim) said, it can break at any time without warning.
     
  7. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    do you have it where they cant interact/break/or destroy?
     
  8. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    Just cancel the interactevent
     
  9. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    is it just me that i remember seeing something highly like this get dealt with?
     
  10. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    There was an issue over at Gen*sys about this that I dealt with a few days ago.
     
  11. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    And Gen*crap has events for this. But not in a way that is proper.
     
  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.