Created an Ability class to be consistent with Tool

This commit is contained in:
bm01 2013-03-04 00:18:23 +01:00
parent e80f60ccee
commit e41adf769b
15 changed files with 95 additions and 82 deletions

View File

@ -11,38 +11,38 @@ public final class AbilityAPI {
private AbilityAPI() {} private AbilityAPI() {}
public static boolean berserkEnabled(Player player) { public static boolean berserkEnabled(Player player) {
return UserManager.getPlayer(player).getSkillManager(SkillType.UNARMED).getAbilityMode(); return UserManager.getPlayer(player).getSkillManager(SkillType.UNARMED).getAbility().getMode();
} }
public static boolean gigaDrillBreakerEnabled(Player player) { public static boolean gigaDrillBreakerEnabled(Player player) {
return UserManager.getPlayer(player).getSkillManager(SkillType.EXCAVATION).getAbilityMode(); return UserManager.getPlayer(player).getSkillManager(SkillType.EXCAVATION).getAbility().getMode();
} }
public static boolean greenTerraEnabled(Player player) { public static boolean greenTerraEnabled(Player player) {
return UserManager.getPlayer(player).getSkillManager(SkillType.HERBALISM).getAbilityMode(); return UserManager.getPlayer(player).getSkillManager(SkillType.HERBALISM).getAbility().getMode();
} }
public static boolean serratedStrikesEnabled(Player player) { public static boolean serratedStrikesEnabled(Player player) {
return UserManager.getPlayer(player).getSkillManager(SkillType.SWORDS).getAbilityMode(); return UserManager.getPlayer(player).getSkillManager(SkillType.SWORDS).getAbility().getMode();
} }
public static boolean skullSplitterEnabled(Player player) { public static boolean skullSplitterEnabled(Player player) {
return UserManager.getPlayer(player).getSkillManager(SkillType.AXES).getAbilityMode(); return UserManager.getPlayer(player).getSkillManager(SkillType.AXES).getAbility().getMode();
} }
public static boolean superBreakerEnabled(Player player) { public static boolean superBreakerEnabled(Player player) {
return UserManager.getPlayer(player).getSkillManager(SkillType.MINING).getAbilityMode(); return UserManager.getPlayer(player).getSkillManager(SkillType.MINING).getAbility().getMode();
} }
public static boolean treeFellerEnabled(Player player) { public static boolean treeFellerEnabled(Player player) {
return UserManager.getPlayer(player).getSkillManager(SkillType.WOODCUTTING).getAbilityMode(); return UserManager.getPlayer(player).getSkillManager(SkillType.WOODCUTTING).getAbility().getMode();
} }
public static boolean isAnyAbilityEnabled(Player player) { public static boolean isAnyAbilityEnabled(Player player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
for (SkillManager skillManager : mcMMOPlayer.getSkillManagers().values()) { for (SkillManager skillManager : mcMMOPlayer.getSkillManagers().values()) {
if (skillManager.getAbilityMode()) { if (skillManager.getAbility().getMode()) {
return true; return true;
} }
} }

View File

@ -125,7 +125,7 @@ public abstract class SkillCommand implements CommandExecutor {
} }
protected String[] calculateLengthDisplayValues() { protected String[] calculateLengthDisplayValues() {
int maxLength = skill.getAbility().getMaxTicks(); int maxLength = skill.getAbilityType().getMaxTicks();
int length = 2 + (int) (skillValue / AdvancedConfig.getInstance().getAbilityLength()); int length = 2 + (int) (skillValue / AdvancedConfig.getInstance().getAbilityLength());
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength); int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);

View File

@ -105,7 +105,7 @@ public class McMMOPlayer {
if (skillManagerClass != null) { if (skillManagerClass != null) {
SkillManager skillManager = skillManagerClass.getConstructor(McMMOPlayer.class).newInstance(this); SkillManager skillManager = skillManagerClass.getConstructor(McMMOPlayer.class).newInstance(this);
skillManager.setTool(tools.get(skillType)); skillManager.setTool(tools.get(skillType.getToolType()));
skillManagers.put(skillType, skillManagerClass.getConstructor(McMMOPlayer.class).newInstance(this)); skillManagers.put(skillType, skillManagerClass.getConstructor(McMMOPlayer.class).newInstance(this));
} }
} }
@ -177,7 +177,7 @@ public class McMMOPlayer {
*/ */
public void resetAbilityMode() { public void resetAbilityMode() {
for (SkillManager skillManager : skillManagers.values()) { for (SkillManager skillManager : skillManagers.values()) {
skillManager.setAbilityMode(false); skillManager.getAbility().setMode(false);
} }
} }

View File

@ -0,0 +1,22 @@
package com.gmail.nossr50.datatypes.skills;
public class Ability {
protected boolean mode;
protected boolean informed = true;
public boolean getMode() {
return mode;
}
public void setMode(boolean mode) {
this.mode = mode;
}
public boolean getInformed() {
return informed;
}
public void setInformed(boolean informed) {
this.informed = informed;
}
}

View File

@ -33,27 +33,27 @@ public enum SkillType {
WOODCUTTING(null, AbilityType.TREE_FELLER, ToolType.AXE); // TODO: Create a proper WoodcuttingManager class WOODCUTTING(null, AbilityType.TREE_FELLER, ToolType.AXE); // TODO: Create a proper WoodcuttingManager class
private Class<? extends SkillManager> managerClass; private Class<? extends SkillManager> managerClass;
private AbilityType ability; private AbilityType abilityType;
private ToolType toolType; private ToolType toolType;
private SkillType(Class<? extends SkillManager> managerClass) { private SkillType(Class<? extends SkillManager> managerClass) {
this.managerClass = managerClass; this.managerClass = managerClass;
ability = null; abilityType = null;
toolType = null; toolType = null;
} }
private SkillType(Class<? extends SkillManager> managerClass, AbilityType ability, ToolType tool) { private SkillType(Class<? extends SkillManager> managerClass, AbilityType abilityType, ToolType toolType) {
this.managerClass = managerClass; this.managerClass = managerClass;
this.ability = ability; this.abilityType = abilityType;
this.toolType = tool; this.toolType = toolType;
} }
public Class<? extends SkillManager> getManagerClass() { public Class<? extends SkillManager> getManagerClass() {
return managerClass; return managerClass;
} }
public AbilityType getAbility() { public AbilityType getAbilityType() {
return ability; return abilityType;
} }
/** /**

View File

@ -178,14 +178,14 @@ public class BlockListener implements Listener {
miningManager.miningBlockCheck(blockState); miningManager.miningBlockCheck(blockState);
if (miningManager.getAbilityMode()) { if (miningManager.getAbility().getMode()) {
miningManager.miningBlockCheck(blockState); miningManager.miningBlockCheck(blockState);
} }
} }
/* WOOD CUTTING */ /* WOOD CUTTING */
else if (BlockUtils.isLog(blockState) && Permissions.skillEnabled(player, SkillType.WOODCUTTING) && !mcMMO.placeStore.isTrue(blockState)) { else if (BlockUtils.isLog(blockState) && Permissions.skillEnabled(player, SkillType.WOODCUTTING) && !mcMMO.placeStore.isTrue(blockState)) {
if (mcMMOPlayer.getSkillManager(SkillType.WOODCUTTING).getAbilityMode() && Permissions.treeFeller(player) && ItemUtils.isAxe(heldItem)) { if (mcMMOPlayer.getSkillManager(SkillType.WOODCUTTING).getAbility().getMode() && Permissions.treeFeller(player) && ItemUtils.isAxe(heldItem)) {
Woodcutting.beginTreeFeller(blockState, player); Woodcutting.beginTreeFeller(blockState, player);
} }
else { else {
@ -206,7 +206,7 @@ public class BlockListener implements Listener {
excavationManager.excavationBlockCheck(blockState); excavationManager.excavationBlockCheck(blockState);
if (excavationManager.getAbilityMode()) { if (excavationManager.getAbility().getMode()) {
excavationManager.gigaDrillBreaker(blockState); excavationManager.gigaDrillBreaker(blockState);
} }
} }
@ -282,12 +282,12 @@ public class BlockListener implements Listener {
ItemStack heldItem = player.getItemInHand(); ItemStack heldItem = player.getItemInHand();
if (HiddenConfig.getInstance().useEnchantmentBuffs()) { if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getSkillManager(SkillType.MINING).getAbilityMode()) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getSkillManager(SkillType.EXCAVATION).getAbilityMode())) { if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getSkillManager(SkillType.MINING).getAbility().getMode()) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getSkillManager(SkillType.EXCAVATION).getAbility().getMode())) {
SkillUtils.removeAbilityBuff(heldItem); SkillUtils.removeAbilityBuff(heldItem);
} }
} }
else { else {
if ((mcMMOPlayer.getSkillManager(SkillType.MINING).getAbilityMode() && !BlockUtils.affectedBySuperBreaker(blockState)) || (mcMMOPlayer.getSkillManager(SkillType.EXCAVATION).getAbilityMode() && !BlockUtils.affectedByGigaDrillBreaker(blockState))) { if ((mcMMOPlayer.getSkillManager(SkillType.MINING).getAbility().getMode() && !BlockUtils.affectedBySuperBreaker(blockState)) || (mcMMOPlayer.getSkillManager(SkillType.EXCAVATION).getAbility().getMode() && !BlockUtils.affectedByGigaDrillBreaker(blockState))) {
SkillUtils.handleAbilitySpeedDecrease(player); SkillUtils.handleAbilitySpeedDecrease(player);
} }
} }

