These belong better in SkillTools than Misc

This commit is contained in:
GJ 2013-02-13 16:45:49 -05:00
parent f4da69a205
commit 55b88f0274
25 changed files with 92 additions and 84 deletions

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.skills;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
public abstract class SkillManager {
@ -13,7 +13,7 @@ public abstract class SkillManager {
public SkillManager(McMMOPlayer mcMMOPlayer, SkillType skill) {
this.mcMMOPlayer = mcMMOPlayer;
this.skillLevel = mcMMOPlayer.getProfile().getSkillLevel(skill);
this.activationChance = Misc.calculateActivationChance(Permissions.lucky(mcMMOPlayer.getPlayer(), skill));
this.activationChance = SkillTools.calculateActivationChance(Permissions.lucky(mcMMOPlayer.getPlayer(), skill));
}
public McMMOPlayer getMcMMOPlayer() {

View File

@ -4,6 +4,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
@ -17,7 +18,7 @@ public class DodgeEventHandler extends AcrobaticsEventHandler {
@Override
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Acrobatics.dodgeMaxBonusLevel);
this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Acrobatics.dodgeMaxBonusLevel);
}
@Override

View File

@ -4,8 +4,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
public class RollEventHandler extends AcrobaticsEventHandler {
@ -29,7 +29,7 @@ public class RollEventHandler extends AcrobaticsEventHandler {
skillModifer = skillModifer * 2;
}
skillModifer = Misc.skillCheck(skillModifer, Acrobatics.rollMaxBonusLevel);
skillModifer = SkillTools.skillCheck(skillModifer, Acrobatics.rollMaxBonusLevel);
this.skillModifier = skillModifer;
}

View File

@ -2,7 +2,7 @@ package com.gmail.nossr50.skills.archery;
import org.bukkit.entity.LivingEntity;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.skills.utilities.SkillTools;
public class ArrowTrackingEventHandler {
private ArcheryManager manager;
@ -18,7 +18,7 @@ public class ArrowTrackingEventHandler {
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Archery.retrieveMaxBonusLevel);
this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Archery.retrieveMaxBonusLevel);
}
protected void addToTracker() {

View File

@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.util.Misc;
public class DazeEventHandler {
@ -25,7 +26,7 @@ public class DazeEventHandler {
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Archery.dazeMaxBonusLevel);
this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Archery.dazeMaxBonusLevel);
}
protected void handleDazeEffect() {

View File

@ -5,7 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.skills.utilities.SkillTools;
public class CriticalHitEventHandler {
private AxeManager manager;
@ -42,6 +42,6 @@ public class CriticalHitEventHandler {
}
private void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Axes.criticalHitMaxBonusLevel);
this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Axes.criticalHitMaxBonusLevel);
}
}

View File

