Class CombatUtil
java.lang.Object
com.palmergames.bukkit.towny.utils.CombatUtil
- Author:
- ElgarL,Shade,LlmDl
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
areAllAllies
(List<Nation> possibleAllies) Test if all the listed nations are alliesstatic boolean
areAllFriends
(List<Resident> possibleFriends) Test if all the listed residents are friendsstatic @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
Is town b an ally of town a?static boolean
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
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
isSameNation
(Resident a, Resident b) Is resident a in a nation with resident b?static boolean
isSameNation
(Town a, Town b) Is town b in a nation with town a?static boolean
isSameTown
(Resident a, Resident b) Is resident a in a town with resident b?static boolean
isSameTown
(Town a, Town b) Is town b the same town as town a?static boolean
isWorldPvP
(TownyWorld world) 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?
-
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 Defenderdefender
- - Entity defending from the Attackercause
- - The DamageCause behind this DamageCall.- Returns:
- true if we should cancel.
-
preventPvP
Is PvP disabled in this TownBlock?- Parameters:
townBlock
- - TownBlock to checkworld
- - World to check if TownBlock is NULL- Returns:
- true if PvP is disallowed
-
isWorldPvP
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 Playerdefender
- - 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 Playerdefender
- Defending Player- Returns:
- true if both player in an Arena plot.
-
isArenaPlot
Return true if both TownBlocks are Arena plots.- Parameters:
defenderTB
- TownBlock being tested.attackerTB
- TownBlock being tested.- Returns:
- true if both TownBlocks are Arena plots.
-
isAlly
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
Is the resident B an ally of resident A?- Parameters:
a
- - Resident A in comparisonb
- - Resident B in comparison- Returns:
- true if they are allies.
-
isAlly
Is town b an ally of town a?- Parameters:
a
- - Town A in comparisonb
- - Town B in comparison- Returns:
- true if they are allies.
-
isSameNation
Is town b in a nation with town a?- Parameters:
a
- - Town A in comparisonb
- - Town B in comparison- Returns:
- true if they are in the same nation.
-
isSameTown
Is town b the same town as town a?- Parameters:
a
- - Town A in comparisonb
- - Town B in comparison- Returns:
- true if they are allies.
-
isSameNation
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
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
Test if all the listed nations are allies- Parameters:
possibleAllies
- - List of Nations (List<Nation>)- Returns:
- true if they are all allies
-
areAllFriends
Test if all the listed residents are friends- Parameters:
possibleFriends
- - List of Residents (List<Resident>)- Returns:
- true if they are all friends
-
isEnemy
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
Is the resident B an enemy of resident A?- Parameters:
a
- - Resident A in comparisonb
- - Resident B in comparison- Returns:
- true if B is an enemy.
-
isEnemy
Is town b an enemy of town a?- Parameters:
a
- - Town A in comparisonb
- - Town B in comparison- Returns:
- true if b is an enemy.
-
isEnemyTownBlock
Does this WorldCoord fall within a plot owned by an enemy town?- Parameters:
player
- - PlayerworldCoord
- - 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)
-