Minor tweaks
This commit is contained in:
parent
0fdc00148e
commit
7821b20758
@ -60,7 +60,7 @@ defmodule Amethyst.ConnectionState.Login do
|
|||||||
Macros.defpacket_serverbound :login_acknowledged, 0x03, 767, []
|
Macros.defpacket_serverbound :login_acknowledged, 0x03, 767, []
|
||||||
Macros.defpacket_serverbound :cookie_response, 0x04, 767, [identifier: :string, payload: {:optional, :byte_array}]
|
Macros.defpacket_serverbound :cookie_response, 0x04, 767, [identifier: :string, payload: {:optional, :byte_array}]
|
||||||
|
|
||||||
def handle(%{packet_type: :login_start, name: name, player_uuid: player_uuid}, 767, state) do
|
def handle(%{packet_type: :login_start, name: name, player_uuid: player_uuid}, 767, _state) do
|
||||||
Logger.debug("Received login start for #{name} with UUID #{player_uuid}")
|
Logger.debug("Received login start for #{name} with UUID #{player_uuid}")
|
||||||
if Application.fetch_env!(:amethyst, :encryption) do
|
if Application.fetch_env!(:amethyst, :encryption) do
|
||||||
raise RuntimeError, "Encryption is not currently supported"
|
raise RuntimeError, "Encryption is not currently supported"
|
||||||
|
@ -78,7 +78,7 @@ defmodule Amethyst.ConnectionState.Macros do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def write_signature(packet, signature) do
|
def write_signature(packet, signature) do
|
||||||
data = Enum.reduce(signature, "", fn {name, type}, acc ->
|
Enum.reduce(signature, "", fn {name, type}, acc ->
|
||||||
#acc <> apply(Write, type, [Map.get(packet, name)])
|
#acc <> apply(Write, type, [Map.get(packet, name)])
|
||||||
case type do
|
case type do
|
||||||
{:optional, {:compound, signature}} ->
|
{:optional, {:compound, signature}} ->
|
||||||
@ -145,7 +145,7 @@ defmodule Amethyst.ConnectionState.Macros do
|
|||||||
_ -> false
|
_ -> false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def type_matches(value, {:optional, type}) when is_nil(value), do: true
|
def type_matches(value, {:optional, _type}) when is_nil(value), do: true
|
||||||
def type_matches(value, {:optional, type}), do: type_matches(value, type)
|
def type_matches(value, {:optional, type}), do: type_matches(value, type)
|
||||||
def type_matches(value, {:array, signature}) when is_list(value), do: Enum.all?(value, fn item -> check_type(item, signature) end)
|
def type_matches(value, {:array, signature}) when is_list(value), do: Enum.all?(value, fn item -> check_type(item, signature) end)
|
||||||
def type_matches(value, {:compound, signature}) when is_map(value), do: check_type(value, signature)
|
def type_matches(value, {:compound, signature}) when is_map(value), do: check_type(value, signature)
|
||||||
|
Loading…
Reference in New Issue
Block a user