mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2025-02-15 09:51:20 +01:00
Auto-correct item code on sign.
This also makes it possible to input IDs on the sign that are longer than the max sign letters that the plugin uses as that just gets auto corrected back down to the correct amount.
This commit is contained in:
parent
afab90d021
commit
2459a406fe
@ -33,22 +33,17 @@ public class ItemChecker implements Listener {
|
||||
|
||||
if (item == null) {
|
||||
if (Properties.ALLOW_AUTO_ITEM_FILL && itemCode.equals(AUTOFILL_CODE)) {
|
||||
boolean foundItem = false;
|
||||
Chest chest = uBlock.findConnectedChest(event.getSign());
|
||||
if (chest != null) {
|
||||
for (ItemStack stack : chest.getInventory().getContents()) {
|
||||
if (!MaterialUtil.isEmpty(stack)) {
|
||||
itemCode = MaterialUtil.getSignName(stack);
|
||||
|
||||
event.setSignLine(ITEM_LINE, itemCode);
|
||||
foundItem = true;
|
||||
|
||||
item = stack;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundItem) {
|
||||
if (item == null) {
|
||||
event.setSignLine(ITEM_LINE, ChatColor.BOLD + ChestShopSign.AUTOFILL_CODE);
|
||||
event.setOutcome(ITEM_AUTOFILL);
|
||||
event.getPlayer().sendMessage(Messages.prefix(Messages.CLICK_TO_AUTOFILL_ITEM));
|
||||
@ -60,10 +55,14 @@ public class ItemChecker implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
itemCode = MaterialUtil.getSignName(item);
|
||||
|
||||
if (itemCode.length() > MAXIMUM_SIGN_LETTERS) {
|
||||
event.setOutcome(INVALID_ITEM);
|
||||
return;
|
||||
}
|
||||
|
||||
event.setSignLine(ITEM_LINE, itemCode);
|
||||
}
|
||||
|
||||
private static boolean isSameItem(String newCode, ItemStack item) {
|
||||
|
Loading…
Reference in New Issue
Block a user