f236013

Bowmap · bowmap.git · Tickets

Branches > main > f236013 > files / src

Move packet keys to net.bowmap.server.protocol.schema

Grahp, 2026-09-13

Commit: f236013678aa2a9012607e1f8bc5811e9c83fb49
Parent: 7472035

5 changed files:

src/net/bowmap/server/protocol/clientbound_packets.clj modified (view file)

@@ -1,16 +1,16 @@ (ns net.bowmap.server.protocol.clientbound-packets   (:require-   [net.bowmap.server.protocol.types :as t]-   [net.bowmap.server.protocol.writers :refer :all]-   [net.bowmap.server.protocol.phase :as phase]))+   [net.bowmap.server.protocol.phase :as phase]+   [net.bowmap.server.protocol.schema :as p]+   [net.bowmap.server.protocol.writers :refer :all]))  (defn ? [_] (throw (Exception. "Error while encoding packet: no packet definition for that packet id")))  (def clientbound-packets   "Map of connection phases to pairs of [clientbound-packet-id writer]"   {::phase/status-   [::status-response [::t/status-response status-response->]-    ::pong-response [::t/timestamp long->]]+   [::status-response status-response->+    ::pong-response [::p/timestamp long->]]    ::phase/login    [::disconnect ?     ::encryption-request ?

src/net/bowmap/server/protocol/schema.clj added (view file)

@@ -0,0 +1 @@+(ns net.bowmap.server.protocol.schema)

src/net/bowmap/server/protocol/serverbound_packets.clj modified (view file)

@@ -1,8 +1,8 @@ (ns net.bowmap.server.protocol.serverbound-packets   (:require+   [net.bowmap.server.protocol.phase :as phase]    [net.bowmap.server.protocol.readers :refer :all]-   [net.bowmap.server.protocol.types :as t]-   [net.bowmap.server.protocol.phase :as phase]))+   [net.bowmap.server.protocol.schema :as p]))  (def serverbound-packets   "Map of connection phases to pairs of [serverbound-packet-id reader]"@@ -13,7 +13,7 @@                    ::phase/phase (->enum ->varint {1 ::phase/status 2 ::phase/login 3 ::phase/transfer})]]    ::phase/status    [::status-request []-    ::ping-request [::t/timestamp ->long]]+    ::ping-request [::p/timestamp ->long]]    ::phase/login    [::login-start []     ::encryption-response []

src/net/bowmap/server/protocol/writers.clj modified (view file)

@@ -3,7 +3,8 @@    Functions look like type->, where 'type' is a Minecraft protocol type.    See https://minecraft.wiki/w/Java_Edition_protocol/Packets#Data_types"   (:require-   [clojure.data.json :as json])+   [clojure.data.json :as json]+   [net.bowmap.server.protocol.schema :as p])   (:import    [io.netty.buffer ByteBuf]    [java.nio.charset Charset]))@@ -36,7 +37,7 @@ (defn json-> [buf s]   (string-> buf (json/write-str s))) -(defn status-response-> [buf {:keys! [version-name protocol]}]+(defn status-response-> [buf {::p/keys! [version-name protocol]}]   (json-> buf {:version {:name version-name                          :protocol protocol}})) 

src/net/bowmap/server/runtime/packets.clj modified (view file)

@@ -3,8 +3,8 @@    [net.bowmap.server.protocol.clientbound-packets :as clientbound]    [net.bowmap.server.protocol.packet :as packet]    [net.bowmap.server.protocol.phase :as phase]-   [net.bowmap.server.protocol.serverbound-packets :as serverbound]-   [net.bowmap.server.protocol.types :as t]))+   [net.bowmap.server.protocol.schema :as p]+   [net.bowmap.server.protocol.serverbound-packets :as serverbound]))  (defn apply-packet   "'Applies' a serverbound packet to a client.@@ -14,8 +14,8 @@     (case id       ::serverbound/handshaking [(assoc client ::phase/phase (req! packet ::phase/phase))]       ::serverbound/status-request [client [{::packet/id ::clientbound/status-response-                                             ::t/status-response {:version-name "26.2"-                                                                  :protocol 776}}]]+                                             ::p/version-name "26.2"+                                             ::p/protocol 776}]]       ::serverbound/login-acknowledged [(assoc client ::phase/phase ::phase/config)]       ::serverbound/finish-config [(assoc client ::phase/phase ::phase/play)]       [client])))