Class CombatUtil

java.lang.Object
com.palmergames.bukkit.towny.utils.CombatUtil

public class CombatUtil extends Object
Author:
ElgarL,Shade,LlmDl
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    areAllAllies(List<Nation> possibleAllies)
    Test if all the listed nations are allies
    static boolean
    areAllFriends(List<Resident> possibleFriends)
    Test if all the listed residents are friends
    static @Nullable org.bukkit.entity.Entity
    getLightningCausingEntity(@NotNull org.bukkit.entity.LightningStrike lightning)
     
    static boolean
    Is the resident B an ally of resident A?
    static boolean
    isAlly(Town a, Town b)
    Is town b an ally of town a?
    static boolean
    isAlly(String attackingResident, String defendingResident)
    Is the defending resident an ally of the attacking resident?
    static boolean
    isArenaPlot(TownBlock attackerTB, TownBlock defenderTB)
    Return true if both TownBlocks are Arena plots.
    static boolean
    isArenaPlot(org.bukkit.entity.Player attacker, org.bukkit.entity.Player defender)
    Returns true if both players are in an arena townblock.
    static boolean
    Is the resident B an enemy of resident A?
    static boolean
    isEnemy(Town a, Town b)
    Is town b an enemy of town a?
    static boolean
    Is resident b an enemy of resident a?
    static boolean
    isEnemyTownBlock(org.bukkit.entity.Player player, WorldCoord worldCoord)
    Does this WorldCoord fall within a plot owned by an enemy town?
    static boolean
    Is resident a in a nation with resident b?
    static boolean
    Is town b in a nation with town a?
    static boolean
    Is resident a in a town with resident b?
    static boolean
    Is town b the same town as town a?
    static boolean
    Is PvP enabled in this world?
    static boolean
    preventDamageCall(org.bukkit.entity.Entity attacker, org.bukkit.entity.Entity defender, org.bukkit.event.entity.EntityDamageEvent.DamageCause cause)
    Tests the attacker against defender to see if we need to cancel the damage event due to world PvP, Plot PvP or Friendly Fire settings.
    static boolean
    preventDispenserDamage(org.bukkit.block.Block dispenser, org.bukkit.entity.Entity entity, org.bukkit.event.entity.EntityDamageEvent.DamageCause cause)
     
    static boolean
    preventFriendlyFire(org.bukkit.entity.Player attacker, org.bukkit.entity.Player defender, TownyWorld world)
    Should we be preventing friendly fire?
    static boolean
    preventPvP(TownyWorld world, TownBlock townBlock)
    Is PvP disabled in this TownBlock?

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CombatUtil

      public CombatUtil()
  • Method Details

    • preventDamageCall

      public static boolean preventDamageCall(org.bukkit.entity.Entity attacker, org.bukkit.entity.Entity defender, org.bukkit.event.entity.EntityDamageEvent.DamageCause cause)
      Tests the attacker against defender to see if we need to cancel the damage event due to world PvP, Plot PvP or Friendly Fire settings. Only allow a Wolves owner to cause it damage, and residents with destroy permissions to damage passive animals and villagers while in a town.
      Parameters:
      attacker - - Entity attacking the Defender
      defender - - Entity defending from the Attacker
      cause - - The DamageCause behind this DamageCall.
      Returns:
      true if we should cancel.
    • preventPvP

      public static boolean preventPvP(TownyWorld world, TownBlock townBlock)
      Is PvP disabled in this TownBlock?
      Parameters:
      world - - World to check if TownBlock is NULL
      townBlock - - TownBlock to check
      Returns:
      true if PvP is disallowed
    • isWorldPvP

      public static boolean isWorldPvP(TownyWorld world)
      Is PvP enabled in this world?
      Parameters:
      world - - World to check
      Returns:
      true if the world is PvP
    • preventFriendlyFire

      public static boolean preventFriendlyFire(org.bukkit.entity.Player attacker, org.bukkit.entity.Player defender, TownyWorld world)
      Should we be preventing friendly fire?
      Parameters:
      attacker - - Attacking Player
      defender - - Defending Player (receiving damage)
      world - - TownyWorld being tested.
      Returns:
      true if we should cancel damage.
    • isArenaPlot

      public static boolean isArenaPlot(org.bukkit.entity.Player attacker, org.bukkit.entity.Player defender)
      Returns true if both players are in an arena townblock.
      Parameters:
      attacker - Attacking Player
      defender - Defending Player
      Returns:
      true if both player in an Arena plot.
    • isArenaPlot

      public static boolean isArenaPlot(TownBlock attackerTB, TownBlock defenderTB)
      Return true if both TownBlocks are Arena plots.
      Parameters:
      attackerTB - TownBlock being tested.
      defenderTB - TownBlock being tested.
      Returns:
      true if both TownBlocks are Arena plots.
    • isAlly

      public static boolean isAlly(String attackingResident, String defendingResident)
      Is the defending resident an ally of the attacking resident?
      Parameters:
      attackingResident - - Attacking Resident (String)
      defendingResident - - Defending Resident (Receiving Damage; String)
      Returns:
      true if the defender is an ally of the attacker.
    • isAlly

      public static boolean isAlly(Resident a, Resident b)
      Is the resident B an ally of resident A?
      Parameters:
      a - - Resident A in comparison
      b - - Resident B in comparison
      Returns:
      true if they are allies.
    • isAlly

      public static boolean isAlly(Town a, Town b)
      Is town b an ally of town a?
      Parameters:
      a - - Town A in comparison
      b - - Town B in comparison
      Returns:
      true if they are allies.
    • isSameNation

      public static boolean isSameNation(Town a, Town b)
      Is town b in a nation with town a?
      Parameters:
      a - - Town A in comparison
      b - - Town B in comparison
      Returns:
      true if they are in the same nation.
    • isSameTown

      public static boolean isSameTown(Town a, Town b)
      Is town b the same town as town a?
      Parameters:
      a - - Town A in comparison
      b - - Town B in comparison
      Returns:
      true if they are allies.
    • isSameNation

      public static boolean isSameNation(Resident a, Resident b)
      Is resident a in a nation with resident b?
      Parameters:
      a - - Resident A in comparison.
      b - - Resident B in comparison.
      Returns:
      true if they are in the same nation.
    • isSameTown

      public static boolean isSameTown(Resident a, Resident b)
      Is resident a in a town with resident b?
      Parameters:
      a - - Resident A in comparison.
      b - - Resident B in comparison.
      Returns:
      true if they are in the same town.
    • areAllAllies

      public static boolean areAllAllies(List<Nation> possibleAllies)
      Test if all the listed nations are allies
      Parameters:
      possibleAllies - - List of Nations (List<Nation>)
      Returns:
      true if they are all allies
    • areAllFriends

      public static boolean areAllFriends(List<Resident> possibleFriends)
      Test if all the listed residents are friends
      Parameters:
      possibleFriends - - List of Residents (List<Resident>)
      Returns:
      true if they are all friends
    • isEnemy

      public static boolean isEnemy(String a, String b)
      Is resident b an enemy of resident a?
      Parameters:
      a - - Resident A in comparison (String)
      b - - Resident B in comparison (String)
      Returns:
      true if b is an enemy.
    • isEnemy

      public static boolean isEnemy(Resident a, Resident b)
      Is the resident B an enemy of resident A?
      Parameters:
      a - - Resident A in comparison
      b - - Resident B in comparison
      Returns:
      true if B is an enemy.
    • isEnemy

      public static boolean isEnemy(Town a, Town b)
      Is town b an enemy of town a?
      Parameters:
      a - - Town A in comparison
      b - - Town B in comparison
      Returns:
      true if b is an enemy.
    • isEnemyTownBlock

      public static boolean isEnemyTownBlock(org.bukkit.entity.Player player, WorldCoord worldCoord)
      Does this WorldCoord fall within a plot owned by an enemy town?
      Parameters:
      player - - Player
      worldCoord - - Location
      Returns:
      true if it is an enemy plot.
    • preventDispenserDamage

      public static boolean preventDispenserDamage(org.bukkit.block.Block dispenser, org.bukkit.entity.Entity entity, org.bukkit.event.entity.EntityDamageEvent.DamageCause cause)
    • getLightningCausingEntity

      @Internal @Nullable public static @Nullable org.bukkit.entity.Entity getLightningCausingEntity(@NotNull @NotNull org.bukkit.entity.LightningStrike lightning)