Skip to content

Cinnamon Minecraft Module

AngelFluffyOokami edited this page Dec 27, 2022 · 18 revisions

This module provides the Minecraft Integration feature to Cinnamon.

To include this feature, you must build Cinnamon with build tags minecraft

This module provides the ability for guilds to integrate their Minecraft servers with their respective guild.

Websocket API Negotiation

When connecting to the websocket API, first JSON message should always be of IncomindData.datatype: negotiateapi containing the max supported API of the client. The bot replies with the highest API compatible between both client and server.

Inbound

type IncomingData struct {
	DataType   string          `json:"datatype"`
	RawData    json.RawMessage `json:"rawdata"`
}

IncomingData.DataType: negotiateapi

type NegotiateAPI struct {
	APIVersion int `json:"version"`
}

JSON: version

Maximum API supported by client.

Valid JSON

int

Outbound

type NegotiateAPI struct {
	APIVersion int `json:"version"`
}

JSON: version

Highest API version appropriate to use between client and bot.

Valid JSON Data

int

Websocket APIv1 IncomingData

Valid API requests inbound from client.

type IncomingData struct{
	DataType   string          `json:"datatype"`
	RawData    json.RawMessage `json:"rawdata"`
	APIVersion int             `json:"version"`
}

JSON: datatype

Type of raw data being sent over JSON field rawdata.

Valid JSON Data

string: minecraft

JSON: rawdata

Raw JSON data, differs according to datatype.

Valid JSON Data

RAW JSON

JSON: version

API Version decided by the bot after negotiating API.

Valid JSON Data

int: 1

IncomingData.datatype: minecraft

First JSON message to the bot must always be of datatype "authenticate", if first message isn't of datatype "authenticate" then bot closes connection with HTTP Status 401 (Unauthorized).

IncomingData.rawdata:

type Data struct {
	DataType string          `json:"datatype"`
	RawData  json.RawMessage `json:"rawdata"`
	AuthKey  string          `json:"authkey"`
}

JSON: datatype

Type of JSON data being sent over JSON:rawdata.

Valid JSON Data

string authenticate

string playerjoinevent

string playermessageevent

JSON: rawdata

Raw JSON data, differs according to JSON:datatype.

Valid JSON Data

RAW JSON

JSON: authkey

Authentication key provided by bot.

Valid JSON Data

String

IncomingData.rawdata.datatype: authenticate

Always sent immediately after negotiating API version over websocket. If message datatype is not authenticate, bot closes connection with HTTP Status 401 (Unauthorized). If authentication is successful, bot responds with HTTP Status 200 (OK) and keeps connection alive. If authentication fails, bot closes connection with HTTP Status 401 (Unauthorized).

IncomingData.rawdata.rawdata:

type Authenticate struct {
	AuthKey        string `json:"authkey"`
	DefaultChannel string `json:"channel"`
	GuildID        string `json:"guild"`
}

JSON: authkey

Authentication key provided by bot.

Valid JSON Data

String

JSON: channel

Default channel (ID) where to send messages sent to when receiving events that require the bot to send a message to the specified channel.

Valid JSON Data

String

JSON: GuildID

Default guild (ID) that the client is linked to.

Valid JSON Data

String

IncomingData.rawdata.datatype: playermessageevent

Sent whenever a player sends a public message to the Minecraft chat.

IncomingData.rawdata.rawdata:

type ChatMessage struct {
	UUID  string `json:"uuid"`
	Message string `json:"message"`
	Mention string `json:"mention"`
	Channel string `json:"channel"`
}

JSON: uuid

Minecraft UUID of player sending the message.

Valid JSON Data

String

JSON: message

Message content of chat message sent by player.

Valid JSON Data

String

JSON: mention

(Optional) Message ID sent on discord to reply to.

Valid JSON Data

String

JSON: channel

(Optional) Channel ID where the Message replying to was sent, only filled if replying to message.

Valid JSON Data

String

IncomingData.rawdata.datatype: playerjoinevent

Sent whenever a player logs into minecraft server. See OutboundData.datatype: playerauthkickevent playerauthevent usernotfoundevent to see what responses to expect.

IncomingData.rawdata.rawdata

type PlayerJoin struct {
	UUID     string `json:"uuid"`
}

JSON: uuid

Minecraft UUID of player that joined Minecraft server.

Valid JSON Data

String

Websocket APIv1 OutboundData

Valid API requests outbound from bot to client.

type OutboundData struct {
	DataType string          `json:"datatype"`
	RawData  json.RawMessage `json:"rawdata"`
	API      int             `json:"version"`
}

JSON: datatype

Type of JSON data being sent over JSON:rawdata

Valid JSON Data

string playerauthkickevent

string playerauthevent

string usernotfoundevent

JSON: rawdata

Raw JSON data, differs according to JSON:datatype

Valid JSON Data

RAW JSON

JSON: version

API version negotiated between bot and client.

Valid JSON Data

int 1

OutboundData.datatype: playerauthevent

Called in response to IncomingData.datatype: playerjoinevent if player authentication successful. If successful.

OutboundData.rawdata:

type playerAuthSuccessful struct {
	UUID     string `json:"uuid"`
	Username string `json:"username"`
}

JSON: uuid

UUID of player authenticated into server.

Valid JSON

String

JSON: username

Discord username of player authenticated into server. To be used to set minecraft nickname of player to this depending on the configuration.

Valid JSON Data

String

OutboundData.datatype: playerauthkickevent

Called in response to InboundData.datatype: playerjoinevent if user has not linked their Discord account with the bot.

OutboundData.rawdata:

type kickForAuth struct {
	UUID    string `json:"uuid"`
	AuthKey string `json:"authkey"`
}

JSON: uuid

UUID of minecraft user to kick.

Valid JSON Data

String

JSON: authkey

Authentication key linked with Minecraft player. When player kicked from server, display instruction on how to link account with their discord account, as well as this authentication key.

Valid JSON Data

String

OutboundData.datatype: usernotfoundevent

Called in response to InboundData.datatype: playerjoinevent if user is not present in server. User should be kicked depending on client configuration.

OutboundData.rawdata:

type kickForNotOnServer struct {
	UUID string `json:"uuid"`
}

JSON: uuid

UUID of minecraft player not found present in discord server.

Valid JSON Data

String

Clone this wiki locally