Skip to content

Detect a LabyMod user

The client will send you this information on join in the labymod3:main plugin channel

Warning

We changed the plugin channel name from LMC to labymod3:main since LabyMod 3.8.0 to support the latest Minecraft 1.16 version

Message key: INFO

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{  
   "version": "3.4.2",
   "ccp": {  
      "enabled": true,
      "version": 2
   },
   "shadow":{  
      "enabled": true,
      "version": 1
   },
   "addons": [  
      {  
         "uuid": "8a2eb0b0-5df9-4687-b36f-df2258b61062",
         "name": "Name of the Addon"
      }
   ],
   "mods": [
      {  
         "hash":"sha256:9aba15fe05724639ad4b4665e1a76970fd7f740bf751eaa708e90287ce3a171d",
         "name":"name_of_the_mod.jar"
      }
   ]
}

Code example in Bukkit

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
@Override
public void onEnable() {
    // Don't forget to register the plugin channel
    getServer().getMessenger().registerIncomingPluginChannel(this, "labymod3:main", this);
}

@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
    if (!channel.equals("labymod3:main")) {
        return;
    }

    DataInputStream in = new DataInputStream(new ByteArrayInputStream(message));

    try {
        ByteBuf buf = Unpooled.wrappedBuffer(message);
        String key = LabyModProtocol.readString(buf, Short.MAX_VALUE);
        String json = LabyModProtocol.readString(buf, Short.MAX_VALUE);

        // LabyMod user joins the server
        if(key.equals("INFO")) {
            // Handle the json message
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}