Solved My core plugin is completely breaking ProtocolLib, and I have no idea why.

Discussion in 'Spigot Plugin Development' started by SeanTMG, Jan 15, 2020.

  1. Title really says it all, my core plugin is completely breaking ProtocolLib, and I have no idea why. If I remove it ProtocolLib loads fine and everything works, but if I load it and my plugin at the same time I get this error:
    Code (Java):
    15.01 00:47:50 [Server] INFO at com.comphenix.protocol.ProtocolLib.onLoad( ~[?:?]
    15.01 00:47:50 [Server] INFO java.lang.IllegalAccessError: tried to access method com.comphenix.protocol.ProtocolLogger.init(Lorg/bukkit/plugin/Plugin;)V from class com.comphenix.protocol.ProtocolLib
    15.01 00:47:50 [Server] ERROR tried to access method com.comphenix.protocol.ProtocolLogger.init(Lorg/bukkit/plugin/Plugin;)V from class com.comphenix.protocol.ProtocolLib initializing ProtocolLib v4.4.0 (Is it up to date?)
    15.01 00:47:50 [Server] INFO Loading ProtocolLib v4.4.0
    and then nothing that uses protocollib loads properly.

    It started randomly happening about a month ago after an update I made to my plugin, I didn't realize it was my plugin causing it at the time but I've since confirmed this. I don't remember what the change I made was. My plugin handles everything from permissions to nametags to vanishing to essential commands like /fly.

    It uses a lot of NMS for things like ActionBar, NameTags, Book opening, etc, but nothing that I would think would straight up break ProtocolLib, and all of that was developed before it started happening iirc. Sorry that I have no code previews to provide, the plugin is simply too big to know where to begin or what to send. Anyone with any ideas are greatly appreciated.
  2. 1. Use latest ProtocolLib version and add the newest one into your libraries.
    2. Did you add softdepend or depend in your plugin.yml?
    • Agree Agree x 1
  3. Make sure you build against the same version you load on your server. (the latest if possible)
  4. To clarify, I don't use ProtocolLib at all in my plugin. 0 references to anything protocollib. Which is why I'm baffled as to how it's breaking it.

    Also the server, protocollib, and my plugin are all 1.8.8 (yes this is a requirement)
  5. That makes no sense... do you use Maven to rebase anything?
    Do you have any other plugin that uses ProtocolLib and do they work fine?

    from Oracle:

    Code (Text):
    Thrown if an application attempts to access or modify a field, or to call a method that it does not have access to.

    Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed.
    Meaning that you or some plugin uses the wrong version of ProtocolLib
  6. Is ProtocolLib the only plugin that would use or reference NMS that you have
  7. You probably use reflections that change the access to nms fields and protocollib tries to access it after that but it just can't..
    You didn't provide a code
  8. yes my code uses reflection for a lot of things, actionbars, nametags, permissablebase injector, the list goes on. But how would that break a completely separate plugin I don't interact with? Would switching some of my Reflect/NMS stuff to use protocollib possibly fix it?
  9. It's on speculation, but that is most likely the issue.
    Only one way to find out :p
  10. So I'm extremely confused right now, but somehow adding ProtocolLib as a depend in the plugin (even though it doesn't use it at all) solved it. So it just needs protocollib to load first for some reason. Not sure why this happened, but hopefully this helps someone else who might have the same problem.
  11. Awesome. Make sure t mark your thread as solved (y)
  12. :eek:
  13. Because you change the access to nms code, like it's accessible, but then you make it not accessible, then protocollib after your plugin tries to access that but it cannot. If protocollib loads first, then the fields are accessible because your plugin havent change it yet. just an explaination