BungeeCord can't pull events from a private Listener

Discussion in 'BungeeCord Plugin Development' started by CraftedFury, May 24, 2015.

  1. I setup an abstract class in my API so that I don't have to register the class myself, just to make it look cleaner, but BungeeCord can't seem to load the events using reflection for whatever reason:
    Code (Text):
    18:12:05 [INFO] [CraftedFury] <-> ServerConnector [lobby] has connected
    18:12:05 [SEVERE] [CraftedFury] <-> ServerConnector [lobby] - encountered exception
    java.lang.Error: Method became inaccessible: ServerConnectedEvent(player=CraftedFury, [email protected])
        at net.md_5.bungee.event.EventBus.post(EventBus.java:50)
        at net.md_5.bungee.api.plugin.PluginManager.callEvent(PluginManager.java:367)
        at net.md_5.bungee.ServerConnector.handle(ServerConnector.java:157)
        at net.md_5.bungee.protocol.packet.Login.handle(Login.java:60)
        at net.md_5.bungee.netty.HandlerBoss.channelRead(HandlerBoss.java:76)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:161)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:161)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
        at io.netty.handler.timeout.ReadTimeoutHandler.channelRead(ReadTimeoutHandler.java:150)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:787)
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:130)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
        at java.lang.Thread.run(Thread.java:745)
    Caused by: java.lang.IllegalAccessException: Class net.md_5.bungee.event.EventHandlerMethod can not access a member of class net.netcoding.niftybungee.NiftyBungee$TestListener with modifiers "public"
        at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:109)
        at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:261)
        at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:253)
        at java.lang.reflect.Method.invoke(Method.java:599)
        at net.md_5.bungee.event.EventHandlerMethod.invoke(EventHandlerMethod.java:19)
        at net.md_5.bungee.event.EventBus.post(EventBus.java:47)
        ... 26 more
    18:12:05 [INFO] [CraftedFury] disconnected with: §fException Connecting:Error : Method became inaccessible: ServerConnectedEvent(player=CraftedFury, [email protected]) @ net.md_5.bungee.event.EventBus:50
    18:12:05 [INFO] [CraftedFury] <-> ServerConnector [lobby] has disconnected
    18:12:06 [INFO] [CraftedFury] -> UpstreamBridge has disconnected
    I trimmed my entire plugin class so that it does nothing but register a listener. Here is the main NiftyBungee class:
    Code (Java):
    package net.netcoding.niftybungee;

    import net.md_5.bungee.api.connection.ProxiedPlayer;
    import net.md_5.bungee.api.event.ServerConnectedEvent;
    import net.md_5.bungee.api.plugin.Plugin;
    import net.md_5.bungee.event.EventHandler;
    import net.netcoding.niftybungee.minecraft.BungeeListener;

    public class NiftyBungee extends Plugin {

        @Override
        public void onEnable() {
            new TestListener(this);
        }

        private class TestListener extends BungeeListener {

            public TestListener(Plugin plugin) {
                super(plugin);
            }

            @EventHandler
            public void onServerConnected(ServerConnectedEvent event) {
                ProxiedPlayer player = event.getPlayer();
                System.out.println(player.getName() + " has logged in");
            }

        }

    }
    Here is what my BungeeListener looks like:
    Code (Java):
    package net.netcoding.niftybungee.minecraft;

    import net.md_5.bungee.api.plugin.Listener;
    import net.md_5.bungee.api.plugin.Plugin;

    public abstract class BungeeListener implements Listener {

        public BungeeListener(Plugin plugin) {
            plugin.getProxy().getPluginManager().registerListener(plugin, this);
        }

    }
    As you can see, nothing strange going on here. I do the same thing with Bukkit, and it works just fine.
    The version I tested this with was the latest download as of this post: git:BungeeCord-Bootstrap:1.8-SNAPSHOT:"9cf57ca":1068