Python を使用して CraftBukkit (Minecraft modded サーバー ソフトウェア) をスクリプト化する方法を構築しています。
これを行うには、Python スクリプトを Jython でロードし、イベントのデコレーターなどを用意します。
現在、イベント デコレータを実装していますが、問題があります。引数のないデコレータは正常に動作しますが、引数を追加するとすぐに、十分な引数がないという不平を言い始めます。
これは機能します:
@script.event
def test(event):
print "hi" # Works
public void event(PyFunction func) {
return func;
}
これはしません:
@script.event("player.PlayerMoveEvent", "normal")
def test(event):
print "player moved!" # TypeError: event(): 1st arg can't be coerced to org.python.core.PyFunction
public void event(PyFunction func, PyString eventType, PyString priority) {
// Do all kinds of crap
return func;
}
これが私のJavaコードです: http://pastebin.com/GsULYdJr