Use Keyword instead of manual changes
All checks were successful
Build & Test / nix-build (push) Successful in 1m11s
All checks were successful
Build & Test / nix-build (push) Successful in 1m11s
This commit is contained in:
parent
ec9f9c87ac
commit
361655da52
@ -236,10 +236,10 @@ defmodule Amethyst.Server.Configuration do
|
|||||||
defp handle_plugin_message("minecraft:brand", data, _client, state) do
|
defp handle_plugin_message("minecraft:brand", data, _client, state) do
|
||||||
{[brand], ""} = Read.start(data) |> Read.string |> Read.stop
|
{[brand], ""} = Read.start(data) |> Read.string |> Read.stop
|
||||||
Logger.info("Client using brand: #{brand}")
|
Logger.info("Client using brand: #{brand}")
|
||||||
{:ok, [{:brand, brand} | state]}
|
{:ok, Keyword.put(state, :brand, brand)}
|
||||||
end
|
end
|
||||||
defp handle_plugin_message("amethyst:hello", _data, _client, state) do
|
defp handle_plugin_message("amethyst:hello", _data, _client, state) do
|
||||||
Logger.info("Client is Amethyst aware! Hello!")
|
Logger.info("Client is Amethyst aware! Hello!")
|
||||||
{:ok, [{:amethyst, true} | state]}
|
{:ok, Keyword.put(state, :knows_amethyst, true)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -53,6 +53,7 @@ require Logger
|
|||||||
@spec serve(:gen_tcp.socket()) :: no_return()
|
@spec serve(:gen_tcp.socket()) :: no_return()
|
||||||
def serve(client, state \\ []) do
|
def serve(client, state \\ []) do
|
||||||
{id, data} = Amethyst.Server.Generic.get_packet(client)
|
{id, data} = Amethyst.Server.Generic.get_packet(client)
|
||||||
|
Logger.debug("State: #{inspect(state)}")
|
||||||
packet = deserialize(id, data)
|
packet = deserialize(id, data)
|
||||||
Logger.debug("Got packet #{inspect(packet)}")
|
Logger.debug("Got packet #{inspect(packet)}")
|
||||||
{result, state} = handle(packet, client, state)
|
{result, state} = handle(packet, client, state)
|
||||||
|
Loading…
Reference in New Issue
Block a user