Make command item missing-item error use display name if present

This commit is contained in:
fullwall 2024-05-08 03:19:55 +08:00
parent 28e2e87a80
commit bb43940a0a

View File

@ -117,7 +117,9 @@ public class CommandTrait extends Trait {
Transaction action = new ItemAction(command.itemCost).take(player, 1); Transaction action = new ItemAction(command.itemCost).take(player, 1);
if (!action.isPossible()) { if (!action.isPossible()) {
ItemStack stack = command.itemCost.get(0); ItemStack stack = command.itemCost.get(0);
sendErrorMessage(player, CommandTraitError.MISSING_ITEM, null, Util.prettyEnum(stack.getType()), sendErrorMessage(player, CommandTraitError.MISSING_ITEM, null,
stack.getItemMeta().hasDisplayName() ? stack.getItemMeta().getDisplayName()
: Util.prettyEnum(stack.getType()),
stack.getAmount()); stack.getAmount());
} }
txns.add(action); txns.add(action);
@ -148,7 +150,9 @@ public class CommandTrait extends Trait {
Transaction action = new ItemAction(itemRequirements).take(player, 1); Transaction action = new ItemAction(itemRequirements).take(player, 1);
if (!action.isPossible()) { if (!action.isPossible()) {
ItemStack stack = itemRequirements.get(0); ItemStack stack = itemRequirements.get(0);
sendErrorMessage(player, CommandTraitError.MISSING_ITEM, null, Util.prettyEnum(stack.getType()), sendErrorMessage(player, CommandTraitError.MISSING_ITEM, null,
stack.getItemMeta().hasDisplayName() ? stack.getItemMeta().getDisplayName()
: Util.prettyEnum(stack.getType()),
stack.getAmount()); stack.getAmount());
} }
txns.add(action); txns.add(action);