Ejemplo n.º 1
0
 public boolean pvp(Player attacker, Player defender) {
   final UDSHashMap<UDSPlayer> udsPlayers = UDSPlugin.getPlayers();
   final UDSPlayer udsDefender = udsPlayers.get(defender.getName());
   final UDSPlayer udsAttacker = udsPlayers.get(attacker.getName());
   if (udsDefender.hasChallenge() && udsAttacker.hasChallenge()) {
     return false;
   } else if (!RegionUtils.canPvp(defender.getLocation())
       || !RegionUtils.canPvp(attacker.getLocation())) {
     attacker.sendMessage(UDSMessage.NO_PVP);
     return true;
   } else if (!udsDefender.isInClan()) {
     attacker.sendMessage(UDSMessage.PVP_PLAYER_NO_CLAN);
     return true;
   } else if (!udsAttacker.isInClan()) {
     attacker.sendMessage(UDSMessage.PVP_NO_CLAN);
   } else if (udsDefender.getClan().equals(udsAttacker.getClan())) {
     return true;
   }
   udsAttacker.newAttack(System.currentTimeMillis());
   return false;
 }
Ejemplo n.º 2
0
 public boolean pve(Player attacker, Entity defender) {
   if (defender instanceof Ocelot) {
     final Ocelot ocelot = (Ocelot) defender;
     if (ocelot.isTamed() && ocelot.getTarget().getUniqueId() != attacker.getUniqueId()) {
       return true;
     }
   } else if (defender instanceof Wolf) {
     final Wolf wolf = (Wolf) defender;
     if (wolf.isTamed() && wolf.getTarget().getUniqueId() != attacker.getUniqueId()) {
       return true;
     }
   } else if ((defender instanceof Animals
           || defender instanceof Villager
           || defender instanceof Golem)
       && RegionUtils.isSafe(defender.getLocation())) {
     return true;
   }
   return false;
 }