How to make a plugin comptiable with multiple versions

Discussion in 'Spigot Plugin Development' started by TKUIYEAGER1, Aug 16, 2018.

  1. Title stays it all, how can I make my plugin compatible for 1.8 - 1.13?
  2. In your plugin.yml there is an api-version key, set that to 1.13 if you developed it in 1.13. That will “fix” things that were updated in 1.13.

    This is not a brilliant fix although aims to allow older plugins to work on a 1.13 server. Otherwise, where appropriate check what version the server’s using and use a comparative statement to perform certain actions based on this.

    Edit: you should not be making things 1.8 compatible. Either 1.12 or 1.13. 1.12 and older should be able to partially work on newer versions via backwards compatibility - however this was quite broken in 1.13.
    • Funny Funny x 1
  3. Make a pom project with modules for each version
  4. do support all versions via nms
  5. The thing is the 1.13 API is very diverse from the 1.12 API
  6. Any video tutorials about that?
  7. you can put all version dependent codes into your core library and share among your plugins.
  9. What a bunch of misinformation, lol. Plugins are compatible across all versions by default, so long as things used in the plugin don't change between versions. If that happens, you have to use reflection if you want everything in the same jar. For instance, the Server#getOnlinePlayers method was changed from an array to a collection somewhere around MC 1.8, this gets around that.
    • Funny Funny x 3
  10. And what about material names? Like stained glass?
  11. if you dont add the api-version thing in your plugin.yml it actually uses the compatibility mode, which still works fine with the old material + subid system. Though not advised, as it's completely legacy, deprecated and legacy mode.
    But that's just the materials and things like that as far as I know.
  12. reflection is not the only way to do that...
    • Funny Funny x 1
  13. Removed the api-version thing and I still get this error:
    Code (Text):
    Error occurred while enabling Punish v1.0 (Is it up to date?)
    java.lang.NoSuchFieldError: GRASS_BLOCK
  14. That means that "GRASS_BLOCK" is not in that version (yet?). In what version are you right now?
  15. Built on 1.13 and trying to use in 1.12.2
  16. Granted you should build against something with the old Materials, not the new ones, so something like the 1.12 jar :p
  17. There is no "only" way to do anything in programming. That's the entire point of it. Everything can be done in multiple ways depending on the developer.