title: How to enable a bukkit plugin first?
body: <p>I have an interesting problem where I want to enable a specific Bukkit plugin first before any other plugins are enabled. This has proven a difficult task. I can't use the <code>plugin.yml</code> dependancy options because those assume I know what plugins are installed on any given server. I don't care if it doesn't load first, but I do need it to enable first.</p>
  
  <p>I have tried several methods to accomplish this but with no luck:</p>
  
  <p>Attempt 1:</p>
  
  <pre><code>static{
  
      try {
          Bukkit.getPluginManager().loadPlugin(plug);
          Bukkit.getPluginManager().enablePlugin(plugin);
      } catch (UnknownDependencyException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (InvalidPluginException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (InvalidDescriptionException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  
  }
  </code></pre>
  
  <p>Allow me to explain. The static seems to run before most anything, including plugin loadups. This means I also have to define when it loads as well. This normally wouldn't be a problem, except non static API like <code>getDataFolder()</code> for the file Path doesn't work.</p>
  
  <pre><code>public static File plug = new File("/plugins/Debugger");
  </code></pre>
  
  <p>So unless I'm doing my Paths wrong, I have no clue why this throws an Exception.</p>
  
  <p>NOTE: Yes, I have tried multiple different paths such as <code>"plugins/Debugger"</code> or "Debugger.jar" and ECT.</p>
  
  <p>Method 2:</p>
  
  <pre><code>public void onLoad(){
          Bukkit.getPluginManager().enablePlugin(plugin);
          console.info("[Debugger] loaded first!");
      }
  </code></pre>
  
  <p>This seemed too good to be true and this method actually seemed to get me closer to solving my problem. This Method is called whenever the plugin loads, so by enabling the plugin within the <code>onLoad</code> Method, it actually caused the plugin to enable first; But there were issues when loading: </p>
  
  <pre><code>[00:15:08] [Server thread/ERROR]: null initializing Debugger v1.0.0 (Is it up to date?)
  java.lang.NullPointerException
      at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:396) ~[craftbukkit.jar:git-Bukkit-0ebb9c7]
      at me.doublehelix457.Debugger.Debugger.onLoad(Debugger.java:20) ~[?:?]
      at org.bukkit.craftbukkit.v1_10_R1.CraftServer.loadPlugins(CraftServer.java:299) [craftbukkit.jar:git-Bukkit-0ebb9c7]
      at org.bukkit.craftbukkit.v1_10_R1.CraftServer.reload(CraftServer.java:723) [craftbukkit.jar:git-Bukkit-0ebb9c7]
      at org.bukkit.Bukkit.reload(Bukkit.java:548) [craftbukkit.jar:git-Bukkit-0ebb9c7]
      at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [craftbukkit.jar:git-Bukkit-0ebb9c7]
  </code></pre>
  
  <p>Somehow despite the weird <code>null initializing Debugger</code> (Debugger is the test plugin name) the plugin still managed to enable first?</p>
  
  <p>So the line it is referring to is <code>Bukkit.getPluginManager().enablePlugin(plugin);</code></p>
  
  <p>Doing some research online I noticed certain API like <code>getServer()</code> was not working within that Method and I believe that maybe this means that <code>Bukkit</code> or <code>PluginManager</code> may not exist yet.</p>
  
  <p>If that's the case, then is there a workaround to this?</p>
  
  <p>That said, I'm willing to take improvements on my current attempts or even try new ones, whatever gets the job done. Please do not ask "Why do you need to enable the plugin first?" I should mention that this version of bukkit is on 1.10.</p>
  
  <p>Any HELPFUL advice would be much appreciated.</p>