Esempio n. 1
0
  /**
   * Is PvP enabled in this world?
   *
   * @param world
   * @return true if the world is PvP
   */
  public static boolean isWorldPvP(TownyWorld world) {

    // Universe is only PvP
    if (world.isForcePVP() || world.isPVP()) return true;

    return false;
  }
Esempio n. 2
0
  /**
   * Is PvP disabled in this TownBlock? Checks the world if the TownBlock is null.
   *
   * @param townBlock
   * @return true if PvP is disallowed
   */
  public static boolean preventPvP(TownyWorld world, TownBlock townBlock) {

    if (townBlock != null) {
      try {

        /*
         * Check the attackers TownBlock and it's Town for their PvP
         * status
         */
        if (townBlock.getTown().isAdminDisabledPVP()) return true;

        if (!townBlock.getTown().isPVP() && !townBlock.getPermissions().pvp && !world.isForcePVP())
          return true;

      } catch (NotRegisteredException ex) {
        /*
         * Failed to fetch the town data
         * so check world PvP
         */
        if (!isWorldPvP(world)) return true;
      }

    } else {

      /*
       * Attacker isn't in a TownBlock so check the world PvP
       */
      if (!isWorldPvP(world)) return true;
    }
    return false;
  }