From 21b8626366fabb8439d7751b806697ae68ae533a Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 25 Feb 2013 16:54:29 -0500 Subject: [PATCH] Put our managers on payroll, rather than firing them at the end of their shift. --- .../nossr50/listeners/EntityListener.java | 12 +-- .../nossr50/listeners/InventoryListener.java | 11 +-- .../nossr50/listeners/PlayerListener.java | 15 ++-- .../gmail/nossr50/skills/SkillManager.java | 15 +++- .../skills/archery/ArcheryManager.java | 2 +- .../nossr50/skills/mining/MiningManager.java | 4 +- .../skills/smelting/SmeltingManager.java | 2 +- .../nossr50/skills/swords/SwordsManager.java | 4 +- .../nossr50/skills/taming/TamingManager.java | 2 +- .../skills/unarmed/UnarmedManager.java | 4 +- .../nossr50/skills/utilities/CombatTools.java | 74 ++++++++----------- 11 files changed, 65 insertions(+), 80 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index cd3d7a3e8..c8c9799b2 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -32,15 +32,14 @@ import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent; import com.gmail.nossr50.events.fake.FakeEntityDamageEvent; import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.acrobatics.Acrobatics; import com.gmail.nossr50.skills.archery.Archery; import com.gmail.nossr50.skills.fishing.Fishing; import com.gmail.nossr50.skills.herbalism.Herbalism; import com.gmail.nossr50.skills.mining.BlastMining; -import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.runnables.BleedTimer; import com.gmail.nossr50.skills.taming.Taming; -import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.utilities.CombatTools; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -328,8 +327,7 @@ public class EntityListener implements Listener { Player player = plugin.getTNTPlayer(id); if (Permissions.biggerBombs(player)) { - MiningManager miningManager = new MiningManager(Users.getPlayer(player)); - miningManager.biggerBombs(event); + SkillManagerStore.getInstance().getMiningManager(player.getName()).biggerBombs(event); } } } @@ -350,8 +348,7 @@ public class EntityListener implements Listener { if (plugin.tntIsTracked(id)) { Player player = plugin.getTNTPlayer(id); - MiningManager miningManager = new MiningManager(Users.getPlayer(player)); - miningManager.blastMiningDropProcessing(event); + SkillManagerStore.getInstance().getMiningManager(player.getName()).blastMiningDropProcessing(event); plugin.removeFromTNTTracker(id); } @@ -430,8 +427,7 @@ public class EntityListener implements Listener { return; } - TamingManager tamingManager = new TamingManager(Users.getPlayer(player)); - tamingManager.awardTamingXP(event); + SkillManagerStore.getInstance().getTamingManager(player.getName()).awardTamingXP(event); } @EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true) diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 75cae3f9f..b127aed13 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -19,7 +19,7 @@ import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.skills.smelting.SmeltingManager; +import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.util.ItemChecks; import com.gmail.nossr50.util.Users; @@ -84,8 +84,7 @@ public class InventoryListener implements Listener{ Player player = plugin.getFurnacePlayer(furnaceBlock); if (player != null) { - SmeltingManager smeltingManager = new SmeltingManager(Users.getPlayer(player)); - smeltingManager.fuelEfficiency(event); + SkillManagerStore.getInstance().getSmeltingManager(player.getName()).fuelEfficiency(event); } } } @@ -104,8 +103,7 @@ public class InventoryListener implements Listener{ Player player = plugin.getFurnacePlayer(furnaceBlock); if (player != null) { - SmeltingManager smeltingManager = new SmeltingManager(Users.getPlayer(player)); - smeltingManager.smeltProcessing(event); + SkillManagerStore.getInstance().getSmeltingManager(player.getName()).smeltProcessing(event); } } } @@ -124,8 +122,7 @@ public class InventoryListener implements Listener{ McMMOPlayer mcMMOPlayer = Users.getPlayer(event.getPlayer()); if (mcMMOPlayer.getPlayer().equals(plugin.getFurnacePlayer(furnaceBlock))) { - SmeltingManager smeltingManager = new SmeltingManager(mcMMOPlayer); - smeltingManager.vanillaXPBoost(event); + SkillManagerStore.getInstance().getSmeltingManager(event.getPlayer().getName()).vanillaXPBoost(event); } } } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index a5a30477f..a039fd5a0 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -34,14 +34,13 @@ import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.ShareHandler; +import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.fishing.Fishing; import com.gmail.nossr50.skills.herbalism.Herbalism; import com.gmail.nossr50.skills.mining.BlastMining; -import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.repair.Salvage; import com.gmail.nossr50.skills.runnables.BleedTimer; -import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.utilities.AbilityType; import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; @@ -296,8 +295,7 @@ public class PlayerListener implements Listener { } /* BLAST MINING CHECK */ else if (player.isSneaking() && Permissions.remoteDetonation(player) && heldItem.getTypeId() == BlastMining.detonatorID) { - MiningManager miningManager = new MiningManager(Users.getPlayer(player)); - miningManager.detonate(event); + SkillManagerStore.getInstance().getMiningManager(player.getName()).detonate(event); } break; @@ -305,8 +303,7 @@ public class PlayerListener implements Listener { case RIGHT_CLICK_AIR: /* BLAST MINING CHECK */ if (player.isSneaking() && Permissions.remoteDetonation(player) && heldItem.getTypeId() == BlastMining.detonatorID) { - MiningManager miningManager = new MiningManager(Users.getPlayer(player)); - miningManager.detonate(event); + SkillManagerStore.getInstance().getMiningManager(player.getName()).detonate(event); } break; @@ -397,12 +394,10 @@ public class PlayerListener implements Listener { Material type = heldItem.getType(); if (type == Material.RAW_FISH) { - TamingManager tamingManager = new TamingManager(Users.getPlayer(player)); - tamingManager.summonOcelot(); + SkillManagerStore.getInstance().getTamingManager(player.getName()).summonOcelot(); } else if (type == Material.BONE) { - TamingManager tamingManager = new TamingManager(Users.getPlayer(player)); - tamingManager.summonWolf(); + SkillManagerStore.getInstance().getTamingManager(player.getName()).summonWolf(); } } diff --git a/src/main/java/com/gmail/nossr50/skills/SkillManager.java b/src/main/java/com/gmail/nossr50/skills/SkillManager.java index f020a8af6..71a2cdbb3 100644 --- a/src/main/java/com/gmail/nossr50/skills/SkillManager.java +++ b/src/main/java/com/gmail/nossr50/skills/SkillManager.java @@ -1,18 +1,19 @@ package com.gmail.nossr50.skills; +import org.bukkit.entity.Player; + import com.gmail.nossr50.datatypes.McMMOPlayer; +import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.skills.utilities.PerksUtils; import com.gmail.nossr50.skills.utilities.SkillType; public abstract class SkillManager { protected McMMOPlayer mcMMOPlayer; - protected int skillLevel; protected int activationChance; protected SkillType skill; public SkillManager(McMMOPlayer mcMMOPlayer, SkillType skill) { this.mcMMOPlayer = mcMMOPlayer; - this.skillLevel = mcMMOPlayer.getProfile().getSkillLevel(skill); this.activationChance = PerksUtils.handleLuckyPerks(mcMMOPlayer.getPlayer(), skill); this.skill = skill; } @@ -21,8 +22,16 @@ public abstract class SkillManager { return mcMMOPlayer; } + public Player getPlayer() { + return mcMMOPlayer.getPlayer(); + } + + public PlayerProfile getProfile() { + return mcMMOPlayer.getProfile(); + } + public int getSkillLevel() { - return skillLevel; + return mcMMOPlayer.getProfile().getSkillLevel(skill); } public int getActivationChance() { diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java index 6ed8e9c18..c5503a1fa 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -75,7 +75,7 @@ public class ArcheryManager extends SkillManager { * @param event The event to modify. */ public void skillShot(EntityDamageEvent event) { - if (skillLevel >= Archery.skillShotIncreaseLevel && Permissions.bonusDamage(mcMMOPlayer.getPlayer(), skill)) { + if (getSkillLevel() >= Archery.skillShotIncreaseLevel && Permissions.bonusDamage(mcMMOPlayer.getPlayer(), skill)) { SkillShotEventHandler eventHandler = new SkillShotEventHandler(this, event); eventHandler.calculateDamageBonus(); diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index 1a75ceb38..bf6d55aa6 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -22,7 +22,7 @@ public class MiningManager extends SkillManager{ * @param event The PlayerInteractEvent */ public void detonate(PlayerInteractEvent event) { - if (skillLevel < BlastMining.rank1) { + if (getSkillLevel() < BlastMining.rank1) { return; } @@ -57,7 +57,7 @@ public class MiningManager extends SkillManager{ return; } - if (skillLevel < BlastMining.rank1) { + if (getSkillLevel() < BlastMining.rank1) { return; } diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java index 846cb764b..71fbc29fc 100644 --- a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java @@ -60,7 +60,7 @@ public class SmeltingManager extends SkillManager { } public void vanillaXPBoost(FurnaceExtractEvent event) { - if (skillLevel < Smelting.vanillaXPBoostRank1Level || !Permissions.vanillaXpBoost(mcMMOPlayer.getPlayer(), skill)) { + if (getSkillLevel() < Smelting.vanillaXPBoostRank1Level || !Permissions.vanillaXpBoost(mcMMOPlayer.getPlayer(), skill)) { return; } 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 3ad14f88e..d00d91188 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java @@ -20,7 +20,7 @@ public class SwordsManager extends SkillManager { public void bleedCheck(LivingEntity defender) { BleedEventHandler eventHandler = new BleedEventHandler(this, defender); - float chance = (float) ((Swords.bleedMaxChance / Swords.bleedMaxBonusLevel) * skillLevel); + float chance = (float) ((Swords.bleedMaxChance / Swords.bleedMaxBonusLevel) * getSkillLevel()); if (chance > Swords.bleedMaxChance) chance = (float) Swords.bleedMaxChance; if (chance > Misc.getRandom().nextInt(activationChance)) { @@ -33,7 +33,7 @@ public class SwordsManager extends SkillManager { CounterAttackEventHandler eventHandler = new CounterAttackEventHandler(this, attacker, damage); eventHandler.calculateSkillModifier(); - float chance = (float) ((Swords.counterAttackMaxChance / Swords.counterAttackMaxBonusLevel) * skillLevel); + float chance = (float) ((Swords.counterAttackMaxChance / Swords.counterAttackMaxBonusLevel) * getSkillLevel()); if (chance > Swords.counterAttackMaxChance) chance = (float) Swords.counterAttackMaxChance; if (chance > Misc.getRandom().nextInt(activationChance)) { diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java index 8d851bf65..3258c2575 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -79,7 +79,7 @@ public class TamingManager extends SkillManager { public void gore(EntityDamageEvent event) { GoreEventHandler eventHandler = new GoreEventHandler(this, event); - float chance = (float) ((Taming.goreMaxChance / Taming.goreMaxBonusLevel) * skillLevel); + float chance = (float) ((Taming.goreMaxChance / Taming.goreMaxBonusLevel) * getSkillLevel()); if (chance > Taming.goreMaxChance) chance = (float) Taming.goreMaxChance; if (chance > Misc.getRandom().nextInt(activationChance)) { diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java index c1a910f14..2c2b6f8ce 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java @@ -28,7 +28,7 @@ public class UnarmedManager extends SkillManager { if (eventHandler.isHoldingItem()) { eventHandler.calculateSkillModifier(); - float chance = (float) ((Unarmed.disarmMaxChance / Unarmed.disarmMaxBonusLevel) * skillLevel); + float chance = (float) ((Unarmed.disarmMaxChance / Unarmed.disarmMaxBonusLevel) * getSkillLevel()); if (chance > Unarmed.disarmMaxChance) chance = (float) Unarmed.disarmMaxChance; if (chance > Misc.getRandom().nextInt(activationChance)) { @@ -47,7 +47,7 @@ public class UnarmedManager extends SkillManager { public void deflectCheck(EntityDamageEvent event) { DeflectEventHandler eventHandler = new DeflectEventHandler(this, event); - float chance = (float) ((Unarmed.deflectMaxChance / Unarmed.deflectMaxBonusLevel) * skillLevel); + float chance = (float) ((Unarmed.deflectMaxChance / Unarmed.deflectMaxBonusLevel) * getSkillLevel()); if (chance > Unarmed.deflectMaxChance) chance = (float) Unarmed.deflectMaxChance; if (chance > Misc.getRandom().nextInt(activationChance)) { diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java index f72bb42f2..6bd831951 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java @@ -29,17 +29,12 @@ import com.gmail.nossr50.events.fake.FakeEntityDamageEvent; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mods.ModChecks; import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.acrobatics.Acrobatics; -import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager; -import com.gmail.nossr50.skills.archery.ArcheryManager; -import com.gmail.nossr50.skills.axes.AxeManager; import com.gmail.nossr50.skills.runnables.BleedTimer; import com.gmail.nossr50.skills.runnables.CombatXpGiver; import com.gmail.nossr50.skills.swords.Swords; -import com.gmail.nossr50.skills.swords.SwordsManager; import com.gmail.nossr50.skills.taming.Taming; -import com.gmail.nossr50.skills.taming.TamingManager; -import com.gmail.nossr50.skills.unarmed.UnarmedManager; import com.gmail.nossr50.util.ItemChecks; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -85,7 +80,7 @@ public final class CombatTools { if (Permissions.skillEnabled(player, SkillType.SWORDS)) { McMMOPlayer mcMMOPlayer = Users.getPlayer(player); PlayerProfile profile = mcMMOPlayer.getProfile(); - SwordsManager swordsManager = new SwordsManager(mcMMOPlayer); + String playerName = player.getName(); boolean canSerratedStrike = Permissions.serratedStrikes(player); //So we don't have to check the same permission twice if (profile.getToolPreparationMode(ToolType.SWORD) && canSerratedStrike) { @@ -93,11 +88,11 @@ public final class CombatTools { } if (Permissions.bleed(player)) { - swordsManager.bleedCheck(target); + SkillManagerStore.getInstance().getSwordsManager(playerName).bleedCheck(target); } if (profile.getAbilityMode(AbilityType.SERRATED_STRIKES) && canSerratedStrike) { - swordsManager.serratedStrikes(target, event.getDamage()); + SkillManagerStore.getInstance().getSwordsManager(playerName).serratedStrikes(target, event.getDamage()); } startGainXp(mcMMOPlayer, target, SkillType.SWORDS); @@ -116,26 +111,27 @@ public final class CombatTools { if (Permissions.skillEnabled(player, SkillType.AXES)) { McMMOPlayer mcMMOPlayer = Users.getPlayer(player); PlayerProfile profile = mcMMOPlayer.getProfile(); - AxeManager axeManager = new AxeManager(mcMMOPlayer); + String playerName = player.getName(); + boolean canSkullSplit = Permissions.skullSplitter(player); //So we don't have to check the same permission twice if (profile.getToolPreparationMode(ToolType.AXE) && canSkullSplit) { SkillTools.abilityCheck(player, SkillType.AXES); } - if (Permissions.bonusDamage(player, axeManager.getSkill())) { - axeManager.bonusDamage(event); + if (Permissions.bonusDamage(player, SkillType.AXES)) { + SkillManagerStore.getInstance().getAxeManager(playerName).bonusDamage(event); } if (!target.isDead() && Permissions.criticalStrikes(player)) { - axeManager.criticalHitCheck(event, target); + SkillManagerStore.getInstance().getAxeManager(playerName).criticalHitCheck(event, target); } if (!target.isDead() && Permissions.armorImpact(player)) { - axeManager.impact(event, target); + SkillManagerStore.getInstance().getAxeManager(playerName).impact(event, target); } if (!target.isDead() && profile.getAbilityMode(AbilityType.SKULL_SPLITTER) && canSkullSplit) { - axeManager.skullSplitter(target, event.getDamage()); + SkillManagerStore.getInstance().getAxeManager(playerName).skullSplitter(target, event.getDamage()); } startGainXp(mcMMOPlayer, target, SkillType.AXES); @@ -154,32 +150,31 @@ public final class CombatTools { if (Permissions.skillEnabled(player, SkillType.UNARMED)) { McMMOPlayer mcMMOPlayer = Users.getPlayer(player); PlayerProfile profile = mcMMOPlayer.getProfile(); - UnarmedManager unarmedManager = new UnarmedManager(mcMMOPlayer); + String playerName = player.getName(); + boolean canBerserk = Permissions.berserk(player); //So we don't have to check the same permission twice if (profile.getToolPreparationMode(ToolType.FISTS) && canBerserk) { SkillTools.abilityCheck(player, SkillType.UNARMED); } - if (Permissions.bonusDamage(player, unarmedManager.getSkill())) { - unarmedManager.bonusDamage(event); + if (Permissions.bonusDamage(player, SkillType.UNARMED)) { + SkillManagerStore.getInstance().getUnarmedManager(playerName).bonusDamage(event); } if (profile.getAbilityMode(AbilityType.BERSERK) && canBerserk) { - unarmedManager.berserkDamage(event); + SkillManagerStore.getInstance().getUnarmedManager(playerName).berserkDamage(event); } if (target instanceof Player && Permissions.disarm(player)) { - unarmedManager.disarmCheck(target); + SkillManagerStore.getInstance().getUnarmedManager(playerName).disarmCheck(target); } startGainXp(mcMMOPlayer, target, SkillType.UNARMED); } } else if (heldItemType == Material.BONE && target instanceof Tameable && Permissions.beastLore(player)) { - TamingManager tamingManager = new TamingManager(Users.getPlayer(player)); - tamingManager.beastLore(target); - event.setCancelled(true); + SkillManagerStore.getInstance().getTamingManager(player.getName()).beastLore(target); } } @@ -205,19 +200,18 @@ public final class CombatTools { if (Permissions.skillEnabled(master, SkillType.TAMING)) { McMMOPlayer mcMMOPlayer = Users.getPlayer(master); - TamingManager tamingManager = new TamingManager(mcMMOPlayer); - int skillLevel = tamingManager.getSkillLevel(); + int skillLevel = SkillManagerStore.getInstance().getTamingManager(master.getName()).getSkillLevel(); if (skillLevel >= Taming.fastFoodServiceUnlockLevel && Permissions.fastFoodService(master)) { - tamingManager.fastFoodService(wolf, event.getDamage()); + SkillManagerStore.getInstance().getTamingManager(master.getName()).fastFoodService(wolf, event.getDamage()); } if (skillLevel >= Taming.sharpenedClawsUnlockLevel && Permissions.sharpenedClaws(master)) { - tamingManager.sharpenedClaws(event); + SkillManagerStore.getInstance().getTamingManager(master.getName()).sharpenedClaws(event); } if (Permissions.gore(master)) { - tamingManager.gore(event); + SkillManagerStore.getInstance().getTamingManager(master.getName()).gore(event); } startGainXp(mcMMOPlayer, target, SkillType.TAMING); @@ -261,24 +255,20 @@ public final class CombatTools { if (damager instanceof Player) { if (SkillType.SWORDS.getPVPEnabled() && ItemChecks.isSword(heldItem) && Permissions.counterAttack(player)) { - SwordsManager swordsManager = new SwordsManager(Users.getPlayer(player)); - swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage()); + SkillManagerStore.getInstance().getSwordsManager(player.getName()).counterAttackChecks((LivingEntity) damager, event.getDamage()); } if (SkillType.ACROBATICS.getPVPEnabled() && Permissions.dodge(player)) { - AcrobaticsManager acrobaticsManager = new AcrobaticsManager(Users.getPlayer(player)); - acrobaticsManager.dodgeCheck(event); + SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).dodgeCheck(event); } } else { if (SkillType.SWORDS.getPVEEnabled() && damager instanceof LivingEntity && ItemChecks.isSword(heldItem) && Permissions.counterAttack(player)) { - SwordsManager swordsManager = new SwordsManager(Users.getPlayer(player)); - swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage()); + SkillManagerStore.getInstance().getSwordsManager(player.getName()).counterAttackChecks((LivingEntity) damager, event.getDamage()); } if (SkillType.ACROBATICS.getPVEEnabled() && !(damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled) && Permissions.dodge(player)) { - AcrobaticsManager acrobaticsManager = new AcrobaticsManager(Users.getPlayer(player)); - acrobaticsManager.dodgeCheck(event); + SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).dodgeCheck(event); } } } @@ -298,26 +288,24 @@ public final class CombatTools { if (Permissions.skillEnabled(shooter, SkillType.ARCHERY)) { McMMOPlayer mcMMOPlayer = Users.getPlayer(shooter); - ArcheryManager archeryManager = new ArcheryManager(mcMMOPlayer); - archeryManager.skillShot(event); + SkillManagerStore.getInstance().getArcheryManager(shooter.getName()).skillShot(event); if (target instanceof Player) { if (SkillType.UNARMED.getPVPEnabled() && ((Player) target).getItemInHand().getType() == Material.AIR && Permissions.arrowDeflect((Player) target)) { - UnarmedManager unarmedManager = new UnarmedManager(Users.getPlayer((Player) target)); - unarmedManager.deflectCheck(event); + SkillManagerStore.getInstance().getUnarmedManager(((Player) target).getName()).deflectCheck(event); } if (Permissions.daze(shooter)) { - archeryManager.dazeCheck((Player) target, event); + SkillManagerStore.getInstance().getArcheryManager(shooter.getName()).dazeCheck((Player) target, event); } } if (!(shooter.getItemInHand().containsEnchantment(Enchantment.ARROW_INFINITE)) && Permissions.arrowRetrieval(shooter)) { - archeryManager.trackArrows(target); + SkillManagerStore.getInstance().getArcheryManager(shooter.getName()).trackArrows(target); } - archeryManager.distanceXpBonus(target); + SkillManagerStore.getInstance().getArcheryManager(shooter.getName()).distanceXpBonus(target); startGainXp(mcMMOPlayer, target, SkillType.ARCHERY); } }