Websocket Events
Events merupakan pesan JSON yang di-push ke semua klien WebSocket yang terautentikasi. Setiap event memiliki struktur sebagai berikut:
{
"event": "NamaEvent",
"data": "{ ... payload terserialisasi... }"
}Bagian data merupakan JSON string. Parse bagian itu untuk mengakses event payload.
Semua nilai enum diserialisasi sebagai nama string (cth. "Zombie", bukan 119).
Protocol Events
OnWsCommandResponse
Terkirim setelah setiap eksekusi perintah (command).
Payload:
{
"success": true,
"requestId": "request-id-anda",
"message": "hasil atau pesan error"
}Cocokkan requestId untuk melacak perintah mana yang menghasilkan respons tersebut.
OnMccCommandResponse
Terkirim saat mengeksekusi perintah MCC berupa plain-text (dimulai dengan /).
Payload:
{
"command": "jalan ke utara",
"status": "Selesai",
"result": ""
}OnGameJoined
Terkirim setelah klien bergabung ke server dan sesi permainan dimulai. Payload: "N/A"
OnWsRestarting
Terikirim saat server WebSocket dimulai ulang (cth. saat reconnect). Payload: "N/A"
OnWsConnectionClose
Terkirim saat server WebSocket mati. Payload: "N/A"
Chat Events
OnChatRaw
Terkirim setiap ada pesan yang masuk, termasuk raw JSON.
Payload:
{
"text": "Isi teks yang terformat",
"json": "{ raw JSON dari server }"
}OnChatPublic
Terkirim saat pesan publik terdeteksi.
Payload:
{
"sender": "NamaPemain",
"message": "Hello world",
"rawText": "<PlayerName> Hello world"
}OnChatPrivate
Terkirim saat pesan privat terdeteksi.
Payload:
{
"sender": "NamaPemain",
"message": "Pesan rahasia",
"rawText": "NamaPemain mengirim pesan privat: Pesan rahasia"
}OnTeleportRequest
Terkirim saat permintaan teleportasi terdeteksi.
Payload:
{
"sender": "NamaPemain",
"rawText": "NamaPemain meminta permintaan teleportasi"
}Connection Events
OnDisconnect
Terkirim saat MCC terputus dari server.
Payload:
{
"reason": "ConnectionLost",
"message": "Koneksi telah terputus."
}Alasan: ConnectionLost, UserLogout, InGameKick, LoginRejected.
Entity Events
Objek entitas termasuk type-nya sebagai string sebuah nama (cth. "Zombie", "Player").
OnEntitySpawn
Terkirim saat entitas muncul.
Payload: Objek entitas penuh.
OnEntityDespawn
Sent when an entity despawns.
Payload: Objek entitas penuh.
OnEntityMove
Sent when an entity moves.
Payload: Full entity object with updated location.
OnEntityAnimation
Sent when an entity plays an animation.
Payload:
{
"entity": { ... },
"animation": 0
}OnEntityHealth
Sent when an entity's health changes.
Payload:
{
"entity": { ... },
"health": 20.0
}OnEntityMetadata
Sent when entity metadata updates.
Payload:
{
"entity": { ... },
"metadata": { "0": ..., "1": ... }
}OnEntityEquipment
Sent when an entity's equipment changes.
Payload:
{
"entity": { ... },
"slot": 0,
"item": { "type": "DiamondSword", "count": 1, ... }
}Item types are string names (e.g., "DiamondSword").
OnEntityEffect
Sent when an entity gets an effect.
Payload:
{
"entity": { ... },
"effect": "Speed",
"amplifier": 1,
"duration": 600,
"flags": 0
}OnBlockBreakAnimation
Sent when a block break animation plays.
Payload:
{
"entity": { ... },
"location": { "x": 10, "y": 64, "z": -20 },
"stage": 5
}Player Events
OnPlayerJoin
Sent when a player joins the server.
Payload:
{
"uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"name": "PlayerName"
}OnPlayerLeave
Sent when a player leaves the server.
Payload:
{
"uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"name": "PlayerName"
}OnPlayerProperty
Sent when player properties update (e.g., speed, attack damage).
Payload: Dictionary of property name to value.
OnPlayerStatus
Sent when the player's status changes.
Payload:
{
"statusId": 0
}OnDeath
Sent when the player dies. Payload: "N/A"
OnRespawn
Sent when the player respawns. Payload: "N/A"
Health and Experience Events
OnHealthUpdate
Sent when the player's health or food level changes.
Payload:
{
"health": 20.0,
"food": 20
}OnSetExperience
Sent when experience updates.
Payload:
{
"experienceBar": 0.5,
"level": 10,
"totalExperience": 200
}Game Events
OnGamemodeUpdate
Sent when a player's gamemode changes.
Payload:
{
"playerName": "Steve",
"uuid": "...",
"gamemode": 1
}OnLatencyUpdate
Sent when a player's latency changes.
Payload:
{
"playerName": "Steve",
"uuid": "...",
"latency": 42
}OnHeldItemChange
Sent when the held item slot changes.
Payload:
{
"slot": 0
}OnExplosion
Sent when an explosion occurs.
Payload:
{
"location": { "x": 10, "y": 64, "z": -20 },
"strength": 4.0,
"recordcount": 12
}OnTitle
Sent when a title, subtitle, or action bar message is displayed.
Payload:
{
"action": 0,
"titleText": "Welcome",
"subtitleText": "",
"actionBarText": "",
"fadeIn": 10,
"stay": 70,
"fadeOut": 20,
"json": "..."
}Server Events
OnServerTpsUpdate
Sent when the server TPS updates.
Payload:
{
"tps": 20.0
}OnTimeUpdate
Sent when the world time updates.
Payload:
{
"worldAge": 1000000,
"timeOfDay": 6000
}OnInternalCommand
Sent when an MCC internal command is executed.
Payload:
{
"commandName": "move",
"commandParams": "north",
"result": {
"status": "Done",
"result": ""
}
}Inventory Events
OnInventoryUpdate
Sent when an inventory's contents change.
Payload:
{
"inventoryId": 0
}OnInventoryOpen
Sent when an inventory window opens.
Payload:
{
"inventoryId": 1
}OnInventoryClose
Sent when an inventory window closes.
Payload:
{
"inventoryId": 1
}Scoreboard Events
OnScoreboardObjective
Sent when a scoreboard objective updates.
Payload:
{
"objectiveName": "health",
"mode": 0,
"objectiveValue": "Health",
"type": 0,
"json": "...",
"numberFormat": 0
}OnUpdateScore
Sent when a scoreboard score updates.
Payload:
{
"entityName": "Steve",
"action": 0,
"objectiveName": "health",
"objectiveDisplayName": "Health",
"value": 20,
"numberFormat": 0
}Map and Trade Events
OnMapData
Sent when map data updates.
Payload:
{
"mapId": 0,
"scale": 1,
"trackingPosition": true,
"locked": false,
"icons": [],
"columnsUpdated": 128,
"rowsUpdated": 128,
"mapColumnX": 0,
"mapRowZ": 0,
"colors": "base64-encoded-string"
}Note: colors is base64-encoded when present, null otherwise.
OnTradeList
Sent when a villager trade list is received.
Payload:
{
"windowId": 1,
"trades": [...],
"villagerInfo": { ... }
}Network Events
OnNetworkPacket
Sent for every network packet (when subscribed).
Payload:
{
"packetID": 42,
"data": "base64-encoded-packet-data",
"isLogin": false,
"isInbound": true
}Note: data is base64-encoded. This event generates heavy traffic and is mainly useful for debugging.
