Permalink
Browse files

Print exception if problems with command

Use plugin directly on file handling
Convert key values to clojure keys. Makes for more sane structures.
  • Loading branch information...
1 parent 0d75a1a commit af4a11fb94c6e8414ebf8b03e5385cceec5e025f @CmdrDats committed Dec 13, 2012
Showing with 9 additions and 7 deletions.
  1. +2 −1 src/cljminecraft/commands.clj
  2. +7 −6 src/cljminecraft/files.clj
@@ -66,8 +66,9 @@
:else
(let [converted (map (partial convert-type sender) param-types args)
{:keys [msg] :as response} (apply f sender converted)]
+ (log/info "Responding with %s" response)
(if msg (respond sender msg))))
- (catch RuntimeException e (respond sender (.getMessage e))))
+ (catch RuntimeException e (.printStackTrace e) (respond sender "An error occurred with this command")))
true)
(defmulti param-type-tabcomplete (fn [_ x _] x))
View
@@ -2,15 +2,16 @@
(:require [cheshire.core :as json])
(:require [clojure.java.io :as io]))
-(defn data-folder [{:keys [server]}]
- (.getDataFolder server))
+(defn data-folder [plugin]
+ (.getDataFolder plugin))
-(defn read-json-file [{:keys [server] :as env} filename]
+(defn read-json-file [plugin filename]
(try
- (json/decode (slurp (io/file (data-folder env) filename)))
+ (json/decode (slurp (io/file (data-folder plugin) filename)) true)
+ (catch java.io.FileNotFoundException e {})
(catch Exception e (.printStackTrace e) {})))
-(defn write-json-file [{:keys [server] :as env} filename data]
- (let [file (io/file (data-folder) filename)]
+(defn write-json-file [plugin filename data]
+ (let [file (io/file (data-folder plugin) filename)]
(io/make-parents file)
(spit file (json/encode data))))

0 comments on commit af4a11f

Please sign in to comment.