Skip to content

Commit 39d73cc

Browse files
Fix /qs create command doesn't work with no arg
1 parent a504001 commit 39d73cc

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_Create.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,8 @@ private boolean isValidMaterial(@Nullable Material material) {
7575
@Override
7676
public void onCommand(@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
7777
BlockIterator bIt = new BlockIterator(sender, 10);
78-
ItemStack item;
79-
if (cmdArg.length < 1) {
80-
plugin.text().of(sender, "command.wrong-args").send();
81-
return;
82-
} else if (cmdArg.length == 1) {
83-
item = sender.getInventory().getItemInMainHand();
78+
ItemStack item = sender.getInventory().getItemInMainHand();
79+
if (cmdArg.length <= 1) {
8480
if (item.getType().isAir()) {
8581
plugin.text().of(sender, "no-anythings-in-your-hand").send();
8682
return;
@@ -107,8 +103,6 @@ public void onCommand(@NotNull Player sender, @NotNull String commandLabel, @Not
107103
}
108104
Util.debugLog("Pending task for material: " + item);
109105

110-
String price = cmdArg[0];
111-
112106
while (bIt.hasNext()) {
113107
final Block b = bIt.next();
114108

@@ -146,10 +140,14 @@ public void onCommand(@NotNull Player sender, @NotNull String commandLabel, @Not
146140
return;
147141
}
148142

143+
149144
// Send creation menu.
150145
plugin.getShopManager().getActions().put(sender.getUniqueId(),
151146
new SimpleInfo(b.getLocation(), ShopAction.CREATE, item, b.getRelative(sender.getFacing().getOppositeFace()), false));
152-
plugin.getShopManager().handleChat(sender, price);
147+
if (cmdArg.length >= 1) {
148+
String price = cmdArg[0];
149+
plugin.getShopManager().handleChat(sender, price);
150+
}
153151
return;
154152
}
155153
plugin.text().of(sender, "not-looking-at-valid-shop-block").send();

0 commit comments

Comments
 (0)