View File

@ -139,7 +139,7 @@ public class PlayerListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (mcMMOPlayer.getSkillManager(SkillType.EXCAVATION).getAbilityMode() || mcMMOPlayer.getSkillManager(SkillType.MINING).getAbilityMode()) { if (mcMMOPlayer.getSkillManager(SkillType.EXCAVATION).getAbility().getMode() || mcMMOPlayer.getSkillManager(SkillType.MINING).getAbility().getMode()) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }

View File

@ -25,7 +25,7 @@ public class SkillMonitorTask implements Runnable {
* MONITOR SKILLS & COOLDOWN * MONITOR SKILLS & COOLDOWN
*/ */
for (SkillType skill : SkillType.values()) { for (SkillType skill : SkillType.values()) {
if (skill.getAbility() == null) { if (skill.getAbilityType() == null) {
continue; continue;
} }
@ -33,7 +33,7 @@ public class SkillMonitorTask implements Runnable {
SkillUtils.monitorSkill(mcMMOPlayer, curTime, skill); SkillUtils.monitorSkill(mcMMOPlayer, curTime, skill);
} }
if (skill.getAbility().getCooldown() > 0) { if (skill.getAbilityType().getCooldown() > 0) {
SkillUtils.watchCooldown(mcMMOPlayer, skill); SkillUtils.watchCooldown(mcMMOPlayer, skill);
} }
} }