@ -109,7 +109,7 @@ public class Excavation {
for (ExcavationTreasure treasure : treasures) {
if (mcMMOPlayer.getProfile().getSkillLevel(SkillType.EXCAVATION) >= treasure.getDropLevel()) {
int activationChance = Misc.calculateActivationChance(Permissions.luckyExcavation(player));
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyExcavation(player));
if (Misc.getRandom().nextDouble() * activationChance <= treasure.getDropChance()) {
xp += treasure.getXp();

View File

@ -160,7 +160,7 @@ public final class Fishing {
FishingTreasure treasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
ItemStack treasureDrop = treasure.getDrop();
int activationChance = Misc.calculateActivationChance(Permissions.luckyFishing(player));
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyFishing(player));
if (Misc.getRandom().nextDouble() * activationChance > treasure.getDropChance()) {
return null;
@ -189,7 +189,7 @@ public final class Fishing {
return false;
}
int activationChance = Misc.calculateActivationChance(Permissions.luckyFishing(player));
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyFishing(player));
if (storm) {
activationChance = (int) (activationChance * 0.909);

View File

@ -17,6 +17,7 @@ import org.bukkit.potion.PotionType;
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
import com.gmail.nossr50.skills.utilities.CombatTools;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
@ -31,7 +32,7 @@ public final class ShakeMob {
* @param skillLevel Fishing level of the player
*/
public static void process(Player player, LivingEntity mob, int skillLevel) {
int activationChance = Misc.calculateActivationChance(Permissions.luckyFishing(player));
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyFishing(player));
if (getShakeProbability(skillLevel) <= Misc.getRandom().nextInt(activationChance)) {
return;

View File

@ -190,8 +190,8 @@ public class Herbalism {
}
if (Permissions.herbalismDoubleDrops(player)) {
int activationChance = Misc.calculateActivationChance(Permissions.luckyHerbalism(player));
double chance = (doubleDropsMaxChance / doubleDropsMaxLevel) * Misc.skillCheck(herbLevel, doubleDropsMaxLevel);
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyHerbalism(player));
double chance = (doubleDropsMaxChance / doubleDropsMaxLevel) * SkillTools.skillCheck(herbLevel, doubleDropsMaxLevel);
if (chance > Misc.getRandom().nextInt(activationChance)) {
Location location = block.getLocation();
@ -259,7 +259,7 @@ public class Herbalism {
break;
}
int activationChance = Misc.calculateActivationChance(Permissions.luckyHerbalism(player));
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyHerbalism(player));
float chance = (float) ((greenThumbMaxChance / greenThumbMaxLevel) * herbLevel);
if (chance > greenThumbMaxChance) chance = (float) greenThumbMaxChance;
@ -326,7 +326,7 @@ public class Herbalism {
player.setItemInHand(new ItemStack(Material.SEEDS, seeds - 1));
int activationChance = Misc.calculateActivationChance(Permissions.luckyHerbalism(player));
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyHerbalism(player));
float chance = (float) ((greenThumbMaxChance / greenThumbMaxLevel) * skillLevel);
if (chance > greenThumbMaxChance) chance = (float) greenThumbMaxChance;
@ -342,8 +342,8 @@ public class Herbalism {
public static void hylianLuck(Block block, Player player, BlockBreakEvent event) {
int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(SkillType.HERBALISM);
double chance = (hylianLuckMaxChance / hylianLuckMaxLevel) * Misc.skillCheck(skillLevel, hylianLuckMaxLevel);
int activationChance = Misc.calculateActivationChance(Permissions.luckyHerbalism(player));
double chance = (hylianLuckMaxChance / hylianLuckMaxLevel) * SkillTools.skillCheck(skillLevel, hylianLuckMaxLevel);
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyHerbalism(player));
if (chance > Misc.getRandom().nextInt(activationChance)) {
List<HylianTreasure> treasures = new ArrayList<HylianTreasure>();

View File

@ -5,7 +5,7 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.skills.utilities.SkillTools;
public class MiningBlockEventHandler {
private MiningManager manager;
@ -24,7 +24,7 @@ public class MiningBlockEventHandler {
}
private void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Mining.doubleDropsMaxLevel);
this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Mining.doubleDropsMaxLevel);
}
/**

View File

@ -55,7 +55,7 @@ public class RemoteDetonationEventHandler {
protected void sendMessages() {
Player player = manager.getMcMMOPlayer().getPlayer();
Misc.sendSkillMessage(player, AbilityType.BLAST_MINING.getAbilityPlayer(player));
SkillTools.sendSkillMessage(player, AbilityType.BLAST_MINING.getAbilityPlayer(player));
player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));
}

View File

@ -17,6 +17,7 @@ import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
@ -109,7 +110,7 @@ public class Repair {
for (Entry<Enchantment, Integer> enchant : enchants.entrySet()) {
Enchantment enchantment = enchant.getKey();
int activationChance = Misc.calculateActivationChance(Permissions.luckyRepair(player));
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyRepair(player));
if (Misc.getRandom().nextInt(activationChance) <= getEnchantChance(rank)) {
int enchantLevel = enchant.getValue();
@ -236,7 +237,7 @@ public class Repair {
int chance = (int) ((SUPER_REPAIR_CHANCE_MAX / SUPER_REPAIR_MAX_BONUS_LEVEL) * skillLevel);
if (skillLevel >= SUPER_REPAIR_MAX_BONUS_LEVEL) chance = (int) SUPER_REPAIR_CHANCE_MAX;
int activationChance = Misc.calculateActivationChance(Permissions.luckyRepair(player));
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyRepair(player));
if (chance > Misc.getRandom().nextInt(activationChance) && Permissions.repairBonus(player)) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy"));

View File

@ -9,6 +9,7 @@ import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.mining.Mining;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
@ -51,7 +52,7 @@ public class FluxMiningEventHandler {
McMMOPlayer mcMMOPlayer = manager.getMcMMOPlayer();
if (Permissions.secondSmelt(mcMMOPlayer.getPlayer())) {
int chance = (int) ((Mining.doubleDropsMaxChance / Mining.doubleDropsMaxLevel) * (Misc.skillCheck(mcMMOPlayer.getProfile().getSkillLevel(SkillType.MINING), Mining.doubleDropsMaxLevel)));
int chance = (int) ((Mining.doubleDropsMaxChance / Mining.doubleDropsMaxLevel) * (SkillTools.skillCheck(mcMMOPlayer.getProfile().getSkillLevel(SkillType.MINING), Mining.doubleDropsMaxLevel)));
Misc.randomDropItem(location, item, chance);
}
}

View File

@ -7,8 +7,8 @@ import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
public class SmeltResourceEventHandler {
@ -23,7 +23,7 @@ public class SmeltResourceEventHandler {
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Smelting.secondSmeltMaxLevel);
this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Smelting.secondSmeltMaxLevel);
}
protected void handleXPGain() {

View File

@ -5,7 +5,7 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.runnables.BleedTimer;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.skills.utilities.SkillTools;
public class BleedEventHandler {
private SwordsManager manager;
@ -22,7 +22,7 @@ public class BleedEventHandler {
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(skillLevel, Swords.bleedMaxBonusLevel);
this.skillModifier = SkillTools.skillCheck(skillLevel, Swords.bleedMaxBonusLevel);
}
protected void addBleedTicks() {

View File

@ -5,7 +5,7 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.CombatTools;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.skills.utilities.SkillTools;
public class CounterAttackEventHandler {
private SwordsManager manager;
@ -20,7 +20,7 @@ public class CounterAttackEventHandler {
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Swords.counterAttackMaxBonusLevel);
this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Swords.counterAttackMaxBonusLevel);
}
protected void dealDamage() {

View File

@ -7,7 +7,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.runnables.BleedTimer;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.skills.utilities.SkillTools;
public class GoreEventHandler {
private TamingManager manager;
@ -23,7 +23,7 @@ public class GoreEventHandler {
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Taming.goreMaxBonusLevel);
this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Taming.goreMaxBonusLevel);
}
protected void modifyEventDamage() {

View File

@ -3,7 +3,7 @@ package com.gmail.nossr50.skills.unarmed;
import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.skills.utilities.SkillTools;
public class DeflectEventHandler {
private UnarmedManager manager;
@ -18,7 +18,7 @@ public class DeflectEventHandler {
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Unarmed.deflectMaxBonusLevel);
this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Unarmed.deflectMaxBonusLevel);
}
protected void sendAbilityMessage() {

View File

@ -7,6 +7,7 @@ import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.events.skills.McMMOPlayerDisarmEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.util.Misc;
public class DisarmEventHandler {
@ -26,7 +27,7 @@ public class DisarmEventHandler {
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Unarmed.disarmMaxBonusLevel);
this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Unarmed.disarmMaxBonusLevel);
}
private void sendAbilityMessage() {

View File

@ -3,8 +3,8 @@ package com.gmail.nossr50.skills.unarmed;
import org.bukkit.entity.Player;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Users;
public class IronGripEventHandler {
@ -20,7 +20,7 @@ public class IronGripEventHandler {
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(Users.getPlayer(defender).getProfile().getSkillLevel(SkillType.UNARMED), Unarmed.ironGripMaxBonusLevel);
this.skillModifier = SkillTools.skillCheck(Users.getPlayer(defender).getProfile().getSkillLevel(SkillType.UNARMED), Unarmed.ironGripMaxBonusLevel);
}
protected void sendAbilityMessages() {

View File

@ -6,6 +6,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
@ -86,7 +87,7 @@ public class UnarmedManager extends SkillManager {
double chance = (Unarmed.ironGripMaxChance / Unarmed.ironGripMaxBonusLevel) * eventHandler.skillModifier;
if (chance > Misc.getRandom().nextInt(Misc.calculateActivationChance(Permissions.luckyUnarmed(defender)))) {
if (chance > Misc.getRandom().nextInt(SkillTools.calculateActivationChance(Permissions.luckyUnarmed(defender)))) {
eventHandler.sendAbilityMessages();
return true;
}

View File

@ -27,6 +27,9 @@ public class SkillTools {
public static int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
public static boolean abilitiesEnabled = Config.getInstance().getAbilitiesEnabled();
public static final int LUCKY_SKILL_ACTIVATION_CHANCE = 75;
public static final int NORMAL_SKILL_ACTIVATION_CHANCE = 100;
public static void handleFoodSkills(Player player, SkillType skill, FoodLevelChangeEvent event, int baseLevel, int maxLevel, int rankChange) {
int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(skill);
@ -205,7 +208,7 @@ public class SkillTools {
profile.setAbilityInformed(ability, false);
player.sendMessage(ability.getAbilityOff());
Misc.sendSkillMessage(player, ability.getAbilityPlayerOff(player));
sendSkillMessage(player, ability.getAbilityPlayerOff(player));
}
}
}
@ -420,7 +423,7 @@ public class SkillTools {
if (!profile.getAbilityMode(ability) && cooldownOver(profile.getSkillDATS(ability), ability.getCooldown(), player)) {
player.sendMessage(ability.getAbilityOn());
Misc.sendSkillMessage(player, ability.getAbilityPlayer(player));
SkillTools.sendSkillMessage(player, ability.getAbilityPlayer(player));
profile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
profile.setAbilityMode(ability, true);
@ -471,4 +474,42 @@ public class SkillTools {
return activate;
}
/**
* Calculate activation chance for a skill.
*
* @param isLucky true if the player has the appropriate "lucky" perk, false otherwise
* @return the activation chance
*/
public static int calculateActivationChance(boolean isLucky) {
if (isLucky) {
return LUCKY_SKILL_ACTIVATION_CHANCE;
}
return NORMAL_SKILL_ACTIVATION_CHANCE;
}
public static void sendSkillMessage(Player player, String message) {
for (Player otherPlayer : player.getWorld().getPlayers()) {
if (otherPlayer != player && Misc.isNear(player.getLocation(), otherPlayer.getLocation(), Misc.SKILL_MESSAGE_MAX_SENDING_DISTANCE)) {
otherPlayer.sendMessage(message);
}
}
}
/**
* Check if a skill level is higher than the max bonus level of the ability.
*
* @param skillLevel Skill level to check
* @param maxLevel Max level of the ability
* @return whichever value is lower
*/
public static int skillCheck(int skillLevel, int maxLevel) {
//TODO: Could we just use Math.min(skillLevel, maxLevel) here?
if (skillLevel > maxLevel) {
return maxLevel;
}
return skillLevel;
}
}

View File

@ -15,6 +15,7 @@ import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.mods.ModChecks;
import com.gmail.nossr50.mods.datatypes.CustomBlock;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
@ -132,7 +133,7 @@ public final class Woodcutting {
double configDoubleDropChance = ADVANCED_CONFIG.getWoodcuttingDoubleDropChance();
int configDoubleDropMaxLevel = ADVANCED_CONFIG.getWoodcuttingDoubleDropMaxLevel();
int probability = (int) ((configDoubleDropChance / configDoubleDropMaxLevel) * Users.getPlayer(player).getProfile().getSkillLevel(SkillType.WOODCUTTING));
int activationChance = Misc.calculateActivationChance(Permissions.luckyWoodcutting(player));
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyWoodcutting(player));
if (probability > configDoubleDropChance) {
probability = (int) configDoubleDropChance;

View File

@ -33,9 +33,6 @@ public final class Misc {
public static final int PLAYER_RESPAWN_COOLDOWN_SECONDS = 5;
public static final int TIME_CONVERSION_FACTOR = 1000;
public static final double SKILL_MESSAGE_MAX_SENDING_DISTANCE = 10.0;
public static final int NORMAL_SKILL_ACTIVATION_CHANCE = 100;
public static final int LUCKY_SKILL_ACTIVATION_CHANCE = 75;
//Sound Pitches & Volumes from CB
public static final float ANVIL_USE_PITCH = 0.3F; // Not in CB directly, I went off the place sound values
public static final float ANVIL_USE_VOLUME = 1.0F; // Not in CB directly, I went off the place sound values
@ -46,20 +43,6 @@ public final class Misc {
private Misc() {};
/**
* Calculate activation chance for a skill.
*
* @param isLucky true if the player has the appropriate "lucky" perk, false otherwise
* @return the activation chance
*/
public static int calculateActivationChance(boolean isLucky) {
if (isLucky) {
return LUCKY_SKILL_ACTIVATION_CHANCE;
}
return NORMAL_SKILL_ACTIVATION_CHANCE;
}
public static boolean isFriendlyPet(Player attacker, Tameable pet) {
if (pet.isTamed()) {
AnimalTamer tamer = pet.getOwner();
@ -92,14 +75,6 @@ public final class Misc {
return false;
}
public static void sendSkillMessage(Player player, String message) {
for (Player otherPlayer : player.getWorld().getPlayers()) {
if (otherPlayer != player && Misc.isNear(player.getLocation(), otherPlayer.getLocation(), Misc.SKILL_MESSAGE_MAX_SENDING_DISTANCE)) {
otherPlayer.sendMessage(message);
}
}
}
/**
* Checks to see if an entity is currently invincible.
*
@ -269,22 +244,6 @@ public final class Misc {
newItem.setItemStack(cloned);
}
/**
* Check if a skill level is higher than the max bonus level of the ability.
*
* @param skillLevel Skill level to check
* @param maxLevel Max level of the ability
* @return whichever value is lower
*/
public static int skillCheck(int skillLevel, int maxLevel) {
//TODO: Could we just use Math.min(skillLevel, maxLevel) here?
if (skillLevel > maxLevel) {
return maxLevel;
}
return skillLevel;
}
/**
* Get the max power level for a player.
*