From 381eba8ddcf814426adff3da950605af7aee659a Mon Sep 17 00:00:00 2001 From: nossr50 Date: Thu, 4 Jul 2019 05:22:52 -0700 Subject: [PATCH] Static Abuse Removal - ComatUtils -> CombatTools --- Changelog.txt | 1 + .../commands/skills/ArcheryCommand.java | 3 +- .../nossr50/commands/skills/AxesCommand.java | 3 +- .../nossr50/commands/skills/SkillCommand.java | 20 ++-- .../commands/skills/SwordsCommand.java | 3 +- .../commands/skills/UnarmedCommand.java | 3 +- .../datatypes/skills/SubSkillType.java | 50 +++------ .../skills/behaviours/RepairBehaviour.java | 6 ++ .../nossr50/listeners/BlockListener.java | 41 ++++--- .../nossr50/listeners/EntityListener.java | 21 ++-- .../nossr50/listeners/InventoryListener.java | 43 +++++--- .../nossr50/listeners/PlayerListener.java | 85 +++++++-------- .../gmail/nossr50/listeners/SelfListener.java | 4 +- src/main/java/com/gmail/nossr50/mcMMO.java | 9 ++ .../com/gmail/nossr50/party/PartyManager.java | 2 +- .../runnables/skills/BleedTimerTask.java | 5 +- .../skills/acrobatics/AcrobaticsManager.java | 2 +- .../nossr50/skills/axes/AxesManager.java | 3 +- .../skills/fishing/FishingManager.java | 3 +- .../nossr50/skills/swords/SwordsManager.java | 5 +- .../skills/taming/TrackedTamingEntity.java | 3 +- .../woodcutting/WoodcuttingManager.java | 3 +- .../com/gmail/nossr50/util/ChimaeraWing.java | 3 +- .../com/gmail/nossr50/util/EventManager.java | 3 +- .../{CombatUtils.java => CombatTools.java} | 100 +++++++++--------- 25 files changed, 203 insertions(+), 221 deletions(-) rename src/main/java/com/gmail/nossr50/util/skills/{CombatUtils.java => CombatTools.java} (84%) diff --git a/Changelog.txt b/Changelog.txt index fffd444ab..9c6895650 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -12,6 +12,7 @@ Version 2.2.0 Parties no longer have a cap, you can level them forever for bragging rights You can now specify multiple repair-items for an item (such as specifying that a wooden sword can be repaired by all types of planks) Repair config has been rewritten and expanded to support much more complex settings + Fixed a bug where salvage anvil noises wouldn't play for a player that lacked repair permissions nodes Removed the following Repair/Salvage permissions mcmmo.ability.repair.stonerepair mcmmo.ability.repair.stringrepair diff --git a/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java index 98065ff3e..dddde2544 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java @@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.archery.Archery; -import com.gmail.nossr50.util.skills.CombatUtils; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.entity.Player; @@ -75,7 +74,7 @@ public class ArcheryCommand extends SkillCommand { if (canUseSubskill(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK)) { messages.add(getStatMessage(SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK, - String.valueOf(CombatUtils.getLimitBreakDamage(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK)))); + String.valueOf(pluginRef.getCombatTools().getLimitBreakDamage(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK)))); } return messages; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java index 048310813..7e6ea838c 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java @@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.axes.Axes; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.RankUtils; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.entity.Player; @@ -95,7 +94,7 @@ public class AxesCommand extends SkillCommand { if (canUseSubskill(player, SubSkillType.AXES_AXES_LIMIT_BREAK)) { messages.add(getStatMessage(SubSkillType.AXES_AXES_LIMIT_BREAK, - String.valueOf(CombatUtils.getLimitBreakDamage(player, SubSkillType.AXES_AXES_LIMIT_BREAK)))); + String.valueOf(pluginRef.getCombatTools().getLimitBreakDamage(player, SubSkillType.AXES_AXES_LIMIT_BREAK)))); } return messages; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java index 2cb24bdbe..371a93910 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java @@ -32,11 +32,11 @@ public abstract class SkillCommand implements TabExecutor { private CommandExecutor skillGuideCommand; protected mcMMO pluginRef; - public SkillCommand(PrimarySkillType skill, mcMMO pluginRef) { + public SkillCommand(PrimarySkillType primarySkillType, mcMMO pluginRef) { this.pluginRef = pluginRef; - this.skill = skill; - skillName = skill.getLocalizedSkillName(); - skillGuideCommand = new SkillGuideCommand(skill, pluginRef); + this.skill = primarySkillType; + skillName = pluginRef.getSkillTools().getLocalizedSkillName(primarySkillType); + skillGuideCommand = new SkillGuideCommand(primarySkillType, pluginRef); } public static String[] addItemToFirstPositionOfArray(String itemToAdd, String... existingArray) { @@ -145,7 +145,7 @@ public abstract class SkillCommand implements TabExecutor { player.sendMessage(pluginRef.getLocaleManager().getString("Skills.Overhaul.Header", skillName)); - if (!skill.isChildSkill()) { + if (!pluginRef.getSkillTools().isChildSkill(skill)) { /* * NON-CHILD SKILLS */ @@ -173,10 +173,10 @@ public abstract class SkillCommand implements TabExecutor { for (int i = 0; i < parentList.size(); i++) { if (i + 1 < parentList.size()) { - parentMessage.append(pluginRef.getLocaleManager().getString("Effects.Child.ParentList", parentList.get(i).getLocalizedSkillName(), mcMMOPlayer.getSkillLevel(parentList.get(i)))); + parentMessage.append(pluginRef.getLocaleManager().getString("Effects.Child.ParentList", pluginRef.getSkillTools().getLocalizedSkillName(parentList.get(i)), mcMMOPlayer.getSkillLevel(parentList.get(i)))); parentMessage.append(ChatColor.GRAY + ", "); } else { - parentMessage.append(pluginRef.getLocaleManager().getString("Effects.Child.ParentList", parentList.get(i).getLocalizedSkillName(), mcMMOPlayer.getSkillLevel(parentList.get(i)))); + parentMessage.append(pluginRef.getLocaleManager().getString("Effects.Child.ParentList", pluginRef.getSkillTools().getLocalizedSkillName(parentList.get(i)), mcMMOPlayer.getSkillLevel(parentList.get(i)))); } } @@ -210,9 +210,9 @@ public abstract class SkillCommand implements TabExecutor { protected String[] formatLengthDisplayValues(Player player, double skillValue) { - int length = pluginRef.getSkillTools().calculateAbilityLength(pluginRef.getUserManager().getPlayer(player), skill, skill.getSuperAbility()); + int length = pluginRef.getSkillTools().calculateAbilityLength(pluginRef.getUserManager().getPlayer(player), skill, pluginRef.getSkillTools().getSuperAbility(skill)); - int enduranceLength = pluginRef.getSkillTools().calculateAbilityLengthPerks(pluginRef.getUserManager().getPlayer(player), skill, skill.getSuperAbility()); + int enduranceLength = pluginRef.getSkillTools().calculateAbilityLengthPerks(pluginRef.getUserManager().getPlayer(player), skill, pluginRef.getSkillTools().getSuperAbility(skill)); return new String[]{String.valueOf(length), String.valueOf(enduranceLength)}; } @@ -223,7 +223,7 @@ public abstract class SkillCommand implements TabExecutor { protected String getStatMessage(boolean isExtra, boolean isCustom, SubSkillType subSkillType, String... vars) { String templateKey = isCustom ? "Ability.Generic.Template.Custom" : "Ability.Generic.Template"; - String statDescriptionKey = !isExtra ? subSkillType.getLocaleKeyStatDescription() : subSkillType.getLocaleKeyStatExtraDescription(); + String statDescriptionKey = !isExtra ? subSkillType.getLocaleKeyStatDescription(pluginRef) : subSkillType.getLocaleKeyStatExtraDescription(pluginRef); if (isCustom) return pluginRef.getLocaleManager().getString(templateKey, pluginRef.getLocaleManager().getString(statDescriptionKey, vars)); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java index b77f94c92..597c44a5e 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java @@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.RankUtils; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.entity.Player; @@ -101,7 +100,7 @@ public class SwordsCommand extends SkillCommand { if (canUseSubskill(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)) { messages.add(getStatMessage(SubSkillType.SWORDS_SWORDS_LIMIT_BREAK, - String.valueOf(CombatUtils.getLimitBreakDamage(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)))); + String.valueOf(pluginRef.getCombatTools().getLimitBreakDamage(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)))); } return messages; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java index 607b7b83b..d2a61260d 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java @@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.RankUtils; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.entity.Player; @@ -113,7 +112,7 @@ public class UnarmedCommand extends SkillCommand { if (canUseSubskill(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK)) { messages.add(getStatMessage(SubSkillType.UNARMED_UNARMED_LIMIT_BREAK, - String.valueOf(CombatUtils.getLimitBreakDamage(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK)))); + String.valueOf(pluginRef.getCombatTools().getLimitBreakDamage(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK)))); } return messages; diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java index 08f4f18fb..498e88b00 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java @@ -131,30 +131,8 @@ public enum SubSkillType { * * @return */ - public PrimarySkillType getParentSkill() { - return PrimarySkillType.getPrimarySkillBySubSkill(this); - } - - /** - * Returns the root address for this skill in the advanced.yml file - * - * @return the root address for this skill in advanced.yml - */ - public String[] getAdvConfigAddress() { - //return "Skills." + StringUtils.getCapitalized(getParentSkill().toString()) + "." + getConfigName(toString()); - //TODO: Reduce string operations - return new String[]{"Skills", StringUtils.getCapitalized(getParentSkill().toString()), getConfigName(toString())}; - } - - /** - * Returns the root address for this skill in the rankskills.yml file - * - * @return the root address for this skill in rankskills.yml - */ - public String[] getRankConfigAddress() { - //return StringUtils.getCapitalized(getParentSkill().toString()) + "." + getConfigName(toString()); - //TODO: Reduce string operations - return new String[]{StringUtils.getCapitalized(getParentSkill().toString()), getConfigName(toString())}; + public PrimarySkillType getParentSkill(mcMMO pluginRef) { + return pluginRef.getSkillTools().getPrimarySkillBySubSkill(this); } /** @@ -162,9 +140,9 @@ public enum SubSkillType { * * @return the permission node for this subskill */ - public String getPermissionNodeAddress() { + public String getPermissionNodeAddress(mcMMO pluginRef) { //TODO: This could be optimized - return "mcmmo.ability." + getParentSkill().toString().toLowerCase() + "." + getConfigName(toString()).toLowerCase(); + return "mcmmo.ability." + getParentSkill(pluginRef).toString().toLowerCase() + "." + getConfigName(toString()).toLowerCase(); } /** @@ -270,7 +248,7 @@ public enum SubSkillType { * @return The parent skill as defined in the locale */ public String getParentNiceNameLocale(mcMMO pluginRef) { - return pluginRef.getLocaleManager().getString(StringUtils.getCapitalized(getParentSkill().toString()) + ".SkillName"); + return pluginRef.getLocaleManager().getString(StringUtils.getCapitalized(getParentSkill(pluginRef).toString()) + ".SkillName"); } /** @@ -304,8 +282,8 @@ public enum SubSkillType { return subStringIndex; } - public String getLocaleKeyRoot() { - return StringUtils.getCapitalized(getParentSkill().toString()) + ".SubSkill." + getConfigName(toString()); + public String getLocaleKeyRoot(mcMMO pluginRef) { + return StringUtils.getCapitalized(getParentSkill(pluginRef).toString()) + ".SubSkill." + getConfigName(toString()); } public String getLocaleName(mcMMO pluginRef) { @@ -320,16 +298,16 @@ public enum SubSkillType { return getFromLocaleSubAddress(pluginRef,".Stat"); } - public String getLocaleKeyStatDescription() { - return getLocaleKeyFromSubAddress(".Stat"); + public String getLocaleKeyStatDescription(mcMMO pluginRef) { + return getLocaleKeyFromSubAddress(pluginRef, ".Stat"); } public String getLocaleStatExtraDescription(mcMMO pluginRef) { return getFromLocaleSubAddress(pluginRef,".Stat.Extra"); } - public String getLocaleKeyStatExtraDescription() { - return getLocaleKeyFromSubAddress(".Stat.Extra"); + public String getLocaleKeyStatExtraDescription(mcMMO pluginRef) { + return getLocaleKeyFromSubAddress(pluginRef, ".Stat.Extra"); } public String getLocaleStat(mcMMO pluginRef, String... vars) { @@ -343,10 +321,10 @@ public enum SubSkillType { } private String getFromLocaleSubAddress(mcMMO pluginRef, String s) { - return pluginRef.getLocaleManager().getString(getLocaleKeyRoot() + s); + return pluginRef.getLocaleManager().getString(getLocaleKeyRoot(pluginRef) + s); } - private String getLocaleKeyFromSubAddress(String s) { - return getLocaleKeyRoot() + s; + private String getLocaleKeyFromSubAddress(mcMMO pluginRef, String subAddress) { + return getLocaleKeyRoot(pluginRef) + subAddress; } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/behaviours/RepairBehaviour.java b/src/main/java/com/gmail/nossr50/datatypes/skills/behaviours/RepairBehaviour.java index a5664a495..8a48ffc96 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/behaviours/RepairBehaviour.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/behaviours/RepairBehaviour.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.datatypes.skills.behaviours; import com.gmail.nossr50.mcMMO; +import org.bukkit.Material; /** * These behaviour classes are a band-aid fix for a larger problem @@ -12,9 +13,14 @@ import com.gmail.nossr50.mcMMO; public class RepairBehaviour { private final mcMMO pluginRef; + private final Material anvilMaterial; public RepairBehaviour(mcMMO pluginRef) { this.pluginRef = pluginRef; + this.anvilMaterial = pluginRef.getConfigManager().getConfigRepair().getRepairGeneral().getRepairAnvilMaterial(); } + public Material getAnvilMaterial() { + return anvilMaterial; + } } diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index b1ad2a382..2b39ba82c 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -10,11 +10,8 @@ import com.gmail.nossr50.events.fake.FakeBlockBreakEvent; import com.gmail.nossr50.events.fake.FakeBlockDamageEvent; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.excavation.ExcavationManager; -import com.gmail.nossr50.skills.herbalism.Herbalism; import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.mining.MiningManager; -import com.gmail.nossr50.skills.repair.Repair; -import com.gmail.nossr50.skills.salvage.Salvage; import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.ItemUtils; @@ -166,10 +163,6 @@ public class BlockListener implements Listener { Player player = event.getPlayer(); - if (!pluginRef.getUserManager().hasPlayerDataKey(player)) { - return; - } - BlockState blockState = event.getBlock().getState(); /* Check if the blocks placed should be monitored so they do not give out XP in the future */ @@ -181,18 +174,20 @@ public class BlockListener implements Listener { McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player); - if (blockState.getType() == Repair.getInstance().getAnvilMaterial() - && PrimarySkillType.REPAIR.doesPlayerHaveSkillPermission(player)) { - if (mcMMOPlayer == null) - return; + if (mcMMOPlayer == null) + return; - if (blockState.getType() == Repair.getInstance().getAnvilMaterial() - && PrimarySkillType.REPAIR.doesPlayerHaveSkillPermission(player)) { - mcMMOPlayer.getRepairManager().placedAnvilCheck(); - } else if (blockState.getType() == Salvage.anvilMaterial - && PrimarySkillType.SALVAGE.doesPlayerHaveSkillPermission(player)) { - mcMMOPlayer.getSalvageManager().placedAnvilCheck(); - } + Material repairAnvil = pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getRepairBehaviour().getAnvilMaterial(); + Material salvageAnvil = pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getSalvageBehaviour().getAnvilMaterial(); + + if (blockState.getType() == repairAnvil + && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.REPAIR, player)) { + //Make some noise + mcMMOPlayer.getRepairManager().placedAnvilCheck(); + + } else if (blockState.getType() == salvageAnvil + && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.SALVAGE, player)) { + mcMMOPlayer.getSalvageManager().placedAnvilCheck(); } } @@ -297,19 +292,19 @@ public class BlockListener implements Listener { * We don't check the block store here because herbalism has too many unusual edge cases. * Instead, we check it inside the drops handler. */ - if (PrimarySkillType.HERBALISM.doesPlayerHaveSkillPermission(player)) { + if (pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.HERBALISM, player)) { herbalismManager.herbalismBlockCheck(blockState); } } /* MINING */ - else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && PrimarySkillType.MINING.doesPlayerHaveSkillPermission(player) && !pluginRef.getPlaceStore().isTrue(blockState)) { + else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.MINING, player) && !pluginRef.getPlaceStore().isTrue(blockState)) { MiningManager miningManager = mcMMOPlayer.getMiningManager(); miningManager.miningBlockCheck(blockState); } /* WOOD CUTTING */ - else if (BlockUtils.isLog(blockState) && ItemUtils.isAxe(heldItem) && PrimarySkillType.WOODCUTTING.doesPlayerHaveSkillPermission(player) && !pluginRef.getPlaceStore().isTrue(blockState)) { + else if (BlockUtils.isLog(blockState) && ItemUtils.isAxe(heldItem) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.WOODCUTTING, player) && !pluginRef.getPlaceStore().isTrue(blockState)) { WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager(); if (woodcuttingManager.canUseTreeFeller(heldItem)) { woodcuttingManager.processTreeFeller(blockState); @@ -319,7 +314,7 @@ public class BlockListener implements Listener { } /* EXCAVATION */ - else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && PrimarySkillType.EXCAVATION.doesPlayerHaveSkillPermission(player) && !pluginRef.getPlaceStore().isTrue(blockState)) { + else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.EXCAVATION, player) && !pluginRef.getPlaceStore().isTrue(blockState)) { ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager(); excavationManager.excavationBlockCheck(blockState); @@ -367,7 +362,7 @@ public class BlockListener implements Listener { BlockState blockState = event.getBlock().getState(); ItemStack heldItem = player.getInventory().getItemInMainHand(); - if (Herbalism.isRecentlyRegrown(blockState)) { + if (pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getHerbalismBehaviour().isRecentlyRegrown(blockState)) { event.setCancelled(true); return; } diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index f6370e73e..55ddaf398 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -8,8 +8,6 @@ import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent; import com.gmail.nossr50.events.fake.FakeEntityDamageEvent; import com.gmail.nossr50.events.fake.FakeEntityTameEvent; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.skills.archery.Archery; -import com.gmail.nossr50.skills.mining.BlastMining; import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.taming.Taming; import com.gmail.nossr50.skills.taming.TamingManager; @@ -18,7 +16,6 @@ import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.random.RandomChanceUtil; -import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.worldguard.WorldGuardUtils; import org.bukkit.Material; @@ -327,7 +324,7 @@ public class EntityListener implements Listener { LivingEntity target = (LivingEntity) defender; - if (CombatUtils.isInvincible(target, damage)) { + if (pluginRef.getCombatTools().isInvincible(target, damage)) { return; } @@ -342,7 +339,7 @@ public class EntityListener implements Listener { attacker = (Entity) animalTamer; } } else if (attacker instanceof TNTPrimed && defender instanceof Player) { - if (BlastMining.processBlastMiningExplosion(event, (TNTPrimed) attacker, (Player) defender)) { + if (pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getMiningBehaviour().processBlastMiningExplosion(event, (TNTPrimed) attacker, (Player) defender)) { return; } } @@ -406,18 +403,18 @@ public class EntityListener implements Listener { return; } - CombatUtils.processCombatAttack(event, attacker, target); - CombatUtils.handleHealthbars(attacker, target, event.getFinalDamage(), pluginRef); + pluginRef.getCombatTools().processCombatAttack(event, attacker, target); + pluginRef.getCombatTools().handleHealthbars(attacker, target, event.getFinalDamage(), pluginRef); /** * This sets entity names back to whatever they are supposed to be */ if (event.getFinalDamage() >= target.getHealth()) { if (attacker instanceof LivingEntity) { - CombatUtils.fixNames((LivingEntity) attacker); + pluginRef.getCombatTools().fixNames((LivingEntity) attacker); } - CombatUtils.fixNames(target); + pluginRef.getCombatTools().fixNames(target); } } @@ -501,7 +498,7 @@ public class EntityListener implements Listener { LivingEntity livingEntity = (LivingEntity) entity; - if (CombatUtils.isInvincible(livingEntity, damage)) { + if (pluginRef.getCombatTools().isInvincible(livingEntity, damage)) { return; } @@ -661,7 +658,7 @@ public class EntityListener implements Listener { return; } - Archery.arrowRetrievalCheck(entity); + pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getArcheryBehaviour().arrowRetrievalCheck(entity); } /** @@ -986,7 +983,7 @@ public class EntityListener implements Listener { Tameable tameable = (Tameable) entity; - if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !CombatUtils.isFriendlyPet(player, tameable)) { + if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !pluginRef.getCombatTools().isFriendlyPet(player, tameable)) { return; } diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index b4f4c0a6d..e991861b7 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.listeners; -import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; @@ -9,7 +8,6 @@ import com.gmail.nossr50.runnables.player.PlayerUpdateInventoryTask; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.worldguard.WorldGuardUtils; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.BrewingStand; @@ -135,7 +133,7 @@ public class InventoryListener implements Listener { return; } - if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !PrimarySkillType.SMELTING.doesPlayerHaveSkillPermission(player)) { + if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.SMELTING, player)) { return; } @@ -401,16 +399,35 @@ public class InventoryListener implements Listener { } ItemStack item = event.getItem(); - - if (MainConfig.getInstance().getPreventHopperTransferIngredients() && item.getType() != Material.POTION && item.getType() != Material.SPLASH_POTION && item.getType() != Material.LINGERING_POTION) { - event.setCancelled(true); - return; - } - - if (MainConfig.getInstance().getPreventHopperTransferBottles() && (item.getType() == Material.POTION || item.getType() == Material.SPLASH_POTION || item.getType() == Material.LINGERING_POTION)) { - event.setCancelled(true); - return; - } + //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced + //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced + //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced + //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced + //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced + //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced + //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced + //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced + //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced + //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced + //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced + //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced + //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced + //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced + //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced + //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced + //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced + //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced + //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced + //TODO: Code here relating to preventing hoppers for Alchemy, needs to be replaced +// if (MainConfig.getInstance().getPreventHopperTransferIngredients() && item.getType() != Material.POTION && item.getType() != Material.SPLASH_POTION && item.getType() != Material.LINGERING_POTION) { +// event.setCancelled(true); +// return; +// } +// +// if (MainConfig.getInstance().getPreventHopperTransferBottles() && (item.getType() == Material.POTION || item.getType() == Material.SPLASH_POTION || item.getType() == Material.LINGERING_POTION)) { +// event.setCancelled(true); +// return; +// } // if (MainConfig.getInstance().getEnabledForHoppers() && AlchemyPotionBrewer.isValidIngredient(null, item)) { // AlchemyPotionBrewer.scheduleCheck(null, (BrewingStand) holder); diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index e900cd05d..440c40e6f 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -14,9 +14,7 @@ import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask; import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.mining.MiningManager; -import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.repair.RepairManager; -import com.gmail.nossr50.skills.salvage.Salvage; import com.gmail.nossr50.skills.salvage.SalvageManager; import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.util.*; @@ -252,7 +250,7 @@ public class PlayerListener implements Listener { return; } - if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !PrimarySkillType.FISHING.doesPlayerHaveSkillPermission(player)) { + if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.FISHING, player)) { return; } @@ -327,7 +325,7 @@ public class PlayerListener implements Listener { return; } - if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !PrimarySkillType.FISHING.doesPlayerHaveSkillPermission(player)) { + if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.FISHING, player)) { return; } @@ -592,8 +590,8 @@ public class PlayerListener implements Listener { if (!pluginRef.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() || player.isSneaking()) { /* REPAIR CHECKS */ - if (type == Repair.getInstance().getAnvilMaterial() - && PrimarySkillType.REPAIR.doesPlayerHaveSkillPermission(player) + if (type == pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getRepairBehaviour().getAnvilMaterial() + && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.REPAIR, player) && pluginRef.getRepairableManager().isRepairable(heldItem) && heldItem.getAmount() <= 1) { RepairManager repairManager = mcMMOPlayer.getRepairManager(); @@ -606,8 +604,8 @@ public class PlayerListener implements Listener { } } /* SALVAGE CHECKS */ - else if (type == Salvage.anvilMaterial - && PrimarySkillType.SALVAGE.doesPlayerHaveSkillPermission(player) + else if (type == pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getSalvageBehaviour().getAnvilMaterial() + && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.SALVAGE, player) && RankUtils.hasUnlockedSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR) && pluginRef.getSalvageableManager().isSalvageable(heldItem) && heldItem.getAmount() <= 1) { @@ -634,30 +632,32 @@ public class PlayerListener implements Listener { break; case LEFT_CLICK_BLOCK: - type = block.getType(); - - if (!pluginRef.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() || player.isSneaking()) { - /* REPAIR CHECKS */ - if (type == Repair.getInstance().getAnvilMaterial() && PrimarySkillType.REPAIR.doesPlayerHaveSkillPermission(player) && pluginRef.getRepairableManager().isRepairable(heldItem)) { - RepairManager repairManager = mcMMOPlayer.getRepairManager(); - - // Cancel repairing an enchanted item - if (repairManager.checkConfirmation(false)) { - repairManager.setLastAnvilUse(0); - player.sendMessage(pluginRef.getLocaleManager().getString("Skills.Cancelled", pluginRef.getLocaleManager().getString("Repair.Pretty.Name"))); - } - } - /* SALVAGE CHECKS */ - else if (type == Salvage.anvilMaterial && PrimarySkillType.SALVAGE.doesPlayerHaveSkillPermission(player) && pluginRef.getSalvageableManager().isSalvageable(heldItem)) { - SalvageManager salvageManager = mcMMOPlayer.getSalvageManager(); - - // Cancel salvaging an enchanted item - if (salvageManager.checkConfirmation(false)) { - salvageManager.setLastAnvilUse(0); - player.sendMessage(pluginRef.getLocaleManager().getString("Skills.Cancelled", pluginRef.getLocaleManager().getString("Salvage.Pretty.Name"))); - } - } - } + //TODO: Not sure why this code is here, I disabled it for now. + //TODO: Not sure why this code is here, I disabled it for now. + //TODO: Not sure why this code is here, I disabled it for now. +// type = block.getType(); +// if (!pluginRef.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() || player.isSneaking()) { +// /* REPAIR CHECKS */ +// if (type == Repair.getInstance().getAnvilMaterial() && PrimarySkillType.REPAIR.doesPlayerHaveSkillPermission(player) && pluginRef.getRepairableManager().isRepairable(heldItem)) { +// RepairManager repairManager = mcMMOPlayer.getRepairManager(); +// +// // Cancel repairing an enchanted item +// if (repairManager.checkConfirmation(false)) { +// repairManager.setLastAnvilUse(0); +// player.sendMessage(pluginRef.getLocaleManager().getString("Skills.Cancelled", pluginRef.getLocaleManager().getString("Repair.Pretty.Name"))); +// } +// } +// /* SALVAGE CHECKS */ +// else if (type == Salvage.anvilMaterial && PrimarySkillType.SALVAGE.doesPlayerHaveSkillPermission(player) && pluginRef.getSalvageableManager().isSalvageable(heldItem)) { +// SalvageManager salvageManager = mcMMOPlayer.getSalvageManager(); +// +// // Cancel salvaging an enchanted item +// if (salvageManager.checkConfirmation(false)) { +// salvageManager.setLastAnvilUse(0); +// player.sendMessage(pluginRef.getLocaleManager().getString("Skills.Cancelled", pluginRef.getLocaleManager().getString("Salvage.Pretty.Name"))); +// } +// } +// } break; @@ -880,11 +880,11 @@ public class PlayerListener implements Listener { String lowerCaseCommand = command.toLowerCase(); // Do these ACTUALLY have to be lower case to work properly? - for (PrimarySkillType skill : PrimarySkillType.values()) { - String skillName = skill.toString().toLowerCase(); - String localizedName = skill.getLocalizedSkillName().toLowerCase(); + for (PrimarySkillType primarySkillType : PrimarySkillType.values()) { + String skillName = primarySkillType.toString().toLowerCase(); + String localizedName = pluginRef.getSkillTools().getLocalizedSkillName(primarySkillType).toLowerCase(); - if (lowerCaseCommand.equals(localizedName)) { + if (command.equalsIgnoreCase(localizedName)) { event.setMessage(message.replace(command, skillName)); break; } @@ -895,17 +895,4 @@ public class PlayerListener implements Listener { } } } - - /*@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onPlayerStatisticIncrementEvent(PlayerStatisticIncrementEvent event) { - *//* WORLD BLACKLIST CHECK *//* - if(pluginRef.getDynamicSettingsManager().isWorldBlacklisted(event.getPlayer().getWorld().getName())) - return; - - if (!mcMMO.getHolidayManager().isAprilFirst()) { - return; - } - - mcMMO.getHolidayManager().handleStatisticEvent(event); - }*/ } diff --git a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java index f42ac51e1..127332328 100644 --- a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java @@ -105,7 +105,7 @@ public class SelfListener implements Listener { return; } - if (primarySkillType.isChildSkill()) { + if (pluginRef.getSkillTools().isChildSkill(primarySkillType)) { return; } @@ -113,7 +113,7 @@ public class SelfListener implements Listener { double guaranteedMinimum = pluginRef.getConfigManager().getConfigLeveling().getGuaranteedMinimums() * rawXp; - double modifiedThreshold = (double) (threshold / primarySkillType.getXpModifier() * pluginRef.getDynamicSettingsManager().getExperienceManager().getGlobalXpMult()); + double modifiedThreshold = (double) (threshold / pluginRef.getSkillTools().getXpModifier(primarySkillType) * pluginRef.getDynamicSettingsManager().getExperienceManager().getGlobalXpMult()); double difference = (mcMMOPlayer.getProfile().getRegisteredXpGain(primarySkillType) - modifiedThreshold) / modifiedThreshold; if (difference > 0) { diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index c8b1689e3..3475200b0 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -39,6 +39,7 @@ import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.util.player.PlayerLevelUtils; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager; +import com.gmail.nossr50.util.skills.CombatTools; import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.SkillTools; import com.gmail.nossr50.worldguard.WorldGuardManager; @@ -88,6 +89,7 @@ public class mcMMO extends JavaPlugin { private DatabaseManagerFactory databaseManagerFactory; private CommandTools commandTools; private SkillTools skillTools; //TODO: Remove once a new skill system is in place + private CombatTools combatTools; //TODO: Rewrite this garbo private TextComponentFactory textComponentFactory; /* Never-Ending tasks */ @@ -239,6 +241,9 @@ public class mcMMO extends JavaPlugin { //Init Skill Tools skillTools = new SkillTools(this); + + //Init Combat Tools + combatTools = new CombatTools(this); } @Override @@ -742,4 +747,8 @@ public class mcMMO extends JavaPlugin { public SkillTools getSkillTools() { return skillTools; } + + public CombatTools getCombatTools() { + return combatTools; + } } diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index 2df76bc35..876c005b6 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -673,7 +673,7 @@ public final class PartyManager { ArrayList hasAlly = new ArrayList(); for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) { - Party party = new Party(partyName); + Party party = new Party(partyName, pluginRef); String[] leaderSplit = partiesFile.getString(partyName + ".Leader").split("[|]"); party.setLeader(new PartyLeader(UUID.fromString(leaderSplit[0]), leaderSplit[1])); diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java index f593b285a..cc2ac6925 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.runnables.skills; import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.skills.BleedContainer; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; @@ -47,7 +46,7 @@ public class BleedTimerTask extends BukkitRunnable { */ if (bleedList.containsKey(entity)) { - CombatUtils.dealNoInvulnerabilityTickDamage(entity, bleedList.get(entity).bleedTicks * 2, bleedList.get(entity).damageSource); + pluginRef.getCombatTools().dealNoInvulnerabilityTickDamage(entity, bleedList.get(entity).bleedTicks * 2, bleedList.get(entity).damageSource); } } @@ -155,7 +154,7 @@ public class BleedTimerTask extends BukkitRunnable { // debugMessage+="TargetHealthBeforeDMG=["+String.valueOf(target.getHealth())+"], "; - CombatUtils.dealNoInvulnerabilityTickDamageRupture(target, damage, containerEntry.getValue().damageSource, toolTier); + pluginRef.getCombatTools().dealNoInvulnerabilityTickDamageRupture(target, damage, containerEntry.getValue().damageSource, toolTier); double victimHealthAftermath = target.getHealth(); diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java index e4dad0434..4e32f226e 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java @@ -71,7 +71,7 @@ public class AcrobaticsManager extends SkillManager { return false; }*/ - return skill.canCombatSkillsTrigger(damager); + return pluginRef.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.ACROBATICS, damager); } return false; diff --git a/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java index 82bd03c06..efd6fab3e 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java @@ -12,7 +12,6 @@ import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.random.RandomChanceUtil; -import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.SkillActivationType; @@ -173,6 +172,6 @@ public class AxesManager extends SkillManager { * @param damage The amount of damage initially dealt by the event */ public void skullSplitterCheck(LivingEntity target, double damage, Map modifiers) { - CombatUtils.applyAbilityAoE(getPlayer(), target, damage / pluginRef.getConfigManager().getConfigAxes().getConfigAxesSkullSplitter().getSkullSplitterDamageDivisor(), modifiers, skill); + pluginRef.getCombatTools().applyAbilityAoE(getPlayer(), target, damage / pluginRef.getConfigManager().getConfigAxes().getConfigAxesSkullSplitter().getSkullSplitterDamageDivisor(), modifiers, skill); } } diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index 30cc26d93..eb6e85e42 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -23,7 +23,6 @@ import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.random.RandomChanceUtil; -import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; @@ -427,7 +426,7 @@ public class FishingManager extends SkillManager { } Misc.dropItem(target.getLocation(), drop); - 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. + pluginRef.getCombatTools().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. applyXpGain(pluginRef.getConfigManager().getConfigExperience().getShakeXP(), XPGainReason.PVE); } } diff --git a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java index dda15b31e..dea7cd829 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java @@ -11,7 +11,6 @@ import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.random.RandomChanceUtil; -import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.SkillActivationType; import org.bukkit.entity.Entity; @@ -121,7 +120,7 @@ public class SwordsManager extends SkillManager { */ public void counterAttackChecks(LivingEntity attacker, double damage) { if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.SWORDS_COUNTER_ATTACK, getPlayer())) { - CombatUtils.dealDamage(attacker, damage / pluginRef.getConfigManager().getConfigSwords().getCounterAttackDamageModifier(), getPlayer()); + pluginRef.getCombatTools().dealDamage(attacker, damage / pluginRef.getConfigManager().getConfigSwords().getCounterAttackDamageModifier(), getPlayer()); pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Countered"); @@ -138,6 +137,6 @@ public class SwordsManager extends SkillManager { * @param damage The amount of damage initially dealt by the event */ public void serratedStrikes(LivingEntity target, double damage, Map modifiers) { - CombatUtils.applyAbilityAoE(getPlayer(), target, damage / pluginRef.getConfigManager().getConfigSwords().getSerratedStrikesDamageModifier(), modifiers, skill); + pluginRef.getCombatTools().applyAbilityAoE(getPlayer(), target, damage / pluginRef.getConfigManager().getConfigSwords().getSerratedStrikesDamageModifier(), modifiers, skill); } } diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java b/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java index ec4898865..ed02f9b86 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.skills.taming; import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils; import org.bukkit.Location; import org.bukkit.Sound; @@ -35,7 +34,7 @@ public class TrackedTamingEntity extends BukkitRunnable { Location location = livingEntity.getLocation(); location.getWorld().playSound(location, Sound.BLOCK_FIRE_EXTINGUISH, 0.8F, 0.8F); ParticleEffectUtils.playCallOfTheWildEffect(livingEntity); - CombatUtils.dealDamage(livingEntity, livingEntity.getMaxHealth(), DamageCause.SUICIDE, livingEntity); + pluginRef.getCombatTools().dealDamage(livingEntity, livingEntity.getMaxHealth(), DamageCause.SUICIDE, livingEntity); } TamingManager.removeFromTracker(this); diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java index cb8a9beec..8e1f83faf 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java @@ -14,7 +14,6 @@ import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.random.RandomChanceUtil; -import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.SkillActivationType; import org.bukkit.Material; @@ -107,7 +106,7 @@ public class WoodcuttingManager extends SkillManager { double health = player.getHealth(); if (health > 1) { - CombatUtils.dealDamage(player, Misc.getRandom().nextInt((int) (health - 1))); + pluginRef.getCombatTools().dealDamage(player, Misc.getRandom().nextInt((int) (health - 1))); } return; diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index eb740f71e..bc88d7fdf 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.items.ChimaeraWingWarmup; -import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import org.bukkit.Location; @@ -84,7 +83,7 @@ public final class ChimaeraWing { pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Item.ChimaeraWing.Fail"); player.updateInventory(); player.setVelocity(new Vector(0, 0.5D, 0)); - CombatUtils.dealDamage(player, Misc.getRandom().nextInt((int) (player.getHealth() - 10))); + pluginRef.getCombatTools().dealDamage(player, Misc.getRandom().nextInt((int) (player.getHealth() - 10))); mcMMOPlayer.actualizeChimeraWingLastUse(); return; } diff --git a/src/main/java/com/gmail/nossr50/util/EventManager.java b/src/main/java/com/gmail/nossr50/util/EventManager.java index 29800cfb7..a192414d1 100644 --- a/src/main/java/com/gmail/nossr50/util/EventManager.java +++ b/src/main/java/com/gmail/nossr50/util/EventManager.java @@ -31,7 +31,6 @@ import com.gmail.nossr50.events.skills.salvage.McMMOPlayerSalvageCheckEvent; import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillEvent; import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDisarmEvent; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.skills.CombatUtils; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; import org.bukkit.block.Block; @@ -133,7 +132,7 @@ public class EventManager { LivingEntity livingEntity = (LivingEntity) entity; - if (CombatUtils.isInvincible(livingEntity, damage)) { + if (pluginRef.getCombatTools().isInvincible(livingEntity, damage)) { return false; } diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatTools.java similarity index 84% rename from src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java rename to src/main/java/com/gmail/nossr50/util/skills/CombatTools.java index ce4efbbf0..60fd4d09d 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatTools.java @@ -39,11 +39,14 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -public final class CombatUtils { - private CombatUtils() { +public final class CombatTools { + private final mcMMO pluginRef; + + public CombatTools(mcMMO pluginRef) { + this.pluginRef = pluginRef; } - private static void processSwordCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) { + private void processSwordCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) { if (event.getCause() == DamageCause.THORNS) { return; } @@ -82,7 +85,7 @@ public final class CombatUtils { startGainXp(mcMMOPlayer, target, PrimarySkillType.SWORDS); } - private static void processAxeCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) { + private void processAxeCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) { if (event.getCause() == DamageCause.THORNS) { return; } @@ -124,7 +127,7 @@ public final class CombatUtils { startGainXp(mcMMOPlayer, target, PrimarySkillType.AXES); } - private static void processUnarmedCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) { + private void processUnarmedCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) { if (event.getCause() == DamageCause.THORNS) { return; } @@ -163,7 +166,7 @@ public final class CombatUtils { Unarmed.lastAttacked = System.currentTimeMillis(); //Track how often the player is punching } - private static void processTamingCombat(LivingEntity target, Player master, Wolf wolf, EntityDamageByEntityEvent event) { + private void processTamingCombat(LivingEntity target, Player master, Wolf wolf, EntityDamageByEntityEvent event) { double initialDamage = event.getDamage(); double finalDamage = initialDamage; @@ -188,7 +191,7 @@ public final class CombatUtils { startGainXp(mcMMOPlayer, target, PrimarySkillType.TAMING); } - private static void processArcheryCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event, Arrow arrow) { + private void processArcheryCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event, Arrow arrow) { double initialDamage = event.getDamage(); McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player); @@ -196,7 +199,8 @@ public final class CombatUtils { double finalDamage = event.getDamage(); - if (target instanceof Player && PrimarySkillType.UNARMED.getPVPEnabled()) { + if (target instanceof Player + && pluginRef.getSkillTools().getPVPEnabled(PrimarySkillType.UNARMED)) { UnarmedManager unarmedManager = pluginRef.getUserManager().getPlayer((Player) target).getUnarmedManager(); if (unarmedManager.canDeflect()) { @@ -239,7 +243,7 @@ public final class CombatUtils { * * @param event The event to run the combat checks on. */ - public static void processCombatAttack(EntityDamageByEntityEvent event, Entity attacker, LivingEntity target) { + public void processCombatAttack(EntityDamageByEntityEvent event, Entity attacker, LivingEntity target) { Entity damager = event.getDamager(); EntityType entityType = damager.getType(); @@ -260,7 +264,7 @@ public final class CombatUtils { } if (ItemUtils.isSword(player.getInventory().getItemInMainHand())) { - if (!PrimarySkillType.SWORDS.canCombatSkillsTrigger(target)) { + if (!pluginRef.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.SWORDS, target)) { return; } @@ -298,27 +302,27 @@ public final class CombatUtils { } if (ItemUtils.isSword(heldItem)) { - if (!PrimarySkillType.SWORDS.canCombatSkillsTrigger(target)) { + if (!pluginRef.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.SWORDS, target)) { return; } - if (PrimarySkillType.SWORDS.doesPlayerHaveSkillPermission(player)) { + if (pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.SWORDS, player)) { processSwordCombat(target, player, event); } } else if (ItemUtils.isAxe(heldItem)) { - if (!PrimarySkillType.AXES.canCombatSkillsTrigger(target)) { + if (!pluginRef.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.AXES, target)) { return; } - if (PrimarySkillType.AXES.doesPlayerHaveSkillPermission(player)) { + if (pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.AXES, player)) { processAxeCombat(target, player, event); } } else if (ItemUtils.isUnarmed(heldItem)) { - if (!PrimarySkillType.UNARMED.canCombatSkillsTrigger(target)) { + if (!pluginRef.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.UNARMED, target)) { return; } - if (PrimarySkillType.UNARMED.doesPlayerHaveSkillPermission(player)) { + if (pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.UNARMED, player)) { processUnarmedCombat(target, player, event); } } @@ -326,10 +330,10 @@ public final class CombatUtils { Wolf wolf = (Wolf) damager; AnimalTamer tamer = wolf.getOwner(); - if (tamer instanceof Player && PrimarySkillType.TAMING.canCombatSkillsTrigger(target)) { + if (tamer instanceof Player && pluginRef.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.TAMING, target)) { Player master = (Player) tamer; - if (!Misc.isNPCEntityExcludingVillagers(master) && PrimarySkillType.TAMING.doesPlayerHaveSkillPermission(master)) { + if (!Misc.isNPCEntityExcludingVillagers(master) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.TAMING, master)) { processTamingCombat(target, master, wolf, event); } } @@ -337,14 +341,14 @@ public final class CombatUtils { Arrow arrow = (Arrow) damager; ProjectileSource projectileSource = arrow.getShooter(); - if (projectileSource instanceof Player && PrimarySkillType.ARCHERY.canCombatSkillsTrigger(target)) { + if (projectileSource instanceof Player && pluginRef.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.ARCHERY, target)) { Player player = (Player) projectileSource; - if (!Misc.isNPCEntityExcludingVillagers(player) && PrimarySkillType.ARCHERY.doesPlayerHaveSkillPermission(player)) { + if (!Misc.isNPCEntityExcludingVillagers(player) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.ARCHERY, player)) { processArcheryCombat(target, player, event, arrow); } - if (target.getType() != EntityType.CREEPER && !Misc.isNPCEntityExcludingVillagers(player) && PrimarySkillType.TAMING.doesPlayerHaveSkillPermission(player)) { + if (target.getType() != EntityType.CREEPER && !Misc.isNPCEntityExcludingVillagers(player) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.TAMING, player)) { McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player); TamingManager tamingManager = mcMMOPlayer.getTamingManager(); tamingManager.attackTarget(target); @@ -358,7 +362,7 @@ public final class CombatUtils { * * @param entity target entity */ - public static void fixNames(LivingEntity entity) { + public void fixNames(LivingEntity entity) { List metadataValue = entity.getMetadata("mcMMO_oldName"); if (metadataValue.size() <= 0) @@ -371,7 +375,7 @@ public final class CombatUtils { } } - public static int getLimitBreakDamage(Player player, SubSkillType subSkillType) { + public int getLimitBreakDamage(Player player, SubSkillType subSkillType) { return RankUtils.getRank(player, subSkillType); } @@ -381,7 +385,7 @@ public final class CombatUtils { * @param player target player * @return true if the player has access to the limit break */ - public static boolean canUseLimitBreak(Player player, SubSkillType subSkillType) { + public boolean canUseLimitBreak(Player player, SubSkillType subSkillType) { return RankUtils.hasUnlockedSubskill(player, subSkillType) && Permissions.isSubSkillEnabled(player, subSkillType); } @@ -393,7 +397,7 @@ public final class CombatUtils { * @param damage Amount of damage to attempt to do */ @Deprecated - public static void dealDamage(LivingEntity target, double damage) { + public void dealDamage(LivingEntity target, double damage) { dealDamage(target, damage, DamageCause.CUSTOM, null); } @@ -405,7 +409,7 @@ public final class CombatUtils { * @param attacker Player to pass to event as damager */ @Deprecated - public static void dealDamage(LivingEntity target, double damage, LivingEntity attacker) { + public void dealDamage(LivingEntity target, double damage, LivingEntity attacker) { dealDamage(target, damage, DamageCause.CUSTOM, attacker); } @@ -416,7 +420,7 @@ public final class CombatUtils { * @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 modifiers, LivingEntity attacker) { + public void dealDamage(LivingEntity target, double damage, Map modifiers, LivingEntity attacker) { if (target.isDead()) { return; } @@ -433,7 +437,7 @@ public final class CombatUtils { * @param attacker Player to pass to event as damager */ @Deprecated - public static void dealDamage(LivingEntity target, double damage, DamageCause cause, Entity attacker) { + public void dealDamage(LivingEntity target, double damage, DamageCause cause, Entity attacker) { if (target.isDead()) { return; } @@ -442,7 +446,7 @@ public final class CombatUtils { target.damage(damage); } - public static void dealNoInvulnerabilityTickDamage(LivingEntity target, double damage, Entity attacker) { + public void dealNoInvulnerabilityTickDamage(LivingEntity target, double damage, Entity attacker) { if (target.isDead()) { return; } @@ -457,7 +461,7 @@ public final class CombatUtils { target.setHealth(newHealth); } - public static void dealNoInvulnerabilityTickDamageRupture(LivingEntity target, double damage, Entity attacker, int toolTier) { + public void dealNoInvulnerabilityTickDamageRupture(LivingEntity target, double damage, Entity attacker, int toolTier) { if (target.isDead()) { return; } @@ -474,7 +478,7 @@ public final class CombatUtils { * @param damage The initial damage amount * @param type The type of skill being used */ - public static void applyAbilityAoE(Player attacker, LivingEntity target, double damage, Map modifiers, PrimarySkillType type) { + public void applyAbilityAoE(Player attacker, LivingEntity target, double damage, Map modifiers, PrimarySkillType type) { int numberOfTargets = getTier(attacker.getInventory().getItemInMainHand()); // The higher the weapon tier, the more targets you hit double damageAmount = Math.max(damage, 1); @@ -515,7 +519,7 @@ public final class CombatUtils { } } - public static void startGainXp(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType) { + public void startGainXp(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType) { startGainXp(mcMMOPlayer, target, primarySkillType, 1.0); } @@ -526,7 +530,7 @@ public final class CombatUtils { * @param target The defending entity * @param primarySkillType The skill being used */ - private static void startGainXp(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType, double multiplier) { + private void startGainXp(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType, double multiplier) { double baseXPMultiplier = 0; XPGainReason xpGainReason; @@ -595,7 +599,7 @@ public final class CombatUtils { * @param entity The defending Entity * @return true if the Entity should be damaged, false otherwise. */ - private static boolean shouldBeAffected(Player player, Entity entity) { + private boolean shouldBeAffected(Player player, Entity entity) { if (entity instanceof Player) { Player defender = (Player) entity; @@ -646,7 +650,7 @@ public final class CombatUtils { * @param eventDamage The damage from the event the entity is involved in * @return true if the entity is invincible, false otherwise */ - public static boolean isInvincible(LivingEntity entity, double eventDamage) { + public boolean isInvincible(LivingEntity entity, double eventDamage) { /* * So apparently if you do more damage to a LivingEntity than its last damage int you bypass the invincibility. * So yeah, this is for that. @@ -661,7 +665,7 @@ public final class CombatUtils { * @param pet The entity to check. * @return true if the entity is friendly, false otherwise */ - public static boolean isFriendlyPet(Player attacker, Tameable pet) { + public boolean isFriendlyPet(Player attacker, Tameable pet) { if (pet.isTamed()) { AnimalTamer tamer = pet.getOwner(); @@ -676,12 +680,12 @@ public final class CombatUtils { } @Deprecated - public static double getFakeDamageFinalResult(Entity attacker, Entity target, double damage) { + public double getFakeDamageFinalResult(Entity attacker, Entity target, double damage) { return getFakeDamageFinalResult(attacker, target, DamageCause.ENTITY_ATTACK, new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, damage))); } @Deprecated - public static double getFakeDamageFinalResult(Entity attacker, Entity target, DamageCause damageCause, double damage) { + public double getFakeDamageFinalResult(Entity attacker, Entity target, DamageCause damageCause, double damage) { EntityDamageEvent damageEvent = sendEntityDamageEvent(attacker, target, damageCause, damage); if (damageEvent.isCancelled()) { @@ -691,7 +695,7 @@ public final class CombatUtils { return damageEvent.getFinalDamage(); } - public static boolean canDamage(Entity attacker, Entity target, DamageCause damageCause, double damage) { + public boolean canDamage(Entity attacker, Entity target, DamageCause damageCause, double damage) { EntityDamageEvent damageEvent = sendEntityDamageEvent(attacker, target, damageCause, damage); if (damageEvent.isCancelled()) { @@ -701,21 +705,21 @@ public final class CombatUtils { return true; } - public static EntityDamageEvent sendEntityDamageEvent(Entity attacker, Entity target, DamageCause damageCause, double damage) { + public EntityDamageEvent sendEntityDamageEvent(Entity attacker, Entity target, DamageCause damageCause, double damage) { EntityDamageEvent damageEvent = attacker == null ? new FakeEntityDamageEvent(target, damageCause, damage) : new FakeEntityDamageByEntityEvent(attacker, target, damageCause, damage); pluginRef.getServer().getPluginManager().callEvent(damageEvent); return damageEvent; } - public static double getFakeDamageFinalResult(Entity attacker, Entity target, Map modifiers) { + public double getFakeDamageFinalResult(Entity attacker, Entity target, Map modifiers) { return getFakeDamageFinalResult(attacker, target, DamageCause.ENTITY_ATTACK, modifiers); } - public static double getFakeDamageFinalResult(Entity attacker, Entity target, double damage, Map modifiers) { + public double getFakeDamageFinalResult(Entity attacker, Entity target, double damage, Map modifiers) { return getFakeDamageFinalResult(attacker, target, DamageCause.ENTITY_ATTACK, getScaledModifiers(damage, modifiers)); } - public static double getFakeDamageFinalResult(Entity attacker, Entity target, DamageCause cause, Map modifiers) { + public double getFakeDamageFinalResult(Entity attacker, Entity target, DamageCause cause, Map modifiers) { EntityDamageEvent damageEvent = attacker == null ? new FakeEntityDamageEvent(target, cause, modifiers) : new FakeEntityDamageByEntityEvent(attacker, target, cause, modifiers); pluginRef.getServer().getPluginManager().callEvent(damageEvent); @@ -726,7 +730,7 @@ public final class CombatUtils { return damageEvent.getFinalDamage(); } - private static Map getModifiers(EntityDamageEvent event) { + private Map getModifiers(EntityDamageEvent event) { Map modifiers = new HashMap<>(); for (DamageModifier modifier : DamageModifier.values()) { modifiers.put(modifier, event.getDamage(modifier)); @@ -735,7 +739,7 @@ public final class CombatUtils { return modifiers; } - private static Map getScaledModifiers(double damage, Map modifiers) { + private Map getScaledModifiers(double damage, Map modifiers) { Map scaledModifiers = new HashMap<>(); for (DamageModifier modifier : modifiers.keySet()) { @@ -750,7 +754,7 @@ public final class CombatUtils { return scaledModifiers; } - public static void applyScaledModifiers(double initialDamage, double finalDamage, EntityDamageByEntityEvent event) { + public void applyScaledModifiers(double initialDamage, double finalDamage, EntityDamageByEntityEvent event) { // No additional damage if (initialDamage == finalDamage) { return; @@ -777,7 +781,7 @@ public final class CombatUtils { * @param inHand The item to check the tier of * @return the tier of the item */ - private static int getTier(ItemStack inHand) { + private int getTier(ItemStack inHand) { int tier = 0; if (ItemUtils.isWoodTool(inHand)) { @@ -798,7 +802,7 @@ public final class CombatUtils { return tier; } - public static void handleHealthbars(Entity attacker, LivingEntity target, double damage, mcMMO plugin) { + public void handleHealthbars(Entity attacker, LivingEntity target, double damage, mcMMO plugin) { if (!(attacker instanceof Player)) { return; }