mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Fixing a bug where Lucky perk wasn't adding to success
This commit is contained in:
parent
7b38658310
commit
5f39a7cb80
@ -8,6 +8,7 @@ Key:
|
||||
- Removal
|
||||
|
||||
Version 2.1.2
|
||||
(Perks) Fixed a bug where the Lucky perk wasn't adding to success
|
||||
(Skills) Tree Feller now works on Mushroom Stems
|
||||
(Experience) Wood blocks now give XP and are affected by Tree Feller (6 sided bark blocks)
|
||||
(API) Moved XPGainReason from skills to experience package
|
||||
|
@ -41,7 +41,7 @@ public class ExcavationManager extends SkillManager {
|
||||
|
||||
for (ExcavationTreasure treasure : treasures) {
|
||||
if (skillLevel >= treasure.getDropLevel()
|
||||
&& RandomChanceUtil.checkRandomChanceExecutionSuccess(treasure.getDropChance())) {
|
||||
&& RandomChanceUtil.checkRandomChanceExecutionSuccess(getPlayer(), PrimarySkillType.EXCAVATION, treasure.getDropChance())) {
|
||||
xp += treasure.getXp();
|
||||
Misc.dropItem(location, treasure.getDrop());
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.gmail.nossr50.util.random;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -11,6 +12,7 @@ public class RandomChanceSkill implements RandomChanceExecution {
|
||||
protected final PrimarySkillType primarySkillType;
|
||||
protected final SubSkillType subSkillType;
|
||||
protected final double probabilityCap;
|
||||
protected final boolean isLucky;
|
||||
private int skillLevel;
|
||||
|
||||
public RandomChanceSkill(Player player, SubSkillType subSkillType)
|
||||
@ -23,6 +25,11 @@ public class RandomChanceSkill implements RandomChanceExecution {
|
||||
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(primarySkillType);
|
||||
else
|
||||
this.skillLevel = 0;
|
||||
|
||||
if(player != null)
|
||||
isLucky = Permissions.lucky(player, primarySkillType);
|
||||
else
|
||||
isLucky = false;
|
||||
}
|
||||
|
||||
public RandomChanceSkill(Player player, SubSkillType subSkillType, boolean hasCap)
|
||||
@ -39,6 +46,11 @@ public class RandomChanceSkill implements RandomChanceExecution {
|
||||
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(primarySkillType);
|
||||
else
|
||||
this.skillLevel = 0;
|
||||
|
||||
if(player != null)
|
||||
isLucky = Permissions.lucky(player, primarySkillType);
|
||||
else
|
||||
isLucky = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,4 +109,8 @@ public class RandomChanceSkill implements RandomChanceExecution {
|
||||
public double getProbabilityCap() {
|
||||
return probabilityCap;
|
||||
}
|
||||
|
||||
public boolean isLucky() {
|
||||
return isLucky;
|
||||
}
|
||||
}
|
||||
|
@ -63,11 +63,13 @@ public class RandomChanceUtil
|
||||
* Checks whether or not the random chance succeeds
|
||||
* @return true if the random chance succeeds
|
||||
*/
|
||||
public static boolean checkRandomChanceExecutionSuccess(double chance)
|
||||
public static boolean checkRandomChanceExecutionSuccess(Player player, PrimarySkillType primarySkillType, double chance)
|
||||
{
|
||||
//Check the odds
|
||||
chance *= 100;
|
||||
|
||||
chance = addLuck(player, primarySkillType, chance);
|
||||
|
||||
/*
|
||||
* Stuff like treasures can specify a drop chance from 0.05 to 100
|
||||
* Because of that we need to use a large int bound and multiply the chance by 100
|
||||
@ -143,6 +145,10 @@ public class RandomChanceUtil
|
||||
//Get chance of success
|
||||
chanceOfSuccess = getChanceOfSuccess(randomChance.getXPos(), maximumProbability, maximumBonusLevel);
|
||||
}
|
||||
|
||||
//Add Luck
|
||||
chanceOfSuccess = addLuck(randomChance.isLucky(), chanceOfSuccess);
|
||||
|
||||
return chanceOfSuccess;
|
||||
}
|
||||
|
||||
@ -281,4 +287,20 @@ public class RandomChanceUtil
|
||||
|
||||
return displayValues;
|
||||
}
|
||||
|
||||
public static double addLuck(Player player, PrimarySkillType primarySkillType, double chance)
|
||||
{
|
||||
if(Permissions.lucky(player, primarySkillType))
|
||||
return chance * 1.333D;
|
||||
else
|
||||
return chance;
|
||||
}
|
||||
|
||||
public static double addLuck(boolean isLucky, double chance)
|
||||
{
|
||||
if(isLucky)
|
||||
return chance * 1.333D;
|
||||
else
|
||||
return chance;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user