Before the release of the Minecraft username changing feature Mojang have released a UUID system. Each user has a unique ID and this persists across username changes.
My add-on simply fetches the UUIDs for all users and stores them in the XenForo database. When a user changes their username on Minecraft, their old UUID will be assigned to their username. When they change their username on your XenForo site, it looks up their old username's UUID and compares it with the one their new username has. If they are the same then the change goes ahead. All UUIDs are fetched off Mojang's website with the API they provide.
To install just upload the contents of the upload folder to your site and install the addon-mcUUID.xml file. After installation, go to your ACP -> Tools -> Regenerate UUIDs and run the tool. This fetches all of the UUIDs for your users and stores them in the database.