From 0c973ba47f539be7f9523b0316218de2cd839f56 Mon Sep 17 00:00:00 2001 From: Warrior <50800980+Warriorrrr@users.noreply.github.com> Date: Tue, 4 Jan 2022 16:59:09 +0100 Subject: [PATCH] Deprecate unused parameter in function --- .../towny/listeners/TownyEntityListener.java | 6 +++--- .../bukkit/towny/utils/CombatUtil.java | 16 +++++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/com/palmergames/bukkit/towny/listeners/TownyEntityListener.java b/src/com/palmergames/bukkit/towny/listeners/TownyEntityListener.java index 37b51581ce..19a3fc3857 100644 --- a/src/com/palmergames/bukkit/towny/listeners/TownyEntityListener.java +++ b/src/com/palmergames/bukkit/towny/listeners/TownyEntityListener.java @@ -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)) @@ -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); } } @@ -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(); diff --git a/src/com/palmergames/bukkit/towny/utils/CombatUtil.java b/src/com/palmergames/bukkit/towny/utils/CombatUtil.java index 74d2d4e136..a4c96a0867 100644 --- a/src/com/palmergames/bukkit/towny/utils/CombatUtil.java +++ b/src/com/palmergames/bukkit/towny/utils/CombatUtil.java @@ -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()); @@ -92,7 +99,7 @@ public static boolean preventDamageCall(Towny plugin, Entity attacker, Entity de 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); } /** @@ -101,7 +108,6 @@ public static boolean preventDamageCall(Towny plugin, Entity attacker, Entity de * 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 @@ -110,7 +116,7 @@ public static boolean preventDamageCall(Towny plugin, Entity attacker, Entity de * @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) { TownBlock defenderTB = TownyAPI.getInstance().getTownBlock(defendingEntity.getLocation()); TownBlock attackerTB = TownyAPI.getInstance().getTownBlock(attackingEntity.getLocation());