Rank synchronisation is handled because of the extensive scope and use of ranks within MCME.
There are user roles on the website, roles on Discord, in-game roles, ...
To avoid burdening people to manage the ranks manually, and to keep the information better up to date there is a system of sorts that can handle rank changes.
There are a few systems that handle groups right now:
- LuckPerms, is the in-game permission handler and management tool that is used to give out roles, badges and ranks on the server.
Luckperms will be used to determine who has what role. The entire point of the sync system is that Luckperms will be used as sole reference point to determine who is part of which role.
Luckperms should only be approached externally (that is: outside the normal use on how you use LP, which is in-game) for consultation: retrieving the permissions from a user, which group does the user belong to, ...
Nothing external should ever have the right to modify the luckperms database.
- DiscordSRV, a spigot plugin that enables cross-functionality between Discord and Minecraft.
Through Minecraft, someone can make an association with his/her Discord username (id) the Minecraft username (uuid).
This can be setup to force-name change Discord users to their associated in-game Minecraft account.
- Forums, these run an addon that can poll information from the Discord server and should only sync accounts that are verified/associated on Discord.
Rank changes should only be done in-game. The rest will be handled automatically.
If you alter the ranks anywhere that is not done by LuckPerms, your action(s) might get overridden. Potentially it could also cause undesired effects since the sync system is supposed to be a linear process from A to Z, so making changes somewhere in the middle could lead to the system have weird behavior.
1. Confirming premium and association Minecraft account and Discord account
2. Syncing from server to Discord
- A user authenticates with the Minecraft session servers.
- The Minecraft authentication server verifies if the user has a valid Minecraft account and if he is premium or not (paid)
- If the user is premium, the Minecraft authentication server will grant the user an auth token that can be used to join servers that only accepts premium users.
- The user joins build.mcmiddleearth.com
- The user can link his (authenticated) Minecraft account by typing
/discord link in the game chat. (Command handled by DiscordSRV)
- A 4 digit token will be sent through the chat to the user, which the user has to sent to the Minecraft Middle Earth discord bot with Direct Message. The bot is connected to Discord, but runs from the same server as the game.
Doing this will create an association between the in-game username and the discord username.
The association is saved in a locally saved file called linkedaccounts.json saved in the /DiscordSRV/ folder.
DiscordSRV is set up that it will force-update Discord usernames of all linked players, so that it matches the minecraft username.
This is important for later on.
Handled by DiscordSRV.
In order to have Discord assign the proper group to someone, a few things need to be done:
- The user must be associated through DiscordSRV <> Minecraft
- DiscordSRV must know what in-game groups there are. This is done by adding a specially crafted discordsrv permission to each group that we want to have synced.
discordsrv.sync.[role id], can be figured out by enabling your Discord client to show development information. When you go to the roles window in Discord you can then right click a role and click on
Copy ID, this will copy the Discord's group's id to the clipboard. For example, the Discord Commoner group id is 269991999241846784
In order to be able to sync the Commoners to Discord, we need to add
discordsrv.sync.269991999241846784 by using LuckPerms.
- The discordsrv configuration file must be updated for each rank that has to be synced.
In this case, we would need to update the GroupRoleSynchronizationRoleIdsToSync line (multiple entries are comma seperated)
# GroupRoleSynchronizationRoleIdsToSync: these are Discord role IDs that you want to be synchronized from Minecraft to Discord# if a role ID is not here, the permission for it (discordsrv.sync.[role id]) is effectively useless
# to get your Discord guild's role IDs, run "/discord debug" and look at the first section
# GroupRoleSynchronizationCycleTime: amount of minutes between repeatedly triggering synchronization for all online players
# GroupRoleSynchronizationRemoveRolesOnUnlink: whether or not to remove synced roles from a Discord user when unlinking accounts
The following is a table of the Discord groups with their group id. Warning:
Group id's are subject to be changed whenever a group is deleted or added. So the system can easily be broken.
As safety measure, Head Ranks and Administrative users are not part of sync mechanism and always require a manual update.
As the Discord has almost 50 different groups, we will keep this list short and only mention the roles that are present.
LuckPerm's group inheritance will be problematic here, as this will give a user the discord identity permissions of more than 1 group.
As of now, the following groups are synced by DiscordSRV between the game server and Discord:
|Discord Group||Role ID|
- The synchronization only works for people who have successfully linked their in-game account. Other people do not get synced.
- Trying to alter groups on Discord or the Forums of people who are linked, while the group/role in LuckPerms is not changed, is useless as the change will get overridden once a new synchronization cycle starts.
Thus, in practice:
- If a user desires a rank or role, this user should be obligated to use the
/link command as this makes everything smoother and easier to manage.
- Users that are updated manually (and not linked) will have to be maintained manually too, which can lead to unwanted permission access if not noticed.
- Removing or adding new Discord roles leads to the sync not (or no longer) working, and requires monitoring that it is properly set up.