New salvage enchant bypass permission node

This commit is contained in:
nossr50 2019-04-13 13:17:28 -07:00
parent f6e01ea910
commit d542098f8a
6 changed files with 35 additions and 2 deletions

View File

@ -10,8 +10,13 @@ Key:
Version 2.1.42 Version 2.1.42
Fixed McMMOPlayerNotFoundException being thrown instead of null Fixed McMMOPlayerNotFoundException being thrown instead of null
(API) UserManager.getPlayer() returns null again (oopsie) (API) UserManager.getPlayer() returns null again (oopsie)
Added new perk permission node `mcmmo.perks.bypass.salvageenchant` - guarantees full enchantment return for Salvage
Added alternative permission node `mcmmo.perks.bypass.repairenchant` - guarantees full enchantment return for Repair
Added new wildcard perk `mcmmo.perks.bypass.*` and `mcmmo.perks.bypass.all` (either of these will grant all new mcmmo.perks.bypass perk permissions)
NOTE: Sorry about that, when trying to improve Bungee Cord compatibility I made a big oopsie! NOTE: Sorry about that, when trying to improve Bungee Cord compatibility I made a big oopsie!
NOTE: Repair's new perk permission works in the exact same way as mcmmo.bypass.arcanebypass, bypass perk permissions will all eventually be moved to `mcmmo.perks.bypass`
NOTE: Expect perk permissions to all be moved to `mcmmo.perks.X` in the near future
Version 2.1.41 Version 2.1.41
Fixed NullPointerException errors when trying to grab PlayerProfiles for players who have not loaded Fixed NullPointerException errors when trying to grab PlayerProfiles for players who have not loaded

View File

@ -86,7 +86,7 @@ public class RepairCommand extends SkillCommand {
canRepairString = Permissions.repairMaterialType(player, MaterialType.STRING); canRepairString = Permissions.repairMaterialType(player, MaterialType.STRING);
canRepairLeather = Permissions.repairMaterialType(player, MaterialType.LEATHER); canRepairLeather = Permissions.repairMaterialType(player, MaterialType.LEATHER);
canRepairWood = Permissions.repairMaterialType(player, MaterialType.WOOD); canRepairWood = Permissions.repairMaterialType(player, MaterialType.WOOD);
arcaneBypass = Permissions.arcaneBypass(player); arcaneBypass = (Permissions.arcaneBypass(player) || Permissions.hasRepairEnchantBypassPerk(player));
} }
@Override @Override

View File

@ -139,7 +139,7 @@ public class RepairManager extends SkillManager {
} }
// Handle the enchants // Handle the enchants
if (ArcaneForging.arcaneForgingEnchantLoss) { if (ArcaneForging.arcaneForgingEnchantLoss && !Permissions.hasRepairEnchantBypassPerk(player)) {
addEnchants(item); addEnchants(item);
} }

View File

@ -182,6 +182,9 @@ public class SalvageManager extends SkillManager {
}*/ }*/
public double getExtractFullEnchantChance() { public double getExtractFullEnchantChance() {
if(Permissions.hasSalvageEnchantBypassPerk(getPlayer()))
return 100.0D;
return AdvancedConfig.getInstance().getArcaneSalvageExtractFullEnchantsChance(getArcaneSalvageRank()); return AdvancedConfig.getInstance().getArcaneSalvageExtractFullEnchantsChance(getArcaneSalvageRank());
} }
@ -205,6 +208,7 @@ public class SalvageManager extends SkillManager {
for (Entry<Enchantment, Integer> enchant : enchants.entrySet()) { for (Entry<Enchantment, Integer> enchant : enchants.entrySet()) {
if (!Salvage.arcaneSalvageEnchantLoss if (!Salvage.arcaneSalvageEnchantLoss
|| Permissions.hasSalvageEnchantBypassPerk(player)
|| RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getExtractFullEnchantChance(), getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE))) { || RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getExtractFullEnchantChance(), getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE))) {
enchantMeta.addStoredEnchant(enchant.getKey(), enchant.getValue(), true); enchantMeta.addStoredEnchant(enchant.getKey(), enchant.getValue(), true);
} }

View File

@ -106,6 +106,11 @@ public final class Permissions {
* PERKS * PERKS
*/ */
/* BYPASS PERKS */
public static boolean hasRepairEnchantBypassPerk(Permissible permissible) { return permissible.hasPermission("mcmmo.perks.bypass.repairenchant"); }
public static boolean hasSalvageEnchantBypassPerk(Permissible permissible) { return permissible.hasPermission("mcmmo.perks.bypass.salvageenchant"); }
public static boolean lucky(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.perks.lucky." + skill.toString().toLowerCase()); } public static boolean lucky(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.perks.lucky." + skill.toString().toLowerCase()); }
/* XP PERKS */ /* XP PERKS */

View File

@ -1328,6 +1328,8 @@ permissions:
default: false default: false
description: implies access to all mcmmo perks description: implies access to all mcmmo perks
children: children:
mcmmo.perks.bypass.salvageenchant: true
mcmmo.perks.bypass.repairenchant: true
mcmmo.perks.activationtime.all: true mcmmo.perks.activationtime.all: true
mcmmo.perks.cooldowns.all: true mcmmo.perks.cooldowns.all: true
mcmmo.perks.lucky.all: true mcmmo.perks.lucky.all: true
@ -1344,6 +1346,23 @@ permissions:
mcmmo.perks.activationtime.eightseconds: true mcmmo.perks.activationtime.eightseconds: true
mcmmo.perks.activationtime.fourseconds: true mcmmo.perks.activationtime.fourseconds: true
mcmmo.perks.activationtime.twelveseconds: true mcmmo.perks.activationtime.twelveseconds: true
mcmmo.perks.bypass.*:
default: false
description: Perks that bypass certain RNG elements and guarantee success
children:
mcmmo.perks.bypass.all: true
mcmmo.perks.bypass.all:
default: false
description: Perks that bypass certain RNG elements and guarantee success
children:
mcmmo.perks.bypass.repairenchant: true
mcmmo.perks.bypass.salvageenchant: true
mcmmo.perks.bypass.repairenchant:
default: false
description: Guarantees repairing without enchantment degradation
mcmmo.perks.bypass.salvageenchant:
default: false
description: Guarantees salvage will return the best legal enchantment book
mcmmo.perks.activationtime.eightseconds: mcmmo.perks.activationtime.eightseconds:
default: false default: false
description: Increases activation time by 8 seconds description: Increases activation time by 8 seconds