try method of higher bukkit version

Discussion in 'Plugin Development' started by MightyOne, Oct 23, 2017.

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

    MightyOne

    Hi,
    Since spigot 1.12 ItemMeta supports the method setUnbreakable(). It is a cool feature but to make my plugin usable for earlier version. So I just wanted to use the method like:
    Code:
    try {
        meta.setUnbreakable(true);
    } catch (Exception e) {}
    buuuuuuut it is throwing a NoSuchMethodError while loading the plugin anyway xD
    I had no idea what to search for so I wrote this.

    Does anybody have an idea how to maybe achieve compatibility for multiple versions? Or is there a better way?
    Thanks in advance
     
  2. Offline

    Zombie_Striker

    @MightyOne
    Add "Exception|Error e" into the catch parameter; The Error object responds to issues with the JVM, not just exceptions.
     
  3. Offline

    MightyOne

    @AlvinB
    but in the end ill have to use a try catch anyway to prevent the NoSuchMethodError while loading.
     
  4. @MightyOne
    Well, if that's the case, no type of try catch will work. You will have to work with separate classes.
     
Thread Status:
Not open for further replies.

Share This Page