mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 17:53:00 +01:00
Compare commits
3 Commits
dev-serial
...
internals
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e41adf769b | ||
|
|
e80f60ccee | ||
|
|
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).getAbility().getMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
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).getAbility().getMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
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).getAbility().getMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
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).getAbility().getMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
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).getAbility().getMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
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).getAbility().getMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
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).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 (AbilityType ability : AbilityType.values()) {
|
for (SkillManager skillManager : mcMMOPlayer.getSkillManagers().values()) {
|
||||||
if (mcMMOPlayer.getAbilityMode(ability)) {
|
if (skillManager.getAbility().getMode()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ 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.Tool;
|
||||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
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;
|
||||||
@@ -69,11 +69,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;
|
||||||
|
|
||||||
@@ -84,6 +79,19 @@ public class McMMOPlayer {
|
|||||||
profile = new PlayerProfile(playerName, true);
|
profile = new PlayerProfile(playerName, true);
|
||||||
party = PartyManager.getPlayerParty(playerName);
|
party = PartyManager.getPlayerParty(playerName);
|
||||||
|
|
||||||
|
Map<ToolType, Tool> tools = new HashMap<ToolType, Tool>();
|
||||||
|
|
||||||
|
// Build Tool objects for the current player, a tool can be used by multiple skills
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
ToolType toolType = skillType.getToolType();
|
||||||
|
|
||||||
|
if (tools.containsKey(toolType)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
tools.put(toolType, new Tool());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* I'm using this method because it makes code shorter and safer (we don't have to add all SkillTypes manually),
|
* I'm using this method because it makes code shorter and safer (we don't have to add all SkillTypes manually),
|
||||||
* but I actually have no idea about the performance impact, if there is any.
|
* but I actually have no idea about the performance impact, if there is any.
|
||||||
@@ -95,6 +103,9 @@ public class McMMOPlayer {
|
|||||||
|
|
||||||
// TODO: The null check is needed only because currently some SkillType doesn't have a valid skillManagerClass
|
// TODO: The null check is needed only because currently some SkillType doesn't have a valid skillManagerClass
|
||||||
if (skillManagerClass != null) {
|
if (skillManagerClass != null) {
|
||||||
|
SkillManager skillManager = skillManagerClass.getConstructor(McMMOPlayer.class).newInstance(this);
|
||||||
|
|
||||||
|
skillManager.setTool(tools.get(skillType.getToolType()));
|
||||||
skillManagers.put(skillType, skillManagerClass.getConstructor(McMMOPlayer.class).newInstance(this));
|
skillManagers.put(skillType, skillManagerClass.getConstructor(McMMOPlayer.class).newInstance(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,16 +114,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 +160,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 +176,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.getAbility().setMode(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 +197,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
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 tool;
|
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;
|
||||||
tool = 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.tool = 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -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() {
|
||||||
|
|||||||
26
src/main/java/com/gmail/nossr50/datatypes/skills/Tool.java
Normal file
26
src/main/java/com/gmail/nossr50/datatypes/skills/Tool.java
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package com.gmail.nossr50.datatypes.skills;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
|
||||||
|
public class Tool {
|
||||||
|
private boolean preparationMode = true;
|
||||||
|
private long preparationATS;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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.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.getAbilityMode(AbilityType.TREE_FELLER) && 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 {
|
||||||
@@ -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.getAbility().getMode()) {
|
||||||
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).getAbility().getMode()) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getSkillManager(SkillType.EXCAVATION).getAbility().getMode())) {
|
||||||
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).getAbility().getMode() && !BlockUtils.affectedBySuperBreaker(blockState)) || (mcMMOPlayer.getSkillManager(SkillType.EXCAVATION).getAbility().getMode() && !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).getAbility().getMode() || mcMMOPlayer.getSkillManager(SkillType.MINING).getAbility().getMode()) {
|
||||||
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.getAbilityType() == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (skill.getToolType() != null) {
|
||||||
SkillUtils.monitorSkill(mcMMOPlayer, curTime, skill);
|
SkillUtils.monitorSkill(mcMMOPlayer, curTime, skill);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
if (skill.getAbilityType().getCooldown() > 0) {
|
||||||
* COOLDOWN MONITORING
|
SkillUtils.watchCooldown(mcMMOPlayer, skill);
|
||||||
*/
|
|
||||||
for (AbilityType ability : AbilityType.values()) {
|
|
||||||
if (ability.getCooldown() > 0) {
|
|
||||||
SkillUtils.watchCooldown(mcMMOPlayer, ability);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,17 @@ 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.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 Ability ability = new Ability();
|
||||||
|
protected Tool tool; // Because tool can be shared, it's instanced in McMMOPlayer
|
||||||
|
|
||||||
public SkillManager(McMMOPlayer mcMMOPlayer, SkillType skill) {
|
public SkillManager(McMMOPlayer mcMMOPlayer, SkillType skill) {
|
||||||
this.mcMMOPlayer = mcMMOPlayer;
|
this.mcMMOPlayer = mcMMOPlayer;
|
||||||
@@ -41,4 +45,16 @@ public abstract class SkillManager {
|
|||||||
public void applyXpGain(int xp) {
|
public void applyXpGain(int xp) {
|
||||||
mcMMOPlayer.beginXpGain(skill, xp);
|
mcMMOPlayer.beginXpGain(skill, xp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Ability getAbility() {
|
||||||
|
return ability;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Tool getTool() {
|
||||||
|
return tool;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTool(Tool tool) {
|
||||||
|
this.tool = 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() && getAbility().getMode() && 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 getAbility().getMode() && 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 getAbility().getMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -286,7 +284,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mcMMOPlayer.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
if (getAbility().getMode()) {
|
||||||
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);
|
getAbility().setInformed(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 getAbility().getMode() && 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 getAbility().getMode() && Permissions.berserk(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canDisarm(LivingEntity target) {
|
public boolean canDisarm(LivingEntity target) {
|
||||||
|
|||||||
@@ -23,14 +23,17 @@ 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.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,18 +92,20 @@ 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();
|
||||||
|
Ability ability = mcMMOPlayer.getSkillManager(skill).getAbility();
|
||||||
|
AbilityType abilityType = skill.getAbilityType();
|
||||||
|
|
||||||
if (!mcMMOPlayer.getAbilityInformed(ability) && 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)) {
|
||||||
mcMMOPlayer.setAbilityInformed(ability, true);
|
ability.setInformed(true);
|
||||||
player.sendMessage(ability.getAbilityRefresh());
|
player.sendMessage(abilityType.getAbilityRefresh());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,45 +120,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.getAbility().getMode()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SkillManager skillManager = mcMMOPlayer.getSkillManager(skill);
|
||||||
|
Tool tool = skillManager.getTool();
|
||||||
|
ToolType toolType = skill.getToolType();
|
||||||
|
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) && tool.inHand(inHand) && !mcMMOPlayer.getToolPreparationMode(tool)) {
|
if (abilityType.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.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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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,38 +175,40 @@ 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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 (mcMMOPlayer.getAbilityMode(ability) && (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);
|
||||||
}
|
}
|
||||||
|
|
||||||
mcMMOPlayer.setAbilityMode(ability, false);
|
ability.setMode(false);
|
||||||
mcMMOPlayer.setAbilityInformed(ability, 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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -365,46 +375,46 @@ 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();
|
Ability ability = skillManager.getAbility();
|
||||||
|
AbilityType abilityType = skill.getAbilityType();
|
||||||
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 (!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 (!mcMMOPlayer.getAbilityMode(ability) && 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(type) / 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));
|
||||||
mcMMOPlayer.setAbilityMode(ability, 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -515,10 +525,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).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.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) {
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user