Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from taufiqkh/master
Added nRepl support and very basic config file reading, removed deprecated bukkit event type and priority enums.
- Loading branch information
Showing
6 changed files
with
71 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,11 @@ pom.xml | |
*jar | ||
/lib/ | ||
/classes/ | ||
.classpath | ||
.lein-failures | ||
.lein-deps-sum | ||
.project | ||
*~ | ||
bin | ||
tmp | ||
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
(ns cljminecraft.config | ||
"Provides a thin wrapper for bukkit config" | ||
(:use cljminecraft.logging)) | ||
|
||
(defrecord Config [bukkit-config defaults]) | ||
|
||
(defn load-config [plugin defaults] | ||
"Loads the bukkit config file for the given plugin and sets defaults" | ||
(let [bukkit-config (.getConfig plugin) | ||
config-defaults (if (nil? defaults) {} defaults)] | ||
(.addDefaults bukkit-config config-defaults) | ||
(Config. bukkit-config config-defaults))) | ||
|
||
(defn get-keyword [config entry-key accepted-values] | ||
"Gets the keyword for the specified entry key, or the default if no entry | ||
exists or the entry is not in the set of accepted values. If no such default | ||
exists, returns nil." | ||
(let [config-entry (keyword (.get (:bukkit-config config) entry-key))] | ||
(if (contains? accepted-values config-entry) | ||
config-entry | ||
(let [default (get (:defaults config) entry-key)] | ||
(warn (format "Unrecognised repl type: %s, using default %s" config-entry (pr-str keyword))) | ||
default)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
(ns cljminecraft.logging | ||
(:require [clojure.tools.logging :as logging])) | ||
|
||
(defmacro info [str] | ||
`(logging/info (.getName ~(symbol "*ns*")) ":" ~str)) | ||
|
||
(defmacro warn [str] | ||
`(logging/warn (.getName ~(symbol "*ns*")) ":" ~str)) | ||
|
||
(defmacro debug [str] | ||
`(logging/debug (.getName ~(symbol "*ns*")) ":" ~str)) |