Package com.pridemc.games.events

Source Code of com.pridemc.games.events.PvP

package com.pridemc.games.events;

import com.pridemc.games.arena.Arena;
import com.pridemc.games.arena.ArenaManager;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;

/**
* Author: Chris H (Zren / Shade)
* Date: 6/3/12
*/
public class PvP implements Listener {

  @EventHandler
  public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    Entity defender = event.getEntity();
    if (defender instanceof Player) {
      Player defenderPlayer = (Player)defender;
      if (ArenaManager.isInArena(defenderPlayer.getName())) {
        Arena arena = ArenaManager.getArenaPlayerIsIn(defenderPlayer.getName());
        if (!arena.getState().canPvP()) {
          event.setCancelled(true);
        }
      }
    }
  }
}
TOP

Related Classes of com.pridemc.games.events.PvP

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.