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

Solved Disable PVP in certain worlds?

Comments in 'Plugin Development' started by cake23, Sep 23, 2015.

  1. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    How i can disable PVP in certain worlds? :oops: Thanks.
  2. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
  3. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    Thank you! <3
  4. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    PHP:
    public function onHurt(EntityDamageEvent $e){
        if(
    $e instanceof EntityDamageByEntityEvent && ($entity $e->getEntity() instanceof Player) && $e->getDamager() instanceof Player && $entity->getLevel()->getName() == "world"){
            
    $e->setCancelled();
        }
    }
    AndrewBit and cake23 like this.
  5. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    PHP:
    $e->setCancelled();
    has to be :
    PHP:
    $e->setCancelled(true);
    TheKofola12 and cake23 like this.
  6. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    it doesn't matter
    PEMapModder and cake23 like this.
  7. CavinMiana
    Offline

    CavinMiana Active Member

    Joined:
    Aug 26, 2015
    Posts:
    101
    Minecraft User:
    CavinMiana
    It would still be the same thing!
    PEMapModder and cake23 like this.
  8. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    I prefer use setCancelled(true). It sounds better xD
    Taha_The_Hacker and Legoboy0215 like this.

Share This Page

Advertisement