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

Anti PVP Code

Discussion in 'Development' started by MadeUpadanaYT, Mar 2, 2017.

  1. MadeUpadanaYT

    MadeUpadanaYT Spider

    Messages:
    12
    Example:
    if we are in the lobby we will not get hit or archery
     
  2. EdwardHamHam

    EdwardHamHam Skeleton

    Messages:
    962
    GitHub:
    edwardhamham
    You can to this by changing the line
    Code:
    pvp=on
    to
    Code:
    pvp=off
    in your server.properties.
     
  3. VentroxStudio

    VentroxStudio Witch

    Messages:
    71
    This disables PvP on the server. If u always to disable it only in some world's use this:

    PHP:
    public function onDamage(EntityDamageEvent $event) {
    $entity $event->getEntity();
    $worlds = array("world1""world2");
    foreach(
    $worlds as $world) {
    if (
    $player->getLevel()->getName() === $world) {
    $event->setCancelled();
    }
    }
    }
    *This blocks the damage for every entity. If u want to block it only for players, u need to check if $entity is a Player
     
    #A6543 likes this.
  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.