Solved disable pvp damage on Y = ?

Discussion in 'Plugin Development' started by ZeyNet, Feb 15, 2022.

Thread Status:
Not open for further replies.
  1. Offline

    ZeyNet

    Verson: spigot 1.18.1
    Need to: disable pvp when player is below Y -40
    It is necessary that there is no damage from arrows and potions either.
    PHP:
    @EventHandlerpublic void pvpOFF(EntityDamageByEntityEvent e){
    if (!(
    e.getEntity() instanceof Player && e.getDamager() instanceof Player)) return;
    Player p = (Playere.getEntity();
    Location l p.getLocation();
    if(
    l.getY() < -40){
    e.setCancelled(true);}
    }
     
  2. Offline

    timtower Administrator Administrator Moderator

    @ZeyNet Damager can also be a projectile.
     
  3. Offline

    ZeyNet

    Works with arrows. How to write correctly to work with potions

    PHP:
    @EventHandlerpublic void pvpOFFPotion(EntityDamageByEntityEvent e){
    if (!(
    e.getEntity() instanceof Player && e.getDamager() instanceof ThrownPotion)) return;
    Player p = (Playere.getEntity();
    Location l p.getLocation(); 
     if(
    l.getY() < -40){
    e.setCancelled(true);
    p.sendMessage("potion work");}
    }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Feb 15, 2022
Thread Status:
Not open for further replies.

Share This Page