From 38da310fd8a092a94d0352c400e4e2637ba00472 Mon Sep 17 00:00:00 2001 From: Kodi Craft Date: Tue, 9 Jul 2024 16:18:04 +0200 Subject: [PATCH] Begin "implementing" configuration stage --- lib/servers/configuration.ex | 10 ++++++++++ lib/servers/login.ex | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/servers/configuration.ex b/lib/servers/configuration.ex index cfeb402..fa63195 100644 --- a/lib/servers/configuration.ex +++ b/lib/servers/configuration.ex @@ -227,7 +227,17 @@ defmodule Amethyst.Server.Configuration do end ## HANDLING + def handle({:serverbound_plugin_message, channel, data}, client) do + handle_plugin_message(channel, data, client) + end def handle(tuple, _) do Logger.error("Unhandled but known packet #{elem(tuple, 0)}") end + defp handle_plugin_message("minecraft:brand", data, _client) do + {[brand], ""} = Read.start(data) |> Read.string |> Read.stop + Logger.info("Client using brand: #{brand}") + end + defp handle_plugin_message("amethyst:hello", _data, _client) do + Logger.info("Client is Amethyst aware! Hello!") + end end diff --git a/lib/servers/login.ex b/lib/servers/login.ex index 6d015bf..3392078 100644 --- a/lib/servers/login.ex +++ b/lib/servers/login.ex @@ -116,8 +116,8 @@ defmodule Amethyst.Server.Login do transmit({:login_success, uuid, name, [], false}, client) end end - def handle({:login_acknowledged}, _client) do - raise RuntimeError, "Configuration stage is not implemented." + def handle({:login_acknowledged}, client) do + Amethyst.Server.Configuration.serve(client) end def handle(tuple, _) do Logger.error("Unhandled but known packet #{elem(tuple, 0)}")