Fixed a bug which caused advanced.yml not to respect every MaxChance node

This commit is contained in:
TfT_02 2013-01-02 01:27:50 +01:00
parent 3aee334fbd
commit 4f8337c11a
11 changed files with 61 additions and 43 deletions

View File

@ -27,6 +27,7 @@ Version 1.3.13-dev
= Fixed a bug where a infinite loop of errors caused by mySQL database could cause the server to crash = Fixed a bug where a infinite loop of errors caused by mySQL database could cause the server to crash
= Fixed a bug where PartyChangeEvent was fired even when a player isn't able to change parties = Fixed a bug where PartyChangeEvent was fired even when a player isn't able to change parties
= Fixed a bug which caused advanced.yml not to work for Swords = Fixed a bug which caused advanced.yml not to work for Swords
= Fixed a bug which caused advanced.yml not to respect every MaxChance node
= Fixed a bug where Repair would remove enchantments but the glow effect remained = Fixed a bug where Repair would remove enchantments but the glow effect remained
= Fixed a bug where dropped items did not retain custom NBT data = Fixed a bug where dropped items did not retain custom NBT data
= Fixed a bug which caused a potentially infinite recursion in a btree structure = Fixed a bug which caused a potentially infinite recursion in a btree structure

View File

@ -89,6 +89,7 @@ public class Axes {
int randomChance = 100; int randomChance = 100;
double chance = (MAX_CHANCE / MAX_BONUS_LEVEL) * skillCheck; double chance = (MAX_CHANCE / MAX_BONUS_LEVEL) * skillCheck;
if (chance > MAX_CHANCE) chance = MAX_CHANCE;
if (attacker.hasPermission("mcmmo.perks.lucky.axes")) { if (attacker.hasPermission("mcmmo.perks.lucky.axes")) {
randomChance = (int) (randomChance * 0.75); randomChance = (int) (randomChance * 0.75);

View File

@ -13,6 +13,7 @@ import org.bukkit.inventory.PlayerInventory;
import org.bukkit.material.MaterialData; import org.bukkit.material.MaterialData;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.mods.CustomBlocksConfig; import com.gmail.nossr50.config.mods.CustomBlocksConfig;
import com.gmail.nossr50.datatypes.AbilityType; import com.gmail.nossr50.datatypes.AbilityType;
@ -30,6 +31,7 @@ import com.gmail.nossr50.util.Users;
public class Herbalism { public class Herbalism {
private static Random random = new Random(); private static Random random = new Random();
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
/** /**
* Activate the Green Terra ability. * Activate the Green Terra ability.
@ -85,7 +87,8 @@ public class Herbalism {
return; return;
final PlayerProfile profile = Users.getProfile(player); final PlayerProfile profile = Users.getProfile(player);
final int MAX_BONUS_LEVEL = 1000; final double MAX_CHANCE = advancedConfig.getHerbalismDoubleDropsChanceMax();
final int MAX_BONUS_LEVEL = advancedConfig.getHerbalismDoubleDropsMaxLevel();
int herbLevel = profile.getSkillLevel(SkillType.HERBALISM); int herbLevel = profile.getSkillLevel(SkillType.HERBALISM);
int id = block.getTypeId(); int id = block.getTypeId();
@ -101,12 +104,15 @@ public class Herbalism {
boolean customPlant = false; boolean customPlant = false;
int randomChance = 1000; int randomChance = 100;
if (player.hasPermission("mcmmo.perks.lucky.herbalism")) { if (player.hasPermission("mcmmo.perks.lucky.herbalism")) {
randomChance = (int) (randomChance * 0.75); randomChance = (int) (randomChance * 0.75);
} }
float chance = (float) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * herbLevel);
if (chance > MAX_CHANCE) chance = (float) MAX_CHANCE;
switch (type) { switch (type) {
case BROWN_MUSHROOM: case BROWN_MUSHROOM:
case RED_MUSHROOM: case RED_MUSHROOM:
@ -122,7 +128,7 @@ public class Herbalism {
if (b.getType().equals(Material.CACTUS)) { if (b.getType().equals(Material.CACTUS)) {
mat = Material.CACTUS; mat = Material.CACTUS;
if (!mcMMO.placeStore.isTrue(b)) { if (!mcMMO.placeStore.isTrue(b)) {
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(randomChance) <= herbLevel) { if (chance > random.nextInt(randomChance)) {
catciDrops++; catciDrops++;
} }
xp += Config.getInstance().getHerbalismXPCactus(); xp += Config.getInstance().getHerbalismXPCactus();
@ -182,7 +188,7 @@ public class Herbalism {
if (b.getType().equals(Material.SUGAR_CANE_BLOCK)) { if (b.getType().equals(Material.SUGAR_CANE_BLOCK)) {
mat = Material.SUGAR_CANE; mat = Material.SUGAR_CANE;
if (!mcMMO.placeStore.isTrue(b)) { if (!mcMMO.placeStore.isTrue(b)) {
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(randomChance) <= herbLevel) { if (chance > random.nextInt(randomChance)) {
caneDrops++; caneDrops++;
} }
xp += Config.getInstance().getHerbalismXPSugarCane(); xp += Config.getInstance().getHerbalismXPSugarCane();
@ -275,7 +281,7 @@ public class Herbalism {
} }
} }
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(randomChance) <= herbLevel) { if (chance > random.nextInt(randomChance)) {
Config configInstance = Config.getInstance(); Config configInstance = Config.getInstance();
switch (type) { switch (type) {
@ -399,7 +405,8 @@ public class Herbalism {
* @param plugin mcMMO plugin instance * @param plugin mcMMO plugin instance
*/ */
private static void greenThumbWheat(Block block, Player player, BlockBreakEvent event, mcMMO plugin) { private static void greenThumbWheat(Block block, Player player, BlockBreakEvent event, mcMMO plugin) {
final int MAX_BONUS_LEVEL = 1500; final int MAX_CHANCE = advancedConfig.getGreenThumbChanceMax();
final int MAX_BONUS_LEVEL = advancedConfig.getGreenThumbMaxLevel();
PlayerProfile profile = Users.getProfile(player); PlayerProfile profile = Users.getProfile(player);
int herbLevel = profile.getSkillLevel(SkillType.HERBALISM); int herbLevel = profile.getSkillLevel(SkillType.HERBALISM);
@ -429,13 +436,16 @@ public class Herbalism {
break; break;
} }
int randomChance = 1500; int randomChance = 100;
if (player.hasPermission("mcmmo.perks.lucky.herbalism")) { if (player.hasPermission("mcmmo.perks.lucky.herbalism")) {
randomChance = (int) (randomChance * 0.75); randomChance = (int) (randomChance * 0.75);
} }
if (hasSeeds && profile.getAbilityMode(AbilityType.GREEN_TERRA) || hasSeeds && (herbLevel > MAX_BONUS_LEVEL || random.nextInt(randomChance) <= herbLevel)) { float chance = (float) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * herbLevel);
if (chance > MAX_CHANCE) chance = (float) MAX_CHANCE;
if (hasSeeds && profile.getAbilityMode(AbilityType.GREEN_TERRA) || hasSeeds && (chance > random.nextInt(randomChance))) {
event.setCancelled(true); event.setCancelled(true);
switch(type) { switch(type) {
@ -481,7 +491,8 @@ public class Herbalism {
* @param block The block being used in the ability * @param block The block being used in the ability
*/ */
public static void greenThumbBlocks(ItemStack is, Player player, Block block) { public static void greenThumbBlocks(ItemStack is, Player player, Block block) {
final int MAX_BONUS_LEVEL = 1500; final int MAX_CHANCE = advancedConfig.getGreenThumbChanceMax();
final int MAX_BONUS_LEVEL = advancedConfig.getGreenThumbMaxLevel();
PlayerProfile profile = Users.getProfile(player); PlayerProfile profile = Users.getProfile(player);
int skillLevel = profile.getSkillLevel(SkillType.HERBALISM); int skillLevel = profile.getSkillLevel(SkillType.HERBALISM);
@ -489,13 +500,16 @@ public class Herbalism {
player.setItemInHand(new ItemStack(Material.SEEDS, seeds - 1)); player.setItemInHand(new ItemStack(Material.SEEDS, seeds - 1));
int randomChance = 1500; int randomChance = 100;
if (player.hasPermission("mcmmo.perks.lucky.herbalism")) { if (player.hasPermission("mcmmo.perks.lucky.herbalism")) {
randomChance = (int) (randomChance * 0.75); randomChance = (int) (randomChance * 0.75);
} }
if (skillLevel > MAX_BONUS_LEVEL || random.nextInt(randomChance) <= skillLevel) { float chance = (float) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * skillLevel);
if (chance > MAX_CHANCE) chance = (float) MAX_CHANCE;
if (chance > random.nextInt(randomChance)) {
greenTerraConvert(player, block); greenTerraConvert(player, block);
} }
else { else {

View File

@ -356,6 +356,7 @@ public class WoodCutting {
int randomChance = 100; int randomChance = 100;
int chance = (int) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * skillLevel); int chance = (int) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * skillLevel);
if (chance > MAX_CHANCE) chance = MAX_CHANCE;
if (player.hasPermission("mcmmo.perks.lucky.woodcutting")) { if (player.hasPermission("mcmmo.perks.lucky.woodcutting")) {
randomChance = (int) (randomChance * 0.75); randomChance = (int) (randomChance * 0.75);

View File

@ -31,10 +31,10 @@ public class Repair {
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private static int repairMasteryChanceMax = advancedConfig.getRepairMasteryChanceMax(); public static final int REPAIR_MASTERY_CHANCE_MAX = advancedConfig.getRepairMasteryChanceMax();
private static int repairMasteryMaxBonusLevel = advancedConfig.getRepairMasteryMaxLevel(); public static final int REPAIR_MASTERY_MAX_BONUS_LEVEL = advancedConfig.getRepairMasteryMaxLevel();
private static int superRepairChanceMax = advancedConfig.getSuperRepairChanceMax(); public static final int SUPER_REPAIR_CHANCE_MAX = advancedConfig.getSuperRepairChanceMax();
private static int superRepairMaxBonusLevel = advancedConfig.getSuperRepairMaxLevel(); public static final int SUPER_REPAIR_MAX_BONUS_LEVEL = advancedConfig.getSuperRepairMaxLevel();
/** /**
* Handle the XP gain for repair events. * Handle the XP gain for repair events.
@ -241,8 +241,8 @@ public class Repair {
*/ */
protected static short repairCalculate(Player player, int skillLevel, short durability, int repairAmount) { protected static short repairCalculate(Player player, int skillLevel, short durability, int repairAmount) {
float bonus; float bonus;
if(skillLevel >= repairMasteryMaxBonusLevel) bonus = ((float) repairMasteryChanceMax / 100F); if(skillLevel >= REPAIR_MASTERY_MAX_BONUS_LEVEL) bonus = ((float) REPAIR_MASTERY_CHANCE_MAX / 100F);
else bonus = (((float) skillLevel) / ((float) repairMasteryMaxBonusLevel)) * (((float) repairMasteryChanceMax) / 100F); else bonus = (((float) skillLevel) / ((float) REPAIR_MASTERY_MAX_BONUS_LEVEL)) * (((float) REPAIR_MASTERY_CHANCE_MAX) / 100F);
if (permInstance.repairMastery(player)) { if (permInstance.repairMastery(player)) {
bonus = (((float) repairAmount) * bonus); bonus = (((float) repairAmount) * bonus);
@ -272,14 +272,11 @@ public class Repair {
* @return true if bonus granted, false otherwise * @return true if bonus granted, false otherwise
*/ */
public static boolean checkPlayerProcRepair(Player player) { public static boolean checkPlayerProcRepair(Player player) {
final int MAX_CHANCE = superRepairChanceMax;
final int MAX_BONUS_LEVEL = superRepairMaxBonusLevel;
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR); int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR);
int randomChance = 100; int randomChance = 100;
int chance = (int) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * skillLevel); int chance = (int) (((double) SUPER_REPAIR_CHANCE_MAX / (double) SUPER_REPAIR_MAX_BONUS_LEVEL) * skillLevel);
if (skillLevel >= MAX_BONUS_LEVEL) chance = MAX_CHANCE; if (skillLevel >= SUPER_REPAIR_MAX_BONUS_LEVEL) chance = SUPER_REPAIR_CHANCE_MAX;
if (player.hasPermission("mcmmo.perks.lucky.repair")) randomChance = (int) (randomChance * 0.75); if (player.hasPermission("mcmmo.perks.lucky.repair")) randomChance = (int) (randomChance * 0.75);

View File

@ -7,10 +7,12 @@ import com.gmail.nossr50.config.AdvancedConfig;
public class Swords { public class Swords {
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
public static final int BLEED_CHANCE_MAX = AdvancedConfig.getInstance().getBleedChanceMax();
public static final int BLEED_MAX_BONUS_LEVEL = advancedConfig.getBleedMaxBonusLevel(); public static final int BLEED_MAX_BONUS_LEVEL = advancedConfig.getBleedMaxBonusLevel();
public static final int MAX_BLEED_TICKS = advancedConfig.getBleedMaxTicks(); public static final int MAX_BLEED_TICKS = advancedConfig.getBleedMaxTicks();
public static final int BASE_BLEED_TICKS = advancedConfig.getBleedBaseTicks(); public static final int BASE_BLEED_TICKS = advancedConfig.getBleedBaseTicks();
public static final int COUNTER_ATTACK_CHANCE_MAX = advancedConfig.getCounterChanceMax();
public static final int COUNTER_ATTACK_MAX_BONUS_LEVEL = advancedConfig.getCounterMaxBonusLevel(); public static final int COUNTER_ATTACK_MAX_BONUS_LEVEL = advancedConfig.getCounterMaxBonusLevel();
public static final int COUNTER_ATTACK_MODIFIER = advancedConfig.getCounterModifier(); public static final int COUNTER_ATTACK_MODIFIER = advancedConfig.getCounterModifier();

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.skills.swords;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.util.Combat; import com.gmail.nossr50.util.Combat;
@ -42,15 +41,15 @@ public class SwordsManager {
if (Combat.shouldBeAffected(player, defender)) { if (Combat.shouldBeAffected(player, defender)) {
BleedEventHandler eventHandler = new BleedEventHandler(this, defender); BleedEventHandler eventHandler = new BleedEventHandler(this, defender);
int bleedChanceMax = AdvancedConfig.getInstance().getBleedChanceMax();
int bleedMaxLevel = AdvancedConfig.getInstance().getBleedMaxBonusLevel();
int randomChance = 100; int randomChance = 100;
if (player.hasPermission("mcmmo.perks.lucky.swords")) { if (player.hasPermission("mcmmo.perks.lucky.swords")) {
randomChance = (int) (randomChance * 0.75); randomChance = (int) (randomChance * 0.75);
} }
final float chance = (float) (((double) bleedChanceMax / (double) bleedMaxLevel) * skillLevel); float chance = (float) (((double) Swords.BLEED_CHANCE_MAX / (double) Swords.BLEED_MAX_BONUS_LEVEL) * skillLevel);
if (chance > Swords.BLEED_CHANCE_MAX) chance = Swords.BLEED_CHANCE_MAX;
if (chance > Swords.getRandom().nextInt(randomChance)) { if (chance > Swords.getRandom().nextInt(randomChance)) {
eventHandler.addBleedTicks(); eventHandler.addBleedTicks();
eventHandler.sendAbilityMessages(); eventHandler.sendAbilityMessages();
@ -73,15 +72,16 @@ public class SwordsManager {
if (eventHandler.isHoldingSword()) { if (eventHandler.isHoldingSword()) {
eventHandler.calculateSkillModifier(); eventHandler.calculateSkillModifier();
int counterChanceMax = AdvancedConfig.getInstance().getCounterChanceMax();
int counterMaxLevel = AdvancedConfig.getInstance().getCounterMaxBonusLevel();
int randomChance = 100; int randomChance = 100;
if (player.hasPermission("mcmmo.perks.lucky.swords")) { if (player.hasPermission("mcmmo.perks.lucky.swords")) {
randomChance = (int) (randomChance * 0.75); randomChance = (int) (randomChance * 0.75);
} }
final float chance = (float) (((double) counterChanceMax / (double) counterMaxLevel) * skillLevel); float chance = (float) (((double) Swords.COUNTER_ATTACK_CHANCE_MAX / (double) Swords.COUNTER_ATTACK_MAX_BONUS_LEVEL) * skillLevel);
if (chance > Swords.COUNTER_ATTACK_CHANCE_MAX) chance = Swords.COUNTER_ATTACK_CHANCE_MAX;
if (chance > Swords.getRandom().nextInt(randomChance)) { if (chance > Swords.getRandom().nextInt(randomChance)) {
eventHandler.dealDamage(); eventHandler.dealDamage();
eventHandler.sendAbilityMessages(); eventHandler.sendAbilityMessages();

View File

@ -12,6 +12,7 @@ public class Taming {
public static final int FAST_FOOD_SERVICE_ACTIVATION_CHANCE = advancedConfig.getFastFoodChance(); public static final int FAST_FOOD_SERVICE_ACTIVATION_CHANCE = advancedConfig.getFastFoodChance();
public static final int FAST_FOOD_SERVICE_ACTIVATION_LEVEL = advancedConfig.getFastFoodUnlock(); public static final int FAST_FOOD_SERVICE_ACTIVATION_LEVEL = advancedConfig.getFastFoodUnlock();
public static final int GORE_CHANCE_MAX = AdvancedConfig.getInstance().getGoreChanceMax();
public static final int GORE_BLEED_TICKS = advancedConfig.getGoreBleedTicks(); public static final int GORE_BLEED_TICKS = advancedConfig.getGoreBleedTicks();
public static final int GORE_MAX_BONUS_LEVEL = advancedConfig.getGoreMaxBonusLevel(); public static final int GORE_MAX_BONUS_LEVEL = advancedConfig.getGoreMaxBonusLevel();
public static final int GORE_MULTIPLIER = advancedConfig.getGoreModifier(); public static final int GORE_MULTIPLIER = advancedConfig.getGoreModifier();

View File

@ -8,7 +8,6 @@ import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.datatypes.SkillType;
@ -103,15 +102,15 @@ public class TamingManager {
GoreEventHandler eventHandler = new GoreEventHandler(this, event); GoreEventHandler eventHandler = new GoreEventHandler(this, event);
int goreChanceMax = AdvancedConfig.getInstance().getGoreChanceMax();
int goreMaxLevel = AdvancedConfig.getInstance().getGoreMaxBonusLevel();
int randomChance = 100; int randomChance = 100;
if (player.hasPermission("mcmmo.perks.lucky.taming")) { if (player.hasPermission("mcmmo.perks.lucky.taming")) {
randomChance = (int) (randomChance * 0.75); randomChance = (int) (randomChance * 0.75);
} }
final float chance = (float) (((double) goreChanceMax / (double) goreMaxLevel) * skillLevel); float chance = (float) (((double) Taming.GORE_CHANCE_MAX / (double) Taming.GORE_MAX_BONUS_LEVEL) * skillLevel);
if (chance > Taming.GORE_CHANCE_MAX) chance = Taming.GORE_CHANCE_MAX;
if (chance > Taming.getRandom().nextInt(randomChance)) { if (chance > Taming.getRandom().nextInt(randomChance)) {
eventHandler.modifyEventDamage(); eventHandler.modifyEventDamage();
eventHandler.applyBleed(); eventHandler.applyBleed();

View File

@ -9,10 +9,13 @@ public class Unarmed {
public static final int BONUS_DAMAGE_MAX_BONUS_MODIFIER = advancedConfig.getIronArmBonus(); public static final int BONUS_DAMAGE_MAX_BONUS_MODIFIER = advancedConfig.getIronArmBonus();
public static final int BONUS_DAMAGE_INCREASE_LEVEL = advancedConfig.getIronArmIncreaseLevel(); public static final int BONUS_DAMAGE_INCREASE_LEVEL = advancedConfig.getIronArmIncreaseLevel();
public static final int DEFLECT_MAX_CHANCE = advancedConfig.getDisarmChanceMax() ; public static final int DEFLECT_MAX_CHANCE = advancedConfig.getDisarmChanceMax() ;
public static final int DEFLECT_MAX_BONUS_LEVEL = advancedConfig.getDisarmMaxBonusLevel(); public static final int DEFLECT_MAX_BONUS_LEVEL = advancedConfig.getDisarmMaxBonusLevel();
public static final int DISARM_MAX_CHANCE = advancedConfig.getDeflectChanceMax(); public static final int DISARM_MAX_CHANCE = advancedConfig.getDeflectChanceMax();
public static final int DISARM_MAX_BONUS_LEVEL = advancedConfig.getDeflectMaxBonusLevel(); public static final int DISARM_MAX_BONUS_LEVEL = advancedConfig.getDeflectMaxBonusLevel();
public static final int IRON_GRIP_MAX_CHANCE = advancedConfig.getIronGripChanceMax(); public static final int IRON_GRIP_MAX_CHANCE = advancedConfig.getIronGripChanceMax();
public static final int IRON_GRIP_MAX_BONUS_LEVEL = advancedConfig.getIronGripMaxBonusLevel(); public static final int IRON_GRIP_MAX_BONUS_LEVEL = advancedConfig.getIronGripMaxBonusLevel();

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.skills.unarmed;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
@ -43,15 +42,15 @@ public class UnarmedManager {
if (eventHandler.isHoldingItem()) { if (eventHandler.isHoldingItem()) {
eventHandler.calculateSkillModifier(); eventHandler.calculateSkillModifier();
int disarmChanceMax = AdvancedConfig.getInstance().getDisarmChanceMax();
int disarmMaxLevel = AdvancedConfig.getInstance().getDisarmMaxBonusLevel();
int randomChance = 100; int randomChance = 100;
if (player.hasPermission("mcmmo.perks.lucky.unarmed")) { if (player.hasPermission("mcmmo.perks.lucky.unarmed")) {
randomChance = (int) (randomChance * 0.75); randomChance = (int) (randomChance * 0.75);
} }
final float chance = (float) (((double) disarmChanceMax / (double) disarmMaxLevel) * skillLevel); float chance = (float) (((double) Unarmed.DISARM_MAX_CHANCE / (double) Unarmed.DISARM_MAX_BONUS_LEVEL) * skillLevel);
if (chance > Unarmed.DISARM_MAX_CHANCE) chance = Unarmed.DISARM_MAX_CHANCE;
if (chance > Unarmed.getRandom().nextInt(randomChance)) { if (chance > Unarmed.getRandom().nextInt(randomChance)) {
if (!hasIronGrip(defender)) { if (!hasIronGrip(defender)) {
eventHandler.sendAbilityMessage(); eventHandler.sendAbilityMessage();
@ -80,15 +79,15 @@ public class UnarmedManager {
DeflectEventHandler eventHandler = new DeflectEventHandler(this, event); DeflectEventHandler eventHandler = new DeflectEventHandler(this, event);
int deflectChanceMax = AdvancedConfig.getInstance().getDeflectChanceMax();
int deflectMaxLevel = AdvancedConfig.getInstance().getDeflectMaxBonusLevel();
int randomChance = 100; int randomChance = 100;
if (player.hasPermission("mcmmo.perks.lucky.unarmed")) { if (player.hasPermission("mcmmo.perks.lucky.unarmed")) {
randomChance = (int) (randomChance * 0.75); randomChance = (int) (randomChance * 0.75);
} }
final float chance = (float) (((double) deflectChanceMax / (double) deflectMaxLevel) * skillLevel); float chance = (float) (((double) Unarmed.DEFLECT_MAX_CHANCE / (double) Unarmed.DEFLECT_MAX_BONUS_LEVEL) * skillLevel);
if (chance > Unarmed.DEFLECT_MAX_CHANCE) chance = Unarmed.DEFLECT_MAX_CHANCE;
if (chance > Unarmed.getRandom().nextInt(randomChance)) { if (chance > Unarmed.getRandom().nextInt(randomChance)) {
eventHandler.cancelEvent(); eventHandler.cancelEvent();
eventHandler.sendAbilityMessage(); eventHandler.sendAbilityMessage();
@ -136,15 +135,15 @@ public class UnarmedManager {
IronGripEventHandler eventHandler = new IronGripEventHandler(this, defender); IronGripEventHandler eventHandler = new IronGripEventHandler(this, defender);
int ironGripChanceMax = AdvancedConfig.getInstance().getIronGripChanceMax();
int ironGripMaxLevel = AdvancedConfig.getInstance().getIronGripMaxBonusLevel();
int randomChance = 100; int randomChance = 100;
if (defender.hasPermission("mcmmo.perks.lucky.unarmed")) { if (defender.hasPermission("mcmmo.perks.lucky.unarmed")) {
randomChance = (int) (randomChance * 0.75); randomChance = (int) (randomChance * 0.75);
} }
final float chance = (float) (((double) ironGripChanceMax / (double) ironGripMaxLevel) * skillLevel); float chance = (float) (((double) Unarmed.IRON_GRIP_MAX_CHANCE / (double) Unarmed.IRON_GRIP_MAX_BONUS_LEVEL) * skillLevel);
if (chance > Unarmed.IRON_GRIP_MAX_CHANCE) chance = Unarmed.IRON_GRIP_MAX_CHANCE;
if (chance > Unarmed.getRandom().nextInt(randomChance)) { if (chance > Unarmed.getRandom().nextInt(randomChance)) {
eventHandler.sendAbilityMessages(); eventHandler.sendAbilityMessages();
return true; return true;