Skip to content

Commit 40864e4

Browse files
committed
Added error message when trying to change an amount of items with a max of 1
1 parent 39acbd7 commit 40864e4

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

Plugin/src/main/java/dev/lrxh/neptune/configs/impl/MessagesLocale.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ public enum MessagesLocale implements IDataAccessor {
274274
CUSTOM_KIT_HEALTH_SET("CUSTOM_KIT.HEALTH_SET", DataType.STRING_LIST, "&aSet health to <health>."),
275275
CUSTOM_KIT_CANCELLED("CUSTOM_KIT.CANCELLED", DataType.STRING_LIST, "&cCancelled."),
276276
CUSTOM_KIT_CANT_ENCHANT("CUSTOM_KIT.CANT_ENCHANT", DataType.STRING_LIST, "&cThis item can't be enchanted."),
277+
CUSTOM_KIT_CANT_STACK("CUSTOM_KIT.CANT_STACK", DataType.STRING_LIST, "&cThis item can't be stacked."),
277278
CUSTOM_KIT_ENCHANT_APPLIED("CUSTOM_KIT.ENCHANT_APPLIED", DataType.STRING_LIST, "&aApplied <enchant> <level>."),
278279
CUSTOM_KIT_NOT_LOBBY("CUSTOM_KIT.NOT_LOBBY", DataType.STRING_LIST, "&cYou can only use this in the lobby."),
279280
CUSTOM_KIT_CANT_HOST("CUSTOM_KIT.CANT_HOST", DataType.STRING_LIST, "&cYou can't host a kit right now."),

Plugin/src/main/java/dev/lrxh/neptune/feature/customkit/menu/CustomKitEditorMenu.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,15 @@ public void onClick(ClickType type, Player p) {
7878
ItemStack item = kit.itemAt(contentsIndex);
7979
if (item != null && !item.getType().isAir()) {
8080
if (type == ClickType.SHIFT_RIGHT) {
81+
if (item.getMaxStackSize() <= 1) {
82+
MessagesLocale.CUSTOM_KIT_CANT_STACK.send(p.getUniqueId());
83+
return;
84+
}
85+
int max = item.getMaxStackSize();
8186
p.closeInventory();
8287
SignInputMenu.open(p, "", SignsLocale.CUSTOM_KIT_AMOUNT.getStringList(), input -> {
8388
try {
84-
item.setAmount(Math.max(1, Math.min(64, Integer.parseInt(input.trim()))));
89+
item.setAmount(Math.max(1, Math.min(max, Integer.parseInt(input.trim()))));
8590
kit.setItemAt(contentsIndex, item);
8691
save(p);
8792
} catch (NumberFormatException ignored) {

0 commit comments

Comments
 (0)