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