@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<>();
        }

        // Expecting one or more parameters that make up the command or comment to add
        StringBuilder sb = new StringBuilder(args[0]);
        for (int i = 1; i < args.length; i++) {
            sb.append(" ").append(args[i]);
        }
        String commandString = sb.toString();

        // Append to the lore
        if (!commandString.startsWith("/")) {
            // Support for colour codes in non-commands
            commandString = commandString.replace('&', ChatColor.COLOR_CHAR);
        }
        // Otherwise append this to the lore

        if (loreStrings.size() == 1) {
            // Handle first-line special case
            String firstLine = loreStrings.get(0);
            int lastPartIndex = firstLine.lastIndexOf("\r") + 1;
            String lastPart = firstLine.substring(lastPartIndex);
            if (lastPart.isEmpty()) {
                loreStrings.set(0, firstLine.substring(0, lastPartIndex) + commandString);
            } else {
                loreStrings.add(commandString);
            }
        } else {
            loreStrings.add(commandString);
        }

        sender.sendMessage(plugin.translate(sender, "script-appended", "{0} was added to the command list of this menu item", commandString));

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