diff --git a/Changelog.txt b/Changelog.txt index 75a97c82d..1a1de3f00 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -12,6 +12,7 @@ Version 1.3.10-dev + Added ability for custom blocks to drop a range of items. + Added Ability API functions + Added 50% & 150% XP boost perks + + Added "lucky" perk for donors = Fixed "GenericLabel belonging to mcMMO..." message = Fixed menu exit button not working = Fixed Repair enchant downgrade not working diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java index 1455305e9..d1d41cdd9 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java @@ -32,7 +32,13 @@ public class AcrobaticsManager { RollEventHandler eventHandler = new RollEventHandler(this, event); - if (Acrobatics.getRandom().nextInt(1000) <= eventHandler.skillModifier && !eventHandler.isFatal(eventHandler.modifiedDamage)) { + int randomChance = 1000; + + if (player.hasPermission("mcmmo.perks.lucky.acrobatics")) { + randomChance = (int) (randomChance * 0.75); + } + + if (Acrobatics.getRandom().nextInt(randomChance) <= eventHandler.skillModifier && !eventHandler.isFatal(eventHandler.modifiedDamage)) { eventHandler.modifyEventDamage(); eventHandler.sendAbilityMessage(); eventHandler.processXPGain(eventHandler.damage * Acrobatics.ROLL_XP_MODIFIER); @@ -54,7 +60,13 @@ public class AcrobaticsManager { DodgeEventHandler eventHandler = new DodgeEventHandler(this, event); - if (Acrobatics.getRandom().nextInt(4000) <= eventHandler.skillModifier && !eventHandler.isFatal(eventHandler.modifiedDamage)) { + int randomChance = 4000; + + if (player.hasPermission("mcmmo.perks.lucky.acrobatics")) { + randomChance = (int) (randomChance * 0.75); + } + + if (Acrobatics.getRandom().nextInt(randomChance) <= eventHandler.skillModifier && !eventHandler.isFatal(eventHandler.modifiedDamage)) { eventHandler.modifyEventDamage(); eventHandler.sendAbilityMessage(); eventHandler.processXPGain(eventHandler.damage * Acrobatics.DODGE_XP_MODIFIER); diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java index ce005b80f..dbad1e72e 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -34,7 +34,13 @@ public class ArcheryManager { ArrowTrackingEventHandler eventHandler = new ArrowTrackingEventHandler(this, livingEntity); - if (Archery.getRandom().nextInt(1000) < eventHandler.skillModifier) { + int randomChance = 1000; + + if (player.hasPermission("mcmmo.perks.lucky.archery")) { + randomChance = (int) (randomChance * 0.75); + } + + if (Archery.getRandom().nextInt(randomChance) < eventHandler.skillModifier) { eventHandler.addToTracker(); } } @@ -52,7 +58,13 @@ public class ArcheryManager { DazeEventHandler eventHandler = new DazeEventHandler(this, event, defender); - if (Archery.getRandom().nextInt(2000) < eventHandler.skillModifier) { + int randomChance = 2000; + + if (player.hasPermission("mcmmo.perks.lucky.archery")) { + randomChance = (int) (randomChance * 0.75); + } + + if (Archery.getRandom().nextInt(randomChance) < eventHandler.skillModifier) { eventHandler.handleDazeEffect(); eventHandler.sendAbilityMessages(); } diff --git a/src/main/java/com/gmail/nossr50/skills/combat/Axes.java b/src/main/java/com/gmail/nossr50/skills/combat/Axes.java index c8761ce10..d211d6440 100644 --- a/src/main/java/com/gmail/nossr50/skills/combat/Axes.java +++ b/src/main/java/com/gmail/nossr50/skills/combat/Axes.java @@ -75,7 +75,13 @@ public class Axes { int skillLevel = PPa.getSkillLevel(SkillType.AXES); int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL); - if (random.nextInt(2000) <= skillCheck && !entity.isDead()){ + int randomChance = 2000; + + if (attacker.hasPermission("mcmmo.perks.lucky.axes")) { + randomChance = (int) (randomChance * 0.75); + } + + if (random.nextInt(randomChance) <= skillCheck && !entity.isDead()){ int damage = event.getDamage(); if (entity instanceof Player){ @@ -139,7 +145,13 @@ public class Axes { return; } - if (random.nextInt(100) <= GREATER_IMPACT_CHANCE) { + int randomChance = 100; + + if (attacker.hasPermission("mcmmo.perks.lucky.axes")) { + randomChance = (int) (randomChance * 0.75); + } + + if (random.nextInt(randomChance) <= GREATER_IMPACT_CHANCE) { event.setDamage(event.getDamage() + 2); target.setVelocity(attacker.getLocation().getDirection().normalize().multiply(GREATER_IMPACT_MULTIPLIER)); attacker.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Proc")); diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Excavation.java b/src/main/java/com/gmail/nossr50/skills/gathering/Excavation.java index a3bb08a55..2d697b454 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Excavation.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Excavation.java @@ -91,7 +91,13 @@ public class Excavation { for (ExcavationTreasure treasure : treasures) { if (skillLevel >= treasure.getDropLevel()) { - if (random.nextDouble() * 100 <= treasure.getDropChance()) { + int randomChance = 100; + + if (player.hasPermission("mcmmo.perks.lucky.excavation")) { + randomChance = (int) (randomChance * 0.75); + } + + if (random.nextDouble() * randomChance <= treasure.getDropChance()) { xp += treasure.getXp(); is.add(treasure.getDrop()); } diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java b/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java index 14e6c09d4..672d5b530 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java @@ -102,7 +102,13 @@ public class Fishing { if (Config.getInstance().getFishingDropsEnabled() && rewards.size() > 0 && Permissions.getInstance().fishingTreasures(player)) { FishingTreasure treasure = rewards.get(random.nextInt(rewards.size())); - if (random.nextDouble() * 100 <= treasure.getDropChance()) { + int randomChance = 100; + + if (player.hasPermission("mcmmo.perks.lucky.fishing")) { + randomChance = (int) (randomChance * 0.75); + } + + if (random.nextDouble() * randomChance <= treasure.getDropChance()) { Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp()); theCatch.setItemStack(treasure.getDrop()); } @@ -138,8 +144,15 @@ public class Fishing { ItemStack fishingResults = theCatch.getItemStack(); player.sendMessage(LocaleLoader.getString("Fishing.ItemFound")); + if (ItemChecks.isArmor(fishingResults) || ItemChecks.isTool(fishingResults)) { - if (random.nextInt(100) <= ENCHANTMENT_CHANCE && Permissions.getInstance().fishingMagic(player)) { + int randomChance = 100; + + if (player.hasPermission("mcmmo.perks.lucky.fishing")) { + randomChance = (int) (randomChance * 0.75); + } + + if (random.nextInt(randomChance) <= ENCHANTMENT_CHANCE && Permissions.getInstance().fishingMagic(player)) { for (Enchantment newEnchant : Enchantment.values()) { if (newEnchant.canEnchantItem(fishingResults)) { Map resultEnchantments = fishingResults.getEnchantments(); @@ -178,7 +191,13 @@ public class Fishing { * @param event The event to modify */ public static void shakeMob(PlayerFishEvent event) { - final int DROP_NUMBER = random.nextInt(100); + int randomChance = 100; + + if (event.getPlayer().hasPermission("mcmmo.perks.lucky.fishing")) { + randomChance = (int) (randomChance * 0.75); + } + + final int DROP_NUMBER = random.nextInt(randomChance); LivingEntity le = (LivingEntity) event.getCaught(); EntityType type = le.getType(); diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java index 7a52d9c5c..9e5b12ce3 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java @@ -92,6 +92,12 @@ public class Herbalism { boolean customPlant = false; + int randomChance = 1000; + + if (player.hasPermission("mcmmo.perks.lucky.herbalism")) { + randomChance = (int) (randomChance * 0.75); + } + switch (type) { case BROWN_MUSHROOM: case RED_MUSHROOM: @@ -107,7 +113,7 @@ public class Herbalism { if (b.getType().equals(Material.CACTUS)) { mat = Material.CACTUS; if (!mcMMO.placeStore.isTrue(b)) { - if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) { + if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(randomChance) <= herbLevel) { catciDrops++; } xp += Config.getInstance().getHerbalismXPCactus(); @@ -163,7 +169,7 @@ public class Herbalism { if (b.getType().equals(Material.SUGAR_CANE_BLOCK)) { mat = Material.SUGAR_CANE; if (!mcMMO.placeStore.isTrue(b)) { - if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) { + if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(randomChance) <= herbLevel) { caneDrops++; } xp += Config.getInstance().getHerbalismXPSugarCane(); @@ -208,7 +214,7 @@ public class Herbalism { is = new ItemStack(mat); } - if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) { + if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(randomChance) <= herbLevel) { Config configInstance = Config.getInstance(); switch (type) { @@ -321,7 +327,13 @@ public class Herbalism { boolean hasSeeds = inventory.contains(Material.SEEDS); Location loc = block.getLocation(); - if (hasSeeds && PP.getAbilityMode(AbilityType.GREEN_TERRA) || hasSeeds && (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1500) <= herbLevel)) { + int randomChance = 1500; + + if (player.hasPermission("mcmmo.perks.lucky.herbalism")) { + randomChance = (int) (randomChance * 0.75); + } + + if (hasSeeds && PP.getAbilityMode(AbilityType.GREEN_TERRA) || hasSeeds && (herbLevel > MAX_BONUS_LEVEL || random.nextInt(randomChance) <= herbLevel)) { event.setCancelled(true); Misc.dropItem(loc, new ItemStack(Material.WHEAT)); @@ -350,7 +362,13 @@ public class Herbalism { player.setItemInHand(new ItemStack(Material.SEEDS, seeds - 1)); - if (skillLevel > MAX_BONUS_LEVEL || random.nextInt(1500) <= skillLevel) { + int randomChance = 1500; + + if (player.hasPermission("mcmmo.perks.lucky.herbalism")) { + randomChance = (int) (randomChance * 0.75); + } + + if (skillLevel > MAX_BONUS_LEVEL || random.nextInt(randomChance) <= skillLevel) { greenTerraConvert(player, block); } else { diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Mining.java b/src/main/java/com/gmail/nossr50/skills/gathering/Mining.java index f4b88c5e7..2d9b3ae97 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Mining.java @@ -307,7 +307,13 @@ public class Mining { int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING); int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL); - if (random.nextInt(1000) <= skillCheck && Permissions.getInstance().miningDoubleDrops(player)) { + int randomChance = 1000; + + if (player.hasPermission("mcmmo.perks.lucky.mining")) { + randomChance = (int) (randomChance * 0.75); + } + + if (random.nextInt(randomChance) <= skillCheck && Permissions.getInstance().miningDoubleDrops(player)) { if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { silkTouchDrops(block); } diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java b/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java index dda02baca..9ef42bbd4 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java @@ -303,7 +303,13 @@ public class WoodCutting { Tree tree = (Tree) block.getState().getData(); TreeSpecies species = tree.getSpecies(); - if ((skillLevel > MAX_SKILL_LEVEL || random.nextInt(1000) <= skillLevel) && Permissions.getInstance().woodcuttingDoubleDrops(player)) { + int randomChance = 1000; + + if (player.hasPermission("mcmmo.perks.lucky.woodcutting")) { + randomChance = (int) (randomChance * 0.75); + } + + if ((skillLevel > MAX_SKILL_LEVEL || random.nextInt(randomChance) <= skillLevel) && Permissions.getInstance().woodcuttingDoubleDrops(player)) { Config configInstance = Config.getInstance(); ItemStack item; Location location; diff --git a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java index fcde5aa6e..6cb640318 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java @@ -104,11 +104,17 @@ public class Repair { for (Entry enchant : enchants.entrySet()) { Enchantment enchantment = enchant.getKey(); - if (random.nextInt(100) <= getEnchantChance(rank)) { + int randomChance = 100; + + if (player.hasPermission("mcmmo.perks.lucky.repair")) { + randomChance = (int) (randomChance * 0.75); + } + + if (random.nextInt(randomChance) <= getEnchantChance(rank)) { int enchantLevel = enchant.getValue(); if (configInstance.getArcaneForgingDowngradeEnabled() && enchantLevel > 1) { - if (random.nextInt(100) <= getDowngradeChance(rank)) { + if (random.nextInt(randomChance) <= getDowngradeChance(rank)) { is.addEnchantment(enchantment, --enchantLevel); downgraded = true; } @@ -223,7 +229,13 @@ public class Repair { int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR); - if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= skillLevel) && permInstance.repairBonus(player)) { + int randomChance = 1000; + + if (player.hasPermission("mcmmo.perks.lucky.repair")) { + randomChance = (int) (randomChance * 0.75); + } + + if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(randomChance) <= skillLevel) && permInstance.repairBonus(player)) { player.sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy")); return true; } diff --git a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java index 7ed885b38..84aff182d 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java @@ -35,7 +35,13 @@ public class SwordsManager { if (Combat.shouldBeAffected(player, defender)) { BleedEventHandler eventHandler = new BleedEventHandler(this, defender); - if (Swords.getRandom().nextInt(1000) < eventHandler.skillModifier) { + int randomChance = 1000; + + if (player.hasPermission("mcmmo.perks.lucky.swords")) { + randomChance = (int) (randomChance * 0.75); + } + + if (Swords.getRandom().nextInt(randomChance) < eventHandler.skillModifier) { eventHandler.addBleedTicks(); eventHandler.sendAbilityMessages(); } @@ -52,7 +58,13 @@ public class SwordsManager { if (eventHandler.isHoldingSword()) { eventHandler.calculateSkillModifier(); - if (Swords.getRandom().nextInt(2000) < eventHandler.skillModifier) { + int randomChance = 2000; + + if (player.hasPermission("mcmmo.perks.lucky.swords")) { + randomChance = (int) (randomChance * 0.75); + } + + if (Swords.getRandom().nextInt(randomChance) < eventHandler.skillModifier) { eventHandler.dealDamage(); eventHandler.sendAbilityMessages(); } @@ -66,7 +78,7 @@ public class SwordsManager { SerratedStrikesEventHandler eventHandler = new SerratedStrikesEventHandler(this, target, damage); - eventHandler.applyAbilityEffects(); + eventHandler.applyAbilityEffects(); } protected int getSkillLevel() { diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java index 73894b741..b75afb633 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -41,7 +41,13 @@ public class TamingManager { } if (skillLevel >= Taming.FAST_FOOD_SERVICE_ACTIVATION_LEVEL) { - if (Taming.getRandom().nextInt(100) < Taming.FAST_FOOD_SERVICE_ACTIVATION_CHANCE) { + int randomChance = 100; + + if (player.hasPermission("mcmmo.perks.lucky.taming")) { + randomChance = (int) (randomChance * 0.75); + } + + if (Taming.getRandom().nextInt(randomChance) < Taming.FAST_FOOD_SERVICE_ACTIVATION_CHANCE) { FastFoodServiceEventHandler eventHandler = new FastFoodServiceEventHandler(wolf); eventHandler.modifyHealth(damage); @@ -78,7 +84,13 @@ public class TamingManager { GoreEventHandler eventHandler = new GoreEventHandler(this, event); - if (Taming.getRandom().nextInt(1000) < eventHandler.skillModifier) { + int randomChance = 1000; + + if (player.hasPermission("mcmmo.perks.lucky.taming")) { + randomChance = (int) (randomChance * 0.75); + } + + if (Taming.getRandom().nextInt(randomChance) < eventHandler.skillModifier) { eventHandler.modifyEventDamage(); eventHandler.applyBleed(); eventHandler.sendAbilityMessage(); diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java index 952f6d1f7..dd04ecffb 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java @@ -36,7 +36,13 @@ public class UnarmedManager { if (eventHandler.isHoldingItem()) { eventHandler.calculateSkillModifier(); - if (Unarmed.getRandom().nextInt(3000) < eventHandler.skillModifier) { + int randomChance = 3000; + + if (player.hasPermission("mcmmo.perks.lucky.unarmed")) { + randomChance = (int) (randomChance * 0.75); + } + + if (Unarmed.getRandom().nextInt(randomChance) < eventHandler.skillModifier) { if (!hasIronGrip(defender)) { eventHandler.sendAbilityMessage(); eventHandler.handleDisarm(); @@ -58,7 +64,13 @@ public class UnarmedManager { DeflectEventHandler eventHandler = new DeflectEventHandler(this, event); - if (Unarmed.getRandom().nextInt(2000) < eventHandler.skillModifier) { + int randomChance = 2000; + + if (player.hasPermission("mcmmo.perks.lucky.unarmed")) { + randomChance = (int) (randomChance * 0.75); + } + + if (Unarmed.getRandom().nextInt(randomChance) < eventHandler.skillModifier) { eventHandler.cancelEvent(); eventHandler.sendAbilityMessage(); } @@ -93,7 +105,13 @@ public class UnarmedManager { IronGripEventHandler eventHandler = new IronGripEventHandler(this, defender); - if (Unarmed.getRandom().nextInt(1000) < eventHandler.skillModifier) { + int randomChance = 1000; + + if (defender.hasPermission("mcmmo.perks.lucky.unarmed")) { + randomChance = (int) (randomChance * 0.75); + } + + if (Unarmed.getRandom().nextInt(randomChance) < eventHandler.skillModifier) { eventHandler.sendAbilityMessages(); return true; } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index a92e698a7..27efcd97a 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -194,6 +194,58 @@ permissions: mcmmo.perks.xp.50percentboost: default: false description: Mulitplies incoming XP by 1.5 + mcmmo.perks.lucky.*: + default: false + description: Gives all abilities & skills a 25% better chance to activate. + children: + mcmmo.perks.lucky.acrobatics: false + mcmmo.perks.lucky.archery: false + mcmmo.perks.lucky.axes: false + mcmmo.perks.lucky.excavation: false + mcmmo.perks.lucky.fishing: false + mcmmo.perks.lucky.herbalism: false + mcmmo.perks.lucky.mining: false + mcmmo.perks.lucky.repair: false + mcmmo.perks.lucky.swords: false + mcmmo.perks.lucky.taming: false + mcmmo.perks.lucky.unarmed: false + mcmmo.perks.lucky.woodcutting: false + mcmmo.perks.lucky.acrobatics: + default: false + description: Gives Acrobatics abilities & skills a 25% better chance to activate. + mcmmo.perks.lucky.archery: + default: false + description: Gives Archery abilities & skills a 25% better chance to activate. + mcmmo.perks.lucky.axes: + default: false + description: Gives Axes abilities & skills a 25% better chance to activate. + mcmmo.perks.lucky.excavation: + default: false + description: Gives Excavation abilities & skills a 25% better chance to activate. + mcmmo.perks.lucky.fishing: + default: false + description: Gives Fishing abilities & skills a 25% better chance to activate. + mcmmo.perks.lucky.herbalism: + default: false + description: Gives Herbalism abilities & skills a 25% better chance to activate. + mcmmo.perks.lucky.mining: + default: false + description: Gives Mining abilities & skills a 25% better chance to activate. + mcmmo.perks.lucky.repair: + default: false + description: Gives Repair abilities & skills a 25% better chance to activate. + mcmmo.perks.lucky.swords: + default: false + description: Gives Swords abilities & skills a 25% better chance to activate. + mcmmo.perks.lucky.taming: + default: false + description: Gives Taming abilities & skills a 25% better chance to activate. + mcmmo.perks.lucky.unarmed: + default: false + description: Gives Unarmed abilities & skills a 25% better chance to activate. + mcmmo.perks.lucky.woodcutting: + default: false + description: Gives Woodcutting abilities & skills a 25% better chance to activate. mcmmo.bypass.*: default: false description: Implies all bypass permissions.