-
Notifications
You must be signed in to change notification settings - Fork 8
/
printers.clj
35 lines (33 loc) · 1.81 KB
/
printers.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(in-ns 'lambdaisland.witchcraft)
(require '[lambdaisland.data-printers :as dp])
#_(import (net.glowstone GlowWorld GlowServer GlowOfflinePlayer)
(net.glowstone.block.entity.state GlowDispenser)
(net.glowstone.chunk ChunkManager)
(net.glowstone.constants GlowEnchantment GlowPotionEffect)
(net.glowstone.io WorldStorageProvider)
(net.glowstone.util.config WorldConfig ServerConfig)
(org.bukkit Bukkit Material Location World)
(org.bukkit.block Block)
(org.bukkit.configuration.serialization ConfigurationSerialization)
(org.bukkit.enchantments Enchantment)
(org.bukkit.entity Entity Player HumanEntity)
(org.bukkit.inventory ItemStack Inventory)
(org.bukkit.material MaterialData Directional)
(org.bukkit.plugin PluginManager Plugin)
(org.bukkit.potion Potion PotionEffectType)
(org.bukkit.scheduler BukkitScheduler)
(org.bukkit.util Vector))
(defn defprint [type tag to-edn]
(dp/register-print type tag to-edn)
(dp/register-pprint type tag to-edn))
(defprint Location 'bukkit/Location #(do [(x %) (y %) (z %) (yaw %) (pitch %) (.getName (world %))]))
(defprint Block 'bukkit/Block #(let [direction (get block-face-names (XBlock/getDirection %))]
(cond-> {:x (x %)
:y (y %)
:z (z %)
:world (.getName (world %))
:material (material-name %)}
(pre-flattening?)
(assoc :data (material-data %))
(not= :self direction)
(assoc :direction direction))))