@Override
    public boolean onCommand(CommandSender sender, ItemStackRef itemStackRef, Command command, String label, String[] args) {
        // Check the player is holding the item
        ItemStack held = itemStackRef.get();
        if (held == null || held.getTypeId() == 0) {
            sender.sendMessage(plugin.translate(sender, "error-no-item-in-hand", "You must be holding a menu item"));
            return true;
        }

        // Get or create the lore
        ItemMeta meta = held.getItemMeta();
        List<String> loreStrings;
        if (meta.hasLore()) {
            loreStrings = meta.getLore();
        } else {
            loreStrings = new ArrayList<>();
        }

        if (args.length != 1) {
            return false;
        }

        String indexString = args[0];
        int index = getIndex(indexString, loreStrings.size(), sender);
        if (index == -1) {
            return true;
        }

        // Remove the deleted line
        String removedText;
        if (index == 0) {
            // Handle first-line special case
            String replacedWith;
            if (loreStrings.size() >= 2) {
                replacedWith = loreStrings.get(1);
                loreStrings.remove(1);
            } else {
                replacedWith = "";
            }
            String firstLine = loreStrings.get(0);
            int lastPartIndex = firstLine.lastIndexOf('\r') + 1;
            removedText = firstLine.substring(lastPartIndex);
            loreStrings.set(0, firstLine.substring(0, lastPartIndex) + replacedWith);
        } else {
            removedText = loreStrings.remove(index);
        }
        sender.sendMessage(plugin.translate(sender, "script-line-removed", "Removed {0} from line {1} in the command list of this menu item", removedText, index));

        // Update the item
        meta.setLore(loreStrings);
        held.setItemMeta(meta);
        return true;
    }