@@ -164,46 +164,6 @@ public Graph createGraph(final String name) {
164164 //Copied from vault, lets see what vault plugins our users use, that we can now hook into!
165165 public void findCustomData () {
166166 // Create our Permission Graph and Add our permission Plotters
167- Graph permGraph = createGraph ("Permission" );
168- Graph chatGraph = createGraph ("Chat" );
169-
170- RegisteredServiceProvider <Permission > rspPerm = null ;
171- RegisteredServiceProvider <Chat > rspChat = null ;
172-
173- if (API .isPluginEnabled (PluginType .VAULT )) {
174- rspPerm = Bukkit .getServer ().getServicesManager ().getRegistration (Permission .class );
175- rspChat = Bukkit .getServer ().getServicesManager ().getRegistration (Chat .class );
176- }
177-
178- Permission perm = null ;
179- Chat chat = null ;
180-
181- if (rspPerm != null ) {
182- perm = rspPerm .getProvider ();
183- }
184-
185- if (rspChat != null ) {
186- chat = rspChat .getProvider ();
187- }
188-
189- final String permName = perm != null ? perm .getName () : "No Permissions" ;
190- final String chatName = chat != null ? chat .getName () : "No Chat" ;
191-
192- permGraph .addPlotter (new Metrics .Plotter (permName ) {
193-
194- @ Override
195- public int getValue () {
196- return 1 ;
197- }
198- });
199-
200- chatGraph .addPlotter (new Metrics .Plotter (chatName ) {
201-
202- @ Override
203- public int getValue () {
204- return 1 ;
205- }
206- });
207167
208168 Graph loadedPlugins = createGraph ("Plugins" );
209169 Plugin [] plugins = Bukkit .getServer ().getPluginManager ().getPlugins ();
@@ -254,6 +214,46 @@ public int getValue() {
254214 return 1 ;
255215 }
256216 });
217+
218+ if (!API .isPluginEnabled (PluginType .VAULT )) {
219+ return ;
220+ }
221+
222+ Graph permGraph = createGraph ("Permission" );
223+ Graph chatGraph = createGraph ("Chat" );
224+
225+ RegisteredServiceProvider <Permission > rspPerm = Bukkit .getServer ().getServicesManager ().getRegistration (Permission .class );
226+ RegisteredServiceProvider <Chat > rspChat = Bukkit .getServer ().getServicesManager ().getRegistration (Chat .class );
227+
228+ Permission perm = null ;
229+ Chat chat = null ;
230+
231+ if (rspPerm != null ) {
232+ perm = rspPerm .getProvider ();
233+ }
234+
235+ if (rspChat != null ) {
236+ chat = rspChat .getProvider ();
237+ }
238+
239+ final String permName = perm != null ? perm .getName () : "No Permissions" ;
240+ final String chatName = chat != null ? chat .getName () : "No Chat" ;
241+
242+ permGraph .addPlotter (new Metrics .Plotter (permName ) {
243+
244+ @ Override
245+ public int getValue () {
246+ return 1 ;
247+ }
248+ });
249+
250+ chatGraph .addPlotter (new Metrics .Plotter (chatName ) {
251+
252+ @ Override
253+ public int getValue () {
254+ return 1 ;
255+ }
256+ });
257257 }
258258
259259 /**
@@ -402,8 +402,14 @@ public void disable() throws IOException {
402402 * @return the File object for the config file
403403 */
404404 public File getConfigFile () {
405+ // I believe the easiest way to get the base folder (e.g craftbukkit set via -P) for plugins to use
406+ // is to abuse the plugin object we already have
407+ // plugin.getDataFolder() => base/plugins/PluginA/
408+ // pluginsFolder => base/plugins/
409+ // The base is not necessarily relative to the startup directory.
405410 File pluginsFolder = plugin .getDataFolder ().getParentFile ();
406411
412+ // return => base/plugins/PluginMetrics/config.yml
407413 return new File (new File (pluginsFolder , "PluginMetrics" ), "config.yml" );
408414 }
409415
0 commit comments