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

Some little bugs #3

Closed
JBou opened this issue Apr 30, 2015 · 6 comments
Closed

Some little bugs #3

JBou opened this issue Apr 30, 2015 · 6 comments

Comments

@JBou
Copy link
Contributor

JBou commented Apr 30, 2015

The gateway cannot be initialized directly, like this:

public ServerGateway<Player> gateway = BukkitGatewayProvider.getGateway("MyChannelName", this);

If i do it how it's written in the documentation, it gives me an IllegalPluginAccessException:

[00:18:18 ERROR]: Could not load 'plugins\test-1.0.0-SNAPSHOT.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: org.bukkit.plugin.IllegalPluginAccessException: Plugin attempted to register com.ikeirnez.pluginmessageframework.bukkit.BukkitGateway@292af07d while not enabled
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:135) ~[spigot.jar:git-Spigot-2ec6f06-7722428]
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[spigot.jar:git-Spigot-2ec6f06-7722428]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [spigot.jar:git-Spigot-2ec6f06-7722428]
        at org.bukkit.craftbukkit.v1_8_R2.CraftServer.loadPlugins(CraftServer.java:291) [spigot.jar:git-Spigot-2ec6f06-7722428]
        at org.bukkit.craftbukkit.v1_8_R2.CraftServer.reload(CraftServer.java:744) [spigot.jar:git-Spigot-2ec6f06-7722428]
        at org.bukkit.Bukkit.reload(Bukkit.java:534) [spigot.jar:git-Spigot-2ec6f06-7722428]
        at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot.jar:git-Spigot-2ec6f06-7722428]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot.jar:git-Spigot-2ec6f06-7722428]
        at org.bukkit.craftbukkit.v1_8_R2.CraftServer.dispatchCommand(CraftServer.java:646) [spigot.jar:git-Spigot-2ec6f06-7722428]
        at org.bukkit.craftbukkit.v1_8_R2.CraftServer.dispatchServerCommand(CraftServer.java:632) [spigot.jar:git-Spigot-2ec6f06-7722428]
        at net.minecraft.server.v1_8_R2.DedicatedServer.aN(DedicatedServer.java:405) [spigot.jar:git-Spigot-2ec6f06-7722428]
        at net.minecraft.server.v1_8_R2.DedicatedServer.A(DedicatedServer.java:369) [spigot.jar:git-Spigot-2ec6f06-7722428]
        at net.minecraft.server.v1_8_R2.MinecraftServer.z(MinecraftServer.java:651) [spigot.jar:git-Spigot-2ec6f06-7722428]
        at net.minecraft.server.v1_8_R2.MinecraftServer.run(MinecraftServer.java:554) [spigot.jar:git-Spigot-2ec6f06-7722428]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_45]
Caused by: org.bukkit.plugin.IllegalPluginAccessException: Plugin attempted to register com.ikeirnez.pluginmessageframework.bukkit.BukkitGateway@292af07d while
not enabled
        at org.bukkit.plugin.SimplePluginManager.registerEvents(SimplePluginManager.java:524) ~[spigot.jar:git-Spigot-2ec6f06-7722428]
        at com.ikeirnez.pluginmessageframework.bukkit.BukkitGateway.<init>(BukkitGateway.java:35) ~[?:?]
        at com.ikeirnez.pluginmessageframework.bukkit.BukkitGatewayProvider.getGateway(BukkitGatewayProvider.java:20) ~[?:?]
        at com.ndependend.test.Test.<init>(Test.java:32) ~[?:?]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_45]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_45]
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_45]
        at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_45]
        at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_45]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[spigot.jar:git-Spigot-2ec6f06-7722428]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[spigot.jar:git-Spigot-2ec6f06-7722428]
        ... 14 more

You have to wait and do it after the plugin has been enabled (in the onEnable()), like so:

public ServerGateway<Player> gateway;

public void onEnable() {
    gateway = BukkitGatewayProvider.getGateway("MyChannelName", this);;
    gateway.registerListener(this);
}

This applies for the Bukkit and the BungeeCord plugin. Maybe you should update the README for both.


If I have the same Packet (class) on BungeeCord and Bukkit, but in a different package, then I get the following NullPointerException on this line:

