mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Make repair & salvage respect the sneaking settings. Fixes #1108
This commit is contained in:
parent
9a5f4b638f
commit
f21fbe2d40
@ -343,26 +343,28 @@ public class PlayerListener implements Listener {
|
|||||||
case RIGHT_CLICK_BLOCK:
|
case RIGHT_CLICK_BLOCK:
|
||||||
int blockID = block.getTypeId();
|
int blockID = block.getTypeId();
|
||||||
|
|
||||||
/* REPAIR CHECKS */
|
if ((Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && player.isSneaking()) || !Config.getInstance().getAbilitiesOnlyActivateWhenSneaking()) {
|
||||||
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
/* REPAIR CHECKS */
|
||||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
||||||
event.setCancelled(true);
|
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
// Make sure the player knows what he's doing when trying to repair an enchanted item
|
// Make sure the player knows what he's doing when trying to repair an enchanted item
|
||||||
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(blockID, true)) {
|
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(blockID, true)) {
|
||||||
repairManager.handleRepair(heldItem);
|
repairManager.handleRepair(heldItem);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
/* SALVAGE CHECKS */
|
||||||
/* SALVAGE CHECKS */
|
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem) && !ItemUtils.isChainmailArmor(heldItem)) {
|
||||||
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem) && !ItemUtils.isChainmailArmor(heldItem)) {
|
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
|
||||||
|
|
||||||
// Make sure the player knows what he's doing when trying to salvage an enchanted item
|
// Make sure the player knows what he's doing when trying to salvage an enchanted item
|
||||||
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(blockID, true)) {
|
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(blockID, true)) {
|
||||||
repairManager.handleSalvage(block.getLocation(), heldItem);
|
repairManager.handleSalvage(block.getLocation(), heldItem);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* BLAST MINING CHECK */
|
/* BLAST MINING CHECK */
|
||||||
@ -380,24 +382,26 @@ public class PlayerListener implements Listener {
|
|||||||
case LEFT_CLICK_BLOCK:
|
case LEFT_CLICK_BLOCK:
|
||||||
blockID = block.getTypeId();
|
blockID = block.getTypeId();
|
||||||
|
|
||||||
/* REPAIR CHECKS */
|
if ((Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && player.isSneaking()) || !Config.getInstance().getAbilitiesOnlyActivateWhenSneaking()) {
|
||||||
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
/* REPAIR CHECKS */
|
||||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
||||||
|
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||||
|
|
||||||
// Cancel repairing an enchanted item
|
// Cancel repairing an enchanted item
|
||||||
if (repairManager.checkConfirmation(blockID, false) && Config.getInstance().getRepairConfirmRequired()) {
|
if (repairManager.checkConfirmation(blockID, false) && Config.getInstance().getRepairConfirmRequired()) {
|
||||||
mcMMOPlayer.setLastAnvilUse(Repair.repairAnvilId, 0);
|
mcMMOPlayer.setLastAnvilUse(Repair.repairAnvilId, 0);
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Repair.Pretty.Name")));
|
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Repair.Pretty.Name")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
/* SALVAGE CHECKS */
|
||||||
/* SALVAGE CHECKS */
|
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) {
|
||||||
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) {
|
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
|
||||||
|
|
||||||
// Cancel salvaging an enchanted item
|
// Cancel salvaging an enchanted item
|
||||||
if (repairManager.checkConfirmation(blockID, false) && Config.getInstance().getRepairConfirmRequired()) {
|
if (repairManager.checkConfirmation(blockID, false) && Config.getInstance().getRepairConfirmRequired()) {
|
||||||
mcMMOPlayer.setLastAnvilUse(Repair.salvageAnvilId, 0);
|
mcMMOPlayer.setLastAnvilUse(Repair.salvageAnvilId, 0);
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Salvage.Pretty.Name")));
|
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Salvage.Pretty.Name")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user