Skip to content

Commit cd286ff

Browse files
committed
only ommit the lowball feature when inventory not loadable
1 parent 10bbe4b commit cd286ff

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

Commands/Minecraft/HotkeyCommand.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,29 @@ public override async Task Execute(MinecraftSocket socket, string arguments)
7171
}
7272
var instaSell = SniperClient.InstaSellPrice(price);
7373
var lbinAuction = await GetAuction(socket, price.Lbin.AuctionId);
74-
int index = await GetItemIndex(auction, inventoryTask);
74+
// The lowball offer relies on locating the item in the player's inventory.
75+
// If that lookup fails (e.g. the player state database is unavailable) we still
76+
// want to show the rest of the item info, so the offer is just disabled.
77+
int index = -1;
78+
bool inventoryAvailable = true;
79+
try
80+
{
81+
index = await GetItemIndex(auction, inventoryTask);
82+
}
83+
catch (Exception e)
84+
{
85+
inventoryAvailable = false;
86+
socket.Error(e, "Failed to load inventory for lowball offer");
87+
}
7588
var filterLink = await filterLinkTask;
7689

7790
var isInInventory = index != -1;
7891
var formattedInstasell = socket.FormatPrice(instaSell.Item1);
7992
socket.Dialog(db => db.MsgLine($"The value of this item is {McColorCodes.AQUA}{socket.FormatPrice(price.Median)}", null,
8093
$"Took into account these modifiers:\n{price.MedianKey}")
8194
.If(() => isInInventory, db => db.CoflCommandButton<LowballCommand>($"{McColorCodes.GREEN}Offer this item to a lowballer", $"offer {index}", "Click to offer this item to lowballers").LineBreak())
95+
.If(() => !inventoryAvailable, db => db.MsgLine($"{McColorCodes.GRAY}{McColorCodes.STRIKE}Offer this item to a lowballer{McColorCodes.RESET}{McColorCodes.GRAY} (temporarily unavailable)", null,
96+
"Could not load your inventory right now,\nso lowball offers are unavailable for this item.\nPlease try again later.").LineBreak())
8297
.If(() => price.Lbin.AuctionId != 0 && lbinAuction != null, db => db
8398
.MsgLine($"Lowest bin sits at {McColorCodes.AQUA}{socket.FormatPrice(price.Lbin.Price)}", "/viewauction " + lbinAuction!.Uuid, "click to open lbin on ah"))
8499
.Msg($"To sell quickly list at {McColorCodes.AQUA}{formattedInstasell}", $"copy:{formattedInstasell}", "click to copy")

0 commit comments

Comments
 (0)