View File

@ -4,6 +4,7 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.Ability;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.Tool; import com.gmail.nossr50.datatypes.skills.Tool;
import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.PerksUtils;
@ -12,9 +13,8 @@ public abstract class SkillManager {
protected McMMOPlayer mcMMOPlayer; protected McMMOPlayer mcMMOPlayer;
protected int activationChance; protected int activationChance;
protected SkillType skill; protected SkillType skill;
protected boolean abilityMode; protected Ability ability = new Ability();
protected boolean abilityInformed = true; protected Tool tool; // Because tool can be shared, it's instanced in McMMOPlayer
protected Tool tool;
public SkillManager(McMMOPlayer mcMMOPlayer, SkillType skill) { public SkillManager(McMMOPlayer mcMMOPlayer, SkillType skill) {
this.mcMMOPlayer = mcMMOPlayer; this.mcMMOPlayer = mcMMOPlayer;
@ -46,20 +46,8 @@ public abstract class SkillManager {
mcMMOPlayer.beginXpGain(skill, xp); mcMMOPlayer.beginXpGain(skill, xp);
} }
public boolean getAbilityMode() { public Ability getAbility() {
return abilityMode; return ability;
}
public void setAbilityMode(boolean abilityMode) {
this.abilityMode = abilityMode;
}
public boolean getAbilityInformed() {
return abilityInformed;
}
public void setAbilityInformed(boolean abilityInformed) {
this.abilityInformed = abilityInformed;
} }
public Tool getTool() { public Tool getTool() {

View File

@ -39,7 +39,7 @@ public class AxesManager extends SkillManager {
} }
public boolean canUseSkullSplitter(LivingEntity target) { public boolean canUseSkullSplitter(LivingEntity target) {
return target.isValid() && abilityMode && Permissions.skullSplitter(getPlayer()); return target.isValid() && getAbility().getMode() && Permissions.skullSplitter(getPlayer());
} }
public boolean canActivateAbility() { public boolean canActivateAbility() {

View File

@ -58,7 +58,7 @@ public class HerbalismManager extends SkillManager {
} }
public boolean canGreenTerraBlock(BlockState blockState) { public boolean canGreenTerraBlock(BlockState blockState) {
return abilityMode && BlockUtils.canMakeMossy(blockState); return getAbility().getMode() && BlockUtils.canMakeMossy(blockState);
} }
public boolean canActivateAbility() { public boolean canActivateAbility() {
@ -66,7 +66,7 @@ public class HerbalismManager extends SkillManager {
} }
public boolean canGreenTerraPlant() { public boolean canGreenTerraPlant() {
return abilityMode; return getAbility().getMode();
} }
/** /**
@ -284,7 +284,7 @@ public class HerbalismManager extends SkillManager {
return; return;
} }
if (abilityMode) { if (getAbility().getMode()) {
playerInventory.removeItem(seed); playerInventory.removeItem(seed);
player.updateInventory(); // Needed until replacement available player.updateInventory(); // Needed until replacement available

View File

@ -97,7 +97,7 @@ public class MiningManager extends SkillManager{
targetBlock.setType(Material.AIR); targetBlock.setType(Material.AIR);
getProfile().setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis()); getProfile().setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis());
abilityInformed = false; getAbility().setInformed(false);
} }
/** /**

View File

@ -27,7 +27,7 @@ public class SwordsManager extends SkillManager {
} }
public boolean canUseSerratedStrike() { public boolean canUseSerratedStrike() {
return abilityMode && Permissions.serratedStrikes(getPlayer()); return getAbility().getMode() && Permissions.serratedStrikes(getPlayer());
} }
/** /**

View File

@ -29,7 +29,7 @@ public class UnarmedManager extends SkillManager {
} }
public boolean canUseBerserk() { public boolean canUseBerserk() {
return abilityMode && Permissions.berserk(getPlayer()); return getAbility().getMode() && Permissions.berserk(getPlayer());
} }
public boolean canDisarm(LivingEntity target) { public boolean canDisarm(LivingEntity target) {

View File

@ -23,6 +23,7 @@ import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.config.spout.SpoutConfig; import com.gmail.nossr50.config.spout.SpoutConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.Ability;
import com.gmail.nossr50.datatypes.skills.AbilityType; import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.Tool; import com.gmail.nossr50.datatypes.skills.Tool;
@ -99,12 +100,12 @@ public class SkillUtils {
} }
Player player = mcMMOPlayer.getPlayer(); Player player = mcMMOPlayer.getPlayer();
SkillManager skillManager = mcMMOPlayer.getSkillManager(skill); Ability ability = mcMMOPlayer.getSkillManager(skill).getAbility();
AbilityType ability = skill.getAbility(); AbilityType abilityType = skill.getAbilityType();
if (!skillManager.getAbilityInformed() && cooldownOver(mcMMOPlayer.getProfile().getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) { if (!ability.getInformed() && cooldownOver(mcMMOPlayer.getProfile().getSkillDATS(abilityType) * Misc.TIME_CONVERSION_FACTOR, abilityType.getCooldown(), player)) {
skillManager.setAbilityInformed(true); ability.setInformed(true);
player.sendMessage(ability.getAbilityRefresh()); player.sendMessage(abilityType.getAbilityRefresh());
} }
} }
@ -132,7 +133,7 @@ public class SkillUtils {
} }
for (SkillManager skillManager : mcMMOPlayer.getSkillManagers().values()) { for (SkillManager skillManager : mcMMOPlayer.getSkillManagers().values()) {
if (skillManager.getAbilityMode()) { if (skillManager.getAbility().getMode()) {
return; return;
} }
} }
@ -140,17 +141,17 @@ public class SkillUtils {
SkillManager skillManager = mcMMOPlayer.getSkillManager(skill); SkillManager skillManager = mcMMOPlayer.getSkillManager(skill);
Tool tool = skillManager.getTool(); Tool tool = skillManager.getTool();
ToolType toolType = skill.getToolType(); ToolType toolType = skill.getToolType();
AbilityType ability = skill.getAbility(); AbilityType abilityType = skill.getAbilityType();
PlayerProfile playerProfile = mcMMOPlayer.getProfile(); PlayerProfile playerProfile = mcMMOPlayer.getProfile();
/* /*
* Woodcutting & Axes need to be treated differently. * Woodcutting & Axes need to be treated differently.
* Basically the tool always needs to ready and we check to see if the cooldown is over when the user takes action * Basically the tool always needs to ready and we check to see if the cooldown is over when the user takes action
*/ */
if (ability.getPermissions(player) && toolType.inHand(inHand) && !tool.getPreparationMode()) { if (abilityType.getPermissions(player) && toolType.inHand(inHand) && !tool.getPreparationMode()) {
if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) { if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
if (!skillManager.getAbilityMode() && !cooldownOver(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) { if (!skillManager.getAbility().getMode() && !cooldownOver(playerProfile.getSkillDATS(abilityType) * Misc.TIME_CONVERSION_FACTOR, abilityType.getCooldown(), player)) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player))); player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(playerProfile.getSkillDATS(abilityType) * Misc.TIME_CONVERSION_FACTOR, abilityType.getCooldown(), player)));
return; return;
} }
} }
@ -185,28 +186,29 @@ public class SkillUtils {
} }
} }
AbilityType ability = skill.getAbility(); Ability ability = skillManager.getAbility();
AbilityType abilityType = skill.getAbilityType();
Player player = mcMMOPlayer.getPlayer(); Player player = mcMMOPlayer.getPlayer();
if (ability.getPermissions(player)) { if (abilityType.getPermissions(player)) {
if (skillManager.getAbilityMode() && (mcMMOPlayer.getProfile().getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR) <= curTime) { if (ability.getMode() && (mcMMOPlayer.getProfile().getSkillDATS(abilityType) * Misc.TIME_CONVERSION_FACTOR) <= curTime) {
if (ability == AbilityType.BERSERK) { if (abilityType == AbilityType.BERSERK) {
player.setCanPickupItems(true); player.setCanPickupItems(true);
} }
else if (ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRILL_BREAKER) { else if (abilityType == AbilityType.SUPER_BREAKER || abilityType == AbilityType.GIGA_DRILL_BREAKER) {
handleAbilitySpeedDecrease(player); handleAbilitySpeedDecrease(player);
} }
skillManager.setAbilityMode(false); ability.setMode(false);
skillManager.setAbilityInformed(false); ability.setInformed(false);
ParticleEffectUtils.playAbilityDisabledEffect(player); ParticleEffectUtils.playAbilityDisabledEffect(player);
if (mcMMOPlayer.useChatNotifications()) { if (mcMMOPlayer.useChatNotifications()) {
player.sendMessage(ability.getAbilityOff()); player.sendMessage(abilityType.getAbilityOff());
} }
sendSkillMessage(player, ability.getAbilityPlayerOff(player)); sendSkillMessage(player, abilityType.getAbilityPlayerOff(player));
} }
} }
} }
@ -377,7 +379,8 @@ public class SkillUtils {
*/ */
public static void abilityCheck(McMMOPlayer mcMMOPlayer, SkillType skill) { public static void abilityCheck(McMMOPlayer mcMMOPlayer, SkillType skill) {
SkillManager skillManager = mcMMOPlayer.getSkillManager(skill); SkillManager skillManager = mcMMOPlayer.getSkillManager(skill);
AbilityType ability = skill.getAbility(); Ability ability = skillManager.getAbility();
AbilityType abilityType = skill.getAbilityType();
Player player = mcMMOPlayer.getPlayer(); Player player = mcMMOPlayer.getPlayer();
PlayerProfile playerProfile = mcMMOPlayer.getProfile(); PlayerProfile playerProfile = mcMMOPlayer.getProfile();
@ -388,30 +391,30 @@ public class SkillUtils {
* We show them the too tired message when they take action. * We show them the too tired message when they take action.
*/ */
if (skill == SkillType.WOODCUTTING || skill == SkillType.AXES) { if (skill == SkillType.WOODCUTTING || skill == SkillType.AXES) {
if (!skillManager.getAbilityMode() && !cooldownOver(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) { if (!ability.getMode() && !cooldownOver(playerProfile.getSkillDATS(abilityType) * Misc.TIME_CONVERSION_FACTOR, abilityType.getCooldown(), player)) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player))); player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(playerProfile.getSkillDATS(abilityType) * Misc.TIME_CONVERSION_FACTOR, abilityType.getCooldown(), player)));
return; return;
} }
} }
if (!skillManager.getAbilityMode() && cooldownOver(playerProfile.getSkillDATS(ability), ability.getCooldown(), player)) { if (!ability.getMode() && cooldownOver(playerProfile.getSkillDATS(abilityType), abilityType.getCooldown(), player)) {
int ticks = PerksUtils.handleActivationPerks(player, 2 + (playerProfile.getSkillLevel(skill) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxTicks()); int ticks = PerksUtils.handleActivationPerks(player, 2 + (playerProfile.getSkillLevel(skill) / AdvancedConfig.getInstance().getAbilityLength()), abilityType.getMaxTicks());
ParticleEffectUtils.playAbilityEnabledEffect(player); ParticleEffectUtils.playAbilityEnabledEffect(player);
if (mcMMOPlayer.useChatNotifications()) { if (mcMMOPlayer.useChatNotifications()) {
player.sendMessage(ability.getAbilityOn()); player.sendMessage(abilityType.getAbilityOn());
} }
SkillUtils.sendSkillMessage(player, ability.getAbilityPlayer(player)); SkillUtils.sendSkillMessage(player, abilityType.getAbilityPlayer(player));
playerProfile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR)); playerProfile.setSkillDATS(abilityType, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
skillManager.setAbilityMode(true); ability.setMode(true);
if (ability == AbilityType.BERSERK) { if (abilityType == AbilityType.BERSERK) {
player.setCanPickupItems(false); player.setCanPickupItems(false);
} }
else if (ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRILL_BREAKER) { else if (abilityType == AbilityType.SUPER_BREAKER || abilityType == AbilityType.GIGA_DRILL_BREAKER) {
handleAbilitySpeedIncrease(player); handleAbilitySpeedIncrease(player);
} }
} }
@ -522,10 +525,10 @@ public class SkillUtils {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
int ticks = 0; int ticks = 0;
if (mcMMOPlayer.getSkillManager(SkillType.MINING).getAbilityMode()) { if (mcMMOPlayer.getSkillManager(SkillType.MINING).getAbility().getMode()) {
ticks = ((int) (mcMMOPlayer.getProfile().getSkillDATS(AbilityType.SUPER_BREAKER) - System.currentTimeMillis())) / Misc.TIME_CONVERSION_FACTOR; ticks = ((int) (mcMMOPlayer.getProfile().getSkillDATS(AbilityType.SUPER_BREAKER) - System.currentTimeMillis())) / Misc.TIME_CONVERSION_FACTOR;
} }
else if (mcMMOPlayer.getSkillManager(SkillType.EXCAVATION).getAbilityMode()) { else if (mcMMOPlayer.getSkillManager(SkillType.EXCAVATION).getAbility().getMode()) {
ticks = ((int) (mcMMOPlayer.getProfile().getSkillDATS(AbilityType.GIGA_DRILL_BREAKER) - System.currentTimeMillis())) / Misc.TIME_CONVERSION_FACTOR; ticks = ((int) (mcMMOPlayer.getProfile().getSkillDATS(AbilityType.GIGA_DRILL_BREAKER) - System.currentTimeMillis())) / Misc.TIME_CONVERSION_FACTOR;
} }