WARNUNG: Error dispatching event PluginMessageEvent(super=TargetedEvent(sender=net.md_5.bungee.ServerConnection@730bf58d receiver=JBou), cancelled=true, tag=MyChannelName, 
data=[-84, -19, 0, 5, 119, 24, 0, 22, 80, 108, 117, 103, 105, 110,
77, 101, 115, 115, 97, 103, 101, 70, 114, 97, 109, 101, 119, 111, 114, 107, 115,
 114, 0, 16, 112, 97, 99, 107, 101, 116, 50, 46, 77, 121, 80, 97, 99, 107, 101,
116, 65, 108, 12, -72, -101, -17, 37, -99, 2, 0, 1, 76, 0, 7, 109, 101, 115, 115
, 97, 103, 101, 116, 0, 18, 76, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 83,
 116, 114, 105, 110, 103, 59, 120, 114, 0, 57, 99, 111, 109, 46, 105, 107, 101,
105, 114, 110, 101, 122, 46, 112, 108, 117, 103, 105, 110, 109, 101, 115, 115, 9
7, 103, 101, 102, 114, 97, 109, 101, 119, 111, 114, 107, 46, 112, 97, 99, 107, 1
01, 116, 46, 83, 116, 97, 110, 100, 97, 114, 100, 80, 97, 99, 107, 101, 116, 114
, 75, -57, 106, 127, 30, -86, 77, 2, 0, 0, 120, 112, 116, 0, 3, 108, 111, 108])
to listener com.ikeirnez.pluginmessageframework.bungeecord.BungeeGateway@59cba5a
java.lang.NullPointerException
    at com.ikeirnez.pluginmessageframework.impl.GatewaySupport.receivePacket(GatewaySupport.java:155)
    at com.ikeirnez.pluginmessageframework.impl.GatewaySupport.incomingPayload(GatewaySupport.java:117)
    at com.ikeirnez.pluginmessageframework.bungeecord.BungeeGateway.onPluginMessage(BungeeGateway.java:71)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.md_5.bungee.event.EventHandlerMethod.invoke(EventHandlerMethod.java:19)
    at net.md_5.bungee.event.EventBus.post(EventBus.java:47)
    at net.md_5.bungee.api.plugin.PluginManager.callEvent(PluginManager.java:367)
    at net.md_5.bungee.connection.DownstreamBridge.handle(DownstreamBridge.java:222)
    at net.md_5.bungee.protocol.packet.PluginMessage.handle(PluginMessage.java:62)
    at net.md_5.bungee.netty.HandlerBoss.channelRead(HandlerBoss.java:75)
    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.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(Unknown Source)

Maybe you can fix this :)

Regards, JBou

@keir-nellyer
Copy link
Owner

Ah yes, that's my fault. I'll update the README when I get on my pc tomorrow :)

As for the other issue, that's how java serialization/deserialization works, it should be the exact same class (meaning same package) on either side.

I suggest you use Maven or Gradle to create a common project for the Bukkit and BungeeCord plugins and shade the common project into both JARs.

Failing that you can simply do as your currently doing making sure the packages are the same.

I will try update the error message displayed tomorrow to make it easier to understand and fix :)

@JBou
Copy link
Contributor Author

JBou commented May 1, 2015

Ok thanks :) I'm just using a common project, it's only for other people if they are wondering why it's not working.
And another question: What's the serialVersionUID in the Packet class for?

@keir-nellyer
Copy link
Owner

Basically the serialVersionUID is a number which should only be changed if breaking changes are made to the packet. It prevents the packet being de-serialized if the serialVersionUIDs of the packet being sent, and the receiving sides copy of the packet do not match.

There's a more detailed explanation available here http://stackoverflow.com/questions/285793/what-is-a-serialversionuid-and-why-should-i-use-it

keir-nellyer added a commit that referenced this issue May 1, 2015
…additonal NullPointerException being thrown) FIXES #3
@JBou
Copy link
Contributor Author

JBou commented May 1, 2015

Aha, I understand. Thanks!

@keir-nellyer
Copy link
Owner

Okay, awesome :D if you encounter any more questions/issues, let me know

@JBou
Copy link
Contributor Author

JBou commented May 1, 2015

Of course :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants