mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 06:36:45 +01:00
Static Abuse Removal - RandomChanceUtil -> RandomChanceTools
This commit is contained in:
parent
8f540796ff
commit
c5a7c88e0c
@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
|||||||
import com.gmail.nossr50.listeners.InteractionManager;
|
import com.gmail.nossr50.listeners.InteractionManager;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceSkill;
|
import com.gmail.nossr50.util.random.RandomChanceSkill;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -64,8 +63,8 @@ public class AcrobaticsCommand extends SkillCommand {
|
|||||||
grace_rcs.setSkillLevel(grace_rcs.getSkillLevel() * 2); //Double Odds
|
grace_rcs.setSkillLevel(grace_rcs.getSkillLevel() * 2); //Double Odds
|
||||||
|
|
||||||
//Chance Stat Calculations
|
//Chance Stat Calculations
|
||||||
rollChance = RandomChanceUtil.getRandomChanceExecutionChance(roll_rcs);
|
rollChance = pluginRef.getRandomChanceTools().getRandomChanceExecutionChance(roll_rcs);
|
||||||
graceChance = RandomChanceUtil.getRandomChanceExecutionChance(grace_rcs);
|
graceChance = pluginRef.getRandomChanceTools().getRandomChanceExecutionChance(grace_rcs);
|
||||||
//damageThreshold = AdvancedConfig.getInstance().getRollDamageThreshold();
|
//damageThreshold = AdvancedConfig.getInstance().getRollDamageThreshold();
|
||||||
|
|
||||||
String[] rollStrings = getAbilityDisplayValues(player, SubSkillType.ACROBATICS_ROLL);
|
String[] rollStrings = getAbilityDisplayValues(player, SubSkillType.ACROBATICS_ROLL);
|
||||||
|
@ -9,7 +9,6 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||||
import com.gmail.nossr50.skills.fishing.FishingManager;
|
import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -81,7 +80,7 @@ public class FishingCommand extends SkillCommand {
|
|||||||
|
|
||||||
// FISHING_SHAKE
|
// FISHING_SHAKE
|
||||||
if (canShake) {
|
if (canShake) {
|
||||||
String[] shakeStrings = RandomChanceUtil.calculateAbilityDisplayValuesStatic(player, PrimarySkillType.FISHING, fishingManager.getShakeChance());
|
String[] shakeStrings = pluginRef.getRandomChanceTools().calculateAbilityDisplayValuesStatic(player, PrimarySkillType.FISHING, fishingManager.getShakeChance());
|
||||||
shakeChance = shakeStrings[0];
|
shakeChance = shakeStrings[0];
|
||||||
shakeChanceLucky = shakeStrings[1];
|
shakeChanceLucky = shakeStrings[1];
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
@ -205,7 +204,7 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected String[] getAbilityDisplayValues(Player player, SubSkillType subSkill) {
|
protected String[] getAbilityDisplayValues(Player player, SubSkillType subSkill) {
|
||||||
return RandomChanceUtil.calculateAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, subSkill);
|
return pluginRef.getRandomChanceTools().calculateAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, subSkill);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String[] formatLengthDisplayValues(Player player, double skillValue) {
|
protected String[] formatLengthDisplayValues(Player player, double skillValue) {
|
||||||
|
@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceSkill;
|
import com.gmail.nossr50.util.random.RandomChanceSkill;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|
||||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
@ -129,14 +128,14 @@ public class Roll extends AcrobaticsSubSkill {
|
|||||||
float skillValue = playerProfile.getSkillLevel(getPrimarySkill());
|
float skillValue = playerProfile.getSkillLevel(getPrimarySkill());
|
||||||
boolean isLucky = Permissions.lucky(player, getPrimarySkill());
|
boolean isLucky = Permissions.lucky(player, getPrimarySkill());
|
||||||
|
|
||||||
String[] rollStrings = RandomChanceUtil.calculateAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_ROLL);
|
String[] rollStrings = pluginRef.getRandomChanceTools().calculateAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_ROLL);
|
||||||
rollChance = rollStrings[0];
|
rollChance = rollStrings[0];
|
||||||
rollChanceLucky = rollStrings[1];
|
rollChanceLucky = rollStrings[1];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Graceful is double the odds of a normal roll
|
* Graceful is double the odds of a normal roll
|
||||||
*/
|
*/
|
||||||
String[] gracefulRollStrings = RandomChanceUtil.calculateAbilityDisplayValuesCustom(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_ROLL, 2.0D);
|
String[] gracefulRollStrings = pluginRef.getRandomChanceTools().calculateAbilityDisplayValuesCustom(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_ROLL, 2.0D);
|
||||||
gracefulRollChance = gracefulRollStrings[0];
|
gracefulRollChance = gracefulRollStrings[0];
|
||||||
gracefulRollChanceLucky = gracefulRollStrings[1];
|
gracefulRollChanceLucky = gracefulRollStrings[1];
|
||||||
|
|
||||||
@ -202,7 +201,7 @@ public class Roll extends AcrobaticsSubSkill {
|
|||||||
double modifiedDamage = calculateModifiedRollDamage(damage, pluginRef.getConfigManager().getConfigAcrobatics().getRollDamageTheshold());
|
double modifiedDamage = calculateModifiedRollDamage(damage, pluginRef.getConfigManager().getConfigAcrobatics().getRollDamageTheshold());
|
||||||
|
|
||||||
if (!isFatal(player, modifiedDamage)
|
if (!isFatal(player, modifiedDamage)
|
||||||
&& RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ACROBATICS_ROLL, player)) {
|
&& pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ACROBATICS_ROLL, player)) {
|
||||||
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Roll.Text");
|
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Roll.Text");
|
||||||
SoundManager.sendCategorizedSound(player, player.getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS);
|
SoundManager.sendCategorizedSound(player, player.getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS);
|
||||||
|
|
||||||
@ -241,7 +240,7 @@ public class Roll extends AcrobaticsSubSkill {
|
|||||||
rcs.setSkillLevel(rcs.getSkillLevel() * 2); //Double the effective odds
|
rcs.setSkillLevel(rcs.getSkillLevel() * 2); //Double the effective odds
|
||||||
|
|
||||||
if (!isFatal(player, modifiedDamage)
|
if (!isFatal(player, modifiedDamage)
|
||||||
&& RandomChanceUtil.checkRandomChanceExecutionSuccess(rcs)) {
|
&& pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(rcs)) {
|
||||||
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Ability.Proc");
|
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Ability.Proc");
|
||||||
SoundManager.sendCategorizedSound(player, player.getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS, 0.5F);
|
SoundManager.sendCategorizedSound(player, player.getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS, 0.5F);
|
||||||
|
|
||||||
@ -373,11 +372,11 @@ public class Roll extends AcrobaticsSubSkill {
|
|||||||
rollGraceHalfMaxSkill.setSkillLevel(1); //Level 1 skill
|
rollGraceHalfMaxSkill.setSkillLevel(1); //Level 1 skill
|
||||||
|
|
||||||
//Chance Stat Calculations
|
//Chance Stat Calculations
|
||||||
rollChanceHalfMax = RandomChanceUtil.getRandomChanceExecutionChance(rollHalfMaxSkill);
|
rollChanceHalfMax = pluginRef.getRandomChanceTools().getRandomChanceExecutionChance(rollHalfMaxSkill);
|
||||||
graceChanceHalfMax = RandomChanceUtil.getRandomChanceExecutionChance(rollGraceHalfMaxSkill);
|
graceChanceHalfMax = pluginRef.getRandomChanceTools().getRandomChanceExecutionChance(rollGraceHalfMaxSkill);
|
||||||
damageThreshold = pluginRef.getConfigManager().getConfigAcrobatics().getRollDamageTheshold();
|
damageThreshold = pluginRef.getConfigManager().getConfigAcrobatics().getRollDamageTheshold();
|
||||||
|
|
||||||
chancePerLevel = RandomChanceUtil.getRandomChanceExecutionChance(rollOneSkillLevel);
|
chancePerLevel = pluginRef.getRandomChanceTools().getRandomChanceExecutionChance(rollOneSkillLevel);
|
||||||
|
|
||||||
double maxLevel = pluginRef.getDynamicSettingsManager().getSkillMaxBonusLevel(SubSkillType.ACROBATICS_ROLL);
|
double maxLevel = pluginRef.getDynamicSettingsManager().getSkillMaxBonusLevel(SubSkillType.ACROBATICS_ROLL);
|
||||||
|
|
||||||
@ -400,8 +399,8 @@ public class Roll extends AcrobaticsSubSkill {
|
|||||||
graceful.setSkillLevel(graceful.getSkillLevel() * 2); //Double odds
|
graceful.setSkillLevel(graceful.getSkillLevel() * 2); //Double odds
|
||||||
|
|
||||||
//Calculate
|
//Calculate
|
||||||
playerChanceRoll = RandomChanceUtil.getRandomChanceExecutionChance(roll);
|
playerChanceRoll = pluginRef.getRandomChanceTools().getRandomChanceExecutionChance(roll);
|
||||||
playerChanceGrace = RandomChanceUtil.getRandomChanceExecutionChance(graceful);
|
playerChanceGrace = pluginRef.getRandomChanceTools().getRandomChanceExecutionChance(graceful);
|
||||||
|
|
||||||
Double[] stats = {playerChanceRoll, playerChanceGrace}; //DEBUG
|
Double[] stats = {playerChanceRoll, playerChanceGrace}; //DEBUG
|
||||||
return stats;
|
return stats;
|
||||||
|
@ -15,7 +15,6 @@ import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
|||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
import com.gmail.nossr50.worldguard.WorldGuardUtils;
|
import com.gmail.nossr50.worldguard.WorldGuardUtils;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -137,7 +136,7 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ARCHERY_ARROW_RETRIEVAL, player)) {
|
if (pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ARCHERY_ARROW_RETRIEVAL, player)) {
|
||||||
projectile.setMetadata(MetadataConstants.ARROW_TRACKER_METAKEY, MetadataConstants.metadataValue);
|
projectile.setMetadata(MetadataConstants.ARROW_TRACKER_METAKEY, MetadataConstants.metadataValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ import com.gmail.nossr50.util.nbt.NBTManager;
|
|||||||
import com.gmail.nossr50.util.player.NotificationManager;
|
import com.gmail.nossr50.util.player.NotificationManager;
|
||||||
import com.gmail.nossr50.util.player.PlayerLevelTools;
|
import com.gmail.nossr50.util.player.PlayerLevelTools;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.gmail.nossr50.util.random.RandomChanceTools;
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
import com.gmail.nossr50.util.skills.CombatTools;
|
import com.gmail.nossr50.util.skills.CombatTools;
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
@ -82,6 +83,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
private EventManager eventManager;
|
private EventManager eventManager;
|
||||||
private UserManager userManager;
|
private UserManager userManager;
|
||||||
private ScoreboardManager scoreboardManager;
|
private ScoreboardManager scoreboardManager;
|
||||||
|
private RandomChanceTools randomChanceTools;
|
||||||
|
|
||||||
/* Not-Managers but my naming scheme sucks */
|
/* Not-Managers but my naming scheme sucks */
|
||||||
private DatabaseManagerFactory databaseManagerFactory;
|
private DatabaseManagerFactory databaseManagerFactory;
|
||||||
@ -108,6 +110,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
private boolean serverAPIOutdated = false;
|
private boolean serverAPIOutdated = false;
|
||||||
// XP Event Check
|
// XP Event Check
|
||||||
private boolean xpEventEnabled;
|
private boolean xpEventEnabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Things to be run when the plugin is enabled.
|
* Things to be run when the plugin is enabled.
|
||||||
*/
|
*/
|
||||||
@ -244,6 +247,9 @@ public class mcMMO extends JavaPlugin {
|
|||||||
|
|
||||||
//Init Combat Tools
|
//Init Combat Tools
|
||||||
combatTools = new CombatTools(this);
|
combatTools = new CombatTools(this);
|
||||||
|
|
||||||
|
//Init Random Chance Tools
|
||||||
|
randomChanceTools = new RandomChanceTools(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -751,4 +757,8 @@ public class mcMMO extends JavaPlugin {
|
|||||||
public CombatTools getCombatTools() {
|
public CombatTools getCombatTools() {
|
||||||
return combatTools;
|
return combatTools;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RandomChanceTools getRandomChanceTools() {
|
||||||
|
return randomChanceTools;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|
||||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
@ -87,7 +86,7 @@ public class AcrobaticsManager extends SkillManager {
|
|||||||
double modifiedDamage = acrobaticsBehaviour.calculateModifiedDodgeDamage(damage, acrobaticsBehaviour.getDodgeDamageModifier());
|
double modifiedDamage = acrobaticsBehaviour.calculateModifiedDodgeDamage(damage, acrobaticsBehaviour.getDodgeDamageModifier());
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
|
|
||||||
if (!isFatal(modifiedDamage) && RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ACROBATICS_DODGE, player)) {
|
if (!isFatal(modifiedDamage) && pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ACROBATICS_DODGE, player)) {
|
||||||
ParticleEffectUtils.playDodgeEffect(player);
|
ParticleEffectUtils.playDodgeEffect(player);
|
||||||
|
|
||||||
if (mcMMOPlayer.useChatNotifications()) {
|
if (mcMMOPlayer.useChatNotifications()) {
|
||||||
|
@ -10,7 +10,6 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -92,7 +91,7 @@ public class ArcheryManager extends SkillManager {
|
|||||||
* @param defender The {@link Player} being affected by the ability
|
* @param defender The {@link Player} being affected by the ability
|
||||||
*/
|
*/
|
||||||
public double daze(Player defender) {
|
public double daze(Player defender) {
|
||||||
if (!RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ARCHERY_DAZE, getPlayer())) {
|
if (!pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ARCHERY_DAZE, getPlayer())) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +119,7 @@ public class ArcheryManager extends SkillManager {
|
|||||||
* @param oldDamage The raw damage value of this arrow before we modify it
|
* @param oldDamage The raw damage value of this arrow before we modify it
|
||||||
*/
|
*/
|
||||||
public double skillShot(double oldDamage) {
|
public double skillShot(double oldDamage) {
|
||||||
if (!RandomChanceUtil.isActivationSuccessful(SkillActivationType.ALWAYS_FIRES, SubSkillType.ARCHERY_SKILL_SHOT, getPlayer())) {
|
if (!pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.ALWAYS_FIRES, SubSkillType.ARCHERY_SKILL_SHOT, getPlayer())) {
|
||||||
return oldDamage;
|
return oldDamage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|
||||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
@ -74,7 +73,7 @@ public class AxesManager extends SkillManager {
|
|||||||
* Handle the effects of the Axe Mastery ability
|
* Handle the effects of the Axe Mastery ability
|
||||||
*/
|
*/
|
||||||
public double axeMastery() {
|
public double axeMastery() {
|
||||||
if (!RandomChanceUtil.isActivationSuccessful(SkillActivationType.ALWAYS_FIRES, SubSkillType.AXES_AXE_MASTERY, getPlayer())) {
|
if (!pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.ALWAYS_FIRES, SubSkillType.AXES_AXE_MASTERY, getPlayer())) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +87,7 @@ public class AxesManager extends SkillManager {
|
|||||||
* @param damage The amount of damage initially dealt by the event
|
* @param damage The amount of damage initially dealt by the event
|
||||||
*/
|
*/
|
||||||
public double criticalHit(LivingEntity target, double damage) {
|
public double criticalHit(LivingEntity target, double damage) {
|
||||||
if (!RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.AXES_CRITICAL_STRIKES, getPlayer())) {
|
if (!pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.AXES_CRITICAL_STRIKES, getPlayer())) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +122,7 @@ public class AxesManager extends SkillManager {
|
|||||||
|
|
||||||
for (ItemStack armor : target.getEquipment().getArmorContents()) {
|
for (ItemStack armor : target.getEquipment().getArmorContents()) {
|
||||||
if (armor != null && ItemUtils.isArmor(armor)) {
|
if (armor != null && ItemUtils.isArmor(armor)) {
|
||||||
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_STATIC_CHANCE, SubSkillType.AXES_ARMOR_IMPACT, getPlayer())) {
|
if (pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_STATIC_CHANCE, SubSkillType.AXES_ARMOR_IMPACT, getPlayer())) {
|
||||||
pluginRef.getSkillTools().handleDurabilityChange(armor, durabilityDamage, 1);
|
pluginRef.getSkillTools().handleDurabilityChange(armor, durabilityDamage, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,7 +140,7 @@ public class AxesManager extends SkillManager {
|
|||||||
*/
|
*/
|
||||||
public double greaterImpact(LivingEntity target) {
|
public double greaterImpact(LivingEntity target) {
|
||||||
//chance (3rd param)
|
//chance (3rd param)
|
||||||
if (!RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_STATIC_CHANCE, SubSkillType.AXES_GREATER_IMPACT, getPlayer())) {
|
if (!pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_STATIC_CHANCE, SubSkillType.AXES_GREATER_IMPACT, getPlayer())) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
@ -46,10 +45,10 @@ public class ExcavationManager extends SkillManager {
|
|||||||
|
|
||||||
for (ExcavationTreasure treasure : treasures) {
|
for (ExcavationTreasure treasure : treasures) {
|
||||||
if (skillLevel >= treasure.getDropLevel()
|
if (skillLevel >= treasure.getDropLevel()
|
||||||
&& RandomChanceUtil.checkRandomChanceExecutionSuccess(getPlayer(), PrimarySkillType.EXCAVATION, treasure.getDropChance())) {
|
&& pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(getPlayer(), PrimarySkillType.EXCAVATION, treasure.getDropChance())) {
|
||||||
|
|
||||||
//Spawn Vanilla XP orbs if a dice roll succeeds
|
//Spawn Vanilla XP orbs if a dice roll succeeds
|
||||||
if(RandomChanceUtil.rollDice(getArchaelogyExperienceOrbChance(), 100)) {
|
if(pluginRef.getRandomChanceTools().rollDice(getArchaelogyExperienceOrbChance(), 100)) {
|
||||||
ExperienceOrb experienceOrb = (ExperienceOrb) getPlayer().getWorld().spawnEntity(location, EntityType.EXPERIENCE_ORB);
|
ExperienceOrb experienceOrb = (ExperienceOrb) getPlayer().getWorld().spawnEntity(location, EntityType.EXPERIENCE_ORB);
|
||||||
experienceOrb.setExperience(getExperienceOrbsReward());
|
experienceOrb.setExperience(getExperienceOrbsReward());
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ import com.gmail.nossr50.util.ItemUtils;
|
|||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
|
import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||||
import com.gmail.nossr50.util.sounds.SoundType;
|
import com.gmail.nossr50.util.sounds.SoundType;
|
||||||
@ -349,7 +348,7 @@ public class FishingManager extends SkillManager {
|
|||||||
* @param target The {@link LivingEntity} affected by the ability
|
* @param target The {@link LivingEntity} affected by the ability
|
||||||
*/
|
*/
|
||||||
public void shakeCheck(LivingEntity target) {
|
public void shakeCheck(LivingEntity target) {
|
||||||
if (RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getShakeChance(), getPlayer(), SubSkillType.FISHING_SHAKE))) {
|
if (pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getShakeChance(), getPlayer(), SubSkillType.FISHING_SHAKE))) {
|
||||||
List<ShakeTreasure> possibleDrops = fishingBehaviour.findPossibleDrops(target);
|
List<ShakeTreasure> possibleDrops = fishingBehaviour.findPossibleDrops(target);
|
||||||
|
|
||||||
if (possibleDrops == null || possibleDrops.isEmpty()) {
|
if (possibleDrops == null || possibleDrops.isEmpty()) {
|
||||||
|
@ -16,7 +16,6 @@ import com.gmail.nossr50.runnables.skills.HerbalismBlockUpdaterTask;
|
|||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.*;
|
import com.gmail.nossr50.util.*;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
|
import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -196,7 +195,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
* @return true if the ability was successful, false otherwise
|
* @return true if the ability was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean processGreenThumbBlocks(BlockState blockState) {
|
public boolean processGreenThumbBlocks(BlockState blockState) {
|
||||||
if (!RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.HERBALISM_GREEN_THUMB, getPlayer())) {
|
if (!pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.HERBALISM_GREEN_THUMB, getPlayer())) {
|
||||||
pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE_FAILED, "Herbalism.Ability.GTh.Fail");
|
pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE_FAILED, "Herbalism.Ability.GTh.Fail");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -211,7 +210,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
* @return true if the ability was successful, false otherwise
|
* @return true if the ability was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean processHylianLuck(BlockState blockState) {
|
public boolean processHylianLuck(BlockState blockState) {
|
||||||
if (!RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.HERBALISM_HYLIAN_LUCK, getPlayer())) {
|
if (!pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.HERBALISM_HYLIAN_LUCK, getPlayer())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +229,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
|
|
||||||
for (HylianTreasure treasure : treasures) {
|
for (HylianTreasure treasure : treasures) {
|
||||||
if (skillLevel >= treasure.getDropLevel()
|
if (skillLevel >= treasure.getDropLevel()
|
||||||
&& RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(treasure.getDropChance(), getPlayer(), SubSkillType.HERBALISM_HYLIAN_LUCK))) {
|
&& pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(treasure.getDropChance(), getPlayer(), SubSkillType.HERBALISM_HYLIAN_LUCK))) {
|
||||||
if (!pluginRef.getEventManager().simulateBlockBreak(blockState.getBlock(), player, false)) {
|
if (!pluginRef.getEventManager().simulateBlockBreak(blockState.getBlock(), player, false)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -267,7 +266,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
playerInventory.removeItem(new ItemStack(Material.RED_MUSHROOM));
|
playerInventory.removeItem(new ItemStack(Material.RED_MUSHROOM));
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
|
|
||||||
if (!RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.HERBALISM_SHROOM_THUMB, player)) {
|
if (!pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.HERBALISM_SHROOM_THUMB, player)) {
|
||||||
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Herbalism.Ability.ShroomThumb.Fail");
|
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Herbalism.Ability.ShroomThumb.Fail");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -320,7 +319,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
|
|
||||||
ItemStack seedStack = new ItemStack(seed);
|
ItemStack seedStack = new ItemStack(seed);
|
||||||
|
|
||||||
if (!greenTerra && !RandomChanceUtil.checkRandomChanceExecutionSuccess(player, SubSkillType.HERBALISM_GREEN_THUMB)) {
|
if (!greenTerra && !pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(player, SubSkillType.HERBALISM_GREEN_THUMB)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ import com.gmail.nossr50.skills.SkillManager;
|
|||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -104,7 +103,7 @@ public class MiningManager extends SkillManager {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
//TODO: Make this readable
|
//TODO: Make this readable
|
||||||
if (RandomChanceUtil.checkRandomChanceExecutionSuccess(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS)) {
|
if (pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS)) {
|
||||||
BlockUtils.markDropsAsBonus(blockState, mcMMOPlayer.getAbilityMode(skill.getSuperAbility()));
|
BlockUtils.markDropsAsBonus(blockState, mcMMOPlayer.getAbilityMode(skill.getSuperAbility()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import com.gmail.nossr50.skills.SkillManager;
|
|||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
|
import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||||
@ -265,7 +264,7 @@ public class RepairManager extends SkillManager {
|
|||||||
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.REPAIR_SUPER_REPAIR))
|
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.REPAIR_SUPER_REPAIR))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.REPAIR_SUPER_REPAIR, getPlayer())) {
|
if (pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.REPAIR_SUPER_REPAIR, getPlayer())) {
|
||||||
pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Repair.Skills.FeltEasy");
|
pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Repair.Skills.FeltEasy");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -316,10 +315,10 @@ public class RepairManager extends SkillManager {
|
|||||||
|
|
||||||
Enchantment enchantment = enchant.getKey();
|
Enchantment enchantment = enchant.getKey();
|
||||||
|
|
||||||
if (RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getKeepEnchantChance(), getPlayer(), SubSkillType.REPAIR_ARCANE_FORGING))) {
|
if (pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getKeepEnchantChance(), getPlayer(), SubSkillType.REPAIR_ARCANE_FORGING))) {
|
||||||
|
|
||||||
if (pluginRef.getConfigManager().getConfigRepair().getArcaneForging().isDowngradesEnabled() && enchantLevel > 1
|
if (pluginRef.getConfigManager().getConfigRepair().getArcaneForging().isDowngradesEnabled() && enchantLevel > 1
|
||||||
&& (!RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(100 - getDowngradeEnchantChance(), getPlayer(), SubSkillType.REPAIR_ARCANE_FORGING)))) {
|
&& (!pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(100 - getDowngradeEnchantChance(), getPlayer(), SubSkillType.REPAIR_ARCANE_FORGING)))) {
|
||||||
item.addUnsafeEnchantment(enchantment, enchantLevel - 1);
|
item.addUnsafeEnchantment(enchantment, enchantLevel - 1);
|
||||||
downgraded = true;
|
downgraded = true;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import com.gmail.nossr50.util.Misc;
|
|||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
|
import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||||
import com.gmail.nossr50.util.sounds.SoundType;
|
import com.gmail.nossr50.util.sounds.SoundType;
|
||||||
@ -113,7 +112,7 @@ public class SalvageManager extends SkillManager {
|
|||||||
|
|
||||||
for(int x = 0; x < potentialSalvageYield-1; x++) {
|
for(int x = 0; x < potentialSalvageYield-1; x++) {
|
||||||
|
|
||||||
if(RandomChanceUtil.rollDice(chanceOfSuccess, 100)) {
|
if(pluginRef.getRandomChanceTools().rollDice(chanceOfSuccess, 100)) {
|
||||||
chanceOfSuccess-=2;
|
chanceOfSuccess-=2;
|
||||||
Math.max(chanceOfSuccess, 95);
|
Math.max(chanceOfSuccess, 95);
|
||||||
|
|
||||||
@ -241,13 +240,13 @@ public class SalvageManager extends SkillManager {
|
|||||||
|
|
||||||
if (!salvageBehaviour.isArcaneSalvageEnchantLoss()
|
if (!salvageBehaviour.isArcaneSalvageEnchantLoss()
|
||||||
|| Permissions.hasSalvageEnchantBypassPerk(player)
|
|| Permissions.hasSalvageEnchantBypassPerk(player)
|
||||||
|| RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getExtractFullEnchantChance(), getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE))) {
|
|| pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getExtractFullEnchantChance(), getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE))) {
|
||||||
|
|
||||||
enchantMeta.addStoredEnchant(enchant.getKey(), enchantLevel, true);
|
enchantMeta.addStoredEnchant(enchant.getKey(), enchantLevel, true);
|
||||||
}
|
}
|
||||||
else if (enchantLevel > 1
|
else if (enchantLevel > 1
|
||||||
&& salvageBehaviour.isArcaneSalvageDowngrades()
|
&& salvageBehaviour.isArcaneSalvageDowngrades()
|
||||||
&& RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getExtractPartialEnchantChance(), getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE))) {
|
&& pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getExtractPartialEnchantChance(), getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE))) {
|
||||||
enchantMeta.addStoredEnchant(enchant.getKey(), enchantLevel - 1, true);
|
enchantMeta.addStoredEnchant(enchant.getKey(), enchantLevel - 1, true);
|
||||||
downgraded = true;
|
downgraded = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
||||||
@ -21,7 +20,7 @@ public class SmeltingManager extends SkillManager {
|
|||||||
|
|
||||||
public boolean isSecondSmeltSuccessful() {
|
public boolean isSecondSmeltSuccessful() {
|
||||||
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.SMELTING_SECOND_SMELT)
|
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.SMELTING_SECOND_SMELT)
|
||||||
&& RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.SMELTING_SECOND_SMELT, getPlayer());
|
&& pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.SMELTING_SECOND_SMELT, getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,7 +10,6 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -58,7 +57,7 @@ public class SwordsManager extends SkillManager {
|
|||||||
* @param target The defending entity
|
* @param target The defending entity
|
||||||
*/
|
*/
|
||||||
public void ruptureCheck(LivingEntity target) {
|
public void ruptureCheck(LivingEntity target) {
|
||||||
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.SWORDS_RUPTURE, getPlayer())) {
|
if (pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.SWORDS_RUPTURE, getPlayer())) {
|
||||||
|
|
||||||
if (target instanceof Player) {
|
if (target instanceof Player) {
|
||||||
Player defender = (Player) target;
|
Player defender = (Player) target;
|
||||||
@ -119,7 +118,7 @@ public class SwordsManager extends SkillManager {
|
|||||||
* @param damage The amount of damage initially dealt by the event
|
* @param damage The amount of damage initially dealt by the event
|
||||||
*/
|
*/
|
||||||
public void counterAttackChecks(LivingEntity attacker, double damage) {
|
public void counterAttackChecks(LivingEntity attacker, double damage) {
|
||||||
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.SWORDS_COUNTER_ATTACK, getPlayer())) {
|
if (pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.SWORDS_COUNTER_ATTACK, getPlayer())) {
|
||||||
pluginRef.getCombatTools().dealDamage(attacker, damage / pluginRef.getConfigManager().getConfigSwords().getCounterAttackDamageModifier(), getPlayer());
|
pluginRef.getCombatTools().dealDamage(attacker, damage / pluginRef.getConfigManager().getConfigSwords().getCounterAttackDamageModifier(), getPlayer());
|
||||||
|
|
||||||
pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Countered");
|
pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Countered");
|
||||||
|
@ -15,7 +15,6 @@ import com.gmail.nossr50.util.Misc;
|
|||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
|
import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|
||||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
@ -114,7 +113,7 @@ public class TamingManager extends SkillManager {
|
|||||||
*/
|
*/
|
||||||
public void fastFoodService(Wolf wolf, double damage) {
|
public void fastFoodService(Wolf wolf, double damage) {
|
||||||
//static chance (3rd param)
|
//static chance (3rd param)
|
||||||
if (!RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_STATIC_CHANCE, SubSkillType.TAMING_FAST_FOOD_SERVICE, getPlayer())) {
|
if (!pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_STATIC_CHANCE, SubSkillType.TAMING_FAST_FOOD_SERVICE, getPlayer())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +133,7 @@ public class TamingManager extends SkillManager {
|
|||||||
* @param damage The initial damage
|
* @param damage The initial damage
|
||||||
*/
|
*/
|
||||||
public double gore(LivingEntity target, double damage) {
|
public double gore(LivingEntity target, double damage) {
|
||||||
if (!RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.TAMING_GORE, getPlayer())) {
|
if (!pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.TAMING_GORE, getPlayer())) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +229,7 @@ public class TamingManager extends SkillManager {
|
|||||||
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_PUMMEL))
|
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_PUMMEL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(AdvancedConfig.getInstance().getPummelChance(), getPlayer(), SubSkillType.TAMING_PUMMEL)))
|
if (!pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(AdvancedConfig.getInstance().getPummelChance(), getPlayer(), SubSkillType.TAMING_PUMMEL)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ParticleEffectUtils.playGreaterImpactEffect(target);
|
ParticleEffectUtils.playGreaterImpactEffect(target);
|
||||||
|
@ -12,7 +12,6 @@ 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.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -67,7 +66,7 @@ public class UnarmedManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean blockCrackerCheck(BlockState blockState) {
|
public boolean blockCrackerCheck(BlockState blockState) {
|
||||||
if (!RandomChanceUtil.isActivationSuccessful(SkillActivationType.ALWAYS_FIRES, SubSkillType.UNARMED_BLOCK_CRACKER, getPlayer())) {
|
if (!pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.ALWAYS_FIRES, SubSkillType.UNARMED_BLOCK_CRACKER, getPlayer())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +92,7 @@ public class UnarmedManager extends SkillManager {
|
|||||||
* @param defender The defending player
|
* @param defender The defending player
|
||||||
*/
|
*/
|
||||||
public void disarmCheck(Player defender) {
|
public void disarmCheck(Player defender) {
|
||||||
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.UNARMED_DISARM, getPlayer()) && !hasIronGrip(defender)) {
|
if (pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.UNARMED_DISARM, getPlayer()) && !hasIronGrip(defender)) {
|
||||||
if (pluginRef.getEventManager().callDisarmEvent(defender).isCancelled()) {
|
if (pluginRef.getEventManager().callDisarmEvent(defender).isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -116,7 +115,7 @@ public class UnarmedManager extends SkillManager {
|
|||||||
* Check for arrow deflection.
|
* Check for arrow deflection.
|
||||||
*/
|
*/
|
||||||
public boolean deflectCheck() {
|
public boolean deflectCheck() {
|
||||||
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.UNARMED_ARROW_DEFLECT, getPlayer())) {
|
if (pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.UNARMED_ARROW_DEFLECT, getPlayer())) {
|
||||||
pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Combat.ArrowDeflect");
|
pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Combat.ArrowDeflect");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -139,7 +138,7 @@ public class UnarmedManager extends SkillManager {
|
|||||||
* Handle the effects of the Iron Arm ability
|
* Handle the effects of the Iron Arm ability
|
||||||
*/
|
*/
|
||||||
public double ironArm() {
|
public double ironArm() {
|
||||||
if (!RandomChanceUtil.isActivationSuccessful(SkillActivationType.ALWAYS_FIRES, SubSkillType.UNARMED_IRON_ARM_STYLE, getPlayer())) {
|
if (!pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.ALWAYS_FIRES, SubSkillType.UNARMED_IRON_ARM_STYLE, getPlayer())) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +167,7 @@ public class UnarmedManager extends SkillManager {
|
|||||||
*/
|
*/
|
||||||
private boolean hasIronGrip(Player defender) {
|
private boolean hasIronGrip(Player defender) {
|
||||||
if (!Misc.isNPCEntityExcludingVillagers(defender) && Permissions.isSubSkillEnabled(defender, SubSkillType.UNARMED_IRON_GRIP)
|
if (!Misc.isNPCEntityExcludingVillagers(defender) && Permissions.isSubSkillEnabled(defender, SubSkillType.UNARMED_IRON_GRIP)
|
||||||
&& RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.UNARMED_IRON_GRIP, getPlayer())) {
|
&& pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.UNARMED_IRON_GRIP, getPlayer())) {
|
||||||
pluginRef.getNotificationManager().sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Unarmed.Ability.IronGrip.Defender");
|
pluginRef.getNotificationManager().sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Unarmed.Ability.IronGrip.Defender");
|
||||||
pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Unarmed.Ability.IronGrip.Attacker");
|
pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Unarmed.Ability.IronGrip.Attacker");
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ import com.gmail.nossr50.util.BlockUtils;
|
|||||||
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.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -53,7 +52,7 @@ public class WoodcuttingManager extends SkillManager {
|
|||||||
public boolean canGetDoubleDrops() {
|
public boolean canGetDoubleDrops() {
|
||||||
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.WOODCUTTING_HARVEST_LUMBER)
|
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.WOODCUTTING_HARVEST_LUMBER)
|
||||||
&& RankUtils.hasReachedRank(1, getPlayer(), SubSkillType.WOODCUTTING_HARVEST_LUMBER)
|
&& RankUtils.hasReachedRank(1, getPlayer(), SubSkillType.WOODCUTTING_HARVEST_LUMBER)
|
||||||
&& RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.WOODCUTTING_HARVEST_LUMBER, getPlayer());
|
&& pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.WOODCUTTING_HARVEST_LUMBER, getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
|||||||
import com.gmail.nossr50.skills.repair.Repair;
|
import com.gmail.nossr50.skills.repair.Repair;
|
||||||
import com.gmail.nossr50.skills.salvage.Salvage;
|
import com.gmail.nossr50.skills.salvage.Salvage;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceSkill;
|
import com.gmail.nossr50.util.random.RandomChanceSkill;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
@ -52,7 +51,7 @@ public final class BlockUtils {
|
|||||||
*/
|
*/
|
||||||
public static boolean checkDoubleDrops(Player player, BlockState blockState, SubSkillType subSkillType) {
|
public static boolean checkDoubleDrops(Player player, BlockState blockState, SubSkillType subSkillType) {
|
||||||
if (pluginRef.getDynamicSettingsManager().isBonusDropsEnabled(blockState.getType()) && Permissions.isSubSkillEnabled(player, subSkillType)) {
|
if (pluginRef.getDynamicSettingsManager().isBonusDropsEnabled(blockState.getType()) && Permissions.isSubSkillEnabled(player, subSkillType)) {
|
||||||
return RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkill(player, subSkillType, true));
|
return pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkill(player, subSkillType, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.util.random;
|
|||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -11,12 +12,15 @@ public class RandomChanceSkill implements RandomChanceExecution {
|
|||||||
protected final SubSkillType subSkillType;
|
protected final SubSkillType subSkillType;
|
||||||
protected final double probabilityCap;
|
protected final double probabilityCap;
|
||||||
protected final boolean isLucky;
|
protected final boolean isLucky;
|
||||||
private int skillLevel;
|
protected int skillLevel;
|
||||||
|
protected final mcMMO pluginRef;
|
||||||
|
|
||||||
public RandomChanceSkill(Player player, SubSkillType subSkillType) {
|
public RandomChanceSkill(mcMMO pluginRef, Player player, SubSkillType subSkillType) {
|
||||||
this.primarySkillType = subSkillType.getParentSkill();
|
this.pluginRef = pluginRef;
|
||||||
|
|
||||||
|
this.primarySkillType = subSkillType.getParentSkill(pluginRef);
|
||||||
this.subSkillType = subSkillType;
|
this.subSkillType = subSkillType;
|
||||||
this.probabilityCap = RandomChanceUtil.LINEAR_CURVE_VAR;
|
this.probabilityCap = pluginRef.getRandomChanceTools().LINEAR_CURVE_VAR;
|
||||||
|
|
||||||
if (player != null)
|
if (player != null)
|
||||||
this.skillLevel = pluginRef.getUserManager().getPlayer(player).getSkillLevel(primarySkillType);
|
this.skillLevel = pluginRef.getUserManager().getPlayer(player).getSkillLevel(primarySkillType);
|
||||||
@ -29,13 +33,15 @@ public class RandomChanceSkill implements RandomChanceExecution {
|
|||||||
isLucky = false;
|
isLucky = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RandomChanceSkill(Player player, SubSkillType subSkillType, boolean hasCap) {
|
public RandomChanceSkill(mcMMO pluginRef, Player player, SubSkillType subSkillType, boolean hasCap) {
|
||||||
|
this.pluginRef = pluginRef;
|
||||||
|
|
||||||
if (hasCap)
|
if (hasCap)
|
||||||
this.probabilityCap = pluginRef.getDynamicSettingsManager().getSkillMaxChance(subSkillType);
|
this.probabilityCap = pluginRef.getDynamicSettingsManager().getSkillMaxChance(subSkillType);
|
||||||
else
|
else
|
||||||
this.probabilityCap = RandomChanceUtil.LINEAR_CURVE_VAR;
|
this.probabilityCap = pluginRef.getRandomChanceTools().LINEAR_CURVE_VAR;
|
||||||
|
|
||||||
this.primarySkillType = subSkillType.getParentSkill();
|
this.primarySkillType = subSkillType.getParentSkill(pluginRef);
|
||||||
this.subSkillType = subSkillType;
|
this.subSkillType = subSkillType;
|
||||||
|
|
||||||
if (player != null)
|
if (player != null)
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
package com.gmail.nossr50.util.random;
|
package com.gmail.nossr50.util.random;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class RandomChanceSkillStatic extends RandomChanceSkill {
|
public class RandomChanceSkillStatic extends RandomChanceSkill {
|
||||||
private final double xPos;
|
private final double xPos;
|
||||||
|
|
||||||
public RandomChanceSkillStatic(double xPos, Player player, SubSkillType subSkillType) {
|
public RandomChanceSkillStatic(mcMMO pluginRef, double xPos, Player player, SubSkillType subSkillType) {
|
||||||
super(player, subSkillType);
|
super(pluginRef, player, subSkillType);
|
||||||
|
|
||||||
this.xPos = xPos;
|
this.xPos = xPos;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
|||||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||||
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillEvent;
|
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillEvent;
|
||||||
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillRandomCheckEvent;
|
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillRandomCheckEvent;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -12,10 +13,19 @@ import org.bukkit.entity.Player;
|
|||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class RandomChanceUtil {
|
public class RandomChanceTools {
|
||||||
public static final DecimalFormat percent = new DecimalFormat("##0.00%");
|
|
||||||
//public static final DecimalFormat decimal = new DecimalFormat("##0.00");
|
private final mcMMO pluginRef;
|
||||||
public static final double LINEAR_CURVE_VAR = 100.0D;
|
|
||||||
|
public final DecimalFormat percent;
|
||||||
|
public final double LINEAR_CURVE_VAR;
|
||||||
|
|
||||||
|
public RandomChanceTools(mcMMO pluginRef) {
|
||||||
|
this.pluginRef = pluginRef;
|
||||||
|
|
||||||
|
percent = new DecimalFormat("##0.00%");
|
||||||
|
LINEAR_CURVE_VAR = 100.0D;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is the final step in determining if a Sub-Skill / Secondary Skill in mcMMO successfully activates either from chance or otherwise
|
* This method is the final step in determining if a Sub-Skill / Secondary Skill in mcMMO successfully activates either from chance or otherwise
|
||||||
@ -27,7 +37,7 @@ public class RandomChanceUtil {
|
|||||||
* @param player The owner of this sub-skill
|
* @param player The owner of this sub-skill
|
||||||
* @return returns true if all conditions are met and the event is not cancelled
|
* @return returns true if all conditions are met and the event is not cancelled
|
||||||
*/
|
*/
|
||||||
public static boolean isActivationSuccessful(SkillActivationType skillActivationType, SubSkillType subSkillType, Player player) {
|
public boolean isActivationSuccessful(SkillActivationType skillActivationType, SubSkillType subSkillType, Player player) {
|
||||||
switch (skillActivationType) {
|
switch (skillActivationType) {
|
||||||
case RANDOM_LINEAR_100_SCALE_WITH_CAP:
|
case RANDOM_LINEAR_100_SCALE_WITH_CAP:
|
||||||
return checkRandomChanceExecutionSuccess(player, subSkillType);
|
return checkRandomChanceExecutionSuccess(player, subSkillType);
|
||||||
@ -41,7 +51,7 @@ public class RandomChanceUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getActivationChance(SkillActivationType skillActivationType, SubSkillType subSkillType, Player player) {
|
public double getActivationChance(SkillActivationType skillActivationType, SubSkillType subSkillType, Player player) {
|
||||||
switch (skillActivationType) {
|
switch (skillActivationType) {
|
||||||
case RANDOM_LINEAR_100_SCALE_WITH_CAP:
|
case RANDOM_LINEAR_100_SCALE_WITH_CAP:
|
||||||
return getRandomChanceExecutionSuccess(player, subSkillType, true);
|
return getRandomChanceExecutionSuccess(player, subSkillType, true);
|
||||||
@ -57,7 +67,7 @@ public class RandomChanceUtil {
|
|||||||
*
|
*
|
||||||
* @return true if the random chance succeeds
|
* @return true if the random chance succeeds
|
||||||
*/
|
*/
|
||||||
public static boolean checkRandomChanceExecutionSuccess(Player player, PrimarySkillType primarySkillType, double chance) {
|
public boolean checkRandomChanceExecutionSuccess(Player player, PrimarySkillType primarySkillType, double chance) {
|
||||||
//Check the odds
|
//Check the odds
|
||||||
chance *= 100;
|
chance *= 100;
|
||||||
|
|
||||||
@ -70,7 +80,7 @@ public class RandomChanceUtil {
|
|||||||
return rollDice(chance, 10000);
|
return rollDice(chance, 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean rollDice(double chanceOfSuccess, int bound) {
|
public boolean rollDice(double chanceOfSuccess, int bound) {
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
|
||||||
if (chanceOfSuccess > random.nextInt(bound))
|
if (chanceOfSuccess > random.nextInt(bound))
|
||||||
@ -85,14 +95,14 @@ public class RandomChanceUtil {
|
|||||||
* @param randomChance
|
* @param randomChance
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean checkRandomChanceExecutionSuccess(RandomChanceSkillStatic randomChance) {
|
public boolean checkRandomChanceExecutionSuccess(RandomChanceSkillStatic randomChance) {
|
||||||
double chanceOfSuccess = calculateChanceOfSuccess(randomChance);
|
double chanceOfSuccess = calculateChanceOfSuccess(randomChance);
|
||||||
|
|
||||||
//Check the odds
|
//Check the odds
|
||||||
return rollDice(chanceOfSuccess, 100);
|
return rollDice(chanceOfSuccess, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkRandomChanceExecutionSuccess(RandomChanceSkill randomChance) {
|
public boolean checkRandomChanceExecutionSuccess(RandomChanceSkill randomChance) {
|
||||||
double chanceOfSuccess = calculateChanceOfSuccess(randomChance);
|
double chanceOfSuccess = calculateChanceOfSuccess(randomChance);
|
||||||
|
|
||||||
//Check the odds
|
//Check the odds
|
||||||
@ -100,25 +110,25 @@ public class RandomChanceUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*public static double getRandomChanceExecutionChance(RandomChanceSkill randomChance)
|
/*public double getRandomChanceExecutionChance(RandomChanceSkill randomChance)
|
||||||
{
|
{
|
||||||
double chanceOfSuccess = calculateChanceOfSuccess(randomChance);
|
double chanceOfSuccess = calculateChanceOfSuccess(randomChance);
|
||||||
return chanceOfSuccess;
|
return chanceOfSuccess;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Static Chance for something to activate
|
* Gets the Chance for something to activate
|
||||||
*
|
*
|
||||||
* @param randomChance
|
* @param randomChance
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static double getRandomChanceExecutionChance(RandomChanceExecution randomChance) {
|
public double getRandomChanceExecutionChance(RandomChanceExecution randomChance) {
|
||||||
double chanceOfSuccess = getChanceOfSuccess(randomChance.getXPos(), randomChance.getProbabilityCap(), LINEAR_CURVE_VAR);
|
double chanceOfSuccess = getChanceOfSuccess(randomChance.getXPos(), randomChance.getProbabilityCap(), LINEAR_CURVE_VAR);
|
||||||
|
|
||||||
return chanceOfSuccess;
|
return chanceOfSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getRandomChanceExecutionChance(RandomChanceStatic randomChance) {
|
public double getRandomChanceExecutionChance(RandomChanceStatic randomChance) {
|
||||||
double chanceOfSuccess = getChanceOfSuccess(randomChance.getXPos(), randomChance.getProbabilityCap(), LINEAR_CURVE_VAR);
|
double chanceOfSuccess = getChanceOfSuccess(randomChance.getXPos(), randomChance.getProbabilityCap(), LINEAR_CURVE_VAR);
|
||||||
|
|
||||||
chanceOfSuccess = addLuck(randomChance.isLucky(), chanceOfSuccess);
|
chanceOfSuccess = addLuck(randomChance.isLucky(), chanceOfSuccess);
|
||||||
@ -126,12 +136,12 @@ public class RandomChanceUtil {
|
|||||||
return chanceOfSuccess;
|
return chanceOfSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*private static double calculateChanceOfSuccess(RandomChanceStatic randomChance) {
|
/*private double calculateChanceOfSuccess(RandomChancerandomChance) {
|
||||||
double chanceOfSuccess = getChanceOfSuccess(randomChance.getXPos(), randomChance.getProbabilityCap());
|
double chanceOfSuccess = getChanceOfSuccess(randomChance.getXPos(), randomChance.getProbabilityCap());
|
||||||
return chanceOfSuccess;
|
return chanceOfSuccess;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
private static double calculateChanceOfSuccess(RandomChanceSkill randomChanceSkill) {
|
private double calculateChanceOfSuccess(RandomChanceSkill randomChanceSkill) {
|
||||||
double skillLevel = randomChanceSkill.getSkillLevel();
|
double skillLevel = randomChanceSkill.getSkillLevel();
|
||||||
double maximumProbability = randomChanceSkill.getProbabilityCap();
|
double maximumProbability = randomChanceSkill.getProbabilityCap();
|
||||||
double maximumBonusLevel = randomChanceSkill.getMaximumBonusLevelCap();
|
double maximumBonusLevel = randomChanceSkill.getMaximumBonusLevelCap();
|
||||||
@ -152,7 +162,7 @@ public class RandomChanceUtil {
|
|||||||
return chanceOfSuccess;
|
return chanceOfSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double calculateChanceOfSuccess(RandomChanceSkillStatic randomChance) {
|
private double calculateChanceOfSuccess(RandomChanceSkillStatic randomChance) {
|
||||||
double chanceOfSuccess = getChanceOfSuccess(randomChance.getXPos(), 100, 100);
|
double chanceOfSuccess = getChanceOfSuccess(randomChance.getXPos(), 100, 100);
|
||||||
|
|
||||||
//Add Luck
|
//Add Luck
|
||||||
@ -167,42 +177,42 @@ public class RandomChanceUtil {
|
|||||||
*
|
*
|
||||||
* @return the chance of success from 0-100 (100 = guaranteed)
|
* @return the chance of success from 0-100 (100 = guaranteed)
|
||||||
*/
|
*/
|
||||||
private static int getChanceOfSuccess(double skillLevel, double maxProbability, double maxLevel) {
|
private int getChanceOfSuccess(double skillLevel, double maxProbability, double maxLevel) {
|
||||||
//return (int) (x / (y / LINEAR_CURVE_VAR));
|
//return (int) (x / (y / LINEAR_CURVE_VAR));
|
||||||
return (int) (maxProbability * (skillLevel / maxLevel));
|
return (int) (maxProbability * (skillLevel / maxLevel));
|
||||||
// max probability * (weight/maxlevel) = chance of success
|
// max probability * (weight/maxlevel) = chance of success
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getChanceOfSuccess(double x, double y) {
|
private int getChanceOfSuccess(double x, double y) {
|
||||||
return (int) (x / (y / LINEAR_CURVE_VAR));
|
return (int) (x / (y / LINEAR_CURVE_VAR));
|
||||||
// max probability * (weight/maxlevel) = chance of success
|
// max probability * (weight/maxlevel) = chance of success
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getRandomChanceExecutionSuccess(Player player, SubSkillType subSkillType, boolean hasCap) {
|
public double getRandomChanceExecutionSuccess(Player player, SubSkillType subSkillType, boolean hasCap) {
|
||||||
RandomChanceSkill rcs = new RandomChanceSkill(player, subSkillType, hasCap);
|
RandomChanceSkill rcs = new RandomChanceSkill(pluginRef, player, subSkillType, hasCap);
|
||||||
return calculateChanceOfSuccess(rcs);
|
return calculateChanceOfSuccess(rcs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getRandomStaticChanceExecutionSuccess(Player player, SubSkillType subSkillType) {
|
public double getRandomStaticChanceExecutionSuccess(Player player, SubSkillType subSkillType) {
|
||||||
try {
|
try {
|
||||||
return getRandomChanceExecutionChance(new RandomChanceSkillStatic(getStaticRandomChance(subSkillType), player, subSkillType));
|
return getRandomChanceExecutionChance(new RandomChanceSkillStatic(pluginRef, getStaticRandomChance(subSkillType), player, subSkillType));
|
||||||
} catch (InvalidStaticChance invalidStaticChance) {
|
} catch (InvalidStaticChance invalidStaticChance) {
|
||||||
//Catch invalid static skills
|
//Catch invalid skills
|
||||||
invalidStaticChance.printStackTrace();
|
invalidStaticChance.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0.1337; //Puts on shades
|
return 0.1337; //Puts on shades
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkRandomChanceExecutionSuccess(Player player, SubSkillType subSkillType) {
|
public boolean checkRandomChanceExecutionSuccess(Player player, SubSkillType subSkillType) {
|
||||||
return checkRandomChanceExecutionSuccess(new RandomChanceSkill(player, subSkillType));
|
return checkRandomChanceExecutionSuccess(new RandomChanceSkill(pluginRef, player, subSkillType));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkRandomStaticChanceExecutionSuccess(Player player, SubSkillType subSkillType) {
|
public boolean checkRandomStaticChanceExecutionSuccess(Player player, SubSkillType subSkillType) {
|
||||||
try {
|
try {
|
||||||
return checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getStaticRandomChance(subSkillType), player, subSkillType));
|
return checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(pluginRef, getStaticRandomChance(subSkillType), player, subSkillType));
|
||||||
} catch (InvalidStaticChance invalidStaticChance) {
|
} catch (InvalidStaticChance invalidStaticChance) {
|
||||||
//Catch invalid static skills
|
//Catch invalid skills
|
||||||
invalidStaticChance.printStackTrace();
|
invalidStaticChance.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,36 +220,36 @@ public class RandomChanceUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grabs static activation rolls for Secondary Abilities
|
* Grabs activation rolls for Secondary Abilities
|
||||||
*
|
*
|
||||||
* @param subSkillType The secondary ability to grab properties of
|
* @param subSkillType The secondary ability to grab properties of
|
||||||
* @return The static activation roll involved in the RNG calculation
|
* @return The activation roll involved in the RNG calculation
|
||||||
* @throws InvalidStaticChance if the skill has no defined static chance this exception will be thrown and you should know you're a naughty boy
|
* @throws InvalidStaticChance if the skill has no defined chance this exception will be thrown and you should know you're a naughty boy
|
||||||
*/
|
*/
|
||||||
public static double getStaticRandomChance(SubSkillType subSkillType) throws InvalidStaticChance {
|
public double getStaticRandomChance(SubSkillType subSkillType) throws InvalidStaticChance {
|
||||||
return pluginRef.getDynamicSettingsManager().getSkillPropertiesManager().getStaticChanceProperty(subSkillType);
|
return pluginRef.getDynamicSettingsManager().getSkillPropertiesManager().getStaticChanceProperty(subSkillType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean sendSkillEvent(Player player, SubSkillType subSkillType, double activationChance) {
|
public boolean sendSkillEvent(Player player, SubSkillType subSkillType, double activationChance) {
|
||||||
SubSkillRandomCheckEvent event = new SubSkillRandomCheckEvent(player, subSkillType, activationChance);
|
SubSkillRandomCheckEvent event = new SubSkillRandomCheckEvent(player, subSkillType, activationChance);
|
||||||
return !event.isCancelled();
|
return !event.isCancelled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public static boolean treasureDropSuccessful(Player player, double dropChance, int activationChance) {
|
/*public boolean treasureDropSuccessful(Player player, double dropChance, int activationChance) {
|
||||||
SubSkillRandomCheckEvent event = new SubSkillRandomCheckEvent(player, SubSkillType.EXCAVATION_ARCHAEOLOGY, dropChance / activationChance);
|
SubSkillRandomCheckEvent event = new SubSkillRandomCheckEvent(player, SubSkillType.EXCAVATION_ARCHAEOLOGY, dropChance / activationChance);
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
return (event.getChance() * activationChance) > (Misc.getRandom().nextDouble() * activationChance) && !event.isCancelled();
|
return (event.getChance() * activationChance) > (Misc.getRandom().nextDouble() * activationChance) && !event.isCancelled();
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
public static boolean isActivationSuccessful(SkillActivationType skillActivationType, AbstractSubSkill abstractSubSkill, Player player) {
|
public boolean isActivationSuccessful(SkillActivationType skillActivationType, AbstractSubSkill abstractSubSkill, Player player) {
|
||||||
return isActivationSuccessful(skillActivationType, abstractSubSkill.getSubSkillType(), player);
|
return isActivationSuccessful(skillActivationType, abstractSubSkill.getSubSkillType(), player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] calculateAbilityDisplayValues(SkillActivationType skillActivationType, Player player, SubSkillType subSkillType) {
|
public String[] calculateAbilityDisplayValues(SkillActivationType skillActivationType, Player player, SubSkillType subSkillType) {
|
||||||
double successChance = getActivationChance(skillActivationType, subSkillType, player);
|
double successChance = getActivationChance(skillActivationType, subSkillType, player);
|
||||||
String[] displayValues = new String[2];
|
String[] displayValues = new String[2];
|
||||||
|
|
||||||
boolean isLucky = Permissions.lucky(player, subSkillType.getParentSkill());
|
boolean isLucky = Permissions.lucky(player, subSkillType.getParentSkill(pluginRef));
|
||||||
|
|
||||||
displayValues[0] = percent.format(Math.min(successChance, 100.0D) / 100.0D);
|
displayValues[0] = percent.format(Math.min(successChance, 100.0D) / 100.0D);
|
||||||
displayValues[1] = isLucky ? percent.format(Math.min(successChance * 1.3333D, 100.0D) / 100.0D) : null;
|
displayValues[1] = isLucky ? percent.format(Math.min(successChance * 1.3333D, 100.0D) / 100.0D) : null;
|
||||||
@ -247,7 +257,7 @@ public class RandomChanceUtil {
|
|||||||
return displayValues;
|
return displayValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] calculateAbilityDisplayValuesStatic(Player player, PrimarySkillType primarySkillType, double chance) {
|
public String[] calculateAbilityDisplayValuesStatic(Player player, PrimarySkillType primarySkillType, double chance) {
|
||||||
RandomChanceStatic rcs = new RandomChanceStatic(chance, false);
|
RandomChanceStatic rcs = new RandomChanceStatic(chance, false);
|
||||||
double successChance = getRandomChanceExecutionChance(rcs);
|
double successChance = getRandomChanceExecutionChance(rcs);
|
||||||
|
|
||||||
@ -264,14 +274,14 @@ public class RandomChanceUtil {
|
|||||||
return displayValues;
|
return displayValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] calculateAbilityDisplayValuesCustom(SkillActivationType skillActivationType, Player player, SubSkillType subSkillType, double multiplier) {
|
public String[] calculateAbilityDisplayValuesCustom(SkillActivationType skillActivationType, Player player, SubSkillType subSkillType, double multiplier) {
|
||||||
double successChance = getActivationChance(skillActivationType, subSkillType, player);
|
double successChance = getActivationChance(skillActivationType, subSkillType, player);
|
||||||
successChance *= multiplier; //Currently only used for graceful roll
|
successChance *= multiplier; //Currently only used for graceful roll
|
||||||
String[] displayValues = new String[2];
|
String[] displayValues = new String[2];
|
||||||
|
|
||||||
//TODO: Account for lucky in this
|
//TODO: Account for lucky in this
|
||||||
|
|
||||||
boolean isLucky = Permissions.lucky(player, subSkillType.getParentSkill());
|
boolean isLucky = Permissions.lucky(player, subSkillType.getParentSkill(pluginRef));
|
||||||
|
|
||||||
displayValues[0] = percent.format(Math.min(successChance, 100.0D) / 100.0D);
|
displayValues[0] = percent.format(Math.min(successChance, 100.0D) / 100.0D);
|
||||||
displayValues[1] = isLucky ? percent.format(Math.min(successChance * 1.3333D, 100.0D) / 100.0D) : null;
|
displayValues[1] = isLucky ? percent.format(Math.min(successChance * 1.3333D, 100.0D) / 100.0D) : null;
|
||||||
@ -279,14 +289,14 @@ public class RandomChanceUtil {
|
|||||||
return displayValues;
|
return displayValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double addLuck(Player player, PrimarySkillType primarySkillType, double chance) {
|
public double addLuck(Player player, PrimarySkillType primarySkillType, double chance) {
|
||||||
if (Permissions.lucky(player, primarySkillType))
|
if (Permissions.lucky(player, primarySkillType))
|
||||||
return chance * 1.333D;
|
return chance * 1.333D;
|
||||||
else
|
else
|
||||||
return chance;
|
return chance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double addLuck(boolean isLucky, double chance) {
|
public double addLuck(boolean isLucky, double chance) {
|
||||||
if (isLucky)
|
if (isLucky)
|
||||||
return chance * 1.333D;
|
return chance * 1.333D;
|
||||||
else
|
else
|
Loading…
Reference in New Issue
Block a user