Skip to content

Commit

Permalink
Merge pull request #5595 from TownyAdvanced/deprecate
Browse files Browse the repository at this point in the history
Deprecate unused parameter in function
  • Loading branch information
LlmDl authored Jan 4, 2022
2 parents f32a6cd + 0c973ba commit 48bc1a8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
/*
* This handles the remaining non-explosion damages.
*/
if (CombatUtil.preventDamageCall(plugin, attacker, defender, event.getCause())) {
if (CombatUtil.preventDamageCall(attacker, defender, event.getCause())) {
// Remove the projectile here so no
// other events can fire to cause damage
if (attacker instanceof Projectile && !attacker.getType().equals(EntityType.TRIDENT))
Expand Down Expand Up @@ -369,7 +369,7 @@ public void onPotionSplashEvent(PotionSplashEvent event) {
* yet allow the use of beneficial potions on all.
*/
if (attacker != defender)
if (CombatUtil.preventDamageCall(plugin, attacker, defender, DamageCause.MAGIC) && detrimental) {
if (CombatUtil.preventDamageCall(attacker, defender, DamageCause.MAGIC) && detrimental) {
event.setIntensity(defender, -1.0);
}
}
Expand Down Expand Up @@ -642,7 +642,7 @@ public void onEntityCombustByEntityEvent(EntityCombustByEntityEvent event) {
// There is an attacker.
if (attacker != null) {

if (CombatUtil.preventDamageCall(plugin, attacker, defender, DamageCause.PROJECTILE)) {
if (CombatUtil.preventDamageCall(attacker, defender, DamageCause.PROJECTILE)) {
// Remove the projectile here so no
// other events can fire to cause damage
combuster.remove();
Expand Down
16 changes: 11 additions & 5 deletions src/com/palmergames/bukkit/towny/utils/CombatUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,26 @@
*/
public class CombatUtil {

/**
* @deprecated As of 0.97.5.9, please use {@link #preventDamageCall(Entity, Entity, DamageCause)}
*/
@Deprecated
public static boolean preventDamageCall(Towny plugin, Entity attacker, Entity defender, DamageCause cause) {
return preventDamageCall(attacker, defender, 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.
*
* @param plugin - Reference to Towny
* @param attacker - Entity attacking the Defender
* @param defender - Entity defending from the Attacker
* @param cause - The DamageCause behind this DamageCall.
* @return true if we should cancel.
*/
public static boolean preventDamageCall(Towny plugin, Entity attacker, Entity defender, DamageCause cause) {
public static boolean preventDamageCall(Entity attacker, Entity defender, DamageCause cause) {

TownyWorld world = TownyAPI.getInstance().getTownyWorld(defender.getWorld().getName());

Expand Down Expand Up @@ -92,7 +99,7 @@ else if (source instanceof BlockProjectileSource blockProjectileSource) {
if (a == b && a != null && b != null)
return false;

return preventDamageCall(plugin, world, attacker, defender, a, b, cause);
return preventDamageCall(world, attacker, defender, a, b, cause);
}

/**
Expand All @@ -101,7 +108,6 @@ else if (source instanceof BlockProjectileSource blockProjectileSource) {
* Only allow a Wolves owner to cause it damage, and residents with destroy
* permissions to damage passive animals and villagers while in a town.
*
* @param plugin - Reference to Towny
* @param world - World in which DamageCall was issued
* @param attackingEntity - Entity attacking
* @param defendingEntity - Entity defending
Expand All @@ -110,7 +116,7 @@ else if (source instanceof BlockProjectileSource blockProjectileSource) {
* @param cause - The DamageCause behind this DamageCall.
* @return true if we should cancel.
*/
private static boolean preventDamageCall(Towny plugin, TownyWorld world, Entity attackingEntity, Entity defendingEntity, Player attackingPlayer, Player defendingPlayer, DamageCause cause) {
private static boolean preventDamageCall(TownyWorld world, Entity attackingEntity, Entity defendingEntity, Player attackingPlayer, Player defendingPlayer, DamageCause cause) {

Projectile projectileAttacker = null;
if (attackingEntity instanceof Projectile projectile) {
Expand Down

0 comments on commit 48bc1a8

Please sign in to comment.