Add handler for serverbound_plugin_message (play)
All checks were successful
Build & Test / nix-build (push) Successful in 1m15s

This commit is contained in:
Kodi Craft 2024-08-12 12:23:00 +02:00
parent 0c94bab3e4
commit c6f0df489e
Signed by: kodi
GPG Key ID: 69D9EED60B242822

View File

@ -31,7 +31,10 @@ defmodule Amethyst.Server.Play do
## DESERIALIZATION ## DESERIALIZATION
@impl true @impl true
def deserialize(0x12, data) do
{[channel], data} = Read.start(data) |> Read.string |> Read.stop
{:serverbound_plugin_message, channel, data}
end
def deserialize(type, _) do def deserialize(type, _) do
raise RuntimeError, "Got unknown packet type #{type}!" raise RuntimeError, "Got unknown packet type #{type}!"
end end
@ -73,6 +76,10 @@ defmodule Amethyst.Server.Play do
## HANDLING ## HANDLING
@impl true @impl true
def handle({:serverbound_plugin_message, channel, data}, _client, state) do
Logger.debug("Got plugin message #{channel} with data #{inspect(data)}")
{:ok, state}
end
def handle(tuple, _, state) do def handle(tuple, _, state) do
Logger.error("Unhandled but known packet #{elem(tuple, 0)}") Logger.error("Unhandled but known packet #{elem(tuple, 0)}")
{:unhandled, state} {:unhandled, state}