Solved Using other plugins and failing to connect to them safely

Discussion in 'Plugin Development' started by Tirelessly, Feb 24, 2013.

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

    Tirelessly

    Ok, so in my plugin PvPTag, I use TagAPI to change people's name colors. However, I'd like that to be optional. Usually enabling/disabling features is easy (conditionally registering the listener), however I'm not sure how it'd work with a third party plugin. If TagAPI isn't on the server, will an exception will be thrown when an instance of the listener (containing all the imports and things from TagAPI I'll be using) is generated or will an exception be thrown as soon as the plugin is loaded?
     
  2. Offline

    Minecrell

    Check before you use TagAPI if it is loaded on the server:
    Code:java
    1. if (Bukkit.getPluginManager().getPlugin("TagAPI") != null) {
    2. // TagAPI is loaded on the server
    3. } else {
    4. // TagAPI is not loaded on the server
    5. }
     
  3. Offline

    Tirelessly

    But will it throw an exception if it tries to import TagAPI objects? Because I can't stop it from importing them. Actually, maybe I can use the full names.. mbaxter Do you know?
     
  4. Offline

    Minecrell

    Tirelessly
    If you don't use TagAPI objects / methods it won't give an error.
     
  5. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    Create a separate listener class for TagAPI listening. Only instantiate if TagAPI is loaded.
     
  6. Offline

    Tirelessly

    Thanks. I wasn't sure if the imports would make it not work.
     
  7. Offline

    Technius

    Imports are ok, but referring to classes when they are not present will throw a NoClassDefFoundError.
     
Thread Status:
Not open for further replies.

Share This Page