Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not pass event PlayerMoveEvent to ConsolesCore v1.2 #52

Open
justdave opened this issue Feb 20, 2016 · 1 comment
Open

Could not pass event PlayerMoveEvent to ConsolesCore v1.2 #52

justdave opened this issue Feb 20, 2016 · 1 comment
Assignees
Labels

Comments

@justdave
Copy link

[10:47:13 ERROR]: Could not pass event PlayerMoveEvent to ConsolesCore v1.2
org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
        at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:270) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
        at net.minecraft.server.v1_8_R3.PacketPlayInFlying.a(SourceFile:126) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
        at net.minecraft.server.v1_8_R3.PacketPlayInFlying$PacketPlayInPosition.a(SourceFile:57) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
        at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_66]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_66]
        at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
        at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
        at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
        at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_66]
Caused by: java.lang.IllegalArgumentException: Cannot measure distance between survival and hub
        at org.bukkit.Location.distanceSquared(Location.java:456) ~[spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
        at ca.jarcode.consoles.internal.ConsolePixelBuffer$PlayerListener.onPlayerMove(ConsolePixelBuffer.java:170) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor61.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_66]
        at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_66]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.8.8.jar:git-Spigot-db6de12-07c3001]
        ... 15 more

The money line from the traceback is of course Caused by: java.lang.IllegalArgumentException: Cannot measure distance between survival and hub at org.bukkit.Location.distanceSquared(Location.java:456)

The onPlayerMove() handler has an explicit check to make sure the renderer is in the same world as the player. Except at the point the event fires, the player hasn't actually moved yet, so you're checking against the source of the move. If the player is moving from the world with the renderer to a different one (stepped into a portal), then this check will pass because they are currently in the same world. Except then you're trying to do distance math on the destination of the move, which doesn't work since the destination wasn't in the same world.

The fix is to check the world of the destination instead of the player's current world.

diff --git a/consoles-core/src/main/java/ca/jarcode/consoles/internal/ConsolePixelBuffer.java b/consoles-core/src/main/java/ca/jarcode/consoles/internal/ConsolePixelBuffer.java
index 02e5025..5bbde59 100644
--- a/consoles-core/src/main/java/ca/jarcode/consoles/internal/ConsolePixelBuffer.java
+++ b/consoles-core/src/main/java/ca/jarcode/consoles/internal/ConsolePixelBuffer.java
@@ -166,7 +166,7 @@ public class ConsolePixelBuffer {
         @SuppressWarnings("unused")
         public void onPlayerMove(PlayerMoveEvent e) {
             boolean last = inside;
-            inside = renderer.pos.getWorld() == e.getPlayer().getWorld()
+            inside = renderer.pos.getWorld() == e.getTo().getWorld()
                 && renderer.pos.distanceSquared(e.getTo()) <= 1280;
             // if the player entered the radius, update the painting
             if (!last && inside)
@jarcode-foss
Copy link
Owner

Thanks for the detailed report and fix, I will get this change in once I can get version 1.3 working. I've been incredibly busy with other things and trying to get the native component for Consoles to work has been a chore (if anyone is able to help me with the codebase, that would be great).

@jarcode-foss jarcode-foss self-assigned this Feb 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants