Simplify the SuperAbilityType ENUM

This commit is contained in:
nossr50
2019-09-23 14:44:40 -07:00
parent d4826eebd8
commit 67a2841705
33 changed files with 982 additions and 1038 deletions

View File

@@ -52,16 +52,16 @@ public class CooldownCommand implements TabExecutor {
player.sendMessage(pluginRef.getLocaleManager().getString("mcMMO.NoSkillNote"));
for (SuperAbilityType ability : SuperAbilityType.values()) {
if (!ability.getPermissions(player)) {
if (!ability.superAbilityPermissionCheck(player)) {
continue;
}
int seconds = mcMMOPlayer.calculateTimeRemaining(ability);
if (seconds <= 0) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Cooldowns.Row.Y", ability.getName()));
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Cooldowns.Row.Y", ability.getPrettySuperAbilityName()));
} else {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Cooldowns.Row.N", ability.getName(), seconds));
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Cooldowns.Row.N", ability.getPrettySuperAbilityName(), seconds));
}
}

View File

@@ -77,12 +77,12 @@ public class MiningCommand extends SkillCommand {
if (canBiggerBombs) {
messages.add(getStatMessage(true, true, SubSkillType.MINING_BLAST_MINING, String.valueOf(blastRadiusIncrease)));
//messages.add(pluginRef.getLocaleManager().getString("Mining.Blast.Radius.Increase", blastRadiusIncrease));
//messages.add(pluginRef.getLocaleManager().getString("SuperAbility.BlastMining.Radius.Increase", blastRadiusIncrease));
}
if (canBlast) {
messages.add(getStatMessage(false, true, SubSkillType.MINING_BLAST_MINING, String.valueOf(blastMiningRank), String.valueOf(pluginRef.getRankTools().getHighestRank(SubSkillType.MINING_BLAST_MINING)), pluginRef.getLocaleManager().getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
//messages.add(pluginRef.getLocaleManager().getString("Mining.Blast.Rank", blastMiningRank, RankUtils.getHighestRank(SubSkillType.MINING_BLAST_MINING), pluginRef.getLocaleManager().getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
messages.add(getStatMessage(false, true, SubSkillType.MINING_BLAST_MINING, String.valueOf(blastMiningRank), String.valueOf(pluginRef.getRankTools().getHighestRank(SubSkillType.MINING_BLAST_MINING)), pluginRef.getLocaleManager().getString("SuperAbility.BlastMining.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
//messages.add(pluginRef.getLocaleManager().getString("SuperAbility.BlastMining.Rank", blastMiningRank, RankUtils.getHighestRank(SubSkillType.MINING_BLAST_MINING), pluginRef.getLocaleManager().getString("SuperAbility.BlastMining.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
}
if (canDemoExpert) {

View File

@@ -1,6 +1,7 @@
package com.gmail.nossr50.config.hocon.superabilities;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@@ -58,7 +59,7 @@ public class ConfigSuperAbilities {
return superAbilityLimits;
}
public int getCooldownForSuper(SuperAbilityType superAbilityType) {
public int getCooldownForSuper(mcMMO pluginRef, SuperAbilityType superAbilityType) {
switch (superAbilityType) {
case BERSERK:
return superAbilityCooldowns.getBerserk();
@@ -82,7 +83,7 @@ public class ConfigSuperAbilities {
}
}
public int getMaxLengthForSuper(SuperAbilityType superAbilityType) {
public int getMaxLengthForSuper(mcMMO pluginRef, SuperAbilityType superAbilityType) {
switch (superAbilityType) {
case BERSERK:
return superAbilityMaxLength.getBerserk();

View File

@@ -899,9 +899,9 @@ public class McMMOPlayer {
public void checkAbilityActivation(PrimarySkillType primarySkillType) {
//TODO: Disgusting..
ToolType tool = pluginRef.getSkillTools().getPrimarySkillToolType(primarySkillType);
SuperAbilityType ability = pluginRef.getSkillTools().getSuperAbility(primarySkillType);
SuperAbilityType superAbility = pluginRef.getSkillTools().getSuperAbility(primarySkillType);
if (getAbilityMode(ability) || !ability.getPermissions(player)) {
if (getAbilityMode(superAbility) || !pluginRef.getSkillTools().superAbilityPermissionCheck(superAbility, player)) {
return;
}
@@ -915,7 +915,7 @@ public class McMMOPlayer {
return;
}
int timeRemaining = calculateTimeRemaining(ability);
int timeRemaining = calculateTimeRemaining(superAbility);
if (timeRemaining > 0) {
/*
@@ -935,27 +935,27 @@ public class McMMOPlayer {
}
if (useChatNotifications()) {
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUPER_ABILITY, ability.getAbilityOn());
//player.sendMessage(ability.getAbilityOn());
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUPER_ABILITY, pluginRef.getSkillTools().getSuperAbilityOn(superAbility));
}
pluginRef.getSkillTools().sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS, ability.getAbilityPlayer());
pluginRef.getSkillTools().sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS,
pluginRef.getSkillTools().getSuperAbilityOtherPlayerActivationStr(superAbility));
//Sounds
SoundManager.worldSendSound(player.getWorld(), player.getLocation(), SoundType.ABILITY_ACTIVATED_GENERIC);
int abilityLength = pluginRef.getSkillTools().calculateAbilityLengthPerks(this, primarySkillType, ability);
int abilityLength = pluginRef.getSkillTools().calculateAbilityLengthPerks(this, primarySkillType, superAbility);
// Enable the ability
profile.setAbilityDATS(ability, System.currentTimeMillis() + (abilityLength * Misc.TIME_CONVERSION_FACTOR));
setAbilityMode(ability, true);
profile.setAbilityDATS(superAbility, System.currentTimeMillis() + (abilityLength * Misc.TIME_CONVERSION_FACTOR));
setAbilityMode(superAbility, true);
if (ability == SuperAbilityType.SUPER_BREAKER || ability == SuperAbilityType.GIGA_DRILL_BREAKER) {
if (superAbility == SuperAbilityType.SUPER_BREAKER || superAbility == SuperAbilityType.GIGA_DRILL_BREAKER) {
pluginRef.getSkillTools().handleAbilitySpeedIncrease(player);
}
setToolPreparationMode(tool, false);
new AbilityDisableTask(pluginRef, this, ability).runTaskLater(pluginRef, abilityLength * Misc.TICK_CONVERSION_FACTOR);
new AbilityDisableTask(pluginRef, this, superAbility).runTaskLater(pluginRef, abilityLength * Misc.TICK_CONVERSION_FACTOR);
}
public void processAbilityActivation(PrimarySkillType primarySkillType) {
@@ -1009,12 +1009,13 @@ public class McMMOPlayer {
/**
* Calculate the time remaining until the ability'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) {
long deactivatedTimestamp = profile.getAbilityDATS(superAbilityType) * Misc.TIME_CONVERSION_FACTOR;
return (int) (((deactivatedTimestamp + (PerksUtils.handleCooldownPerks(player,
pluginRef.getSkillTools().getSuperAbilityCooldown(superAbilityType)) * Misc.TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / Misc.TIME_CONVERSION_FACTOR);
}
/*

View File

@@ -1,70 +1,16 @@
package com.gmail.nossr50.datatypes.skills;
import com.gmail.nossr50.util.StringUtils;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
public enum SuperAbilityType {
BERSERK(
"Unarmed.Skills.Berserk.On",
"Unarmed.Skills.Berserk.Off",
"Unarmed.Skills.Berserk.Other.On",
"Unarmed.Skills.Berserk.Refresh",
"Unarmed.Skills.Berserk.Other.Off"),
SUPER_BREAKER(
"Mining.Skills.SuperBreaker.On",
"Mining.Skills.SuperBreaker.Off",
"Mining.Skills.SuperBreaker.Other.On",
"Mining.Skills.SuperBreaker.Refresh",
"Mining.Skills.SuperBreaker.Other.Off"),
GIGA_DRILL_BREAKER(
"Excavation.Skills.GigaDrillBreaker.On",
"Excavation.Skills.GigaDrillBreaker.Off",
"Excavation.Skills.GigaDrillBreaker.Other.On",
"Excavation.Skills.GigaDrillBreaker.Refresh",
"Excavation.Skills.GigaDrillBreaker.Other.Off"),
GREEN_TERRA(
"Herbalism.Skills.GTe.On",
"Herbalism.Skills.GTe.Off",
"Herbalism.Skills.GTe.Other.On",
"Herbalism.Skills.GTe.Refresh",
"Herbalism.Skills.GTe.Other.Off"),
SKULL_SPLITTER(
"Axes.Skills.SS.On",
"Axes.Skills.SS.Off",
"Axes.Skills.SS.Other.On",
"Axes.Skills.SS.Refresh",
"Axes.Skills.SS.Other.Off"),
TREE_FELLER(
"Woodcutting.Skills.TreeFeller.On",
"Woodcutting.Skills.TreeFeller.Off",
"Woodcutting.Skills.TreeFeller.Other.On",
"Woodcutting.Skills.TreeFeller.Refresh",
"Woodcutting.Skills.TreeFeller.Other.Off"),
SERRATED_STRIKES(
"Swords.Skills.SS.On",
"Swords.Skills.SS.Off",
"Swords.Skills.SS.Other.On",
"Swords.Skills.SS.Refresh",
"Swords.Skills.SS.Other.Off"),
/**
* Has cooldown - but has to share a skill with Super Breaker, so needs special treatment
*/
BLAST_MINING(
null,
null,
"Mining.Blast.Other.On",
"Mining.Blast.Refresh",
null),
;
BERSERK,
SUPER_BREAKER,
GIGA_DRILL_BREAKER,
GREEN_TERRA,
SKULL_SPLITTER,
TREE_FELLER,
SERRATED_STRIKES,
BLAST_MINING;
/*
* Defining their associated SubSkillType definitions
@@ -81,51 +27,15 @@ public enum SuperAbilityType {
BLAST_MINING.subSkillTypeDefinition = SubSkillType.MINING_BLAST_MINING;
}
private String abilityOn;
private String abilityOff;
private String abilityPlayer;
private String abilityRefresh;
private String abilityPlayerOff;
private SubSkillType subSkillTypeDefinition;
SuperAbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
this.abilityOn = abilityOn;
this.abilityOff = abilityOff;
this.abilityPlayer = abilityPlayer;
this.abilityRefresh = abilityRefresh;
this.abilityPlayerOff = abilityPlayerOff;
}
public int getCooldown() {
return pluginRef.getConfigManager().getConfigSuperAbilities().getCooldownForSuper(this);
}
public int getMaxLength() {
return pluginRef.getConfigManager().getConfigSuperAbilities().getMaxLengthForSuper(this);
}
public String getAbilityOn() {
return abilityOn;
}
public String getAbilityOff() {
return abilityOff;
}
public String getAbilityPlayer() {
return abilityPlayer;
}
public String getAbilityPlayerOff() {
return abilityPlayerOff;
}
public String getAbilityRefresh() {
return abilityRefresh;
}
public String getName() {
return StringUtils.getPrettyAbilityString(this);
/**
* Grabs the associated SubSkillType definition for this SuperAbilityType
*
* @return the matching SubSkillType definition for this SuperAbilityType
*/
public SubSkillType getSubSkillTypeDefinition() {
return subSkillTypeDefinition;
}
@Override
@@ -148,78 +58,4 @@ public enum SuperAbilityType {
return formattedString;
}
/**
* Get the permissions for this ability.
*
* @param player Player to check permissions for
* @return true if the player has permissions, false otherwise
*/
public boolean getPermissions(Player player) {
switch (this) {
case BERSERK:
return pluginRef.getPermissionTools().berserk(player);
case BLAST_MINING:
return pluginRef.getPermissionTools().remoteDetonation(player);
case GIGA_DRILL_BREAKER:
return pluginRef.getPermissionTools().gigaDrillBreaker(player);
case GREEN_TERRA:
return pluginRef.getPermissionTools().greenTerra(player);
case SERRATED_STRIKES:
return pluginRef.getPermissionTools().serratedStrikes(player);
case SKULL_SPLITTER:
return pluginRef.getPermissionTools().skullSplitter(player);
case SUPER_BREAKER:
return pluginRef.getPermissionTools().superBreaker(player);
case TREE_FELLER:
return pluginRef.getPermissionTools().treeFeller(player);
default:
return false;
}
}
/**
* Check if a block is affected by this ability.
*
* @param blockState the block to check
* @return true if the block is affected by this ability, false otherwise
*/
public boolean blockCheck(BlockState blockState) {
switch (this) {
case BERSERK:
return (pluginRef.getBlockTools().affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW);
case GIGA_DRILL_BREAKER:
return pluginRef.getBlockTools().affectedByGigaDrillBreaker(blockState);
case GREEN_TERRA:
return pluginRef.getBlockTools().canMakeMossy(blockState);
case SUPER_BREAKER:
return pluginRef.getBlockTools().affectedBySuperBreaker(blockState);
case TREE_FELLER:
return pluginRef.getBlockTools().isLog(blockState);
default:
return false;
}
}
/**
* Grabs the associated SubSkillType definition for this SuperAbilityType
*
* @return the matching SubSkillType definition for this SuperAbilityType
*/
public SubSkillType getSubSkillTypeDefinition() {
return subSkillTypeDefinition;
}
}

View File

@@ -517,7 +517,8 @@ public class BlockListener implements Listener {
blockState.update(true);
}
} else if (mcMMOPlayer.getAbilityMode(SuperAbilityType.BERSERK) && heldItem.getType() == Material.AIR) {
if (SuperAbilityType.BERSERK.blockCheck(block.getState()) && pluginRef.getEventManager().simulateBlockBreak(block, player, true)) {
if (pluginRef.getSkillTools().superAbilityBlockCheck(SuperAbilityType.BERSERK, block.getState())
&& pluginRef.getEventManager().simulateBlockBreak(block, player, true)) {
event.setInstaBreak(true);
SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
} else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && pluginRef.getBlockTools().affectedByBlockCracker(blockState) && pluginRef.getEventManager().simulateBlockBreak(block, player, true)) {

View File

@@ -25,7 +25,7 @@ public class AbilityCooldownTask extends BukkitRunnable {
mcMMOPlayer.setAbilityInformed(ability, true);
pluginRef.getNotificationManager().sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.ABILITY_REFRESHED, ability.getAbilityRefresh());
pluginRef.getNotificationManager().sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.ABILITY_REFRESHED, ability.getSuperAbilityRefreshedStr());
//mcMMOPlayer.getPlayer().sendMessage(ability.getAbilityRefresh());
}
}

View File

@@ -14,23 +14,23 @@ import org.bukkit.scheduler.BukkitRunnable;
public class AbilityDisableTask extends BukkitRunnable {
private final mcMMO pluginRef;
private McMMOPlayer mcMMOPlayer;
private SuperAbilityType ability;
private SuperAbilityType superAbilityType;
public AbilityDisableTask(mcMMO pluginRef, McMMOPlayer mcMMOPlayer, SuperAbilityType ability) {
public AbilityDisableTask(mcMMO pluginRef, McMMOPlayer mcMMOPlayer, SuperAbilityType superAbilityType) {
this.pluginRef = pluginRef;
this.mcMMOPlayer = mcMMOPlayer;
this.ability = ability;
this.superAbilityType = superAbilityType;
}
@Override
public void run() {
if (!mcMMOPlayer.getAbilityMode(ability)) {
if (!mcMMOPlayer.getAbilityMode(superAbilityType)) {
return;
}
Player player = mcMMOPlayer.getPlayer();
switch (ability) {
switch (superAbilityType) {
case SUPER_BREAKER:
case GIGA_DRILL_BREAKER:
pluginRef.getSkillTools().handleAbilitySpeedDecrease(player);
@@ -44,19 +44,23 @@ public class AbilityDisableTask extends BukkitRunnable {
break;
}
pluginRef.getEventManager().callAbilityDeactivateEvent(player, ability);
pluginRef.getEventManager().callAbilityDeactivateEvent(player, superAbilityType);
mcMMOPlayer.setAbilityMode(ability, false);
mcMMOPlayer.setAbilityInformed(ability, false);
mcMMOPlayer.setAbilityMode(superAbilityType, false);
mcMMOPlayer.setAbilityInformed(superAbilityType, false);
if (mcMMOPlayer.useChatNotifications()) {
//player.sendMessage(ability.getAbilityOff());
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ABILITY_OFF, ability.getAbilityOff());
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ABILITY_OFF,
pluginRef.getSkillTools().getSuperAbilityOff(superAbilityType));
}
pluginRef.getSkillTools().sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS, ability.getAbilityPlayerOff());
new AbilityCooldownTask(pluginRef, mcMMOPlayer, ability).runTaskLater(pluginRef, PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR);
pluginRef.getSkillTools().sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS,
pluginRef.getSkillTools().getSuperAbilityOtherPlayerDeactivationStr(superAbilityType));
new AbilityCooldownTask(pluginRef, mcMMOPlayer, superAbilityType).runTaskLater(pluginRef,
PerksUtils.handleCooldownPerks(player,
pluginRef.getSkillTools().getSuperAbilityCooldown(superAbilityType) * Misc.TICK_CONVERSION_FACTOR));
}
private void resendChunkRadiusAt(Player player) {

View File

@@ -90,13 +90,13 @@ public class WoodcuttingManager extends SkillManager {
if (treeFellerReachedThreshold) {
treeFellerReachedThreshold = false;
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Woodcutting.Skills.TreeFeller.Threshold");
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "SuperAbility.TreeFeller.Threshold");
return;
}
// If the tool can't sustain the durability loss
if (!handleDurabilityLoss(treeFellerBlocks, player.getInventory().getItemInMainHand())) {
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Woodcutting.Skills.TreeFeller.Splinter");
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "SuperAbility.TreeFeller.Splinter");
double health = player.getHealth();

View File

@@ -395,15 +395,15 @@ public final class PermissionTools {
/* MINING */
public boolean biggerBombs(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.mining.blastmining.biggerbombs");
return permissible.hasPermission("mcmmo.ability.SuperAbility.BlastMining.biggerbombs");
}
public boolean demolitionsExpertise(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.mining.blastmining.demolitionsexpertise");
return permissible.hasPermission("mcmmo.ability.SuperAbility.BlastMining.demolitionsexpertise");
}
public boolean remoteDetonation(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.mining.blastmining.detonate");
return permissible.hasPermission("mcmmo.ability.SuperAbility.BlastMining.detonate");
}
public boolean superBreaker(Permissible permissible) {

View File

@@ -102,10 +102,10 @@ public class ScoreboardStrings {
skillLabelBuilder.put(primarySkillType, getShortenedName(colors.get(i) + pluginRef.getSkillTools().getLocalizedSkillName(primarySkillType), false));
if (pluginRef.getSkillTools().getSuperAbility(primarySkillType) != null) {
abilityLabelBuilder.put(pluginRef.getSkillTools().getSuperAbility(primarySkillType), getShortenedName(colors.get(i) + pluginRef.getSkillTools().getSuperAbility(primarySkillType).getName()));
abilityLabelBuilder.put(pluginRef.getSkillTools().getSuperAbility(primarySkillType), getShortenedName(colors.get(i) + pluginRef.getSkillTools().getSuperAbility(primarySkillType).getPrettySuperAbilityName()));
if (primarySkillType == PrimarySkillType.MINING) {
abilityLabelBuilder.put(SuperAbilityType.BLAST_MINING, getShortenedName(colors.get(i) + SuperAbilityType.BLAST_MINING.getName()));
abilityLabelBuilder.put(SuperAbilityType.BLAST_MINING, getShortenedName(colors.get(i) + SuperAbilityType.BLAST_MINING.getPrettySuperAbilityName()));
}
}
@@ -124,17 +124,17 @@ public class ScoreboardStrings {
skillLabelBuilder.put(primarySkillType, getShortenedName(ChatColor.GREEN + pluginRef.getSkillTools().getLocalizedSkillName(primarySkillType)));
if (pluginRef.getSkillTools().getSuperAbility(primarySkillType) != null) {
abilityLabelBuilder.put(pluginRef.getSkillTools().getSuperAbility(primarySkillType), formatAbility(pluginRef.getSkillTools().getSuperAbility(primarySkillType).getName()));
abilityLabelBuilder.put(pluginRef.getSkillTools().getSuperAbility(primarySkillType), formatAbility(pluginRef.getSkillTools().getSuperAbility(primarySkillType).getPrettySuperAbilityName()));
if (primarySkillType == PrimarySkillType.MINING) {
abilityLabelBuilder.put(SuperAbilityType.BLAST_MINING, formatAbility(SuperAbilityType.BLAST_MINING.getName()));
abilityLabelBuilder.put(SuperAbilityType.BLAST_MINING, formatAbility(SuperAbilityType.BLAST_MINING.getPrettySuperAbilityName()));
}
}
}
}
for (SuperAbilityType type : SuperAbilityType.values()) {
abilityLabelSkillBuilder.put(type, formatAbility((type == SuperAbilityType.BLAST_MINING ? ChatColor.BLUE : ChatColor.AQUA), type.getName()));
abilityLabelSkillBuilder.put(type, formatAbility((type == SuperAbilityType.BLAST_MINING ? ChatColor.BLUE : ChatColor.AQUA), type.getPrettySuperAbilityName()));
}
skillLabels = skillLabelBuilder.build();

View File

@@ -17,6 +17,7 @@ import com.google.common.collect.ImmutableSet;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@@ -255,7 +256,7 @@ public class SkillTools {
//These values change depending on whether or not the server is in retro mode
int abilityLengthVar = pluginRef.getConfigManager().getConfigSuperAbilities().getSuperAbilityStartingSeconds();
int maxLength = pluginRef.getConfigManager().getConfigSuperAbilities().getMaxLengthForSuper(superAbilityType);
int maxLength = pluginRef.getConfigManager().getConfigSuperAbilities().getMaxLengthForSuper(pluginRef, superAbilityType);
int skillLevel = mcMMOPlayer.getSkillLevel(skill);
@@ -759,4 +760,104 @@ public class SkillTools {
public String getCapitalizedPrimarySkillName(PrimarySkillType primarySkillType) {
return StringUtils.getCapitalized(primarySkillType.toString());
}
public int getSuperAbilityCooldown(SuperAbilityType superAbilityType) {
return pluginRef.getConfigManager().getConfigSuperAbilities().getCooldownForSuper(pluginRef, superAbilityType);
}
public int getSuperAbilityMaxLength(SuperAbilityType superAbilityType) {
return pluginRef.getConfigManager().getConfigSuperAbilities().getMaxLengthForSuper(pluginRef, superAbilityType);
}
public String getSuperAbilityOn(SuperAbilityType superAbilityType) {
return pluginRef.getLocaleManager().getString("SuperAbility." + superAbilityType.toString() + ".On");
}
public String getSuperAbilityOff(SuperAbilityType superAbilityType) {
return pluginRef.getLocaleManager().getString("SuperAbility." + superAbilityType.toString() + ".Off");
}
public String getSuperAbilityOtherPlayerActivationStr(SuperAbilityType superAbilityType) {
return pluginRef.getLocaleManager().getString("SuperAbility." + superAbilityType.toString() + ".Other.On");
}
public String getSuperAbilityOtherPlayerDeactivationStr(SuperAbilityType superAbilityType) {
return pluginRef.getLocaleManager().getString("SuperAbility." + superAbilityType.toString() + "Other.Off");
}
public String getSuperAbilityRefreshedStr(SuperAbilityType superAbilityType) {
return pluginRef.getLocaleManager().getString("SuperAbility." + superAbilityType.toString() + ".Refresh");
}
public String getPrettySuperAbilityName(SuperAbilityType superAbilityType) {
return StringUtils.getPrettyAbilityString(superAbilityType);
}
/**
* Get the permissions for this ability.
*
* @param player Player to check permissions for
* @param superAbilityType target super ability
* @return true if the player has permissions, false otherwise
*/
public boolean superAbilityPermissionCheck(SuperAbilityType superAbilityType, Player player) {
switch (superAbilityType) {
case BERSERK:
return pluginRef.getPermissionTools().berserk(player);
case BLAST_MINING:
return pluginRef.getPermissionTools().remoteDetonation(player);
case GIGA_DRILL_BREAKER:
return pluginRef.getPermissionTools().gigaDrillBreaker(player);
case GREEN_TERRA:
return pluginRef.getPermissionTools().greenTerra(player);
case SERRATED_STRIKES:
return pluginRef.getPermissionTools().serratedStrikes(player);
case SKULL_SPLITTER:
return pluginRef.getPermissionTools().skullSplitter(player);
case SUPER_BREAKER:
return pluginRef.getPermissionTools().superBreaker(player);
case TREE_FELLER:
return pluginRef.getPermissionTools().treeFeller(player);
default:
return false;
}
}
/**
* Check if a block is affected by this ability.
*
* @param blockState the block to check
* @param superAbilityType target super ability
* @return true if the block is affected by this ability, false otherwise
*/
public boolean superAbilityBlockCheck(SuperAbilityType superAbilityType, BlockState blockState) {
switch (superAbilityType) {
case BERSERK:
return (pluginRef.getBlockTools().affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW);
case GIGA_DRILL_BREAKER:
return pluginRef.getBlockTools().affectedByGigaDrillBreaker(blockState);
case GREEN_TERRA:
return pluginRef.getBlockTools().canMakeMossy(blockState);
case SUPER_BREAKER:
return pluginRef.getBlockTools().affectedBySuperBreaker(blockState);
case TREE_FELLER:
return pluginRef.getBlockTools().isLog(blockState);
default:
return false;
}
}
}