|
@@ -1,26 +1,21 @@
|
|
|
package com.gmail.nossr50.datatypes.player;
|
|
|
|
|
|
-import com.gmail.nossr50.config.AdvancedConfig;
|
|
|
import com.gmail.nossr50.config.Config;
|
|
|
import com.gmail.nossr50.config.WorldBlacklist;
|
|
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
|
|
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
|
|
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
|
|
import com.gmail.nossr50.datatypes.experience.XPGainSource;
|
|
|
-import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
|
|
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
|
|
import com.gmail.nossr50.datatypes.party.Party;
|
|
|
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
|
|
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
|
|
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
|
|
-import com.gmail.nossr50.datatypes.skills.ToolType;
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
|
|
import com.gmail.nossr50.mcMMO;
|
|
|
import com.gmail.nossr50.party.PartyManager;
|
|
|
import com.gmail.nossr50.party.ShareHandler;
|
|
|
-import com.gmail.nossr50.runnables.skills.AbilityDisableTask;
|
|
|
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
|
|
-import com.gmail.nossr50.runnables.skills.ToolLowerTask;
|
|
|
import com.gmail.nossr50.skills.SkillManager;
|
|
|
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
|
|
import com.gmail.nossr50.skills.alchemy.AlchemyManager;
|
|
@@ -44,19 +39,18 @@ import com.gmail.nossr50.util.EventUtils;
|
|
|
import com.gmail.nossr50.util.Misc;
|
|
|
import com.gmail.nossr50.util.Permissions;
|
|
|
import com.gmail.nossr50.util.experience.ExperienceBarManager;
|
|
|
+import com.gmail.nossr50.util.input.SuperAbilityManager;
|
|
|
import com.gmail.nossr50.util.player.NotificationManager;
|
|
|
import com.gmail.nossr50.util.player.UserManager;
|
|
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
|
|
import com.gmail.nossr50.util.skills.PerksUtils;
|
|
|
import com.gmail.nossr50.util.skills.RankUtils;
|
|
|
-import com.gmail.nossr50.util.skills.SkillUtils;
|
|
|
import com.gmail.nossr50.util.sounds.SoundManager;
|
|
|
import com.gmail.nossr50.util.sounds.SoundType;
|
|
|
import org.apache.commons.lang.Validate;
|
|
|
import org.bukkit.GameMode;
|
|
|
import org.bukkit.Location;
|
|
|
import org.bukkit.entity.Player;
|
|
|
-import org.bukkit.inventory.ItemStack;
|
|
|
import org.bukkit.metadata.FixedMetadataValue;
|
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
|
@@ -84,15 +78,9 @@ public class McMMOPlayer {
|
|
|
private boolean displaySkillNotifications = true;
|
|
|
private boolean debugMode;
|
|
|
|
|
|
- private boolean abilityUse = true;
|
|
|
private boolean godMode;
|
|
|
private boolean chatSpy = false; //Off by default
|
|
|
|
|
|
- private final Map<SuperAbilityType, Boolean> abilityMode = new HashMap<>();
|
|
|
- private final Map<SuperAbilityType, Boolean> abilityInformed = new HashMap<>();
|
|
|
-
|
|
|
- private final Map<ToolType, Boolean> toolMode = new HashMap<>();
|
|
|
-
|
|
|
private int recentlyHurt;
|
|
|
private int respawnATS;
|
|
|
private int teleportATS;
|
|
@@ -104,6 +92,7 @@ public class McMMOPlayer {
|
|
|
private boolean isUsingUnarmed;
|
|
|
private final FixedMetadataValue playerMetadata;
|
|
|
private final String playerName;
|
|
|
+ private final SuperAbilityManager superAbilityManager;
|
|
|
|
|
|
public McMMOPlayer(Player player, PlayerProfile profile) {
|
|
|
this.playerName = player.getName();
|
|
@@ -132,14 +121,7 @@ public class McMMOPlayer {
|
|
|
mcMMO.p.getPluginLoader().disablePlugin(mcMMO.p);
|
|
|
}
|
|
|
|
|
|
- for (SuperAbilityType superAbilityType : SuperAbilityType.values()) {
|
|
|
- abilityMode.put(superAbilityType, false);
|
|
|
- abilityInformed.put(superAbilityType, true); // This is intended
|
|
|
- }
|
|
|
-
|
|
|
- for (ToolType toolType : ToolType.values()) {
|
|
|
- toolMode.put(toolType, false);
|
|
|
- }
|
|
|
+ superAbilityManager = new SuperAbilityManager(this);
|
|
|
|
|
|
experienceBarManager = new ExperienceBarManager(this, profile.getXpBarStateMap());
|
|
|
|
|
@@ -159,11 +141,6 @@ public class McMMOPlayer {
|
|
|
this.attackStrength = attackStrength;
|
|
|
}
|
|
|
|
|
|
- /*public void hideXpBar(PrimarySkillType primarySkillType)
|
|
|
- {
|
|
|
- experienceBarManager.hideExperienceBar(primarySkillType);
|
|
|
- }*/
|
|
|
-
|
|
|
public void processPostXpEvent(PrimarySkillType primarySkillType, Plugin plugin, XPGainSource xpGainSource)
|
|
|
{
|
|
|
//Check if they've reached the power level cap just now
|
|
@@ -279,100 +256,6 @@ public class McMMOPlayer {
|
|
|
return (WoodcuttingManager) skillManagers.get(PrimarySkillType.WOODCUTTING);
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- * Abilities
|
|
|
- */
|
|
|
-
|
|
|
- /**
|
|
|
- * Reset the mode of all abilities.
|
|
|
- */
|
|
|
- public void resetAbilityMode() {
|
|
|
- for (SuperAbilityType ability : SuperAbilityType.values()) {
|
|
|
- // Correctly disable and handle any special deactivate code
|
|
|
- new AbilityDisableTask(this, ability).run();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Get the mode of an ability.
|
|
|
- *
|
|
|
- * @param ability The ability to check
|
|
|
- * @return true if the ability is enabled, false otherwise
|
|
|
- */
|
|
|
- public boolean getAbilityMode(SuperAbilityType ability) {
|
|
|
- return abilityMode.get(ability);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Set the mode of an ability.
|
|
|
- *
|
|
|
- * @param ability The ability to check
|
|
|
- * @param isActive True if the ability is active, false otherwise
|
|
|
- */
|
|
|
- public void setAbilityMode(SuperAbilityType ability, boolean isActive) {
|
|
|
- abilityMode.put(ability, isActive);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 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(SuperAbilityType ability) {
|
|
|
- return abilityInformed.get(ability);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Set the informed state of an ability.
|
|
|
- *
|
|
|
- * @param ability The ability to check
|
|
|
- * @param isInformed True if the ability is informed, false otherwise
|
|
|
- */
|
|
|
- public void setAbilityInformed(SuperAbilityType ability, boolean isInformed) {
|
|
|
- abilityInformed.put(ability, isInformed);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 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 toolMode.get(tool);
|
|
|
- }
|
|
|
-
|
|
|
- public boolean getAbilityUse() {
|
|
|
- return abilityUse;
|
|
|
- }
|
|
|
-
|
|
|
- public void toggleAbilityUse() {
|
|
|
- abilityUse = !abilityUse;
|
|
|
- }
|
|
|
-
|
|
|
- /*
|
|
|
- * Tools
|
|
|
- */
|
|
|
-
|
|
|
- /**
|
|
|
- * Reset the prep modes of all tools.
|
|
|
- */
|
|
|
- public void resetToolPrepMode() {
|
|
|
- for (ToolType tool : ToolType.values()) {
|
|
|
- setToolPreparationMode(tool, false);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Set the current prep mode of a tool.
|
|
|
- *
|
|
|
- * @param tool Tool to set the mode for
|
|
|
- * @param isPrepared true if the tool should be prepped, false otherwise
|
|
|
- */
|
|
|
- public void setToolPreparationMode(ToolType tool, boolean isPrepared) {
|
|
|
- toolMode.put(tool, isPrepared);
|
|
|
- }
|
|
|
|
|
|
/*
|
|
|
* Recently Hurt
|
|
@@ -855,149 +738,16 @@ public class McMMOPlayer {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Check to see if an ability can be activated.
|
|
|
- *
|
|
|
- * @param skill The skill the ability is based on
|
|
|
- */
|
|
|
- public void checkAbilityActivation(PrimarySkillType skill) {
|
|
|
- ToolType tool = skill.getTool();
|
|
|
- SuperAbilityType ability = skill.getAbility();
|
|
|
-
|
|
|
- if (getAbilityMode(ability) || !ability.getPermissions(player)) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- //TODO: This is hacky and temporary solution until skills are move to the new system
|
|
|
- //Potential problems with this include skills with two super abilities (ie mining)
|
|
|
- if(!skill.isSuperAbilityUnlocked(getPlayer()))
|
|
|
- {
|
|
|
- int diff = RankUtils.getSuperAbilityUnlockRequirement(skill.getAbility()) - getSkillLevel(skill);
|
|
|
-
|
|
|
- //Inform the player they are not yet skilled enough
|
|
|
- NotificationManager.sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Skills.AbilityGateRequirementFail", String.valueOf(diff), skill.getName());
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- int timeRemaining = calculateTimeRemaining(ability);
|
|
|
-
|
|
|
- if (timeRemaining > 0) {
|
|
|
- /*
|
|
|
- * Axes and Woodcutting are odd because they share the same tool.
|
|
|
- * We show them the too tired message when they take action.
|
|
|
- */
|
|
|
- if (skill == PrimarySkillType.WOODCUTTING || skill == PrimarySkillType.AXES) {
|
|
|
- NotificationManager.sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Skills.TooTired", String.valueOf(timeRemaining));
|
|
|
- //SoundManager.sendSound(player, player.getLocation(), SoundType.TIRED);
|
|
|
- }
|
|
|
-
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (EventUtils.callPlayerAbilityActivateEvent(player, skill).isCancelled()) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- //These values change depending on whether or not the server is in retro mode
|
|
|
- int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
|
|
|
- int abilityLengthCap = AdvancedConfig.getInstance().getAbilityLengthCap();
|
|
|
-
|
|
|
- int ticks;
|
|
|
-
|
|
|
- //Ability cap of 0 or below means no cap
|
|
|
- if(abilityLengthCap > 0)
|
|
|
- {
|
|
|
- ticks = PerksUtils.handleActivationPerks(player, 2 + (Math.min(abilityLengthCap, getSkillLevel(skill)) / abilityLengthVar), ability.getMaxLength());
|
|
|
- } else {
|
|
|
- ticks = PerksUtils.handleActivationPerks(player, 2 + (getSkillLevel(skill) / abilityLengthVar), ability.getMaxLength());
|
|
|
- }
|
|
|
-
|
|
|
- if (useChatNotifications()) {
|
|
|
- NotificationManager.sendPlayerInformation(player, NotificationType.SUPER_ABILITY, ability.getAbilityOn());
|
|
|
- //player.sendMessage(ability.getAbilityOn());
|
|
|
- }
|
|
|
-
|
|
|
- if (AdvancedConfig.getInstance().sendAbilityNotificationToOtherPlayers()) {
|
|
|
- SkillUtils.sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS, ability.getAbilityPlayer());
|
|
|
- }
|
|
|
-
|
|
|
- //Sounds
|
|
|
- SoundManager.worldSendSound(player.getWorld(), player.getLocation(), SoundType.ABILITY_ACTIVATED_GENERIC);
|
|
|
-
|
|
|
- // Enable the ability
|
|
|
- profile.setAbilityDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
|
|
|
- setAbilityMode(ability, true);
|
|
|
-
|
|
|
- if (ability == SuperAbilityType.SUPER_BREAKER || ability == SuperAbilityType.GIGA_DRILL_BREAKER) {
|
|
|
- SkillUtils.handleAbilitySpeedIncrease(player);
|
|
|
- }
|
|
|
-
|
|
|
- setToolPreparationMode(tool, false);
|
|
|
- new AbilityDisableTask(this, ability).runTaskLater(mcMMO.p, ticks * Misc.TICK_CONVERSION_FACTOR);
|
|
|
- }
|
|
|
-
|
|
|
- public void processAbilityActivation(PrimarySkillType skill) {
|
|
|
- if (!skill.getPermissions(getPlayer())) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && !player.isSneaking()) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- ItemStack inHand = player.getInventory().getItemInMainHand();
|
|
|
-
|
|
|
- if (mcMMO.getModManager().isCustomTool(inHand) && !mcMMO.getModManager().getTool(inHand).isAbilityEnabled()) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (!getAbilityUse()) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- for (SuperAbilityType superAbilityType : SuperAbilityType.values()) {
|
|
|
- if (getAbilityMode(superAbilityType)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- SuperAbilityType ability = skill.getAbility();
|
|
|
- ToolType tool = skill.getTool();
|
|
|
-
|
|
|
- /*
|
|
|
- * 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
|
|
|
- */
|
|
|
- if (tool.inHand(inHand) && !getToolPreparationMode(tool)) {
|
|
|
- if (skill != PrimarySkillType.WOODCUTTING && skill != PrimarySkillType.AXES) {
|
|
|
- int timeRemaining = calculateTimeRemaining(ability);
|
|
|
-
|
|
|
- if (!getAbilityMode(ability) && timeRemaining > 0) {
|
|
|
- NotificationManager.sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Skills.TooTired", String.valueOf(timeRemaining));
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (Config.getInstance().getAbilityMessagesEnabled()) {
|
|
|
- NotificationManager.sendPlayerInformation(player, NotificationType.TOOL, tool.getRaiseTool());
|
|
|
- SoundManager.sendSound(player, player.getLocation(), SoundType.TOOL_READY);
|
|
|
- }
|
|
|
-
|
|
|
- setToolPreparationMode(tool, true);
|
|
|
- new ToolLowerTask(this, tool).runTaskLater(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
- * Calculate the time remaining until the ability's cooldown expires.
|
|
|
+ * Calculate the time remaining until the superAbilityType's cooldown expires.
|
|
|
*
|
|
|
- * @param ability SuperAbilityType whose cooldown to check
|
|
|
+ * @param superAbilityType SuperAbilityType whose cooldown to check
|
|
|
*
|
|
|
* @return the number of seconds remaining before the cooldown expires
|
|
|
*/
|
|
|
- public int calculateTimeRemaining(SuperAbilityType ability) {
|
|
|
- long deactivatedTimestamp = profile.getAbilityDATS(ability) * Misc.TIME_CONVERSION_FACTOR;
|
|
|
- return (int) (((deactivatedTimestamp + (PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / Misc.TIME_CONVERSION_FACTOR);
|
|
|
+ public int calculateTimeRemaining(SuperAbilityType superAbilityType) {
|
|
|
+ return superAbilityManager.calculateTimeRemaining(superAbilityType);
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -1080,6 +830,11 @@ public class McMMOPlayer {
|
|
|
mcMMO.getDatabaseManager().cleanupUser(thisPlayer.getUniqueId());
|
|
|
}
|
|
|
|
|
|
+ public SuperAbilityManager getSuperAbilityManager() {
|
|
|
+ return superAbilityManager;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* Cleanup various things related to this player
|
|
|
* Such as temporary summons..
|
|
@@ -1087,7 +842,7 @@ public class McMMOPlayer {
|
|
|
* Etc...
|
|
|
*/
|
|
|
public void cleanup() {
|
|
|
- resetAbilityMode();
|
|
|
+ superAbilityManager.resetSuperAbilities();
|
|
|
getTamingManager().cleanupAllSummons();
|
|
|
}
|
|
|
}
|