Discussion in 'Spigot Plugin Help' started by JordyPwner, May 20, 2015.

  1. Im making a option to use VanishNoPacket but how would i able to do that? So when VanishNoPacket is not found it wont use that. I cant figure it out. Links can be handy
  2. create a conditional to see if the plugin is loaded?

    Code (Text):
    if(Bukkit.getServer().getPluginManager().getPlugin("VanishNoPacket") != null){

    // do stuff


    //other stuff

  3. Yeah but now i have it in my buildpath. So when someone does not have the plugin in his plugins it still throws a error and then it doesnt load.
  4. The VanishNoPacket jar is in my buildpath thats what i mean*
  5. Reflection instead of importing I guess...
  6. What u mean? I never used reflection xd
  7. 1. Make sure you add VanishNoPacket to your softdepend section in the plugin.yml.
    Example: softdepend: [OnePlugin, AnotherPlugin]
    This will make sure soft-depended plugin will load before yours.

    2. Use Bukkit.getPluginManager.getPlugin("VanishNoPlugin"), if it is null, means it is never loaded.

  8. Im using VanishNoPacket to check if someone is vanished. How would i be able to do that then?
  9. Well I can't write the whole thing for you.. sorry. But all the information you need to get this done has been given. If you do not understand reflection in Java, then I can help you out:


    Two people have no told you the exact same answer, and you keep saying 'I don't get it'... then learn it :p.
  10. Still dont understand it. Isnt there a class file for VNP?
  11. Why so complicated?
    Do this: Create a class (call it VNPHook or something else)
    Put everything, which needs VNP, into this class and only call the methods in it, if VNP is found...
    • Agree Agree x 2
  12. Yeah.. 3rd person to tell him this.
  13. So, what I think the people above tried to explain (... but, well, didn't manage to) is that you shouldn't import anything from VanishNoPacket into your main class, but keep it to a separate class (with listeners etc.). If VanishNoPacket is loaded, then you register those listeners - That way you have no imports from VNP in your plugin, unless the plugin is loaded.

    Main Class
    Code (Java):

    private VNPHook vnpHook;
    public void onEnable() {
      if (Bukkit.getServer().getPluginManager().getPlugin("VanishNoPacket") != null)
        vnpHook = new VNPHook();
    Code (Java):

    various imports from vnp;
    public class VNPHook() implements Listeners {
      public VNPHook() {
        vnpStuff goes in this class :D;
  14. The problem is. I have vnp in my build path.
  15. That's no problem if you only use the vnp stuff if the plugin is available and all vnp stuff is ONLY in that class