Unable to get Properties/Methods for Event
ellisgl opened this issue ยท 1 comments
I've tried several things to output the Properties / Methods of an event, but have hit road blocks. I've tried to do it with the player object, but same deals.
Running this on Spigot:
git-Spigot-90f61bc-29e1d72 (MC: 1.10.2) (Implementing API version 1.10.2-R0.1-SNAPSHOT)
On CentOS 7.x and
openjdk version "1.8.0_101"
OpenJDK Runtime Environment (build 1.8.0_101-b13)
OpenJDK 64-Bit Server VM (build 25.101-b13, mixed mode)
Code...
events.playerMove(function(event)
{
console.log(JSON.stringify(event));
}
This code returns: [03:32:28 INFO]: [scriptcraft] undefined
If I try it against this:
var getKeys = function(obj)
{
var keys = [];
for(var key in obj){
keys.push(key);
}
return keys;
}
It outputs blank.
If I do Object.keys(event), I get:
[03:37:16 ERROR]: Could not pass event PlayerMoveEvent to scriptcraft v3.2.0-2016-03-19
jdk.nashorn.internal.runtime.ECMAException: TypeError: org.bukkit.event.player.PlayerMoveEvent@3755be94 is not an Object
at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:213) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:185) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:172) ~[nashorn.jar:?]
at jdk.nashorn.internal.objects.NativeObject.notAnObject(NativeObject.java:136) ~[nashorn.jar:?]
at jdk.nashorn.internal.objects.NativeObject.keys(NativeObject.java:439) ~[nashorn.jar:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$264$209AA$\^eval\_.L:1$L:11(<eval>:22) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$64$1377AA$\^eval\_.L:1$on$execute(<eval>:61) ~[?:?]
at org.bukkit.plugin.EventExecutor$$NashornJavaAdapter.execute(Unknown Source) ~[?:?]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.10.2.jar:git-Spigot-90f61bc-29e1d72]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.10.2.jar:git-Spigot-90f61bc-29e1d72]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.10.2.jar:git-Spigot-90f61bc-29e1d72]
at net.minecraft.server.v1_10_R1.PlayerConnection.a(PlayerConnection.java:610) [spigot-1.10.2.jar:git-Spigot-90f61bc-29e1d72]
at net.minecraft.server.v1_10_R1.PacketPlayInFlying.a(SourceFile:126) [spigot-1.10.2.jar:git-Spigot-90f61bc-29e1d72]
at net.minecraft.server.v1_10_R1.PacketPlayInFlying$PacketPlayInLook.a(SourceFile:88) [spigot-1.10.2.jar:git-Spigot-90f61bc-29e1d72]
at net.minecraft.server.v1_10_R1.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.10.2.jar:git-Spigot-90f61bc-29e1d72]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_101]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_101]
at net.minecraft.server.v1_10_R1.SystemUtils.a(SourceFile:45) [spigot-1.10.2.jar:git-Spigot-90f61bc-29e1d72]
at net.minecraft.server.v1_10_R1.MinecraftServer.D(MinecraftServer.java:732) [spigot-1.10.2.jar:git-Spigot-90f61bc-29e1d72]
at net.minecraft.server.v1_10_R1.DedicatedServer.D(DedicatedServer.java:400) [spigot-1.10.2.jar:git-Spigot-90f61bc-29e1d72]
at net.minecraft.server.v1_10_R1.MinecraftServer.C(MinecraftServer.java:668) [spigot-1.10.2.jar:git-Spigot-90f61bc-29e1d72]
at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:567) [spigot-1.10.2.jar:git-Spigot-90f61bc-29e1d72]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_101]
You can't use JSON.stringify() on Java objects. Refer to the Spigot API docs for details on specific Spigot/MC events.
https://hub.spigotmc.org/javadocs/spigot/