mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-01-19 00:45:27 +01:00
Moved ability and tool stuff from McMMOPlayer to SkillManager classes
Warning: Because Woodcutting and Repair don't have a "proper" manager class, this doesn't work yet.
This commit is contained in:
parent
1b461ac96a
commit
12b548bf46
@ -3,45 +3,46 @@ package com.gmail.nossr50.api;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public final class AbilityAPI {
|
public final class AbilityAPI {
|
||||||
private AbilityAPI() {}
|
private AbilityAPI() {}
|
||||||
|
|
||||||
public static boolean berserkEnabled(Player player) {
|
public static boolean berserkEnabled(Player player) {
|
||||||
return UserManager.getPlayer(player).getAbilityMode(AbilityType.BERSERK);
|
return UserManager.getPlayer(player).getSkillManager(SkillType.UNARMED).getAbilityMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean gigaDrillBreakerEnabled(Player player) {
|
public static boolean gigaDrillBreakerEnabled(Player player) {
|
||||||
return UserManager.getPlayer(player).getAbilityMode(AbilityType.GIGA_DRILL_BREAKER);
|
return UserManager.getPlayer(player).getSkillManager(SkillType.EXCAVATION).getAbilityMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean greenTerraEnabled(Player player) {
|
public static boolean greenTerraEnabled(Player player) {
|
||||||
return UserManager.getPlayer(player).getAbilityMode(AbilityType.GREEN_TERRA);
|
return UserManager.getPlayer(player).getSkillManager(SkillType.HERBALISM).getAbilityMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean serratedStrikesEnabled(Player player) {
|
public static boolean serratedStrikesEnabled(Player player) {
|
||||||
return UserManager.getPlayer(player).getAbilityMode(AbilityType.SERRATED_STRIKES);
|
return UserManager.getPlayer(player).getSkillManager(SkillType.SWORDS).getAbilityMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean skullSplitterEnabled(Player player) {
|
public static boolean skullSplitterEnabled(Player player) {
|
||||||
return UserManager.getPlayer(player).getAbilityMode(AbilityType.SKULL_SPLITTER);
|
return UserManager.getPlayer(player).getSkillManager(SkillType.AXES).getAbilityMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean superBreakerEnabled(Player player) {
|
public static boolean superBreakerEnabled(Player player) {
|
||||||
return UserManager.getPlayer(player).getAbilityMode(AbilityType.SUPER_BREAKER);
|
return UserManager.getPlayer(player).getSkillManager(SkillType.MINING).getAbilityMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean treeFellerEnabled(Player player) {
|
public static boolean treeFellerEnabled(Player player) {
|
||||||
return UserManager.getPlayer(player).getAbilityMode(AbilityType.TREE_FELLER);
|
return UserManager.getPlayer(player).getSkillManager(SkillType.WOODCUTTING).getAbilityMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAnyAbilityEnabled(Player player) {
|
public static boolean isAnyAbilityEnabled(Player player) {
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
for (AbilityType ability : AbilityType.values()) {
|
for (SkillManager skillManager : mcMMOPlayer.getSkillManagers().values()) {
|
||||||
if (mcMMOPlayer.getAbilityMode(ability)) {
|
if (skillManager.getAbilityMode()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,7 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
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.ToolType;
|
|
||||||
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
|
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
|
||||||
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
@ -69,11 +67,6 @@ public class McMMOPlayer {
|
|||||||
private boolean placedSalvageAnvil;
|
private boolean placedSalvageAnvil;
|
||||||
private boolean godMode;
|
private boolean godMode;
|
||||||
|
|
||||||
private Map<AbilityType, Boolean> abilityMode = new HashMap<AbilityType, Boolean>();
|
|
||||||
private Map<AbilityType, Boolean> abilityInformed = new HashMap<AbilityType, Boolean>();
|
|
||||||
private Map<ToolType, Boolean> toolPreparationMode = new HashMap<ToolType, Boolean>();
|
|
||||||
private Map<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
|
|
||||||
|
|
||||||
private int recentlyHurt;
|
private int recentlyHurt;
|
||||||
private int respawnATS;
|
private int respawnATS;
|
||||||
|
|
||||||
@ -103,16 +96,6 @@ public class McMMOPlayer {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
mcMMO.p.getPluginLoader().disablePlugin(mcMMO.p);
|
mcMMO.p.getPluginLoader().disablePlugin(mcMMO.p);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AbilityType abilityType : AbilityType.values()) {
|
|
||||||
abilityMode.put(abilityType, false);
|
|
||||||
abilityInformed.put(abilityType, true); // This is intended
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ToolType toolType : ToolType.values()) {
|
|
||||||
toolPreparationMode.put(toolType, false);
|
|
||||||
toolATS.put(toolType, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AcrobaticsManager getAcrobaticsManager() {
|
public AcrobaticsManager getAcrobaticsManager() {
|
||||||
@ -159,6 +142,14 @@ public class McMMOPlayer {
|
|||||||
return (UnarmedManager) skillManagers.get(SkillType.UNARMED);
|
return (UnarmedManager) skillManagers.get(SkillType.UNARMED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SkillManager getSkillManager(SkillType skillType) {
|
||||||
|
return skillManagers.get(skillType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<SkillType, SkillManager> getSkillManagers() {
|
||||||
|
return skillManagers;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Abilities
|
* Abilities
|
||||||
*/
|
*/
|
||||||
@ -167,61 +158,11 @@ public class McMMOPlayer {
|
|||||||
* Reset the mode of all abilities.
|
* Reset the mode of all abilities.
|
||||||
*/
|
*/
|
||||||
public void resetAbilityMode() {
|
public void resetAbilityMode() {
|
||||||
for (AbilityType ability : AbilityType.values()) {
|
for (SkillManager skillManager : skillManagers.values()) {
|
||||||
setAbilityMode(ability, false);
|
skillManager.setAbilityMode(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the mode of an ability.
|
|
||||||
*
|
|
||||||
* @param ability The ability to check
|
|
||||||
* @return true if the ability is enabled, false otherwise
|
|
||||||
*/
|
|
||||||
public boolean getAbilityMode(AbilityType ability) {
|
|
||||||
return abilityMode.get(ability);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the mode of an ability.
|
|
||||||
*
|
|
||||||
* @param ability The ability to check
|
|
||||||
* @param bool True if the ability is active, false otherwise
|
|
||||||
*/
|
|
||||||
public void setAbilityMode(AbilityType ability, boolean bool) {
|
|
||||||
abilityMode.put(ability, bool);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the informed state of an ability
|
|
||||||
*
|
|
||||||
* @param ability The ability to check
|
|
||||||
* @return true if the ability is informed, false otherwise
|
|
||||||
*/
|
|
||||||
public boolean getAbilityInformed(AbilityType ability) {
|
|
||||||
return abilityInformed.get(ability);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the informed state of an ability.
|
|
||||||
*
|
|
||||||
* @param ability The ability to check
|
|
||||||
* @param bool True if the ability is informed, false otherwise
|
|
||||||
*/
|
|
||||||
public void setAbilityInformed(AbilityType ability, boolean bool) {
|
|
||||||
abilityInformed.put(ability, bool);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the current prep mode of a tool.
|
|
||||||
*
|
|
||||||
* @param tool Tool to get the mode for
|
|
||||||
* @return true if the tool is prepped, false otherwise
|
|
||||||
*/
|
|
||||||
public boolean getToolPreparationMode(ToolType tool) {
|
|
||||||
return toolPreparationMode.get(tool);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getAbilityUse() {
|
public boolean getAbilityUse() {
|
||||||
return abilityUse;
|
return abilityUse;
|
||||||
}
|
}
|
||||||
@ -238,43 +179,11 @@ public class McMMOPlayer {
|
|||||||
* Reset the prep modes of all tools.
|
* Reset the prep modes of all tools.
|
||||||
*/
|
*/
|
||||||
public void resetToolPrepMode() {
|
public void resetToolPrepMode() {
|
||||||
for (ToolType tool : ToolType.values()) {
|
for (SkillManager skillManager : skillManagers.values()) {
|
||||||
setToolPreparationMode(tool, false);
|
skillManager.getTool().setPreparationMode(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the current prep mode of a tool.
|
|
||||||
*
|
|
||||||
* @param tool Tool to set the mode for
|
|
||||||
* @param bool true if the tool should be prepped, false otherwise
|
|
||||||
*/
|
|
||||||
public void setToolPreparationMode(ToolType tool, boolean bool) {
|
|
||||||
toolPreparationMode.put(tool, bool);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the current prep ATS of a tool.
|
|
||||||
*
|
|
||||||
* @param tool Tool to get the ATS for
|
|
||||||
* @return the ATS for the tool
|
|
||||||
*/
|
|
||||||
public long getToolPreparationATS(ToolType tool) {
|
|
||||||
return toolATS.get(tool);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the current prep ATS of a tool.
|
|
||||||
*
|
|
||||||
* @param tool Tool to set the ATS for
|
|
||||||
* @param ATS the ATS of the tool
|
|
||||||
*/
|
|
||||||
public void setToolPreparationATS(ToolType tool, long ATS) {
|
|
||||||
int startTime = (int) (ATS / Misc.TIME_CONVERSION_FACTOR);
|
|
||||||
|
|
||||||
toolATS.put(tool, startTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Recently Hurt
|
* Recently Hurt
|
||||||
*/
|
*/
|
||||||
|
@ -34,18 +34,18 @@ public enum SkillType {
|
|||||||
|
|
||||||
private Class<? extends SkillManager> managerClass;
|
private Class<? extends SkillManager> managerClass;
|
||||||
private AbilityType ability;
|
private AbilityType ability;
|
||||||
private ToolType tool;
|
private ToolType toolType;
|
||||||
|
|
||||||
private SkillType(Class<? extends SkillManager> managerClass) {
|
private SkillType(Class<? extends SkillManager> managerClass) {
|
||||||
this.managerClass = managerClass;
|
this.managerClass = managerClass;
|
||||||
ability = null;
|
ability = null;
|
||||||
tool = null;
|
toolType = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SkillType(Class<? extends SkillManager> managerClass, AbilityType ability, ToolType tool) {
|
private SkillType(Class<? extends SkillManager> managerClass, AbilityType ability, ToolType tool) {
|
||||||
this.managerClass = managerClass;
|
this.managerClass = managerClass;
|
||||||
this.ability = ability;
|
this.ability = ability;
|
||||||
this.tool = tool;
|
this.toolType = tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<? extends SkillManager> getManagerClass() {
|
public Class<? extends SkillManager> getManagerClass() {
|
||||||
@ -77,8 +77,8 @@ public enum SkillType {
|
|||||||
return Config.getInstance().getDoubleDropsDisabled(this);
|
return Config.getInstance().getDoubleDropsDisabled(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ToolType getTool() {
|
public ToolType getToolType() {
|
||||||
return tool;
|
return toolType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getXpModifier() {
|
public double getXpModifier() {
|
||||||
|
44
src/main/java/com/gmail/nossr50/datatypes/skills/Tool.java
Normal file
44
src/main/java/com/gmail/nossr50/datatypes/skills/Tool.java
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package com.gmail.nossr50.datatypes.skills;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
|
||||||
|
public class Tool {
|
||||||
|
private static Map<ToolType, Tool> tools = new HashMap<ToolType, Tool>();
|
||||||
|
private boolean preparationMode = true;
|
||||||
|
private long preparationATS;
|
||||||
|
|
||||||
|
private Tool(ToolType toolType) {
|
||||||
|
tools.put(toolType, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getPreparationMode() {
|
||||||
|
return preparationMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPreparationMode(boolean preparationMode) {
|
||||||
|
this.preparationMode = preparationMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getPreparationATS() {
|
||||||
|
return preparationATS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPreparationATS(long toolPreparationATS) {
|
||||||
|
int startTime = (int) (toolPreparationATS / Misc.TIME_CONVERSION_FACTOR);
|
||||||
|
|
||||||
|
preparationATS = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Tool getTool(ToolType toolType) {
|
||||||
|
Tool tool = tools.get(toolType);
|
||||||
|
|
||||||
|
if (tool == null) {
|
||||||
|
tool = new Tool(toolType);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tool;
|
||||||
|
}
|
||||||
|
}
|
@ -25,7 +25,6 @@ import com.gmail.nossr50.config.HiddenConfig;
|
|||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
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.ToolType;
|
|
||||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||||
@ -176,16 +175,17 @@ public class BlockListener implements Listener {
|
|||||||
/* MINING */
|
/* MINING */
|
||||||
else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.placeStore.isTrue(blockState)) {
|
else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.placeStore.isTrue(blockState)) {
|
||||||
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
|
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
|
||||||
|
|
||||||
miningManager.miningBlockCheck(blockState);
|
miningManager.miningBlockCheck(blockState);
|
||||||
|
|
||||||
if (mcMMOPlayer.getAbilityMode(AbilityType.SUPER_BREAKER)) {
|
if (miningManager.getAbilityMode()) {
|
||||||
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.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.treeFeller(player) && ItemUtils.isAxe(heldItem)) {
|
if (mcMMOPlayer.getSkillManager(SkillType.WOODCUTTING).getAbilityMode() && Permissions.treeFeller(player) && ItemUtils.isAxe(heldItem)) {
|
||||||
Woodcutting.beginTreeFeller(blockState, player);
|
Woodcutting.beginTreeFeller(blockState, player);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -203,9 +203,10 @@ public class BlockListener implements Listener {
|
|||||||
/* EXCAVATION */
|
/* EXCAVATION */
|
||||||
else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && Permissions.skillEnabled(player, SkillType.EXCAVATION) && !mcMMO.placeStore.isTrue(blockState)) {
|
else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && Permissions.skillEnabled(player, SkillType.EXCAVATION) && !mcMMO.placeStore.isTrue(blockState)) {
|
||||||
ExcavationManager excavationManager = UserManager.getPlayer(player).getExcavationManager();
|
ExcavationManager excavationManager = UserManager.getPlayer(player).getExcavationManager();
|
||||||
|
|
||||||
excavationManager.excavationBlockCheck(blockState);
|
excavationManager.excavationBlockCheck(blockState);
|
||||||
|
|
||||||
if (mcMMOPlayer.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) {
|
if (excavationManager.getAbilityMode()) {
|
||||||
excavationManager.gigaDrillBreaker(blockState);
|
excavationManager.gigaDrillBreaker(blockState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -281,29 +282,29 @@ 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.getAbilityMode(AbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER))) {
|
if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getSkillManager(SkillType.MINING).getAbilityMode()) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getSkillManager(SkillType.EXCAVATION).getAbilityMode())) {
|
||||||
SkillUtils.removeAbilityBuff(heldItem);
|
SkillUtils.removeAbilityBuff(heldItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ((mcMMOPlayer.getAbilityMode(AbilityType.SUPER_BREAKER) && !BlockUtils.affectedBySuperBreaker(blockState)) || (mcMMOPlayer.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && !BlockUtils.affectedByGigaDrillBreaker(blockState))) {
|
if ((mcMMOPlayer.getSkillManager(SkillType.MINING).getAbilityMode() && !BlockUtils.affectedBySuperBreaker(blockState)) || (mcMMOPlayer.getSkillManager(SkillType.EXCAVATION).getAbilityMode() && !BlockUtils.affectedByGigaDrillBreaker(blockState))) {
|
||||||
SkillUtils.handleAbilitySpeedDecrease(player);
|
SkillUtils.handleAbilitySpeedDecrease(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) {
|
if (mcMMOPlayer.getSkillManager(SkillType.HERBALISM).getTool().getPreparationMode() && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) {
|
||||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.HERBALISM);
|
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.HERBALISM);
|
||||||
}
|
}
|
||||||
else if (mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && ItemUtils.isAxe(heldItem) && BlockUtils.isLog(blockState) && Permissions.treeFeller(player)) {
|
else if (mcMMOPlayer.getSkillManager(SkillType.WOODCUTTING).getTool().getPreparationMode() && ItemUtils.isAxe(heldItem) && BlockUtils.isLog(blockState) && Permissions.treeFeller(player)) {
|
||||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.WOODCUTTING);
|
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.WOODCUTTING);
|
||||||
}
|
}
|
||||||
else if (mcMMOPlayer.getToolPreparationMode(ToolType.PICKAXE) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
|
else if (mcMMOPlayer.getSkillManager(SkillType.MINING).getTool().getPreparationMode() && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
|
||||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.MINING);
|
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.MINING);
|
||||||
}
|
}
|
||||||
else if (mcMMOPlayer.getToolPreparationMode(ToolType.SHOVEL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) {
|
else if (mcMMOPlayer.getSkillManager(SkillType.EXCAVATION).getTool().getPreparationMode() && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) {
|
||||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.EXCAVATION);
|
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.EXCAVATION);
|
||||||
}
|
}
|
||||||
else if (mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || BlockUtils.affectedByBlockCracker(blockState) && Permissions.berserk(player))) {
|
else if (mcMMOPlayer.getSkillManager(SkillType.UNARMED).getTool().getPreparationMode() && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || BlockUtils.affectedByBlockCracker(blockState) && Permissions.berserk(player))) {
|
||||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.UNARMED);
|
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.UNARMED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -313,7 +314,7 @@ public class BlockListener implements Listener {
|
|||||||
*
|
*
|
||||||
* We don't need to check permissions here because they've already been checked for the ability to even activate.
|
* We don't need to check permissions here because they've already been checked for the ability to even activate.
|
||||||
*/
|
*/
|
||||||
if (mcMMOPlayer.getAbilityMode(AbilityType.TREE_FELLER) && BlockUtils.isLog(blockState)) {
|
if (mcMMOPlayer.getSkillManager(SkillType.WOODCUTTING).getTool().getPreparationMode() && BlockUtils.isLog(blockState)) {
|
||||||
player.playSound(blockState.getLocation(), Sound.FIZZ, Misc.FIZZ_VOLUME, Misc.FIZZ_PITCH);
|
player.playSound(blockState.getLocation(), Sound.FIZZ, Misc.FIZZ_VOLUME, Misc.FIZZ_PITCH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -351,7 +352,7 @@ public class BlockListener implements Listener {
|
|||||||
blockState.update(true);
|
blockState.update(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mcMMOPlayer.getAbilityMode(AbilityType.BERSERK)) {
|
else if (mcMMOPlayer.getSkillManager(SkillType.UNARMED).getTool().getPreparationMode()) {
|
||||||
if (SkillUtils.triggerCheck(player, block, AbilityType.BERSERK)) {
|
if (SkillUtils.triggerCheck(player, block, AbilityType.BERSERK)) {
|
||||||
if (heldItem.getType() == Material.AIR) {
|
if (heldItem.getType() == Material.AIR) {
|
||||||
plugin.getServer().getPluginManager().callEvent(new FakePlayerAnimationEvent(player));
|
plugin.getServer().getPluginManager().callEvent(new FakePlayerAnimationEvent(player));
|
||||||
|
@ -30,7 +30,6 @@ import com.gmail.nossr50.chat.ChatManager;
|
|||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
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.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.ShareHandler;
|
import com.gmail.nossr50.party.ShareHandler;
|
||||||
@ -140,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.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) || mcMMOPlayer.getAbilityMode(AbilityType.SUPER_BREAKER)) {
|
if (mcMMOPlayer.getSkillManager(SkillType.EXCAVATION).getAbilityMode() || mcMMOPlayer.getSkillManager(SkillType.MINING).getAbilityMode()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
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.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
@ -23,20 +22,19 @@ public class SkillMonitorTask implements Runnable {
|
|||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MONITOR SKILLS
|
* MONITOR SKILLS & COOLDOWN
|
||||||
*/
|
*/
|
||||||
for (SkillType skill : SkillType.values()) {
|
for (SkillType skill : SkillType.values()) {
|
||||||
if (skill.getTool() != null && skill.getAbility() != null) {
|
if (skill.getAbility() == null) {
|
||||||
SkillUtils.monitorSkill(mcMMOPlayer, curTime, skill);
|
continue;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if (skill.getToolType() != null) {
|
||||||
* COOLDOWN MONITORING
|
SkillUtils.monitorSkill(mcMMOPlayer, curTime, skill);
|
||||||
*/
|
}
|
||||||
for (AbilityType ability : AbilityType.values()) {
|
|
||||||
if (ability.getCooldown() > 0) {
|
if (skill.getAbility().getCooldown() > 0) {
|
||||||
SkillUtils.watchCooldown(mcMMOPlayer, ability);
|
SkillUtils.watchCooldown(mcMMOPlayer, skill);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,17 +5,22 @@ 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.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.Tool;
|
||||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||||
|
|
||||||
public abstract class SkillManager {
|
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 boolean abilityInformed = true;
|
||||||
|
protected Tool tool;
|
||||||
|
|
||||||
public SkillManager(McMMOPlayer mcMMOPlayer, SkillType skill) {
|
public SkillManager(McMMOPlayer mcMMOPlayer, SkillType skill) {
|
||||||
this.mcMMOPlayer = mcMMOPlayer;
|
this.mcMMOPlayer = mcMMOPlayer;
|
||||||
this.activationChance = PerksUtils.handleLuckyPerks(mcMMOPlayer.getPlayer(), skill);
|
this.activationChance = PerksUtils.handleLuckyPerks(mcMMOPlayer.getPlayer(), skill);
|
||||||
this.skill = skill;
|
this.skill = skill;
|
||||||
|
this.tool = Tool.getTool(skill.getToolType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public McMMOPlayer getMcMMOPlayer() {
|
public McMMOPlayer getMcMMOPlayer() {
|
||||||
@ -41,4 +46,24 @@ public abstract class SkillManager {
|
|||||||
public void applyXpGain(int xp) {
|
public void applyXpGain(int xp) {
|
||||||
mcMMOPlayer.beginXpGain(skill, xp);
|
mcMMOPlayer.beginXpGain(skill, xp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getAbilityMode() {
|
||||||
|
return abilityMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAbilityMode(boolean abilityMode) {
|
||||||
|
this.abilityMode = abilityMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getAbilityInformed() {
|
||||||
|
return abilityInformed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAbilityInformed(boolean abilityInformed) {
|
||||||
|
this.abilityInformed = abilityInformed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Tool getTool() {
|
||||||
|
return tool;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
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.ToolType;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
@ -41,11 +39,11 @@ public class AxesManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseSkullSplitter(LivingEntity target) {
|
public boolean canUseSkullSplitter(LivingEntity target) {
|
||||||
return target.isValid() && mcMMOPlayer.getAbilityMode(AbilityType.SKULL_SPLITTER) && Permissions.skullSplitter(getPlayer());
|
return target.isValid() && abilityMode && Permissions.skullSplitter(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canActivateAbility() {
|
public boolean canActivateAbility() {
|
||||||
return mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && Permissions.skullSplitter(getPlayer());
|
return tool.getPreparationMode() && Permissions.skullSplitter(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,9 +15,7 @@ import com.gmail.nossr50.config.Config;
|
|||||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
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.ToolType;
|
|
||||||
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.runnables.skills.herbalism.GreenTerraTimerTask;
|
import com.gmail.nossr50.runnables.skills.herbalism.GreenTerraTimerTask;
|
||||||
@ -60,15 +58,15 @@ public class HerbalismManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canGreenTerraBlock(BlockState blockState) {
|
public boolean canGreenTerraBlock(BlockState blockState) {
|
||||||
return mcMMOPlayer.getAbilityMode(AbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState);
|
return abilityMode && BlockUtils.canMakeMossy(blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canActivateAbility() {
|
public boolean canActivateAbility() {
|
||||||
return mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && Permissions.greenTerra(getPlayer());
|
return tool.getPreparationMode() && Permissions.greenTerra(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canGreenTerraPlant() {
|
public boolean canGreenTerraPlant() {
|
||||||
return mcMMOPlayer.getAbilityMode(AbilityType.GREEN_TERRA);
|
return abilityMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -286,7 +284,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mcMMOPlayer.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
if (abilityMode) {
|
||||||
playerInventory.removeItem(seed);
|
playerInventory.removeItem(seed);
|
||||||
player.updateInventory(); // Needed until replacement available
|
player.updateInventory(); // Needed until replacement available
|
||||||
|
|
||||||
|
@ -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());
|
||||||
mcMMOPlayer.setAbilityInformed(AbilityType.BLAST_MINING, false);
|
abilityInformed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,9 +4,7 @@ import org.bukkit.entity.LivingEntity;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
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.ToolType;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
@ -21,7 +19,7 @@ public class SwordsManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canActivateAbility() {
|
public boolean canActivateAbility() {
|
||||||
return mcMMOPlayer.getToolPreparationMode(ToolType.SWORD) && Permissions.serratedStrikes(getPlayer());
|
return tool.getPreparationMode() && Permissions.serratedStrikes(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseBleed() {
|
public boolean canUseBleed() {
|
||||||
@ -29,7 +27,7 @@ public class SwordsManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseSerratedStrike() {
|
public boolean canUseSerratedStrike() {
|
||||||
return mcMMOPlayer.getAbilityMode(AbilityType.SERRATED_STRIKES) && Permissions.serratedStrikes(getPlayer());
|
return abilityMode && Permissions.serratedStrikes(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7,9 +7,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
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.ToolType;
|
|
||||||
import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDisarmEvent;
|
import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDisarmEvent;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
@ -23,7 +21,7 @@ public class UnarmedManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canActivateAbility() {
|
public boolean canActivateAbility() {
|
||||||
return mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && Permissions.berserk(getPlayer());
|
return tool.getPreparationMode() && Permissions.berserk(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseIronArm() {
|
public boolean canUseIronArm() {
|
||||||
@ -31,7 +29,7 @@ public class UnarmedManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseBerserk() {
|
public boolean canUseBerserk() {
|
||||||
return mcMMOPlayer.getAbilityMode(AbilityType.BERSERK) && Permissions.berserk(getPlayer());
|
return abilityMode && Permissions.berserk(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canDisarm(LivingEntity target) {
|
public boolean canDisarm(LivingEntity target) {
|
||||||
|
@ -25,12 +25,14 @@ 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.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.ToolType;
|
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.ModUtils;
|
import com.gmail.nossr50.util.ModUtils;
|
||||||
@ -89,17 +91,19 @@ public class SkillUtils {
|
|||||||
* Sends a message to the player when the cooldown expires.
|
* Sends a message to the player when the cooldown expires.
|
||||||
*
|
*
|
||||||
* @param mcMMOPlayer The player to send a message to
|
* @param mcMMOPlayer The player to send a message to
|
||||||
* @param ability The ability to watch cooldowns for
|
* @param skill The skill type to watch cooldowns for
|
||||||
*/
|
*/
|
||||||
public static void watchCooldown(McMMOPlayer mcMMOPlayer, AbilityType ability) {
|
public static void watchCooldown(McMMOPlayer mcMMOPlayer, SkillType skill) {
|
||||||
if (mcMMOPlayer == null || ability == null) {
|
if (mcMMOPlayer == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = mcMMOPlayer.getPlayer();
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
|
SkillManager skillManager = mcMMOPlayer.getSkillManager(skill);
|
||||||
|
AbilityType ability = skill.getAbility();
|
||||||
|
|
||||||
if (!mcMMOPlayer.getAbilityInformed(ability) && cooldownOver(mcMMOPlayer.getProfile().getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
|
if (!skillManager.getAbilityInformed() && cooldownOver(mcMMOPlayer.getProfile().getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
|
||||||
mcMMOPlayer.setAbilityInformed(ability, true);
|
skillManager.setAbilityInformed(true);
|
||||||
player.sendMessage(ability.getAbilityRefresh());
|
player.sendMessage(ability.getAbilityRefresh());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,45 +119,48 @@ public class SkillUtils {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
|
||||||
AbilityType ability = skill.getAbility();
|
|
||||||
ToolType tool = skill.getTool();
|
|
||||||
ItemStack inHand = player.getItemInHand();
|
ItemStack inHand = player.getItemInHand();
|
||||||
|
|
||||||
if (ModUtils.isCustomTool(inHand) && !ModUtils.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
if (ModUtils.isCustomTool(inHand) && !ModUtils.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
if (!mcMMOPlayer.getAbilityUse()) {
|
if (!mcMMOPlayer.getAbilityUse()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AbilityType abilityType : AbilityType.values()) {
|
for (SkillManager skillManager : mcMMOPlayer.getSkillManagers().values()) {
|
||||||
if (mcMMOPlayer.getAbilityMode(abilityType)) {
|
if (skillManager.getAbilityMode()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SkillManager skillManager = mcMMOPlayer.getSkillManager(skill);
|
||||||
|
Tool tool = skillManager.getTool();
|
||||||
|
ToolType toolType = skill.getToolType();
|
||||||
|
AbilityType ability = skill.getAbility();
|
||||||
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) && tool.inHand(inHand) && !mcMMOPlayer.getToolPreparationMode(tool)) {
|
if (ability.getPermissions(player) && toolType.inHand(inHand) && !tool.getPreparationMode()) {
|
||||||
if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
|
if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
|
||||||
if (!mcMMOPlayer.getAbilityMode(ability) && !cooldownOver(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
|
if (!skillManager.getAbilityMode() && !cooldownOver(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.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(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getInstance().getAbilityMessagesEnabled()) {
|
if (Config.getInstance().getAbilityMessagesEnabled()) {
|
||||||
player.sendMessage(tool.getRaiseTool());
|
player.sendMessage(toolType.getRaiseTool());
|
||||||
}
|
}
|
||||||
|
|
||||||
mcMMOPlayer.setToolPreparationATS(tool, System.currentTimeMillis());
|
tool.setPreparationATS(System.currentTimeMillis());
|
||||||
mcMMOPlayer.setToolPreparationMode(tool, true);
|
tool.setPreparationMode(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,13 +174,14 @@ public class SkillUtils {
|
|||||||
*/
|
*/
|
||||||
public static void monitorSkill(McMMOPlayer mcMMOPlayer, long curTime, SkillType skill) {
|
public static void monitorSkill(McMMOPlayer mcMMOPlayer, long curTime, SkillType skill) {
|
||||||
final int FOUR_SECONDS = 4000;
|
final int FOUR_SECONDS = 4000;
|
||||||
ToolType tool = skill.getTool();
|
SkillManager skillManager = mcMMOPlayer.getSkillManager(skill);
|
||||||
|
Tool tool = skillManager.getTool();
|
||||||
|
|
||||||
if (mcMMOPlayer.getToolPreparationMode(tool) && curTime - (mcMMOPlayer.getToolPreparationATS(tool) * Misc.TIME_CONVERSION_FACTOR) >= FOUR_SECONDS) {
|
if (tool.getPreparationMode() && curTime - (tool.getPreparationATS() * Misc.TIME_CONVERSION_FACTOR) >= FOUR_SECONDS) {
|
||||||
mcMMOPlayer.setToolPreparationMode(tool, false);
|
tool.setPreparationMode(false);
|
||||||
|
|
||||||
if (Config.getInstance().getAbilityMessagesEnabled()) {
|
if (Config.getInstance().getAbilityMessagesEnabled()) {
|
||||||
mcMMOPlayer.getPlayer().sendMessage(tool.getLowerTool());
|
mcMMOPlayer.getPlayer().sendMessage(skill.getToolType().getLowerTool());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +189,7 @@ public class SkillUtils {
|
|||||||
Player player = mcMMOPlayer.getPlayer();
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
|
|
||||||
if (ability.getPermissions(player)) {
|
if (ability.getPermissions(player)) {
|
||||||
if (mcMMOPlayer.getAbilityMode(ability) && (mcMMOPlayer.getProfile().getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR) <= curTime) {
|
if (skillManager.getAbilityMode() && (mcMMOPlayer.getProfile().getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR) <= curTime) {
|
||||||
if (ability == AbilityType.BERSERK) {
|
if (ability == AbilityType.BERSERK) {
|
||||||
player.setCanPickupItems(true);
|
player.setCanPickupItems(true);
|
||||||
}
|
}
|
||||||
@ -189,8 +197,8 @@ public class SkillUtils {
|
|||||||
handleAbilitySpeedDecrease(player);
|
handleAbilitySpeedDecrease(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
mcMMOPlayer.setAbilityMode(ability, false);
|
skillManager.setAbilityMode(false);
|
||||||
mcMMOPlayer.setAbilityInformed(ability, false);
|
skillManager.setAbilityInformed(false);
|
||||||
|
|
||||||
ParticleEffectUtils.playAbilityDisabledEffect(player);
|
ParticleEffectUtils.playAbilityDisabledEffect(player);
|
||||||
|
|
||||||
@ -365,30 +373,29 @@ public class SkillUtils {
|
|||||||
* Check to see if an ability can be activated.
|
* Check to see if an ability can be activated.
|
||||||
*
|
*
|
||||||
* @param mcMMOPlayer The player activating the ability
|
* @param mcMMOPlayer The player activating the ability
|
||||||
* @param type The skill the ability is based on
|
* @param skill The skill the ability is based on
|
||||||
*/
|
*/
|
||||||
public static void abilityCheck(McMMOPlayer mcMMOPlayer, SkillType type) {
|
public static void abilityCheck(McMMOPlayer mcMMOPlayer, SkillType skill) {
|
||||||
ToolType tool = type.getTool();
|
SkillManager skillManager = mcMMOPlayer.getSkillManager(skill);
|
||||||
AbilityType ability = type.getAbility();
|
AbilityType ability = skill.getAbility();
|
||||||
|
|
||||||
mcMMOPlayer.setToolPreparationMode(tool, false);
|
|
||||||
|
|
||||||
Player player = mcMMOPlayer.getPlayer();
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
PlayerProfile playerProfile = mcMMOPlayer.getProfile();
|
PlayerProfile playerProfile = mcMMOPlayer.getProfile();
|
||||||
|
|
||||||
|
skillManager.getTool().setPreparationMode(false);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Axes and Woodcutting are odd because they share the same tool.
|
* Axes and Woodcutting are odd because they share the same tool.
|
||||||
* We show them the too tired message when they take action.
|
* We show them the too tired message when they take action.
|
||||||
*/
|
*/
|
||||||
if (type == SkillType.WOODCUTTING || type == SkillType.AXES) {
|
if (skill == SkillType.WOODCUTTING || skill == SkillType.AXES) {
|
||||||
if (!mcMMOPlayer.getAbilityMode(ability) && !cooldownOver(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
|
if (!skillManager.getAbilityMode() && !cooldownOver(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.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(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mcMMOPlayer.getAbilityMode(ability) && cooldownOver(playerProfile.getSkillDATS(ability), ability.getCooldown(), player)) {
|
if (!skillManager.getAbilityMode() && cooldownOver(playerProfile.getSkillDATS(ability), ability.getCooldown(), player)) {
|
||||||
int ticks = PerksUtils.handleActivationPerks(player, 2 + (playerProfile.getSkillLevel(type) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxTicks());
|
int ticks = PerksUtils.handleActivationPerks(player, 2 + (playerProfile.getSkillLevel(skill) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxTicks());
|
||||||
|
|
||||||
ParticleEffectUtils.playAbilityEnabledEffect(player);
|
ParticleEffectUtils.playAbilityEnabledEffect(player);
|
||||||
|
|
||||||
@ -399,7 +406,7 @@ public class SkillUtils {
|
|||||||
SkillUtils.sendSkillMessage(player, ability.getAbilityPlayer(player));
|
SkillUtils.sendSkillMessage(player, ability.getAbilityPlayer(player));
|
||||||
|
|
||||||
playerProfile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
|
playerProfile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
|
||||||
mcMMOPlayer.setAbilityMode(ability, true);
|
skillManager.setAbilityMode(true);
|
||||||
|
|
||||||
if (ability == AbilityType.BERSERK) {
|
if (ability == AbilityType.BERSERK) {
|
||||||
player.setCanPickupItems(false);
|
player.setCanPickupItems(false);
|
||||||
@ -515,10 +522,10 @@ public class SkillUtils {
|
|||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
int ticks = 0;
|
int ticks = 0;
|
||||||
|
|
||||||
if (mcMMOPlayer.getAbilityMode(AbilityType.SUPER_BREAKER)) {
|
if (mcMMOPlayer.getSkillManager(SkillType.MINING).getAbilityMode()) {
|
||||||
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.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) {
|
else if (mcMMOPlayer.getSkillManager(SkillType.EXCAVATION).getAbilityMode()) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user