Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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.
commit af4a11fb94c6e8414ebf8b03e5385cceec5e025f 1 parent 0d75a1a
CmdrDats authored
Showing with 9 additions and 7 deletions.
  1. +2 −1  src/cljminecraft/commands.clj
  2. +7 −6 src/cljminecraft/files.clj
3  src/cljminecraft/commands.clj
View
@@ -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))
13 src/cljminecraft/files.clj
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))))
Please sign in to comment.
Something went wrong with that request. Please try again.