Solved How do I disable PVP in a plugin?

Discussion in 'Plugin Development' started by waremanu, May 18, 2013.

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

    waremanu

    How do I disable PVP in a plugin? I can't get it work, can someone paste me the done EntityDamageEvent?
     
  2. Offline

    GodzOfMadness

  3. Offline

    waremanu

    GodzOfMadness
    Code:
        @EventHandler(priority = EventPriority.NORMAL)
        public void onTestEntityDamage(final EntityDamageEvent e) {
            //TODO Disable PVP
        }
     
  4. Offline

    ZeusAllMighty11

    e.setCancelled(true);

    add then in.


    Remove the final modifiers. Remove the priority. Register the event
     
  5. Offline

    waremanu

    TheGreenGamerHD
    I would only remove PvP, if i add e.setCancelled(true); will every damage de cancelled.
     
  6. Offline

    GodzOfMadness

    waremanu Check if It's a player getting damaged. If so then e.setCancelled(true);
     
  7. Offline

    waremanu

    The player should be able to lose health but will not be able to lose health if it is damaged by a player. How do I do this, can anyone tell me the code for it?
     
  8. Offline

    Jake0oo0

    check if the damager is an instanceof player
     
  9. Offline

    waremanu

    Jake0oo0 That's what I'm asking about... How do I do it?
     
  10. Offline

    Aqua

    Code:
        @EventHandler
        public void onTestEntityDamage(EntityDamageByEntityEvent event) {
            if (event.getDamager() instanceof Player){
                if (event.getEntity() instanceof Player) {
                    event.setCancelled(true);
                }
            }
        }
    Try this.
     
    waremanu likes this.
Thread Status:
Not open for further replies.

Share This Page