mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-11-04 02:53:43 +01:00 
			
		
		
		
	minor refactoring
This commit is contained in:
		@@ -555,7 +555,8 @@ public class FishingManager extends SkillManager {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            ItemUtils.spawnItem(getPlayer(), target.getLocation(), drop, ItemSpawnReason.FISHING_SHAKE_TREASURE);
 | 
					            ItemUtils.spawnItem(getPlayer(), target.getLocation(), drop, ItemSpawnReason.FISHING_SHAKE_TREASURE);
 | 
				
			||||||
            CombatUtils.dealDamage(target, Math.min(Math.max(target.getMaxHealth() / 4, 1), 10), EntityDamageEvent.DamageCause.CUSTOM, getPlayer()); // Make it so you can shake a mob no more than 4 times.
 | 
					            // Make it so you can shake a mob no more than 4 times.
 | 
				
			||||||
 | 
					            CombatUtils.dealDamage(target, Math.min(Math.max(target.getMaxHealth() / 4, 1), 10), getPlayer());
 | 
				
			||||||
            applyXpGain(ExperienceConfig.getInstance().getFishingShakeXP(), XPGainReason.PVE);
 | 
					            applyXpGain(ExperienceConfig.getInstance().getFishingShakeXP(), XPGainReason.PVE);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -509,7 +509,6 @@ public final class CombatUtils {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                if (mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.SWORDS)) {
 | 
					                if (mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.SWORDS)) {
 | 
				
			||||||
                    processSwordCombat(target, player, event);
 | 
					                    processSwordCombat(target, player, event);
 | 
				
			||||||
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            } else if (ItemUtils.isAxe(heldItem)) {
 | 
					            } else if (ItemUtils.isAxe(heldItem)) {
 | 
				
			||||||
                if (!mcMMO.p.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.AXES, target)) {
 | 
					                if (!mcMMO.p.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.AXES, target)) {
 | 
				
			||||||
@@ -698,46 +697,17 @@ public final class CombatUtils {
 | 
				
			|||||||
     * @param damage Amount of damage to attempt to do
 | 
					     * @param damage Amount of damage to attempt to do
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static void dealDamage(@NotNull LivingEntity target, double damage) {
 | 
					    public static void dealDamage(@NotNull LivingEntity target, double damage) {
 | 
				
			||||||
        dealDamage(target, damage, DamageCause.CUSTOM, null);
 | 
					        dealDamage(target, damage, null);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
 | 
					     * Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param target LivingEntity which to attempt to damage
 | 
					     * @param target the entity to attempt to damage
 | 
				
			||||||
     * @param damage Amount of damage to attempt to do
 | 
					     * @param damage Amount of damage to attempt to do
 | 
				
			||||||
     * @param attacker Player to pass to event as damager
 | 
					     * @param attacker the responsible entity (nullable)
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Deprecated
 | 
					    public static void dealDamage(@NotNull LivingEntity target, double damage, @Nullable Entity attacker) {
 | 
				
			||||||
    public static void dealDamage(@NotNull LivingEntity target, double damage, @NotNull LivingEntity attacker) {
 | 
					 | 
				
			||||||
        dealDamage(target, damage, DamageCause.CUSTOM, attacker);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//    /**
 | 
					 | 
				
			||||||
//     * Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
 | 
					 | 
				
			||||||
//     *
 | 
					 | 
				
			||||||
//     * @param target LivingEntity which to attempt to damage
 | 
					 | 
				
			||||||
//     * @param damage Amount of damage to attempt to do
 | 
					 | 
				
			||||||
//     * @param attacker Player to pass to event as damager
 | 
					 | 
				
			||||||
//     */
 | 
					 | 
				
			||||||
//    public static void dealDamage(LivingEntity target, double damage, Map<DamageModifier, Double> modifiers, LivingEntity attacker) {
 | 
					 | 
				
			||||||
//        if (target.isDead()) {
 | 
					 | 
				
			||||||
//            return;
 | 
					 | 
				
			||||||
//        }
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
//        // Aren't we applying the damage twice????
 | 
					 | 
				
			||||||
//        target.damage(getFakeDamageFinalResult(attacker, target, damage, modifiers));
 | 
					 | 
				
			||||||
//    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param target LivingEntity which to attempt to damage
 | 
					 | 
				
			||||||
     * @param damage Amount of damage to attempt to do
 | 
					 | 
				
			||||||
     * @param attacker Player to pass to event as damager
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    @Deprecated
 | 
					 | 
				
			||||||
    public static void dealDamage(@NotNull LivingEntity target, double damage, @NotNull DamageCause cause, @Nullable Entity attacker) {
 | 
					 | 
				
			||||||
        if (target.isDead()) {
 | 
					        if (target.isDead()) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -812,7 +782,8 @@ public final class CombatUtils {
 | 
				
			|||||||
     * @param damage The initial damage amount
 | 
					     * @param damage The initial damage amount
 | 
				
			||||||
     * @param type The type of skill being used
 | 
					     * @param type The type of skill being used
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static void applyAbilityAoE(@NotNull Player attacker, @NotNull LivingEntity target, double damage, @NotNull PrimarySkillType type) {
 | 
					    public static void applyAbilityAoE(@NotNull Player attacker, @NotNull LivingEntity target,
 | 
				
			||||||
 | 
					                                       double damage, @NotNull PrimarySkillType type) {
 | 
				
			||||||
        int numberOfTargets = getTier(attacker.getInventory().getItemInMainHand()); // The higher the weapon tier, the more targets you hit
 | 
					        int numberOfTargets = getTier(attacker.getInventory().getItemInMainHand()); // The higher the weapon tier, the more targets you hit
 | 
				
			||||||
        double damageAmount = Math.max(damage, 1);
 | 
					        double damageAmount = Math.max(damage, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -821,7 +792,8 @@ public final class CombatUtils {
 | 
				
			|||||||
                break;
 | 
					                break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if ((ExperienceConfig.getInstance().isNPCInteractionPrevented() && Misc.isNPCEntityExcludingVillagers(entity))
 | 
					            if ((ExperienceConfig.getInstance().isNPCInteractionPrevented()
 | 
				
			||||||
 | 
					                    && Misc.isNPCEntityExcludingVillagers(entity))
 | 
				
			||||||
                    || !(entity instanceof LivingEntity livingEntity) || !shouldBeAffected(attacker, entity)) {
 | 
					                    || !(entity instanceof LivingEntity livingEntity) || !shouldBeAffected(attacker, entity)) {
 | 
				
			||||||
                continue;
 | 
					                continue;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -831,7 +803,8 @@ public final class CombatUtils {
 | 
				
			|||||||
            switch (type) {
 | 
					            switch (type) {
 | 
				
			||||||
                case SWORDS:
 | 
					                case SWORDS:
 | 
				
			||||||
                    if (entity instanceof Player) {
 | 
					                    if (entity instanceof Player) {
 | 
				
			||||||
                        NotificationManager.sendPlayerInformation((Player)entity, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.SS.Struck");
 | 
					                        NotificationManager.sendPlayerInformation((Player)entity, NotificationType.SUBSKILL_MESSAGE,
 | 
				
			||||||
 | 
					                                "Swords.Combat.SS.Struck");
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    final McMMOPlayer mmoAttacker = UserManager.getPlayer(attacker);
 | 
					                    final McMMOPlayer mmoAttacker = UserManager.getPlayer(attacker);
 | 
				
			||||||
@@ -844,9 +817,9 @@ public final class CombatUtils {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                case AXES:
 | 
					                case AXES:
 | 
				
			||||||
                    if (entity instanceof Player) {
 | 
					                    if (entity instanceof Player) {
 | 
				
			||||||
                        NotificationManager.sendPlayerInformation((Player)entity, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.SS.Struck");
 | 
					                        NotificationManager.sendPlayerInformation((Player) entity, NotificationType.SUBSKILL_MESSAGE,
 | 
				
			||||||
 | 
					                                "Axes.Combat.SS.Struck");
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                default:
 | 
					                default:
 | 
				
			||||||
@@ -963,7 +936,9 @@ public final class CombatUtils {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (mcMMO.p.getPartyConfig().isPartyEnabled()) {
 | 
					            if (mcMMO.p.getPartyConfig().isPartyEnabled()) {
 | 
				
			||||||
                if ((mcMMO.p.getPartyManager().inSameParty(player, defender) || mcMMO.p.getPartyManager().areAllies(player, defender)) && !(Permissions.friendlyFire(player) && Permissions.friendlyFire(defender))) {
 | 
					                if ((mcMMO.p.getPartyManager().inSameParty(player, defender)
 | 
				
			||||||
 | 
					                        || mcMMO.p.getPartyManager().areAllies(player, defender))
 | 
				
			||||||
 | 
					                        && !(Permissions.friendlyFire(player) && Permissions.friendlyFire(defender))) {
 | 
				
			||||||
                    return false;
 | 
					                    return false;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -1015,7 +990,9 @@ public final class CombatUtils {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            if (tamer instanceof Player owner) {
 | 
					            if (tamer instanceof Player owner) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                return (owner == attacker || (mcMMO.p.getPartyConfig().isPartyEnabled() && (mcMMO.p.getPartyManager().inSameParty(attacker, owner) || mcMMO.p.getPartyManager().areAllies(attacker, owner))));
 | 
					                return (owner == attacker || (mcMMO.p.getPartyConfig().isPartyEnabled()
 | 
				
			||||||
 | 
					                        && (mcMMO.p.getPartyManager().inSameParty(attacker, owner)
 | 
				
			||||||
 | 
					                        || mcMMO.p.getPartyManager().areAllies(attacker, owner))));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user