mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-25 18:17:46 +01:00
Copy-pasta code is bad.
This commit is contained in:
parent
67fd45ef25
commit
ddbf5a559a
@ -4,17 +4,21 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public abstract class SkillManager {
|
||||
protected Player player;
|
||||
protected PlayerProfile profile;
|
||||
protected int skillLevel;
|
||||
protected int activationChance;
|
||||
|
||||
public SkillManager(Player player, SkillType skill) {
|
||||
this.player = player;
|
||||
this.profile = Users.getProfile(player);
|
||||
this.skillLevel = profile.getSkillLevel(skill);
|
||||
this.activationChance = Misc.calculateActivationChance(Permissions.lucky(player, skill));
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
@ -28,4 +32,8 @@ public abstract class SkillManager {
|
||||
public int getSkillLevel() {
|
||||
return skillLevel;
|
||||
}
|
||||
|
||||
public int getActivationChance() {
|
||||
return activationChance;
|
||||
}
|
||||
}
|
||||
|
@ -30,11 +30,6 @@ public class AcrobaticsManager extends SkillManager {
|
||||
|
||||
RollEventHandler eventHandler = new RollEventHandler(this, event);
|
||||
|
||||
int randomChance = 100;
|
||||
if (Permissions.luckyAcrobatics(player)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
|
||||
double chance;
|
||||
|
||||
if (eventHandler.isGraceful) {
|
||||
@ -44,7 +39,7 @@ public class AcrobaticsManager extends SkillManager {
|
||||
chance = (Acrobatics.rollMaxChance / Acrobatics.rollMaxBonusLevel) * eventHandler.skillModifier;
|
||||
}
|
||||
|
||||
if (chance > Misc.getRandom().nextInt(randomChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
|
||||
if (chance > Misc.getRandom().nextInt(activationChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
|
||||
eventHandler.modifyEventDamage();
|
||||
eventHandler.sendAbilityMessage();
|
||||
eventHandler.processXPGain(eventHandler.damage * Acrobatics.rollXpModifier);
|
||||
@ -66,14 +61,9 @@ public class AcrobaticsManager extends SkillManager {
|
||||
|
||||
DodgeEventHandler eventHandler = new DodgeEventHandler(this, event);
|
||||
|
||||
int randomChance = 100;
|
||||
if (Permissions.luckyAcrobatics(player)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
|
||||
double chance = (Acrobatics.dodgeMaxChance / Acrobatics.dodgeMaxBonusLevel) * eventHandler.skillModifier;
|
||||
|
||||
if (chance > Misc.getRandom().nextInt(randomChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
|
||||
if (chance > Misc.getRandom().nextInt(activationChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
|
||||
eventHandler.modifyEventDamage();
|
||||
eventHandler.sendAbilityMessage();
|
||||
eventHandler.processXPGain(eventHandler.damage * Acrobatics.dodgeXpModifier);
|
||||
|
@ -26,14 +26,9 @@ public class ArcheryManager extends SkillManager {
|
||||
|
||||
ArrowTrackingEventHandler eventHandler = new ArrowTrackingEventHandler(this, livingEntity);
|
||||
|
||||
int randomChance = 100;
|
||||
if (Permissions.luckyArchery(player)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
|
||||
double chance = (Archery.retrieveMaxChance / Archery.retrieveMaxBonusLevel) * eventHandler.skillModifier;
|
||||
|
||||
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||
eventHandler.addToTracker();
|
||||
}
|
||||
}
|
||||
@ -51,14 +46,9 @@ public class ArcheryManager extends SkillManager {
|
||||
|
||||
DazeEventHandler eventHandler = new DazeEventHandler(this, event, defender);
|
||||
|
||||
int randomChance = 100;
|
||||
if (Permissions.luckyArchery(player)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
|
||||
double chance = (Archery.dazeMaxBonus / Archery.dazeMaxBonusLevel) * eventHandler.skillModifier;
|
||||
|
||||
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||
eventHandler.handleDazeEffect();
|
||||
eventHandler.sendAbilityMessages();
|
||||
}
|
||||
|
@ -47,14 +47,9 @@ public class AxeManager extends SkillManager {
|
||||
return;
|
||||
}
|
||||
|
||||
int randomChance = 100;
|
||||
if (Permissions.luckyAxes(player)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
|
||||
double chance = (Axes.criticalHitMaxChance / Axes.criticalHitMaxBonusLevel) * eventHandler.skillModifier;
|
||||
|
||||
if (chance > Misc.getRandom().nextInt(randomChance) && !eventHandler.defender.isDead()) {
|
||||
if (chance > Misc.getRandom().nextInt(activationChance) && !eventHandler.defender.isDead()) {
|
||||
eventHandler.modifyEventDamage();
|
||||
eventHandler.sendAbilityMessages();
|
||||
}
|
||||
|
@ -62,12 +62,7 @@ public class ImpactEventHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
int randomChance = 100;
|
||||
if (Permissions.luckyAxes(player)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
|
||||
if (Misc.getRandom().nextInt(randomChance) <= Axes.greaterImpactChance) {
|
||||
if (Misc.getRandom().nextInt(manager.getActivationChance()) <= Axes.greaterImpactChance) {
|
||||
handleGreaterImpactEffect();
|
||||
sendAbilityMessge();
|
||||
}
|
||||
|
@ -94,13 +94,9 @@ public class Excavation {
|
||||
|
||||
for (ExcavationTreasure treasure : treasures) {
|
||||
if (skillLevel >= treasure.getDropLevel()) {
|
||||
int randomChance = 100;
|
||||
int activationChance = Misc.calculateActivationChance(Permissions.luckyExcavation(player));
|
||||
|
||||
if (Permissions.luckyExcavation(player)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
|
||||
if (Misc.getRandom().nextDouble() * randomChance <= treasure.getDropChance()) {
|
||||
if (Misc.getRandom().nextDouble() * activationChance <= treasure.getDropChance()) {
|
||||
xp += treasure.getXp();
|
||||
is.add(treasure.getDrop());
|
||||
}
|
||||
|
@ -95,12 +95,9 @@ public class Fishing {
|
||||
|
||||
FishingTreasure foundTreasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
|
||||
|
||||
int randomChance = 100;
|
||||
if (Permissions.luckyFishing(player)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
int activationChance = Misc.calculateActivationChance(Permissions.luckyFishing(player));
|
||||
|
||||
if (Misc.getRandom().nextDouble() * randomChance <= foundTreasure.getDropChance()) {
|
||||
if (Misc.getRandom().nextDouble() * activationChance <= foundTreasure.getDropChance()) {
|
||||
Users.getPlayer(player).addXP(SkillType.FISHING, foundTreasure.getXp());
|
||||
theCatch.setItemStack(foundTreasure.getDrop());
|
||||
}
|
||||
@ -144,14 +141,10 @@ public class Fishing {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.ItemFound"));
|
||||
|
||||
if (ItemChecks.isEnchantable(fishingResults)) {
|
||||
int randomChance = 100;
|
||||
|
||||
if (Permissions.luckyFishing(player)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
int activationChance = Misc.calculateActivationChance(Permissions.luckyFishing(player));
|
||||
|
||||
if (player.getWorld().hasStorm()) {
|
||||
randomChance = (int) (randomChance * 0.909);
|
||||
activationChance = (int) (activationChance * 0.909);
|
||||
}
|
||||
|
||||
/* CHANCE OF ITEM BEING ENCHANTED
|
||||
@ -161,7 +154,7 @@ public class Fishing {
|
||||
* 20% - Tier 4
|
||||
* 25% - Tier 5
|
||||
*/
|
||||
if (Misc.getRandom().nextInt(randomChance) <= (lootTier * magicHunterMultiplier) && Permissions.fishingMagic(player)) {
|
||||
if (Misc.getRandom().nextInt(activationChance) <= (lootTier * magicHunterMultiplier) && Permissions.fishingMagic(player)) {
|
||||
for (Enchantment newEnchant : Enchantment.values()) {
|
||||
boolean conflicts = false;
|
||||
|
||||
@ -218,6 +211,7 @@ public class Fishing {
|
||||
public static void shakeMob(PlayerFishEvent event) {
|
||||
int randomChance = 100;
|
||||
|
||||
//TODO: Invert this so it matches the rest of our lucky checks...
|
||||
if (Permissions.luckyFishing(event.getPlayer())) {
|
||||
randomChance = 125;
|
||||
}
|
||||
|
@ -101,11 +101,7 @@ public class Herbalism {
|
||||
|
||||
boolean customPlant = false;
|
||||
|
||||
int randomChance = 100;
|
||||
|
||||
if (Permissions.luckyHerbalism(player)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
int activationChance = Misc.calculateActivationChance(Permissions.luckyHerbalism(player));
|
||||
|
||||
float chance = (float) ((MAX_CHANCE / MAX_BONUS_LEVEL) * herbLevel);
|
||||
if (chance > MAX_CHANCE) chance = (float) MAX_CHANCE;
|
||||
@ -125,7 +121,7 @@ public class Herbalism {
|
||||
if (b.getType().equals(Material.CACTUS)) {
|
||||
mat = Material.CACTUS;
|
||||
if (!mcMMO.placeStore.isTrue(b)) {
|
||||
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||
catciDrops++;
|
||||
}
|
||||
xp += Config.getInstance().getHerbalismXPCactus();
|
||||
@ -185,7 +181,7 @@ public class Herbalism {
|
||||
if (b.getType().equals(Material.SUGAR_CANE_BLOCK)) {
|
||||
mat = Material.SUGAR_CANE;
|
||||
if (!mcMMO.placeStore.isTrue(b)) {
|
||||
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||
caneDrops++;
|
||||
}
|
||||
xp += Config.getInstance().getHerbalismXPSugarCane();
|
||||
@ -286,7 +282,7 @@ public class Herbalism {
|
||||
}
|
||||
}
|
||||
|
||||
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
switch (type) {
|
||||
@ -448,16 +444,12 @@ public class Herbalism {
|
||||
break;
|
||||
}
|
||||
|
||||
int randomChance = 100;
|
||||
|
||||
if (Permissions.luckyHerbalism(player)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
int activationChance = Misc.calculateActivationChance(Permissions.luckyHerbalism(player));
|
||||
|
||||
float chance = (float) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * herbLevel);
|
||||
if (chance > MAX_CHANCE) chance = MAX_CHANCE;
|
||||
|
||||
if (hasSeeds && profile.getAbilityMode(AbilityType.GREEN_TERRA) || hasSeeds && (chance > Misc.getRandom().nextInt(randomChance))) {
|
||||
if (hasSeeds && profile.getAbilityMode(AbilityType.GREEN_TERRA) || hasSeeds && (chance > Misc.getRandom().nextInt(activationChance))) {
|
||||
event.setCancelled(true);
|
||||
|
||||
switch(type) {
|
||||
@ -522,16 +514,12 @@ public class Herbalism {
|
||||
|
||||
player.setItemInHand(new ItemStack(Material.SEEDS, seeds - 1));
|
||||
|
||||
int randomChance = 100;
|
||||
|
||||
if (Permissions.luckyHerbalism(player)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
int activationChance = Misc.calculateActivationChance(Permissions.luckyHerbalism(player));
|
||||
|
||||
float chance = (float) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * skillLevel);
|
||||
if (chance > MAX_CHANCE) chance = MAX_CHANCE;
|
||||
|
||||
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||
greenTerraConvert(player, block);
|
||||
}
|
||||
else {
|
||||
@ -542,12 +530,9 @@ public class Herbalism {
|
||||
public static void hylianLuck(Block block, Player player, BlockBreakEvent event) {
|
||||
int chance = Users.getProfile(player).getSkillLevel(SkillType.HERBALISM) / 100;
|
||||
|
||||
int randomChance = 100;
|
||||
if (Permissions.luckyHerbalism(player)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
int activationChance = Misc.calculateActivationChance(Permissions.luckyHerbalism(player));
|
||||
|
||||
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||
Location location = block.getLocation();
|
||||
int dropNumber = Misc.getRandom().nextInt(3);
|
||||
ItemStack item = null;
|
||||
|
@ -353,15 +353,12 @@ public class WoodCutting {
|
||||
|
||||
Material mat = Material.getMaterial(block.getTypeId());
|
||||
|
||||
int randomChance = 100;
|
||||
int chance = (int) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * skillLevel);
|
||||
if (chance > MAX_CHANCE) chance = MAX_CHANCE;
|
||||
|
||||
if (Permissions.luckyWoodcutting(player)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
int activationChance = Misc.calculateActivationChance(Permissions.luckyWoodcutting(player));
|
||||
|
||||
if (chance > Misc.getRandom().nextInt(randomChance) && Permissions.woodcuttingDoubleDrops(player)) {
|
||||
if (chance > Misc.getRandom().nextInt(activationChance) && Permissions.woodcuttingDoubleDrops(player)) {
|
||||
Config configInstance = Config.getInstance();
|
||||
ItemStack item;
|
||||
Location location;
|
||||
|
@ -132,14 +132,9 @@ public class MiningManager extends SkillManager{
|
||||
return;
|
||||
}
|
||||
|
||||
int randomChance = 100;
|
||||
if (Permissions.luckyMining(player)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
|
||||
float chance = ((float) Mining.DOUBLE_DROPS_MAX_CHANCE / Mining.DOUBLE_DROPS_MAX_BONUS_LEVEL) * eventHandler.skillModifier;
|
||||
|
||||
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||
eventHandler.processDrops();
|
||||
}
|
||||
}
|
||||
|
@ -110,17 +110,13 @@ public class Repair {
|
||||
for (Entry<Enchantment, Integer> enchant : enchants.entrySet()) {
|
||||
Enchantment enchantment = enchant.getKey();
|
||||
|
||||
int randomChance = 100;
|
||||
int activationChance = Misc.calculateActivationChance(Permissions.luckyRepair(player));
|
||||
|
||||
if (Permissions.luckyRepair(player)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
|
||||
if (Misc.getRandom().nextInt(randomChance) <= getEnchantChance(rank)) {
|
||||
if (Misc.getRandom().nextInt(activationChance) <= getEnchantChance(rank)) {
|
||||
int enchantLevel = enchant.getValue();
|
||||
|
||||
if (advancedConfig.getArcaneForgingDowngradeEnabled() && enchantLevel > 1) {
|
||||
if (Misc.getRandom().nextInt(randomChance) < getDowngradeChance(rank)) {
|
||||
if (Misc.getRandom().nextInt(activationChance) < getDowngradeChance(rank)) {
|
||||
is.addEnchantment(enchantment, --enchantLevel);
|
||||
downgraded = true;
|
||||
}
|
||||
@ -238,13 +234,12 @@ public class Repair {
|
||||
public static boolean checkPlayerProcRepair(Player player) {
|
||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR);
|
||||
|
||||
int randomChance = 100;
|
||||
int chance = (int) (((double) SUPER_REPAIR_CHANCE_MAX / (double) SUPER_REPAIR_MAX_BONUS_LEVEL) * skillLevel);
|
||||
if (skillLevel >= SUPER_REPAIR_MAX_BONUS_LEVEL) chance = SUPER_REPAIR_CHANCE_MAX;
|
||||
|
||||
if (Permissions.luckyRepair(player)) randomChance = 75;
|
||||
int activationChance = Misc.calculateActivationChance(Permissions.luckyRepair(player));
|
||||
|
||||
if (chance > Misc.getRandom().nextInt(randomChance) && Permissions.repairBonus(player)) {
|
||||
if (chance > Misc.getRandom().nextInt(activationChance) && Permissions.repairBonus(player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy"));
|
||||
return true;
|
||||
}
|
||||
|
@ -31,16 +31,10 @@ public class SwordsManager extends SkillManager {
|
||||
if (Combat.shouldBeAffected(player, defender)) {
|
||||
BleedEventHandler eventHandler = new BleedEventHandler(this, defender);
|
||||
|
||||
int randomChance = 100;
|
||||
|
||||
if (Permissions.luckySwords(player)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
|
||||
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 > Misc.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||
eventHandler.addBleedTicks();
|
||||
eventHandler.sendAbilityMessages();
|
||||
}
|
||||
@ -60,16 +54,10 @@ public class SwordsManager extends SkillManager {
|
||||
if (eventHandler.isHoldingSword()) {
|
||||
eventHandler.calculateSkillModifier();
|
||||
|
||||
int randomChance = 100;
|
||||
|
||||
if (Permissions.luckySwords(player)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
|
||||
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 > Misc.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||
eventHandler.dealDamage();
|
||||
eventHandler.sendAbilityMessages();
|
||||
}
|
||||
|
@ -37,13 +37,7 @@ public class TamingManager extends SkillManager {
|
||||
}
|
||||
|
||||
if (skillLevel >= Taming.FAST_FOOD_SERVICE_ACTIVATION_LEVEL) {
|
||||
int randomChance = 100;
|
||||
|
||||
if (Permissions.luckyTaming(player)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
|
||||
if (Misc.getRandom().nextInt(randomChance) < Taming.FAST_FOOD_SERVICE_ACTIVATION_CHANCE) {
|
||||
if (Misc.getRandom().nextInt(activationChance) < Taming.FAST_FOOD_SERVICE_ACTIVATION_CHANCE) {
|
||||
FastFoodServiceEventHandler eventHandler = new FastFoodServiceEventHandler(wolf);
|
||||
|
||||
eventHandler.modifyHealth(damage);
|
||||
@ -86,16 +80,10 @@ public class TamingManager extends SkillManager {
|
||||
|
||||
GoreEventHandler eventHandler = new GoreEventHandler(this, event);
|
||||
|
||||
int randomChance = 100;
|
||||
|
||||
if (Permissions.luckyTaming(player)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
|
||||
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 > Misc.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||
eventHandler.modifyEventDamage();
|
||||
eventHandler.applyBleed();
|
||||
eventHandler.sendAbilityMessage();
|
||||
|
@ -28,16 +28,10 @@ public class UnarmedManager extends SkillManager {
|
||||
if (eventHandler.isHoldingItem()) {
|
||||
eventHandler.calculateSkillModifier();
|
||||
|
||||
int randomChance = 100;
|
||||
|
||||
if (Permissions.luckyUnarmed(player)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
|
||||
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 > Misc.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||
if (!hasIronGrip(defender)) {
|
||||
eventHandler.handleDisarm();
|
||||
}
|
||||
@ -61,16 +55,10 @@ public class UnarmedManager extends SkillManager {
|
||||
|
||||
DeflectEventHandler eventHandler = new DeflectEventHandler(this, event);
|
||||
|
||||
int randomChance = 100;
|
||||
|
||||
if (Permissions.luckyUnarmed(player)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
|
||||
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 > Misc.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||
eventHandler.cancelEvent();
|
||||
eventHandler.sendAbilityMessage();
|
||||
}
|
||||
@ -111,16 +99,10 @@ public class UnarmedManager extends SkillManager {
|
||||
|
||||
IronGripEventHandler eventHandler = new IronGripEventHandler(this, defender);
|
||||
|
||||
int randomChance = 100;
|
||||
|
||||
if (Permissions.luckyUnarmed(defender)) {
|
||||
randomChance = 75;
|
||||
}
|
||||
|
||||
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 > Misc.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||
eventHandler.sendAbilityMessages();
|
||||
return true;
|
||||
}
|
||||
|
@ -33,6 +33,22 @@ public 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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player has armor.
|
||||
|
@ -3,6 +3,8 @@ package com.gmail.nossr50.util;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
|
||||
public class Permissions {
|
||||
public static boolean hasPermission(CommandSender sender, String perm)
|
||||
{
|
||||
@ -75,6 +77,10 @@ public class Permissions {
|
||||
* MCMMO.PERKS.LUCKY*
|
||||
*/
|
||||
|
||||
public static boolean lucky(Player player, SkillType skill) {
|
||||
return hasPermission(player, "mcmmo.perks.lucky." + skill.toString().toLowerCase());
|
||||
}
|
||||
|
||||
public static boolean luckyAcrobatics(Player player) {
|
||||
return hasPermission(player, "mcmmo.perks.lucky.acrobatics");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user