• Welcome to MCME!

    Minecraft Middle Earth is a Minecraft community that recreates the world described by JRR Tolkien and his writings. Everyone can participate in organized events in which we collaborate to create major landmarks, terrain, caves, castles, towns, farms and more.

    To get started, visit The New Player Guide

    Joining the server

    Joining the server can be done straight away, but you will have to pass the New Player Quiz. Use the The New Player Guide to get acquainted with our community.

    IP: build.mcmiddleearth.com

Rank sync

  • Views Views: 10,379
  • Last updated Last updated:
  • 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.

    Systems
    There are a few systems that handle groups right now:
    1. 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.

    2. 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.

    3. Forums, these run an addon that can poll information from the Discord server and should only sync accounts that are verified/associated on Discord.
    Principles
    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
    1. A user authenticates with the Minecraft session servers.
    2. The Minecraft authentication server verifies if the user has a valid Minecraft account and if he is premium or not (paid)
    3. 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.
    4. The user joins build.mcmiddleearth.com
    5. The user can link his (authenticated) Minecraft account by typing /discord link in the game chat. (Command handled by DiscordSRV)
    6. 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.
    2. Syncing from server to Discord
    Handled by DiscordSRV.

    In order to have Discord assign the proper group to someone, a few things need to be done:
    1. The user must be associated through DiscordSRV <> Minecraft
    2. 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.
      This permission, 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.
    3. The discordsrv configuration file must be updated for each rank that has to be synced.
      Code:
      # 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
      #
      GroupRoleSynchronizationRoleIdsToSync: [""]
      GroupRoleSynchronizationCycleTime: 5
      GroupRoleSynchronizationRemoveRolesOnUnlink: true
      In this case, we would need to update the GroupRoleSynchronizationRoleIdsToSync line (multiple entries are comma seperated)
    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 GroupRole ID
    Designer250868902085656577
    Foreman269992150123413507
    Artist258281478377439243
    Guide250869717428862976
    Commoner269991999241846784

    Potential issues
    - 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:
    1. 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.
    2. 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.
    3. Removing or adding new Discord roles leads to the sync not (or no longer) working, and requires monitoring that it is properly set up.
Top