Catches a potential error when starting a new session

This commit is contained in:
Kristian Knarvik 2024-10-24 21:59:29 +02:00
parent f5bfbfd4f8
commit 90d3c49c12
2 changed files with 13 additions and 3 deletions

View File

@ -94,7 +94,12 @@ public class BlacksmithTrait extends CustomTrait<BlacksmithSetting> {
//Start a new reforge session for the player
currentSessionStartTime = System.currentTimeMillis();
try {
session = new ReforgeSession(this, player, npc, config);
} catch (IllegalArgumentException exception) {
BlacksmithPlugin.error(exception.getMessage());
return;
}
//Tell the player the cost of repairing the item
String cost = EconomyManager.formatBlacksmithCost(player);

View File

@ -109,8 +109,13 @@ public class ScrapperTrait extends CustomTrait<ScrapperSetting> {
//Start a new scrapper session for the player
currentSessionStartTime = System.currentTimeMillis();
try {
session = new SalvageSession(this, player, npc, getSettings(), result.salvage(),
result.salvageMethod(), result.requiredAmount());
} catch (IllegalArgumentException exception) {
BlacksmithPlugin.error(exception.getMessage());
return;
}
// Print the cost to the player
printCostMessage(player, itemInHand, EconomyManager.formatSalvageCost(result.salvageMethod()),
result.salvageMethod());