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
create a conditional to see if the plugin is loaded? Code (Text): if(Bukkit.getServer().getPluginManager().getPlugin("VanishNoPacket") != null){ // do stuff }else{ //other stuff } Reference.
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.
http://stackoverflow.com/questions/37628/what-is-reflection-and-why-is-it-useful Check and see if it VanishNoPacket is loaded, if it is, cast a method call to it, and then use it as reference. If it is not, then don't use it .
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. Reference: http://wiki.bukkit.org/Plugin_YAML
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: Here. Two people have no told you the exact same answer, and you keep saying 'I don't get it'... then learn it .
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...
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; @Override public void onEnable() { if (Bukkit.getServer().getPluginManager().getPlugin("VanishNoPacket") != null) vnpHook = new VNPHook(); } ... VNPHook Code (Java): various imports from vnp; public class VNPHook() implements Listeners { public VNPHook() { vnpStuff goes in this class :D; } }
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