Skip to content
This repository was archived by the owner on Mar 8, 2022. It is now read-only.

Commit 4bf3524

Browse files
committed
fix NPE in sell command w/o ongoing req
1 parent 9026b9c commit 4bf3524

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/main/java/cat/nyaa/HamsterEcoHelper/requisition/RequisitionCommands.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,16 @@ public static void haltRequisition(CommandSender sender, Arguments args, Hamster
7070
public static void userSell(CommandSender sender, Arguments args, HamsterEcoHelper plugin) {
7171
Player p = asPlayer(sender);
7272
RequisitionInstance req = plugin.reqManager.getCurrentRequisition();
73-
if (req.owner != null && req.owner.getUniqueId().equals(p.getUniqueId())) {
74-
return;
75-
}
7673
if (req == null) {
7774
msg(sender, "user.info.no_current_requisition");
7875
return;
7976
}
8077

78+
if (req.owner != null && req.owner.getUniqueId().equals(p.getUniqueId())) {
79+
msg(sender, "user.req.sell_to_self");
80+
return;
81+
}
82+
8183
int amount;
8284
if (args.length() == 1) {
8385
amount = Math.min(getItemInHand(sender).getAmount(), req.getAmountRemains());

src/main/resources/lang/en_US.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ user:
9595
sold_out: "Requisition limit reached. Requisition finished."
9696
sold_amount_0: "Player %s has sold %d "
9797
sold_amount_1: "! %d remains."
98+
sell_to_self: "You cannot sell to yourself"
9899
market:
99100
title: "[Market]"
100101
mailbox: "[Mailbox]"

0 commit comments

Comments
 (0)