fix possible NPE when no economy/perm is loaded for vault-info

This commit is contained in:
Sleaker 2012-04-25 07:16:44 -07:00
parent a584b7db61
commit 21aa840679

View File

@ -487,13 +487,21 @@ public class Vault extends JavaPlugin {
} }
// Get Economy & Permission primary Services // Get Economy & Permission primary Services
Economy econ = getServer().getServicesManager().getRegistration(Economy.class).getProvider(); RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
Permission perm = getServer().getServicesManager().getRegistration(Permission.class).getProvider(); Economy econ = null;
if (rsp != null) {
econ = rsp.getProvider();
}
Permission perm = null;
RegisteredServiceProvider<Permission> rspp = getServer().getServicesManager().getRegistration(Permission.class);
if (rspp != null) {
perm = rspp.getProvider();
}
// Send user some info! // Send user some info!
sender.sendMessage(String.format("[%s] Vault v%s Information", getDescription().getName(), getDescription().getVersion())); sender.sendMessage(String.format("[%s] Vault v%s Information", getDescription().getName(), getDescription().getVersion()));
sender.sendMessage(String.format("[%s] Economy: %s [%s]", getDescription().getName(), econ.getName(), registeredEcons)); sender.sendMessage(String.format("[%s] Economy: %s [%s]", getDescription().getName(), econ == null ? "None" : econ.getName(), registeredEcons));
sender.sendMessage(String.format("[%s] Permission: %s [%s]", getDescription().getName(), perm.getName(), registeredPerms)); sender.sendMessage(String.format("[%s] Permission: %s [%s]", getDescription().getName(), perm == null ? "None" : perm.getName(), registeredPerms));
} }
/** /**