mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-01 16:19:53 +01:00
Put our managers on payroll, rather than firing them at the end of
their shift.
This commit is contained in:
parent
4c10fdf34a
commit
21b8626366
@ -32,15 +32,14 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
|||||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
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.Acrobatics;
|
||||||
import com.gmail.nossr50.skills.archery.Archery;
|
import com.gmail.nossr50.skills.archery.Archery;
|
||||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||||
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||||
import com.gmail.nossr50.skills.mining.BlastMining;
|
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.runnables.BleedTimer;
|
||||||
import com.gmail.nossr50.skills.taming.Taming;
|
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.skills.utilities.CombatTools;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@ -328,8 +327,7 @@ public class EntityListener implements Listener {
|
|||||||
Player player = plugin.getTNTPlayer(id);
|
Player player = plugin.getTNTPlayer(id);
|
||||||
|
|
||||||
if (Permissions.biggerBombs(player)) {
|
if (Permissions.biggerBombs(player)) {
|
||||||
MiningManager miningManager = new MiningManager(Users.getPlayer(player));
|
SkillManagerStore.getInstance().getMiningManager(player.getName()).biggerBombs(event);
|
||||||
miningManager.biggerBombs(event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -350,8 +348,7 @@ public class EntityListener implements Listener {
|
|||||||
if (plugin.tntIsTracked(id)) {
|
if (plugin.tntIsTracked(id)) {
|
||||||
Player player = plugin.getTNTPlayer(id);
|
Player player = plugin.getTNTPlayer(id);
|
||||||
|
|
||||||
MiningManager miningManager = new MiningManager(Users.getPlayer(player));
|
SkillManagerStore.getInstance().getMiningManager(player.getName()).blastMiningDropProcessing(event);
|
||||||
miningManager.blastMiningDropProcessing(event);
|
|
||||||
|
|
||||||
plugin.removeFromTNTTracker(id);
|
plugin.removeFromTNTTracker(id);
|
||||||
}
|
}
|
||||||
@ -430,8 +427,7 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TamingManager tamingManager = new TamingManager(Users.getPlayer(player));
|
SkillManagerStore.getInstance().getTamingManager(player.getName()).awardTamingXP(event);
|
||||||
tamingManager.awardTamingXP(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
@ -19,7 +19,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
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.skills.utilities.SkillTools;
|
||||||
import com.gmail.nossr50.util.ItemChecks;
|
import com.gmail.nossr50.util.ItemChecks;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
@ -84,8 +84,7 @@ public class InventoryListener implements Listener{
|
|||||||
Player player = plugin.getFurnacePlayer(furnaceBlock);
|
Player player = plugin.getFurnacePlayer(furnaceBlock);
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
SmeltingManager smeltingManager = new SmeltingManager(Users.getPlayer(player));
|
SkillManagerStore.getInstance().getSmeltingManager(player.getName()).fuelEfficiency(event);
|
||||||
smeltingManager.fuelEfficiency(event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,8 +103,7 @@ public class InventoryListener implements Listener{
|
|||||||
Player player = plugin.getFurnacePlayer(furnaceBlock);
|
Player player = plugin.getFurnacePlayer(furnaceBlock);
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
SmeltingManager smeltingManager = new SmeltingManager(Users.getPlayer(player));
|
SkillManagerStore.getInstance().getSmeltingManager(player.getName()).smeltProcessing(event);
|
||||||
smeltingManager.smeltProcessing(event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,8 +122,7 @@ public class InventoryListener implements Listener{
|
|||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(event.getPlayer());
|
McMMOPlayer mcMMOPlayer = Users.getPlayer(event.getPlayer());
|
||||||
|
|
||||||
if (mcMMOPlayer.getPlayer().equals(plugin.getFurnacePlayer(furnaceBlock))) {
|
if (mcMMOPlayer.getPlayer().equals(plugin.getFurnacePlayer(furnaceBlock))) {
|
||||||
SmeltingManager smeltingManager = new SmeltingManager(mcMMOPlayer);
|
SkillManagerStore.getInstance().getSmeltingManager(event.getPlayer().getName()).vanillaXPBoost(event);
|
||||||
smeltingManager.vanillaXPBoost(event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,14 +34,13 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.Party;
|
import com.gmail.nossr50.party.Party;
|
||||||
import com.gmail.nossr50.party.ShareHandler;
|
import com.gmail.nossr50.party.ShareHandler;
|
||||||
|
import com.gmail.nossr50.skills.SkillManagerStore;
|
||||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||||
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||||
import com.gmail.nossr50.skills.mining.BlastMining;
|
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.Repair;
|
||||||
import com.gmail.nossr50.skills.repair.Salvage;
|
import com.gmail.nossr50.skills.repair.Salvage;
|
||||||
import com.gmail.nossr50.skills.runnables.BleedTimer;
|
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.AbilityType;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
@ -296,8 +295,7 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
/* BLAST MINING CHECK */
|
/* BLAST MINING CHECK */
|
||||||
else if (player.isSneaking() && Permissions.remoteDetonation(player) && heldItem.getTypeId() == BlastMining.detonatorID) {
|
else if (player.isSneaking() && Permissions.remoteDetonation(player) && heldItem.getTypeId() == BlastMining.detonatorID) {
|
||||||
MiningManager miningManager = new MiningManager(Users.getPlayer(player));
|
SkillManagerStore.getInstance().getMiningManager(player.getName()).detonate(event);
|
||||||
miningManager.detonate(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -305,8 +303,7 @@ public class PlayerListener implements Listener {
|
|||||||
case RIGHT_CLICK_AIR:
|
case RIGHT_CLICK_AIR:
|
||||||
/* BLAST MINING CHECK */
|
/* BLAST MINING CHECK */
|
||||||
if (player.isSneaking() && Permissions.remoteDetonation(player) && heldItem.getTypeId() == BlastMining.detonatorID) {
|
if (player.isSneaking() && Permissions.remoteDetonation(player) && heldItem.getTypeId() == BlastMining.detonatorID) {
|
||||||
MiningManager miningManager = new MiningManager(Users.getPlayer(player));
|
SkillManagerStore.getInstance().getMiningManager(player.getName()).detonate(event);
|
||||||
miningManager.detonate(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -397,12 +394,10 @@ public class PlayerListener implements Listener {
|
|||||||
Material type = heldItem.getType();
|
Material type = heldItem.getType();
|
||||||
|
|
||||||
if (type == Material.RAW_FISH) {
|
if (type == Material.RAW_FISH) {
|
||||||
TamingManager tamingManager = new TamingManager(Users.getPlayer(player));
|
SkillManagerStore.getInstance().getTamingManager(player.getName()).summonOcelot();
|
||||||
tamingManager.summonOcelot();
|
|
||||||
}
|
}
|
||||||
else if (type == Material.BONE) {
|
else if (type == Material.BONE) {
|
||||||
TamingManager tamingManager = new TamingManager(Users.getPlayer(player));
|
SkillManagerStore.getInstance().getTamingManager(player.getName()).summonWolf();
|
||||||
tamingManager.summonWolf();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
package com.gmail.nossr50.skills;
|
package com.gmail.nossr50.skills;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
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.PerksUtils;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
|
|
||||||
public abstract class SkillManager {
|
public abstract class SkillManager {
|
||||||
protected McMMOPlayer mcMMOPlayer;
|
protected McMMOPlayer mcMMOPlayer;
|
||||||
protected int skillLevel;
|
|
||||||
protected int activationChance;
|
protected int activationChance;
|
||||||
protected SkillType skill;
|
protected SkillType skill;
|
||||||
|
|
||||||
public SkillManager(McMMOPlayer mcMMOPlayer, SkillType skill) {
|
public SkillManager(McMMOPlayer mcMMOPlayer, SkillType skill) {
|
||||||
this.mcMMOPlayer = mcMMOPlayer;
|
this.mcMMOPlayer = mcMMOPlayer;
|
||||||
this.skillLevel = mcMMOPlayer.getProfile().getSkillLevel(skill);
|
|
||||||
this.activationChance = PerksUtils.handleLuckyPerks(mcMMOPlayer.getPlayer(), skill);
|
this.activationChance = PerksUtils.handleLuckyPerks(mcMMOPlayer.getPlayer(), skill);
|
||||||
this.skill = skill;
|
this.skill = skill;
|
||||||
}
|
}
|
||||||
@ -21,8 +22,16 @@ public abstract class SkillManager {
|
|||||||
return mcMMOPlayer;
|
return mcMMOPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Player getPlayer() {
|
||||||
|
return mcMMOPlayer.getPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerProfile getProfile() {
|
||||||
|
return mcMMOPlayer.getProfile();
|
||||||
|
}
|
||||||
|
|
||||||
public int getSkillLevel() {
|
public int getSkillLevel() {
|
||||||
return skillLevel;
|
return mcMMOPlayer.getProfile().getSkillLevel(skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getActivationChance() {
|
public int getActivationChance() {
|
||||||
|
@ -75,7 +75,7 @@ public class ArcheryManager extends SkillManager {
|
|||||||
* @param event The event to modify.
|
* @param event The event to modify.
|
||||||
*/
|
*/
|
||||||
public void skillShot(EntityDamageEvent event) {
|
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);
|
SkillShotEventHandler eventHandler = new SkillShotEventHandler(this, event);
|
||||||
|
|
||||||
eventHandler.calculateDamageBonus();
|
eventHandler.calculateDamageBonus();
|
||||||
|
@ -22,7 +22,7 @@ public class MiningManager extends SkillManager{
|
|||||||
* @param event The PlayerInteractEvent
|
* @param event The PlayerInteractEvent
|
||||||
*/
|
*/
|
||||||
public void detonate(PlayerInteractEvent event) {
|
public void detonate(PlayerInteractEvent event) {
|
||||||
if (skillLevel < BlastMining.rank1) {
|
if (getSkillLevel() < BlastMining.rank1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ public class MiningManager extends SkillManager{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skillLevel < BlastMining.rank1) {
|
if (getSkillLevel() < BlastMining.rank1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public class SmeltingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void vanillaXPBoost(FurnaceExtractEvent event) {
|
public void vanillaXPBoost(FurnaceExtractEvent event) {
|
||||||
if (skillLevel < Smelting.vanillaXPBoostRank1Level || !Permissions.vanillaXpBoost(mcMMOPlayer.getPlayer(), skill)) {
|
if (getSkillLevel() < Smelting.vanillaXPBoostRank1Level || !Permissions.vanillaXpBoost(mcMMOPlayer.getPlayer(), skill)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public class SwordsManager extends SkillManager {
|
|||||||
public void bleedCheck(LivingEntity defender) {
|
public void bleedCheck(LivingEntity defender) {
|
||||||
BleedEventHandler eventHandler = new BleedEventHandler(this, 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 > Swords.bleedMaxChance) chance = (float) Swords.bleedMaxChance;
|
||||||
|
|
||||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||||
@ -33,7 +33,7 @@ public class SwordsManager extends SkillManager {
|
|||||||
CounterAttackEventHandler eventHandler = new CounterAttackEventHandler(this, attacker, damage);
|
CounterAttackEventHandler eventHandler = new CounterAttackEventHandler(this, attacker, damage);
|
||||||
eventHandler.calculateSkillModifier();
|
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 > Swords.counterAttackMaxChance) chance = (float) Swords.counterAttackMaxChance;
|
||||||
|
|
||||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||||
|
@ -79,7 +79,7 @@ public class TamingManager extends SkillManager {
|
|||||||
public void gore(EntityDamageEvent event) {
|
public void gore(EntityDamageEvent event) {
|
||||||
GoreEventHandler eventHandler = new GoreEventHandler(this, 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 > Taming.goreMaxChance) chance = (float) Taming.goreMaxChance;
|
||||||
|
|
||||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||||
|
@ -28,7 +28,7 @@ public class UnarmedManager extends SkillManager {
|
|||||||
if (eventHandler.isHoldingItem()) {
|
if (eventHandler.isHoldingItem()) {
|
||||||
eventHandler.calculateSkillModifier();
|
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 > Unarmed.disarmMaxChance) chance = (float) Unarmed.disarmMaxChance;
|
||||||
|
|
||||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||||
@ -47,7 +47,7 @@ public class UnarmedManager extends SkillManager {
|
|||||||
public void deflectCheck(EntityDamageEvent event) {
|
public void deflectCheck(EntityDamageEvent event) {
|
||||||
DeflectEventHandler eventHandler = new DeflectEventHandler(this, 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 > Unarmed.deflectMaxChance) chance = (float) Unarmed.deflectMaxChance;
|
||||||
|
|
||||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||||
|
@ -29,17 +29,12 @@ import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.mods.ModChecks;
|
import com.gmail.nossr50.mods.ModChecks;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
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.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.BleedTimer;
|
||||||
import com.gmail.nossr50.skills.runnables.CombatXpGiver;
|
import com.gmail.nossr50.skills.runnables.CombatXpGiver;
|
||||||
import com.gmail.nossr50.skills.swords.Swords;
|
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.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.ItemChecks;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@ -85,7 +80,7 @@ public final class CombatTools {
|
|||||||
if (Permissions.skillEnabled(player, SkillType.SWORDS)) {
|
if (Permissions.skillEnabled(player, SkillType.SWORDS)) {
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
|
||||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
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
|
boolean canSerratedStrike = Permissions.serratedStrikes(player); //So we don't have to check the same permission twice
|
||||||
|
|
||||||
if (profile.getToolPreparationMode(ToolType.SWORD) && canSerratedStrike) {
|
if (profile.getToolPreparationMode(ToolType.SWORD) && canSerratedStrike) {
|
||||||
@ -93,11 +88,11 @@ public final class CombatTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.bleed(player)) {
|
if (Permissions.bleed(player)) {
|
||||||
swordsManager.bleedCheck(target);
|
SkillManagerStore.getInstance().getSwordsManager(playerName).bleedCheck(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (profile.getAbilityMode(AbilityType.SERRATED_STRIKES) && canSerratedStrike) {
|
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);
|
startGainXp(mcMMOPlayer, target, SkillType.SWORDS);
|
||||||
@ -116,26 +111,27 @@ public final class CombatTools {
|
|||||||
if (Permissions.skillEnabled(player, SkillType.AXES)) {
|
if (Permissions.skillEnabled(player, SkillType.AXES)) {
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
|
||||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
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
|
boolean canSkullSplit = Permissions.skullSplitter(player); //So we don't have to check the same permission twice
|
||||||
if (profile.getToolPreparationMode(ToolType.AXE) && canSkullSplit) {
|
if (profile.getToolPreparationMode(ToolType.AXE) && canSkullSplit) {
|
||||||
SkillTools.abilityCheck(player, SkillType.AXES);
|
SkillTools.abilityCheck(player, SkillType.AXES);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.bonusDamage(player, axeManager.getSkill())) {
|
if (Permissions.bonusDamage(player, SkillType.AXES)) {
|
||||||
axeManager.bonusDamage(event);
|
SkillManagerStore.getInstance().getAxeManager(playerName).bonusDamage(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!target.isDead() && Permissions.criticalStrikes(player)) {
|
if (!target.isDead() && Permissions.criticalStrikes(player)) {
|
||||||
axeManager.criticalHitCheck(event, target);
|
SkillManagerStore.getInstance().getAxeManager(playerName).criticalHitCheck(event, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!target.isDead() && Permissions.armorImpact(player)) {
|
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) {
|
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);
|
startGainXp(mcMMOPlayer, target, SkillType.AXES);
|
||||||
@ -154,32 +150,31 @@ public final class CombatTools {
|
|||||||
if (Permissions.skillEnabled(player, SkillType.UNARMED)) {
|
if (Permissions.skillEnabled(player, SkillType.UNARMED)) {
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
|
||||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
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
|
boolean canBerserk = Permissions.berserk(player); //So we don't have to check the same permission twice
|
||||||
|
|
||||||
if (profile.getToolPreparationMode(ToolType.FISTS) && canBerserk) {
|
if (profile.getToolPreparationMode(ToolType.FISTS) && canBerserk) {
|
||||||
SkillTools.abilityCheck(player, SkillType.UNARMED);
|
SkillTools.abilityCheck(player, SkillType.UNARMED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.bonusDamage(player, unarmedManager.getSkill())) {
|
if (Permissions.bonusDamage(player, SkillType.UNARMED)) {
|
||||||
unarmedManager.bonusDamage(event);
|
SkillManagerStore.getInstance().getUnarmedManager(playerName).bonusDamage(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (profile.getAbilityMode(AbilityType.BERSERK) && canBerserk) {
|
if (profile.getAbilityMode(AbilityType.BERSERK) && canBerserk) {
|
||||||
unarmedManager.berserkDamage(event);
|
SkillManagerStore.getInstance().getUnarmedManager(playerName).berserkDamage(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target instanceof Player && Permissions.disarm(player)) {
|
if (target instanceof Player && Permissions.disarm(player)) {
|
||||||
unarmedManager.disarmCheck(target);
|
SkillManagerStore.getInstance().getUnarmedManager(playerName).disarmCheck(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
startGainXp(mcMMOPlayer, target, SkillType.UNARMED);
|
startGainXp(mcMMOPlayer, target, SkillType.UNARMED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (heldItemType == Material.BONE && target instanceof Tameable && Permissions.beastLore(player)) {
|
else if (heldItemType == Material.BONE && target instanceof Tameable && Permissions.beastLore(player)) {
|
||||||
TamingManager tamingManager = new TamingManager(Users.getPlayer(player));
|
SkillManagerStore.getInstance().getTamingManager(player.getName()).beastLore(target);
|
||||||
tamingManager.beastLore(target);
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,19 +200,18 @@ public final class CombatTools {
|
|||||||
|
|
||||||
if (Permissions.skillEnabled(master, SkillType.TAMING)) {
|
if (Permissions.skillEnabled(master, SkillType.TAMING)) {
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(master);
|
McMMOPlayer mcMMOPlayer = Users.getPlayer(master);
|
||||||
TamingManager tamingManager = new TamingManager(mcMMOPlayer);
|
int skillLevel = SkillManagerStore.getInstance().getTamingManager(master.getName()).getSkillLevel();
|
||||||
int skillLevel = tamingManager.getSkillLevel();
|
|
||||||
|
|
||||||
if (skillLevel >= Taming.fastFoodServiceUnlockLevel && Permissions.fastFoodService(master)) {
|
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)) {
|
if (skillLevel >= Taming.sharpenedClawsUnlockLevel && Permissions.sharpenedClaws(master)) {
|
||||||
tamingManager.sharpenedClaws(event);
|
SkillManagerStore.getInstance().getTamingManager(master.getName()).sharpenedClaws(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.gore(master)) {
|
if (Permissions.gore(master)) {
|
||||||
tamingManager.gore(event);
|
SkillManagerStore.getInstance().getTamingManager(master.getName()).gore(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
startGainXp(mcMMOPlayer, target, SkillType.TAMING);
|
startGainXp(mcMMOPlayer, target, SkillType.TAMING);
|
||||||
@ -261,24 +255,20 @@ public final class CombatTools {
|
|||||||
|
|
||||||
if (damager instanceof Player) {
|
if (damager instanceof Player) {
|
||||||
if (SkillType.SWORDS.getPVPEnabled() && ItemChecks.isSword(heldItem) && Permissions.counterAttack(player)) {
|
if (SkillType.SWORDS.getPVPEnabled() && ItemChecks.isSword(heldItem) && Permissions.counterAttack(player)) {
|
||||||
SwordsManager swordsManager = new SwordsManager(Users.getPlayer(player));
|
SkillManagerStore.getInstance().getSwordsManager(player.getName()).counterAttackChecks((LivingEntity) damager, event.getDamage());
|
||||||
swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SkillType.ACROBATICS.getPVPEnabled() && Permissions.dodge(player)) {
|
if (SkillType.ACROBATICS.getPVPEnabled() && Permissions.dodge(player)) {
|
||||||
AcrobaticsManager acrobaticsManager = new AcrobaticsManager(Users.getPlayer(player));
|
SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).dodgeCheck(event);
|
||||||
acrobaticsManager.dodgeCheck(event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (SkillType.SWORDS.getPVEEnabled() && damager instanceof LivingEntity && ItemChecks.isSword(heldItem) && Permissions.counterAttack(player)) {
|
if (SkillType.SWORDS.getPVEEnabled() && damager instanceof LivingEntity && ItemChecks.isSword(heldItem) && Permissions.counterAttack(player)) {
|
||||||
SwordsManager swordsManager = new SwordsManager(Users.getPlayer(player));
|
SkillManagerStore.getInstance().getSwordsManager(player.getName()).counterAttackChecks((LivingEntity) damager, event.getDamage());
|
||||||
swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SkillType.ACROBATICS.getPVEEnabled() && !(damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled) && Permissions.dodge(player)) {
|
if (SkillType.ACROBATICS.getPVEEnabled() && !(damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled) && Permissions.dodge(player)) {
|
||||||
AcrobaticsManager acrobaticsManager = new AcrobaticsManager(Users.getPlayer(player));
|
SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).dodgeCheck(event);
|
||||||
acrobaticsManager.dodgeCheck(event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -298,26 +288,24 @@ public final class CombatTools {
|
|||||||
|
|
||||||
if (Permissions.skillEnabled(shooter, SkillType.ARCHERY)) {
|
if (Permissions.skillEnabled(shooter, SkillType.ARCHERY)) {
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(shooter);
|
McMMOPlayer mcMMOPlayer = Users.getPlayer(shooter);
|
||||||
ArcheryManager archeryManager = new ArcheryManager(mcMMOPlayer);
|
SkillManagerStore.getInstance().getArcheryManager(shooter.getName()).skillShot(event);
|
||||||
archeryManager.skillShot(event);
|
|
||||||
|
|
||||||
if (target instanceof Player) {
|
if (target instanceof Player) {
|
||||||
if (SkillType.UNARMED.getPVPEnabled() && ((Player) target).getItemInHand().getType() == Material.AIR && Permissions.arrowDeflect((Player) target)) {
|
if (SkillType.UNARMED.getPVPEnabled() && ((Player) target).getItemInHand().getType() == Material.AIR && Permissions.arrowDeflect((Player) target)) {
|
||||||
UnarmedManager unarmedManager = new UnarmedManager(Users.getPlayer((Player) target));
|
SkillManagerStore.getInstance().getUnarmedManager(((Player) target).getName()).deflectCheck(event);
|
||||||
unarmedManager.deflectCheck(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (Permissions.daze(shooter)) {
|
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)) {
|
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);
|
startGainXp(mcMMOPlayer, target, SkillType.ARCHERY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user