Item enchant level should not be negative.

This commit is contained in:
MobiusDevelopment
2022-06-14 21:36:22 +00:00
parent c9864ae60c
commit 56788f6fa1
28 changed files with 178 additions and 144 deletions

View File

@@ -914,16 +914,18 @@ public class Item extends WorldObject
}
/**
* @param enchantLevel the enchant value to set
* @param level the enchant value to set
*/
public void setEnchantLevel(int enchantLevel)
public void setEnchantLevel(int level)
{
if (_enchantLevel == enchantLevel)
final int newLevel = Math.max(0, level);
if (_enchantLevel == newLevel)
{
return;
}
clearEnchantStats();
_enchantLevel = enchantLevel;
_enchantLevel = newLevel;
applyEnchantStats();
_storedInDb = false;
}