Jycraft / jycraft

Extend Minecraft servers with Python using Jython.
BSD 3-Clause "New" or "Revised" License
13 stars 2 forks source link

Spigot version can't import mcapi.py #15

Closed pauleveritt closed 8 years ago

pauleveritt commented 8 years ago

Jycraft ships with a Python module of mcapi.py which can be imported inside a websocket-driven interpreter.

In the canary version, if you put this .py file in the root of your canary installation, you can import it with "from mcapi import yell". In the spigot version, though, you get the following traceback. In an ideal world, we'd put this .py file in the plugins directory or some "jycraft" top-level directory.

[12:02:07 WARN]: [Bukkit_Jython_Console] Task #2 for Bukkit_Jython_Console v0.1 generated an exception org.python.core.PyException at org.python.core.Py.ImportError(Py.java:332) ~[?:?] at org.python.core.imp.import_logic(imp.java:893) ~[?:?] at org.python.core.imp.import_module_level(imp.java:959) ~[?:?] at org.python.core.imp.importName(imp.java:1041) ~[?:?] at org.python.core.ImportFunction.call(builtin.java:1280) ~[?:?] at org.python.core.PyObject.call(PyObject.java:431) ~[?:?] at org.python.core.builtin.import(builtin.java:1232) ~[?:?] at org.python.core.imp.importFromAs(imp.java:1132) ~[?:?] at org.python.core.imp.importFrom(imp.java:1108) ~[?:?] at mcapi$py.f$0(./mcapi.py:229) ~[?:?] at mcapi$py.call_function(./mcapi.py) ~[?:?] at org.python.core.PyTableCode.call(PyTableCode.java:167) ~[?:?] at org.python.core.PyCode.call(PyCode.java:18) ~[?:?] at org.python.core.imp.createFromCode(imp.java:432) ~[?:?] at org.python.core.imp.createFromSource(imp.java:393) ~[?:?] at org.python.core.imp.loadFromSource(imp.java:652) ~[?:?] at org.python.core.imp.find_module(imp.java:537) ~[?:?] at org.python.core.imp.import_next(imp.java:823) ~[?:?] at org.python.core.imp.import_module_level(imp.java:940) ~[?:?] at org.python.core.imp.importName(imp.java:1041) ~[?:?] at org.python.core.ImportFunction.call(builtin.java:1280) ~[?:?] at org.python.core.PyObject.call(PyObject.java:431) ~[?:?] at org.python.core.builtin.import(builtin.java:1232) ~[?:?] at org.python.core.imp.importFromAs(imp.java:1132) ~[?:?] at org.python.core.imp.importFrom(imp.java:1108) ~[?:?] at org.python.pycode._pyx0.f$0(:3) ~[?:?] at org.python.pycode._pyx0.call_function() ~[?:?] at org.python.core.PyTableCode.call(PyTableCode.java:167) ~[?:?] at org.python.core.PyCode.call(PyCode.java:18) ~[?:?] at org.python.core.Py.runCode(Py.java:1390) ~[?:?] at org.python.core.Py.exec(Py.java:1434) ~[?:?] at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:267) ~[?:?] at jycraft.plugin.spigot.MainPlugin$1.run(MainPlugin.java:33) ~[?:?] at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24] at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:350) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:723) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24] at java.lang.Thread.run(Thread.java:745) [?:1.8.0_25]

BenLewis-Seequent commented 8 years ago

The problem is that mcapi.py is specific to Canary as it's just a wrapper around the canary api. Looking at the stack trace mcapi.py was imported but my guess is that the import of the Canary api from mcapi.py failed. Anyways mcapi.py should already be bundled with the canary build so no need to put it in the canary root. Should there be some sort of common api between the different versions?

pauleveritt commented 8 years ago

Well, you are right, I should have thought more about that, my apologies. I'll close this ticket and make a new one for a Spigot-capable wrapper.