Solved Enchantment class?

Discussion in 'Spigot Plugin Development' started by YogurtSmudge, Mar 31, 2020.

Thread Status:
Not open for further replies.
  1. This might be a noob question but, I have a core plugin that I made in 1.8.8, and I want it to support 1.14.4. I successfully created a 'Glow' enchantment in 1.8.8, however in 1.14.4 it's different. I know I can use NMS for every version, that's not what I'm talking about. The 1.14.4 uses a NamespacedKey. However in 1.8.8, it uses just an id. How can I have one plugin support both these Minecraft versions, I prefer leaving reflection as a last resort if possible. Also, how can I implement the isCursed() and the isTreasure() to the 1.14.4 Glow class?

    If you're still confused on what I want, how can I create a 'Glow' enchantment with NMS, that supports both 1.8.8 and 1.14.4.

    I tried having both Spigot API's in my dependencies using IntelliJ however, it takes the top dependency as the main priority, so it won't let me use seperate Enchantment classes.

    Is there any other way I can do this? or am I just thinking about it all wrong?

    I know I'm a big noob
     
  2. I’m not sure what you mean by this, I read the link a bit but I was mostly confused.
     
  3. drives_a_ford

    Moderator

    What you want to do is use a multi-module project.
    You'll have to use a build automation tool (i.e maven or gradle) if you aren't already.

    In one module you define an interface with all the methods that it needs.

    Then you create another module for each different implementation and implement the interface there depending on the use case/version. Each one depends on the specific version of spigot.

    You can find more info e.g here. Or you can search for multi version support and abstraction.
     
    • Winner Winner x 1
Thread Status:
Not open for further replies.