Giter Club home page Giter Club logo

bukkit-for-clojure-template's People

Contributors

cpmcdaniel avatar

Watchers

 avatar  avatar

bukkit-for-clojure-template's Issues

Error: NullPointerException in the Event Handler

Hello,
first of all: A big thanks for driving this project forward.
I am posting this here because issues seem to be disabled on your Bukkit4Clojure fork
When I generate a new lein project according to your instructions and then trying to put the example event handler code in it,
I cannot produce the uberjar of my project. While compiling, the error log is as following:

{:clojure.main/message
 "Execution error (NullPointerException) at bukkitclj.event/register-event (event.clj:48).\nnull\n",
 :clojure.main/triage
 {:clojure.error/class java.lang.NullPointerException,
  :clojure.error/line 48,
  :clojure.error/symbol bukkitclj.event/register-event,
  :clojure.error/source "event.clj",
  :clojure.error/phase :execution},
 :clojure.main/trace
 {:via
  [{:type clojure.lang.Compiler$CompilerException,
    :message "Syntax error macroexpanding at (plugin.clj:19:1).",
    :data
    {:clojure.error/phase :execution,
     :clojure.error/line 19,
     :clojure.error/column 1,
     :clojure.error/source "plugin.clj"},
    :at [clojure.lang.Compiler$InvokeExpr eval "Compiler.java" 3707]}
   {:type java.lang.NullPointerException,
    :at [bukkitclj.event$register_event invokeStatic "event.clj" 48]}],
  :trace
  [[bukkitclj.event$register_event invokeStatic "event.clj" 48]
   [bukkitclj.event$register_event invoke "event.clj" 36]
   [bukkitclj.event$register_event invokeStatic "event.clj" 40]
   [bukkitclj.event$register_event invoke "event.clj" 36]
   [lobbymania.plugin$fn__472 invokeStatic "plugin.clj" 20]
   [lobbymania.plugin$fn__472 invoke "plugin.clj" 19]
   [clojure.lang.AFn applyToHelper "AFn.java" 152]
   [clojure.lang.AFn applyTo "AFn.java" 144]
   [clojure.lang.Compiler$InvokeExpr eval "Compiler.java" 3702]
   [clojure.lang.Compiler compile1 "Compiler.java" 7731]
   [clojure.lang.Compiler compile "Compiler.java" 7798]
   [clojure.lang.RT compile "RT.java" 411]
   [clojure.lang.RT load "RT.java" 457]
   [clojure.lang.RT load "RT.java" 424]
   [clojure.core$load$fn__6839 invoke "core.clj" 6126]
   [clojure.core$load invokeStatic "core.clj" 6125]
   [clojure.core$load doInvoke "core.clj" 6109]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5908]
   [clojure.core$compile$fn__6844 invoke "core.clj" 6136]
   [clojure.core$compile invokeStatic "core.clj" 6136]
   [clojure.core$compile invoke "core.clj" 6128]
   [user$eval155$fn__164 invoke "form-init1447454908815526697.clj" 1]
   [user$eval155 invokeStatic "form-init1447454908815526697.clj" 1]
   [user$eval155 invoke "form-init1447454908815526697.clj" 1]
   [clojure.lang.Compiler eval "Compiler.java" 7177]
   [clojure.lang.Compiler eval "Compiler.java" 7167]
   [clojure.lang.Compiler eval "Compiler.java" 7167]
   [clojure.lang.Compiler load "Compiler.java" 7636]
   [clojure.lang.Compiler loadFile "Compiler.java" 7574]
   [clojure.main$load_script invokeStatic "main.clj" 475]
   [clojure.main$init_opt invokeStatic "main.clj" 477]
   [clojure.main$init_opt invoke "main.clj" 477]
   [clojure.main$initialize invokeStatic "main.clj" 508]
   [clojure.main$null_opt invokeStatic "main.clj" 542]
   [clojure.main$null_opt invoke "main.clj" 539]
   [clojure.main$main invokeStatic "main.clj" 664]
   [clojure.main$main doInvoke "main.clj" 616]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.main main "main.java" 40]],
  :phase :execution}}

From plugin.clj:

(ns lobbymania.plugin
  (:gen-class
   :name lobbymania.Lobbymania
   :extends bukkitclj.ClojurePlugin)
  (:import [org.bukkit.plugin.java JavaPlugin]))

(set! *warn-on-reflection* true)

(defn -onEnable [^JavaPlugin this]
  (.. this (getLogger) (info "Clojure plugin Lobbymania enabled")))

(defn -onDisable [^JavaPlugin this])

(require '[bukkitclj.event :as ev])
(require '[bukkitclj.repl])
(ev/find-event "player-toggle")
(ev/describe-event :player/player-toggle-sneak)
;; use a reference to your own plugin instance here...
(let [plugin (deref bukkitclj.repl/plugin-ref)]
  (ev/register-event plugin
                     :player/player-toggle-sneak
                     (fn [e] (println "event triggered!"))
                     :priority/normal))

I looked at the event.clj file line 48, where it says:

(bk/plugin-manager)

But this refers to bukkit.clj which contains the macro
I do not know why the compiler even tries to runtime-check the value of plugin-manager against null, as this variable will be set on runtime and can never be initialized in an isolated environment.
Maybe I am getting something wrong here though, correct me if i do ๐Ÿ˜„

Thanks for looking into this,
m0rtis0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.