Correct display error when successfully salvaging enchantments

This commit is contained in:
nossr50
2019-04-13 22:04:35 -07:00
parent 908ac7c541
commit 138b109ff5
4 changed files with 19 additions and 22 deletions

View File

@ -65,11 +65,13 @@ public class BlockListener implements Listener {
if(is.getAmount() <= 0)
continue;
//TODO: Ignore this abomination its rewritten in 2.2
if(!Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.MINING, is.getType())
&& !Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.HERBALISM, is.getType())
&& !Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.WOODCUTTING, is.getType()))
continue;
//TODO: Should just store the amount of drops in the metadata itself and use a loop
if(event.getBlock().getState().getMetadata(mcMMO.doubleDrops).size() > 0)
{
event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is);

View File

@ -204,7 +204,7 @@ public class SalvageManager extends SkillManager {
EnchantmentStorageMeta enchantMeta = (EnchantmentStorageMeta) book.getItemMeta();
boolean downgraded = false;
boolean arcaneFailure = false;
int arcaneFailureCount = 0;
for (Entry<Enchantment, Integer> enchant : enchants.entrySet()) {
if (!Salvage.arcaneSalvageEnchantLoss
@ -217,36 +217,28 @@ public class SalvageManager extends SkillManager {
&& RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getExtractPartialEnchantChance(), getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE))) {
enchantMeta.addStoredEnchant(enchant.getKey(), enchant.getValue() - 1, true);
downgraded = true;
}
else {
arcaneFailure = true;
downgraded = true;
} else {
arcaneFailureCount++;
}
}
if(!arcaneFailure)
if(failedAllEnchants(arcaneFailureCount, enchants.entrySet().size()))
{
Map<Enchantment, Integer> newEnchants = enchantMeta.getStoredEnchants();
if (downgraded || newEnchants.size() < enchants.size()) {
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Salvage.Skills.ArcanePartial");
}
else {
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Salvage.Skills.ArcanePartial");
}
book.setItemMeta(enchantMeta);
} else {
if(enchantMeta.getStoredEnchants().size() > 0)
{
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Salvage.Skills.ArcaneFailed");
}
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Salvage.Skills.ArcaneFailed");
return null;
} else if(downgraded)
{
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Salvage.Skills.ArcanePartial");
}
book.setItemMeta(enchantMeta);
return book;
}
private boolean failedAllEnchants(int arcaneFailureCount, int size) {
return arcaneFailureCount == size;
}
/**
* Check if the player has tried to use an Anvil before.
* @param actualize