Development Assistance Version dependant imports

Discussion in 'Plugin Help/Development/Requests' started by Koobaczech, May 20, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Koobaczech

    Hello everyone. My current Plugin is on version 1.8. I have updated it to 1.8.4, but i have a small issue. I want to make it compatible across all versions. My issue is that on 1.8 i need the imports to be
    Code:
    import net.minecraft.server.v1_8_R1.EntityInsentient;
    import org.bukkit.craftbukkit.v1_8_R1.entity.CraftEntity;
    And on 1.8.3 and above the 1 changes to 2
    Code:
    import net.minecraft.server.v1_8_R2.EntityInsentient;
    import org.bukkit.craftbukkit.v1_8_R2.entity.CraftEntity;
    This is the line of code dependent on those imports
    Code:
    ((EntityInsentient) ((CraftEntity) e).getHandle()).getNavigation().a(p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ(), 1.2F);
    Both imports work the same for the function.

    My question is, how can i make my plugin detect if Minecraft is running the correct version and import accordingly? Thank you for your help.
     
  2. Offline

    nverdier

    @Koobaczech You would have to use reflection for that.
     
  3. Offline

    Konato_K

    @Koobaczech Alternatively, you'll have to put your version dependent code in a special class for that specific version, and create the proper instance of it on enable.

    An example can be this.
     
    nverdier likes this.
  4. Offline

    mythbusterma

    @nverdier

    But don't. This is entirely counter-intuitive to the reason it was done like this in the first place.


    @Koobaczech

    If you're using Maven, you can separate it into modules that are loaded based on version. See this.
     
  5. Offline

    Koobaczech

    @Konato_K @nverdier @mythbusterma Thank you guys, i need to learn more java it seems. I have no idea what to do in a separate class or how to use modules, but its cool to see its possible! Any other guidance you can all give me before i start learning how to modularize?
     
  6. Offline

    timtower Administrator Administrator Moderator

    Moved to Bukkit alternatives
     
Thread Status:
Not open for further replies.

Share This Page