component.clj

Bowmap · bowmap.git · Tickets

Branches > main > dab4740 > files / src / net / bowmap / server / protocol / component.clj

(ns net.bowmap.server.protocol.component
  "The subset of the protocol text component format used by this server.
   See https://minecraft.wiki/w/Text_component_format for the full format."
  (:require
   [clojure.spec.alpha :as s]))

(s/def ::type #{"text" #_"translatable" #_"score" #_"selector" #_"keybind" #_"nbt"})
(s/def ::text string?)

(s/def ::color #(re-matches #"#[0-9a-fA-F]{6}" %))
(s/def ::extra (s/* ::component))

(s/def ::component (s/keys :opt-un [::type ::text #_::translate #_::score #_::selector #_::keybind #_::nbt
                                    ::extra
                                    ::color #_::font #_::bold #_::italic #_::underlined #_::strikethrough #_::obfuscated #_::shadow_color
                                    #_::insertion #_::click_event #_::hover_event]))