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

ItemFrameDropItemPacket - Error

Discussion in 'Plugin Help' started by PainTR, Jun 9, 2017.

  1. PainTR

    PainTR Creeper

    Messages:
    4
    GitHub:
    paintr
    Hello everyone, i have a problem
    i want to cancel ItemFrameDropItemPacket, but my code is not working
    what is wrong with my code ?

    Code:
    public function itemDrop(ItemFrameDropItemPacket $event){
                $event->setCancelled(true);
    }
    
     
  2. Keith

    Keith Spider Jockey

    Messages:
    42
    GitHub:
    k3ithos
    You are trying to cancel a packet, not an event?
     
  3. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    If you only want to protect item frames from taking out the item in it, use:
    PHP:
    public function onTouch(PlayerInteractEvent $event) {
            
    $block $event->getBlock();
            
    $player $event->getPlayer();
            
    $level $player->getLevel();
            if(
    $level->getName() === "Shop") { // if you don't want players to take out the item in world "Shop"
                
    if(!$player->hasPermission("itemframes.touch")) { // if the player has permissions
                    
    if($block->getId() === Block::ITEM_FRAME_BLOCK) {
                        
    $event->setCancelled();
                    }
                }
            }
        }
     
  4. PainTR

    PainTR Creeper

    Messages:
    4
    GitHub:
    paintr
    i was using this code when version 1.0.7 and that was working very well
    but thank you WinterBuild7074 for the code
     
  5. Keith

    Keith Spider Jockey

    Messages:
    42
    GitHub:
    k3ithos
    Using $level->getFolderName() might be better than $level->getName(). Most people change the folder name instead of the actual world name in level.dat.
     
  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.