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

Disable drop gamemode?

Discussion in 'Plugin Help' started by WylSmart, May 14, 2020.

  1. WylSmart

    WylSmart Slime

    Messages:
    93
    Tell me how to prevent all players in the creative from throwing things away?
     
  2. Diduhless

    Diduhless Baby Zombie

    Messages:
    199
    GitHub:
    Diduhless
    Cancel PlayerItemDropEvent if the player is in creative.
     
  3. WylSmart

    WylSmart Slime

    Messages:
    93
    and how to do it?
     
  4. Diduhless

    Diduhless Baby Zombie

    Messages:
    199
    GitHub:
    Diduhless
    I already told you how to do it?
     
    ethaniccc likes this.
  5. ethaniccc

    ethaniccc Baby Zombie

    Messages:
    189
    GitHub:
    ethaniccc
    PHP:
    public function onDrop(PlayerDropItemEvent $event){
        
    $player $event->getPlayer();
        if(
    $player->isCreative()) $event->setCancelled();
    }
     
  6. Diduhless

    Diduhless Baby Zombie

    Messages:
    199
    GitHub:
    Diduhless
    No need to define $player. Use $event->getPlayer()->isCreative() instead.
     
    ethaniccc likes this.
  7. ethaniccc

    ethaniccc Baby Zombie

    Messages:
    189
    GitHub:
    ethaniccc
    True, but this is to make things more laid out and plain in sight for OP
     
  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.