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

[Useful!!!] How to Disable PvP!

Comments in 'Plugin Development' started by Samueljh1, Jan 22, 2015.

  1. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    Hey guys, i thought i might post this as a lot of people have been wondering how to do this! :)

    Note: this is in CERTAIN areas!! If u want to disable it throughout the server, modify the server.properties :p

    Here is the code:

    PHP:
    public function onEntityDamageByEntity(EntityDamageEvent $eventPvP){

                if(
    $eventPvP instanceof EntityDamageByEntityEvent){



                        if(
    $eventPvP->getEntity() instanceof Player && $eventPvP->getDamager() instanceof Player){



                                 
    $player $eventPvP->getDamager();

                                 
    //If statement here

                                 
    $eventPvP->setCancelled(); //Prevent Default Action

                                 
    $player->sendMessage("You are in a No-PVP Zone!");



                        }     
               }
    }
    Let me know if i helped you! :D
    Last edited: Jan 23, 2015
    luca28pet and xFlare like this.
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It should be in the Resources forum.
    Praxthisnovcht and iksaku like this.
  3. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,132
    Plugins:
    4
    Minecraft User:
    iksaku
    Hahahaha! You can just disable PvP from" server.properties" xD
    hoyinm14mc likes this.
  4. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    Lol ik, but in certain areas LOL

    (I use this in my server to stop PvP in certain areas, look for yourself!

    IP: samcraft.zapto.org

    )

    Omg how DUMB do you think I AM??? I have been running servers and developing for years!!! :p
    Last edited: Jan 23, 2015
    Angelo Vidrio likes this.

Share This Page

Advertisement