1

我正在尝试在 Clojure 中编写一个 Bukkit 插件。

通常一个 Bukkit 插件需要重写Plugin类,有一个onEnable()和一个onDisable()方法。还有一些其他要求,例如结果在 JAR 文件中并定义了plugin.yml,但我拥有所有这些。

(ns net.jonnay.watershipdown.WatershipDown
  (:import org.bukkit.Bukkit
           org.bukkit.plugin.Plugin)
  (:gen-class
   :name net.jonnay.watershipdown.WatershipDown
   :extends org.bukkit.plugin.Plugin
   :methods [ [onEnable [] void]
              [onDisable [] void] ]
   )
)

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

(defn debug-to-mc-log [^String msg]
  (let [logger (Bukkit/getLogger)]
    (. logger info (str "(DEBUG) " msg))))

(defn -onEnable []
  (debug-to-mc-log "Enabled Watership down.  Super Clojure Powers!"))

(defn -onDisable []
  (debug-to-mc-log "Disabled Watership down."))

我的代码编译得很好,但是当我尝试在服务器中加载它时,我得到了这个异常:

13:29:20 [SEVERE] Could not load 'plugins/watershipdown-0.1.jar' in folder 'plugins': 
java.lang.ClassFormatError: Duplicate method name&signature in class file net/jonnay/watershipdown/WatershipDown
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:41)
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:29)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131)
    at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:285)
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:200)
    at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:156)
    at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:132)
    at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:52)
    at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:148)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:407)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:465)
4

1 回答 1

4

onEnableonDisable定义Plugin在?

如果是这样,他们可能会导致问题。genClass 文档特别指出您不应该重新声明继承的方法。

于 2012-02-07T02:44:42.247 回答