Fix double drops for mining

This commit is contained in:
nossr50 2019-06-16 04:59:34 -07:00
parent 43ca43cc48
commit a1e3bb18a4
23 changed files with 108 additions and 321 deletions

View File

@ -55,7 +55,7 @@ public class AxesCommand extends SkillCommand {
// SKULL SPLITTER
if (canSkullSplitter) {
String[] skullSplitterStrings = calculateLengthDisplayValues(player, skillValue);
String[] skullSplitterStrings = formatLengthDisplayValues(player, skillValue);
skullSplitterLength = skullSplitterStrings[0];
skullSplitterLengthEndurance = skullSplitterStrings[1];
}

View File

@ -27,7 +27,7 @@ public class ExcavationCommand extends SkillCommand {
protected void dataCalculations(Player player, double skillValue) {
// GIGA DRILL BREAKER
if (canGigaDrill) {
String[] gigaDrillStrings = calculateLengthDisplayValues(player, skillValue);
String[] gigaDrillStrings = formatLengthDisplayValues(player, skillValue);
gigaDrillBreakerLength = gigaDrillStrings[0];
gigaDrillBreakerLengthEndurance = gigaDrillStrings[1];
}

View File

@ -56,7 +56,7 @@ public class HerbalismCommand extends SkillCommand {
// GREEN TERRA
if (canGreenTerra) {
String[] greenTerraStrings = calculateLengthDisplayValues(player, skillValue);
String[] greenTerraStrings = formatLengthDisplayValues(player, skillValue);
greenTerraLength = greenTerraStrings[0];
greenTerraLengthEndurance = greenTerraStrings[1];
}

View File

@ -60,7 +60,7 @@ public class MiningCommand extends SkillCommand {
// SUPER BREAKER
if (canSuperBreaker) {
String[] superBreakerStrings = calculateLengthDisplayValues(player, skillValue);
String[] superBreakerStrings = formatLengthDisplayValues(player, skillValue);
superBreakerLength = superBreakerStrings[0];
superBreakerLengthEndurance = superBreakerStrings[1];
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
@ -14,9 +13,9 @@ import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.RandomChanceUtil;
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.SkillActivationType;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.google.common.collect.ImmutableList;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.TextComponent;
@ -74,7 +73,7 @@ public abstract class SkillCommand implements TabExecutor {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
boolean isLucky = Permissions.lucky(player, skill);
boolean hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0);
boolean hasEndurance = SkillUtils.getEnduranceLength(player) > 0;
double skillValue = mcMMOPlayer.getSkillLevel(skill);
//Send the players a few blank lines to make finding the top of the skill command easier
@ -193,24 +192,6 @@ public abstract class SkillCommand implements TabExecutor {
//player.sendMessage(LocaleLoader.getString("Effects.Child.Overhaul", skillValue, skillValue));
}
/*
if (!skill.isChildSkill()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
player.sendMessage(LocaleLoader.getString("Effects.Level", skillValue, mcMMOPlayer.getSkillXpLevel(skill), mcMMOPlayer.getXpToLevel(skill)));
} else {
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child")));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain.Child")));
player.sendMessage(LocaleLoader.getString("Effects.Child", skillValue));
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Skills.Parents")));
Set<PrimarySkillType> parents = FamilyTree.getParents(skill);
for (PrimarySkillType parent : parents) {
player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent)));
}
}
*/
}
@Override
@ -231,24 +212,11 @@ public abstract class SkillCommand implements TabExecutor {
return RandomChanceUtil.calculateAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, subSkill);
}
protected String[] calculateLengthDisplayValues(Player player, double skillValue) {
int maxLength = skill.getAbility().getMaxLength();
int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
int abilityLengthCap = AdvancedConfig.getInstance().getAbilityLengthCap();
protected String[] formatLengthDisplayValues(Player player, double skillValue) {
int length;
int length = SkillUtils.calculateAbilityLength(UserManager.getPlayer(player), skill, skill.getSuperAbility());
if (abilityLengthCap <= 0) {
length = 2 + (int) (skillValue / abilityLengthVar);
} else {
length = 2 + (int) (Math.min(abilityLengthCap, skillValue) / abilityLengthVar);
}
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
if (maxLength != 0) {
length = Math.min(length, maxLength);
}
int enduranceLength = SkillUtils.calculateAbilityLengthPerks(UserManager.getPlayer(player), skill, skill.getSuperAbility());
return new String[]{String.valueOf(length), String.valueOf(enduranceLength)};
}

View File

@ -52,7 +52,7 @@ public class SwordsCommand extends SkillCommand {
// SERRATED STRIKES
if (canSerratedStrike) {
String[] serratedStrikesStrings = calculateLengthDisplayValues(player, skillValue);
String[] serratedStrikesStrings = formatLengthDisplayValues(player, skillValue);
serratedStrikesLength = serratedStrikesStrings[0];
serratedStrikesLengthEndurance = serratedStrikesStrings[1];
}

View File

@ -46,7 +46,7 @@ public class UnarmedCommand extends SkillCommand {
// BERSERK
if (canBerserk) {
String[] berserkStrings = calculateLengthDisplayValues(player, skillValue);
String[] berserkStrings = formatLengthDisplayValues(player, skillValue);
berserkLength = berserkStrings[0];
berserkLengthEndurance = berserkStrings[1];
}

View File

@ -38,7 +38,7 @@ public class WoodcuttingCommand extends SkillCommand {
// TREE FELLER
if (canTreeFell) {
String[] treeFellerStrings = calculateLengthDisplayValues(player, skillValue);
String[] treeFellerStrings = formatLengthDisplayValues(player, skillValue);
treeFellerLength = treeFellerStrings[0];
treeFellerLengthEndurance = treeFellerStrings[1];
}

View File

@ -1,11 +1,7 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.mcMMO;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import org.bukkit.ChatColor;
import java.util.ArrayList;
import java.util.List;
@ -192,120 +188,8 @@ public class AdvancedConfig extends ConfigValidated {
return getIntValue(SKILLS, GENERAL, ABILITY, ENCHANT_BUFF);
}
/**
* Grabs the max bonus level for a skill used in RNG calculations
* All max level values in the config are multiplied by 10 if the server is in retro mode as the values in the config are based around the new 1-100 skill system scaling
* A value of 10 in the file will be returned as 100 for retro mode servers to accommodate the change in scaling
*
* @param subSkillType target subskill
* @return the level at which this skills max benefits will be reached on the curve
*/
public int getMaxBonusLevel(SubSkillType subSkillType) {
String[] category = subSkillType.getAdvConfigAddress();
if (!mcMMO.isRetroModeEnabled())
return getIntValue(category[0], category[1], category[2], MAX_BONUS_LEVEL, STANDARD);
else
return getIntValue(category[0], category[1], category[2], MAX_BONUS_LEVEL, RETRO_MODE);
}
public int getMaxBonusLevel(AbstractSubSkill abstractSubSkill) {
return getMaxBonusLevel(abstractSubSkill.getSubSkillType());
}
public double getMaximumProbability(SubSkillType subSkillType) {
String[] category = subSkillType.getAdvConfigAddress();
double maximumProbability = getDoubleValue(category[0], category[1], category[2], CHANCE_MAX);
return maximumProbability;
}
public double getMaximumProbability(AbstractSubSkill abstractSubSkill) {
return getMaximumProbability(abstractSubSkill.getSubSkillType());
}
/* Notification Settings */
public boolean doesSkillCommandSendBlankLines() {
return getBooleanValue(FEEDBACK, SKILL_COMMAND, BLANK_LINES_ABOVE_HEADER);
}
public boolean doesNotificationUseActionBar(NotificationType notificationType) {
return getBooleanValue(FEEDBACK, ACTION_BAR_NOTIFICATIONS, notificationType.toString(), ENABLED);
}
public boolean doesNotificationSendCopyToChat(NotificationType notificationType) {
return getBooleanValue(FEEDBACK, ACTION_BAR_NOTIFICATIONS, notificationType.toString(), SEND_COPY_OF_MESSAGE_TO_CHAT);
}
public boolean useTitlesForXPEvent() {
return getBooleanValue(FEEDBACK, EVENTS, XP, SEND_TITLES);
}
private ChatColor getChatColorFromKey(String keyLocation) {
String colorName = getStringValue(keyLocation);
return getChatColor(colorName);
}
private ChatColor getChatColor(String configColor) {
for (ChatColor chatColor : ChatColor.values()) {
if (configColor.equalsIgnoreCase(chatColor.toString()))
return chatColor;
}
//Invalid Color
System.out.println("[mcMMO] " + configColor + " is an invalid color value");
return ChatColor.WHITE;
}
/* ACROBATICS */
public double getDodgeDamageModifier() {
return getDoubleValue(SKILLS, ACROBATICS, DODGE, DAMAGE_MODIFIER);
}
public double getRollDamageThreshold() {
return getDoubleValue(SKILLS, ACROBATICS, ROLL, DAMAGE_THRESHOLD);
}
public double getGracefulRollDamageThreshold() {
return getDoubleValue(SKILLS, ACROBATICS, GRACEFUL_ROLL, DAMAGE_THRESHOLD);
}
/* ALCHEMY */
public int getCatalysisMaxBonusLevel() {
return getIntValue(SKILLS, ALCHEMY, CATALYSIS, MAX_BONUS_LEVEL);
}
public double getCatalysisMinSpeed() {
return getDoubleValue(SKILLS, ALCHEMY, CATALYSIS, MIN_SPEED);
}
public double getCatalysisMaxSpeed() {
return getDoubleValue(SKILLS, ALCHEMY, CATALYSIS, MAX_SPEED);
}
/* ARCHERY */
public double getSkillShotRankDamageMultiplier() {
return getDoubleValue(SKILLS, ARCHERY, SKILL_SHOT, RANK_DAMAGE_MULTIPLIER);
}
public double getSkillShotDamageMax() {
return getDoubleValue(SKILLS, ARCHERY, SKILL_SHOT, MAX_DAMAGE);
}
public double getDazeBonusDamage() {
return getDoubleValue(SKILLS, ARCHERY, DAZE, BONUS_DAMAGE);
}
public double getForceMultiplier() {
return getDoubleValue(SKILLS, ARCHERY, FORCE_MULTIPLIER);
}
/* EXCAVATION */
//Nothing to configure, everything is already configurable in config.yml
/* FISHING */
public double getShakeChance(int rank) {
return getDoubleValue(SKILLS, FISHING, SHAKE, CHANCE, RANK, String.valueOf(rank));
@ -319,20 +203,11 @@ public class AdvancedConfig extends ConfigValidated {
return getDoubleValue(SKILLS, FISHING, MASTER_ANGLER, BIOME_MODIFIER);
}
/* HERBALISM */
//public int getFarmerDietRankChange() { return getIntValue(SKILLS, ".Herbalism.FarmersDiet.RankChange"); }
//public int getGreenThumbStageChange() { return getIntValue(SKILLS, ".Herbalism.GreenThumb.StageChange"); }
/* MINING */
public boolean getDoubleDropSilkTouchEnabled() {
return getBooleanValue(SKILLS, MINING, "DoubleDrops", "SilkTouch");
}
public int getBlastMiningRankLevel(int rank) {
return getIntValue(SKILLS, MINING, BLAST_MINING, RANK, LEVELS, RANK, String.valueOf(rank));
}
public double getBlastDamageDecrease(int rank) {
return getDoubleValue(SKILLS, MINING, BLAST_MINING, BLAST_DAMAGE_DECREASE, RANK, String.valueOf(rank));
}
@ -353,39 +228,6 @@ public class AdvancedConfig extends ConfigValidated {
return getDoubleValue(SKILLS, MINING, BLAST_MINING, BLAST_RADIUS, MODIFIER, RANK, String.valueOf(rank));
}
/* REPAIR */
public double getRepairMasteryMaxBonus() {
return getDoubleValue(SKILLS, REPAIR, REPAIR_MASTERY, MAX_BONUS_PERCENTAGE);
}
//public int getRepairMasteryMaxLevel() { return getIntValue(SKILLS, REPAIR, REPAIR_MASTERY, MAX_BONUS_LEVEL); }
/* Arcane Forging */
public boolean getArcaneForgingEnchantLossEnabled() {
return getBooleanValue(SKILLS, REPAIR, ARCANE_FORGING, MAY_LOSE_ENCHANTS);
}
public double getArcaneForgingKeepEnchantsChance(int rank) {
return getDoubleValue(SKILLS, REPAIR, ARCANE_FORGING, KEEP_ENCHANTS, CHANCE, RANK, String.valueOf(rank));
}
public boolean getArcaneForgingDowngradeEnabled() {
return getBooleanValue(SKILLS, REPAIR, ARCANE_FORGING, DOWNGRADES_ENABLED);
}
public double getArcaneForgingDowngradeChance(int rank) {
return getDoubleValue(SKILLS, REPAIR, ARCANE_FORGING, DOWNGRADES, CHANCE, RANK, String.valueOf(rank));
}
/* SALVAGE */
public boolean getArcaneSalvageEnchantDowngradeEnabled() {
return getBooleanValue(SKILLS, SALVAGE, ARCANE_SALVAGE, ENCHANT_DOWNGRADE_ENABLED);
}
public boolean getArcaneSalvageEnchantLossEnabled() {
return getBooleanValue(SKILLS, SALVAGE, ARCANE_SALVAGE, ENCHANT_LOSS_ENABLED);
}
public double getArcaneSalvageExtractFullEnchantsChance(int rank) {
return getDoubleValue(SKILLS, SALVAGE, ARCANE_SALVAGE, EXTRACT_FULL_ENCHANT, RANK, String.valueOf(rank));
}
@ -394,20 +236,6 @@ public class AdvancedConfig extends ConfigValidated {
return getDoubleValue(SKILLS, SALVAGE, ARCANE_SALVAGE, EXTRACT_PARTIAL_ENCHANT, RANK, String.valueOf(rank));
}
/* SMELTING */
//public int getBurnModifierMaxLevel() { return getIntValue(SKILLS, SMELTING, FUEL_EFFICIENCY, MAX_BONUS_LEVEL); }
public double getBurnTimeMultiplier() {
return getDoubleValue(SKILLS, SMELTING, FUEL_EFFICIENCY, MULTIPLIER);
}
public int getSmeltingRankLevel(int rank) {
return getIntValue(SKILLS, SMELTING, RANK, LEVELS, RANK, String.valueOf(rank));
}
public int getSmeltingVanillaXPBoostMultiplier(int rank) {
return getIntValue(SKILLS, SMELTING, VANILLA_XPMULTIPLIER, RANK, String.valueOf(rank));
}
/* SWORDS */
public double getRuptureDamagePlayer() {
return getDoubleValue(SKILLS, SWORDS, RUPTURE, DAMAGE_PLAYER);
@ -421,10 +249,6 @@ public class AdvancedConfig extends ConfigValidated {
return getIntValue(SKILLS, SWORDS, RUPTURE, MAX_TICKS);
}
public int getRuptureBaseTicks() {
return getIntValue(SKILLS, SWORDS, RUPTURE, BASE_TICKS);
}
public double getCounterAttackModifier() {
return getDoubleValue(SKILLS, SWORDS, COUNTER_ATTACK, DAMAGE_MODIFIER);
}
@ -432,7 +256,6 @@ public class AdvancedConfig extends ConfigValidated {
public double getSerratedStrikesModifier() {
return getDoubleValue(SKILLS, SWORDS, SERRATED_STRIKES, DAMAGE_MODIFIER);
}
//public int getSerratedStrikesTicks() { return getIntValue(SKILLS, SWORDS, SERRATED_STRIKES, RUPTURE, TICKS); }
/* TAMING */
public double getGoreModifier() {
@ -466,11 +289,4 @@ public class AdvancedConfig extends ConfigValidated {
public double getMaxHorseJumpStrength() {
return getDoubleValue(SKILLS, TAMING, CALL_OF_THE_WILD, MAX_HORSE_JUMP_STRENGTH);
}
/* UNARMED */
public boolean getDisarmProtected() {
return getBooleanValue(SKILLS, UNARMED, DISARM, ANTI_THEFT);
}
/* WOODCUTTING */
}

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.config.hocon.skills.mining;
import com.gmail.nossr50.config.ConfigConstants;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ -49,7 +50,7 @@ public class ConfigMining {
"\nUse Minecraft friendly names for entries, not Bukkit material names.")
private HashSet<String> bonusDrops = DEFAULT_BONUS_DROPS;
@Setting(value = "Sub-Skills")
@Setting(value = ConfigConstants.SUB_SKILL_NODE)
private ConfigMiningSubskills miningSubskills = new ConfigMiningSubskills();
public ConfigMiningSubskills getMiningSubskills() {

View File

@ -11,6 +11,12 @@ public class ConfigSuperAbilities {
public static final boolean SUPER_ABILITY_DEFAULT = true;
public static final boolean MUST_SNEAK_TO_ACTIVATE_DEFAULT = false;
@Setting(value = "Base-Time-In-Seconds", comment = "The minimum duration of time based super abilities in seconds.")
private int superAbilityStartingSeconds = 4;
@Setting(value = "Super-Ability-Length-Increment", comment = "How many seconds to add to a super ability as it reaches now scaling milestones")
private int superAbilityLengthIncrease = 1;
@Setting(value = "Enable-Super-Abilities",
comment = "Turn this off to disable all super abilities." +
"\nDefault value: " + SUPER_ABILITY_DEFAULT)
@ -98,4 +104,12 @@ public class ConfigSuperAbilities {
return 60;
}
}
public int getSuperAbilityStartingSeconds() {
return superAbilityStartingSeconds;
}
public int getSuperAbilityLengthIncrease() {
return superAbilityLengthIncrease;
}
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.datatypes.player;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.datatypes.chat.ChatMode;
@ -808,17 +807,16 @@ public class McMMOPlayer {
*/
public void checkAbilityActivation(PrimarySkillType skill) {
ToolType tool = skill.getTool();
SuperAbilityType ability = skill.getAbility();
SuperAbilityType ability = skill.getSuperAbility();
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);
int diff = RankUtils.getSuperAbilityUnlockRequirement(skill.getSuperAbility()) - getSkillLevel(skill);
//Inform the player they are not yet skilled enough
mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Skills.AbilityGateRequirementFail", String.valueOf(diff), skill.getName());
@ -844,19 +842,6 @@ public class McMMOPlayer {
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());
}
// Notify people that ability has been activated
ParticleEffectUtils.playAbilityEnabledEffect(player);
@ -870,9 +855,10 @@ public class McMMOPlayer {
//Sounds
SoundManager.worldSendSound(player.getWorld(), player.getLocation(), SoundType.ABILITY_ACTIVATED_GENERIC);
int abilityLength = SkillUtils.calculateAbilityLengthPerks(this, skill, ability);
// Enable the ability
profile.setAbilityDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
profile.setAbilityDATS(ability, System.currentTimeMillis() + (abilityLength * Misc.TIME_CONVERSION_FACTOR));
setAbilityMode(ability, true);
if (ability == SuperAbilityType.SUPER_BREAKER || ability == SuperAbilityType.GIGA_DRILL_BREAKER) {
@ -880,7 +866,7 @@ public class McMMOPlayer {
}
setToolPreparationMode(tool, false);
new AbilityDisableTask(this, ability).runTaskLater(mcMMO.p, ticks * Misc.TICK_CONVERSION_FACTOR);
new AbilityDisableTask(this, ability).runTaskLater(mcMMO.p, abilityLength * Misc.TICK_CONVERSION_FACTOR);
}
public void processAbilityActivation(PrimarySkillType skill) {
@ -904,7 +890,7 @@ public class McMMOPlayer {
}
}
SuperAbilityType ability = skill.getAbility();
SuperAbilityType ability = skill.getSuperAbility();
ToolType tool = skill.getTool();
/*

View File

@ -157,7 +157,7 @@ public enum PrimarySkillType {
public static PrimarySkillType byAbility(SuperAbilityType ability) {
for (PrimarySkillType type : values()) {
if (type.getAbility() == ability) {
if (type.getSuperAbility() == ability) {
return type;
}
}
@ -169,7 +169,7 @@ public enum PrimarySkillType {
return managerClass;
}
public SuperAbilityType getAbility() {
public SuperAbilityType getSuperAbility() {
return ability;
}
@ -187,7 +187,7 @@ public enum PrimarySkillType {
}*/
public boolean isSuperAbilityUnlocked(Player player) {
return RankUtils.getRank(player, getAbility().getSubSkillTypeDefinition()) >= 1;
return RankUtils.getRank(player, getSuperAbility().getSubSkillTypeDefinition()) >= 1;
}
/*public void setHardcoreStatLossEnabled(boolean enable) {

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.datatypes.skills.subskills.acrobatics;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@ -238,7 +237,7 @@ public class Roll extends AcrobaticsSubSkill {
* @return the modified event damage if the ability was successful, the original event damage otherwise
*/
private double gracefulRollCheck(Player player, McMMOPlayer mcMMOPlayer, double damage, int skillLevel) {
double modifiedDamage = calculateModifiedRollDamage(damage, AdvancedConfig.getInstance().getRollDamageThreshold() * 2);
double modifiedDamage = calculateModifiedRollDamage(damage, mcMMO.getConfigManager().getConfigAcrobatics().getRollDamageTheshold() * 2);
RandomChanceSkill rcs = new RandomChanceSkill(player, subSkillType);
rcs.setSkillLevel(rcs.getSkillLevel() * 2); //Double the effective odds
@ -378,11 +377,11 @@ public class Roll extends AcrobaticsSubSkill {
//Chance Stat Calculations
rollChanceHalfMax = RandomChanceUtil.getRandomChanceExecutionChance(rollHalfMaxSkill);
graceChanceHalfMax = RandomChanceUtil.getRandomChanceExecutionChance(rollGraceHalfMaxSkill);
damageThreshold = AdvancedConfig.getInstance().getRollDamageThreshold();
damageThreshold = mcMMO.getConfigManager().getConfigAcrobatics().getRollDamageTheshold();
chancePerLevel = RandomChanceUtil.getRandomChanceExecutionChance(rollOneSkillLevel);
double maxLevel = AdvancedConfig.getInstance().getMaxBonusLevel(SubSkillType.ACROBATICS_ROLL);
double maxLevel = mcMMO.getDynamicSettingsManager().getSkillMaxBonusLevel(SubSkillType.ACROBATICS_ROLL);
return LocaleLoader.getString("Acrobatics.SubSkill.Roll.Mechanics", rollChanceHalfMax, graceChanceHalfMax, maxLevel, chancePerLevel, damageThreshold, damageThreshold * 2);
}

View File

@ -10,7 +10,7 @@ public class McMMOPlayerAbilityEvent extends McMMOPlayerSkillEvent {
protected McMMOPlayerAbilityEvent(Player player, PrimarySkillType skill) {
super(player, skill);
ability = skill.getAbility();
ability = skill.getSuperAbility();
}
public SuperAbilityType getAbility() {

View File

@ -136,7 +136,7 @@ public class HerbalismManager extends SkillManager {
int amount;
int xp;
boolean greenTerra = mcMMOPlayer.getAbilityMode(skill.getAbility());
boolean greenTerra = mcMMOPlayer.getAbilityMode(skill.getSuperAbility());
// if (mcMMO.getModManager().isCustomHerbalismBlock(blockState)) {
// CustomBlock customBlock = mcMMO.getModManager().getBlock(blockState);
@ -317,7 +317,7 @@ public class HerbalismManager extends SkillManager {
ItemStack seedStack = new ItemStack(seed);
if (!greenTerra && !RandomChanceUtil.checkRandomChanceExecutionSuccess(player, SubSkillType.HERBALISM_GREEN_THUMB, true)) {
if (!greenTerra && !RandomChanceUtil.checkRandomChanceExecutionSuccess(player, SubSkillType.HERBALISM_GREEN_THUMB)) {
return;
}

View File

@ -87,7 +87,7 @@ public class MiningManager extends SkillManager {
return;
}
if (mcMMOPlayer.getAbilityMode(skill.getAbility())) {
if (mcMMOPlayer.getAbilityMode(skill.getSuperAbility())) {
SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), mcMMO.getConfigManager().getConfigSuperAbilities().getSuperAbilityLimits().getToolDurabilityDamage());
}
@ -101,8 +101,8 @@ public class MiningManager extends SkillManager {
return;
//TODO: Make this readable
if (RandomChanceUtil.checkRandomChanceExecutionSuccess(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS, true)) {
BlockUtils.markDropsAsBonus(blockState, mcMMOPlayer.getAbilityMode(skill.getAbility()));
if (RandomChanceUtil.checkRandomChanceExecutionSuccess(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS)) {
BlockUtils.markDropsAsBonus(blockState, mcMMOPlayer.getAbilityMode(skill.getSuperAbility()));
}
}

View File

@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginDescriptionFile;
@ -112,7 +113,7 @@ public final class Motd {
* @param player Target player
*/
public static void displayActivationPerks(Player player) {
int perkAmount = PerksUtils.handleActivationPerks(player, 0, 0);
int perkAmount = SkillUtils.getEnduranceLength(player);
if (perkAmount > 0) {
player.sendMessage(PERK_PREFIX + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.ActivationTime.Name"), LocaleLoader.getString("Perks.ActivationTime.Desc", perkAmount)));

View File

@ -32,7 +32,7 @@ public class RandomChanceUtil {
public static boolean isActivationSuccessful(SkillActivationType skillActivationType, SubSkillType subSkillType, Player player) {
switch (skillActivationType) {
case RANDOM_LINEAR_100_SCALE_WITH_CAP:
return checkRandomChanceExecutionSuccess(player, subSkillType, true);
return checkRandomChanceExecutionSuccess(player, subSkillType);
case RANDOM_STATIC_CHANCE:
return checkRandomStaticChanceExecutionSuccess(player, subSkillType);
case ALWAYS_FIRES:
@ -97,8 +97,6 @@ public class RandomChanceUtil {
public static boolean checkRandomChanceExecutionSuccess(RandomChanceSkill randomChance) {
double chanceOfSuccess = calculateChanceOfSuccess(randomChance);
Random random = new Random();
//Check the odds
return rollDice(chanceOfSuccess, 100);
}
@ -135,10 +133,10 @@ public class RandomChanceUtil {
return chanceOfSuccess;
}*/
private static double calculateChanceOfSuccess(RandomChanceSkill randomChance) {
double skillLevel = randomChance.getSkillLevel();
double maximumProbability = randomChance.getProbabilityCap();
double maximumBonusLevel = randomChance.getMaximumBonusLevelCap();
private static double calculateChanceOfSuccess(RandomChanceSkill randomChanceSkill) {
double skillLevel = randomChanceSkill.getSkillLevel();
double maximumProbability = randomChanceSkill.getProbabilityCap();
double maximumBonusLevel = randomChanceSkill.getMaximumBonusLevelCap();
double chanceOfSuccess;
@ -147,11 +145,11 @@ public class RandomChanceUtil {
chanceOfSuccess = maximumProbability;
} else {
//Get chance of success
chanceOfSuccess = getChanceOfSuccess(randomChance.getXPos(), maximumProbability, maximumBonusLevel);
chanceOfSuccess = getChanceOfSuccess(randomChanceSkill.getXPos(), maximumProbability, maximumBonusLevel);
}
//Add Luck
chanceOfSuccess = addLuck(randomChance.isLucky(), chanceOfSuccess);
chanceOfSuccess = addLuck(randomChanceSkill.isLucky(), chanceOfSuccess);
return chanceOfSuccess;
}
@ -198,10 +196,6 @@ public class RandomChanceUtil {
return 0.1337; //Puts on shades
}
public static boolean checkRandomChanceExecutionSuccess(Player player, SubSkillType subSkillType, boolean hasCap) {
return checkRandomChanceExecutionSuccess(new RandomChanceSkill(player, subSkillType, hasCap));
}
public static boolean checkRandomChanceExecutionSuccess(Player player, SubSkillType subSkillType) {
return checkRandomChanceExecutionSuccess(new RandomChanceSkill(player, subSkillType));
}

View File

@ -88,8 +88,8 @@ public class ScoreboardManager {
// Include child skills
skillLabelBuilder.put(type, getShortenedName(colors.get(i) + type.getName(), false));
if (type.getAbility() != null) {
abilityLabelBuilder.put(type.getAbility(), getShortenedName(colors.get(i) + type.getAbility().getName()));
if (type.getSuperAbility() != null) {
abilityLabelBuilder.put(type.getSuperAbility(), getShortenedName(colors.get(i) + type.getSuperAbility().getName()));
if (type == PrimarySkillType.MINING) {
abilityLabelBuilder.put(SuperAbilityType.BLAST_MINING, getShortenedName(colors.get(i) + SuperAbilityType.BLAST_MINING.getName()));
@ -110,8 +110,8 @@ public class ScoreboardManager {
// Include child skills
skillLabelBuilder.put(type, getShortenedName(ChatColor.GREEN + type.getName()));
if (type.getAbility() != null) {
abilityLabelBuilder.put(type.getAbility(), formatAbility(type.getAbility().getName()));
if (type.getSuperAbility() != null) {
abilityLabelBuilder.put(type.getSuperAbility(), formatAbility(type.getSuperAbility().getName()));
if (type == PrimarySkillType.MINING) {
abilityLabelBuilder.put(SuperAbilityType.BLAST_MINING, formatAbility(SuperAbilityType.BLAST_MINING.getName()));

View File

@ -418,7 +418,7 @@ public class ScoreboardWrapper {
sidebarObjective.getScore(ScoreboardManager.LABEL_LEVEL).setScore(mcMMOPlayer.getSkillLevel(targetSkill));
if (targetSkill.getAbility() != null) {
if (targetSkill.getSuperAbility() != null) {
boolean stopUpdating;
if (targetSkill == PrimarySkillType.MINING) {
@ -433,7 +433,7 @@ public class ScoreboardWrapper {
stopUpdating = (secondsSB == 0 && secondsBM == 0);
} else {
SuperAbilityType ability = targetSkill.getAbility();
SuperAbilityType ability = targetSkill.getSuperAbility();
Score cooldown = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(ability));
int seconds = Math.max(mcMMOPlayer.calculateTimeRemaining(ability), 0);

View File

@ -23,22 +23,6 @@ public final class PerksUtils {
return cooldown;
}
public static int handleActivationPerks(Player player, int ticks, int maxTicks) {
if (maxTicks != 0) {
ticks = Math.min(ticks, maxTicks);
}
if (Permissions.twelveSecondActivationBoost(player)) {
ticks += 12;
} else if (Permissions.eightSecondActivationBoost(player)) {
ticks += 8;
} else if (Permissions.fourSecondActivationBoost(player)) {
ticks += 4;
}
return ticks;
}
/**
* Calculate activation chance for a skill.
*

View File

@ -7,10 +7,12 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -37,35 +39,57 @@ public class SkillUtils {
mcMMOPlayer.beginXpGain(skill, xp, xpGainReason, xpGainSource);
}
/*
* Skill Stat Calculations
/**
* Calculates how long a given ability should last in seconds
* Does not factor in perks
* @param mcMMOPlayer target mcMMO Player
* @param skill target skill
* @param superAbilityType target Super Ability
* @return how long an ability should last in seconds
*/
public static int calculateAbilityLength(McMMOPlayer mcMMOPlayer, PrimarySkillType skill, SuperAbilityType superAbilityType) {
//These values change depending on whether or not the server is in retro mode
int abilityLengthVar = mcMMO.getConfigManager().getConfigSuperAbilities().getSuperAbilityStartingSeconds();
public static String[] calculateLengthDisplayValues(Player player, float skillValue, PrimarySkillType skill) {
int maxLength = skill.getAbility().getMaxLength();
int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
int abilityLengthCap = AdvancedConfig.getInstance().getAbilityLengthCap();
int maxLength = mcMMO.getConfigManager().getConfigSuperAbilities().getMaxLengthForSuper(superAbilityType);
int length;
int skillLevel = mcMMOPlayer.getSkillLevel(skill);
if (abilityLengthCap > 0) {
length = (int) Math.min(abilityLengthCap, 2 + (skillValue / abilityLengthVar));
int ticks;
//Ability cap of 0 or below means no cap
if (maxLength > 0) {
ticks = Math.min(2 + (Math.min(maxLength, skillLevel) / abilityLengthVar), maxLength);
} else {
length = 2 + (int) (skillValue / abilityLengthVar);
ticks = Math.min(2 + (Math.min(maxLength, skillLevel) / abilityLengthVar), maxLength);
}
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
if (maxLength != 0) {
length = Math.min(length, maxLength);
return ticks;
}
return new String[]{String.valueOf(length), String.valueOf(enduranceLength)};
}
/*
* Others
/**
* Calculates how long a given ability should last in seconds
* Adds in perks if the player has any
* @param mcMMOPlayer target mcMMO Player
* @param skill target skill
* @param superAbilityType target Super Ability
* @return how long an ability should last in seconds
*/
public static int calculateAbilityLengthPerks(McMMOPlayer mcMMOPlayer, PrimarySkillType skill, SuperAbilityType superAbilityType) {
return getEnduranceLength(mcMMOPlayer.getPlayer()) + calculateAbilityLength(mcMMOPlayer, skill, superAbilityType);
}
public static int getEnduranceLength(Player player) {
if (Permissions.twelveSecondActivationBoost(player)) {
return 12;
} else if (Permissions.eightSecondActivationBoost(player)) {
return 8;
} else if (Permissions.fourSecondActivationBoost(player)) {
return 4;
} else {
return 0;
}
}
public static int handleFoodSkills(Player player, int eventFoodLevel, SubSkillType subSkillType) {
int curRank = RankUtils.getRank(player, subSkillType);
@ -172,11 +196,11 @@ public class SkillUtils {
if(abilityLengthCap > 0)
{
ticks = PerksUtils.handleActivationPerks(player, Math.min(abilityLengthCap, 2 + (mcMMOPlayer.getSkillLevel(skill) / abilityLengthVar)),
skill.getAbility().getMaxLength()) * Misc.TICK_CONVERSION_FACTOR;
ticks = PerksUtils.calculateAbilityLength(player, Math.min(abilityLengthCap, 2 + (mcMMOPlayer.getSkillLevel(skill) / abilityLengthVar)),
skill.getSuperAbility().getMaxLength()) * Misc.TICK_CONVERSION_FACTOR;
} else {
ticks = PerksUtils.handleActivationPerks(player, 2 + ((mcMMOPlayer.getSkillLevel(skill)) / abilityLengthVar),
skill.getAbility().getMaxLength()) * Misc.TICK_CONVERSION_FACTOR;
ticks = PerksUtils.calculateAbilityLength(player, 2 + ((mcMMOPlayer.getSkillLevel(skill)) / abilityLengthVar),
skill.getSuperAbility().getMaxLength()) * Misc.TICK_CONVERSION_FACTOR;
}
PotionEffect abilityBuff = new PotionEffect(PotionEffectType.FAST_DIGGING, duration + ticks, amplifier + 10);