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

Deactivate PvP (not in all worlds)

Comments in 'Plugin Development' started by Adversarius, Jan 9, 2016.

  1. Adversarius
    Offline

    Adversarius New Member

    Joined:
    Oct 4, 2015
    Posts:
    16
    Minecraft User:
    Adversarius
    Hey,
    Can anyone tell me the public function: How to deactivate PvP in specified Worlds (more than two)?

    Sorry for my bad English :(
    Thanks!
  2. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Look in the plugin WorldProtect!
    you have to cancel some events
  3. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    PHP:
    public function onDamage(EntityDamageEvent $event) {
      
    $player $event->getEntity();
      
    $cause $player->getLastDamageCause();

      if(
    $cause instanceof EntityDamageByEntityEvent) {
        if(
    $level->getName() == "YourWorldName") {
          
    $event->setCancelled();
        }
      }
    }
    Last edited: Jan 9, 2016
  4. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    You haven't define $level
  5. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    I know. I was hoping that he/she would know how to define a level.
  6. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    But I don't know how to define it. Is that
    PHP:
    $player->getLevelByName("blablabla");
    or
    PHP:
    $this->getServer()-getLevelByName("blablabla");
    ?
  7. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    PHP:
    $level $player->getLevel();php]
    Last edited: Jan 10, 2016
    Vaivez66 likes this.
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    :facepalm:
    You search level by name, and then check if the level's name is a certain value?
  9. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Well, that isn't exactly the wrong way to do it.
    PHP:
    $level $this->getServer()->getLevelByName($player->getLevel()->getName());
    if(
    $level->getName() == "Blah") {
    }
    and:
    PHP:
    $level $player->getLevel();
    if(
    $level->getName() == "Blah") {
    }
    Both return a Level object, so they will work the same.
    The second way is much faster though.
  10. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    Can we end this flame wars? I don't like it :p
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    That's why I deleted my posts ;)
    Bluplayz and Hotshot_9930 like this.

Share This Page

Advertisement