From 21aa840679a919d1b24b9dbed25041e40669e84b Mon Sep 17 00:00:00 2001 From: Sleaker Date: Wed, 25 Apr 2012 07:16:44 -0700 Subject: [PATCH] fix possible NPE when no economy/perm is loaded for vault-info --- src/net/milkbowl/vault/Vault.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/net/milkbowl/vault/Vault.java b/src/net/milkbowl/vault/Vault.java index cc7feae..9159abd 100644 --- a/src/net/milkbowl/vault/Vault.java +++ b/src/net/milkbowl/vault/Vault.java @@ -487,13 +487,21 @@ public class Vault extends JavaPlugin { } // Get Economy & Permission primary Services - Economy econ = getServer().getServicesManager().getRegistration(Economy.class).getProvider(); - Permission perm = getServer().getServicesManager().getRegistration(Permission.class).getProvider(); + RegisteredServiceProvider rsp = getServer().getServicesManager().getRegistration(Economy.class); + Economy econ = null; + if (rsp != null) { + econ = rsp.getProvider(); + } + Permission perm = null; + RegisteredServiceProvider rspp = getServer().getServicesManager().getRegistration(Permission.class); + if (rspp != null) { + perm = rspp.getProvider(); + } // Send user some info! 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] Permission: %s [%s]", getDescription().getName(), perm.getName(), registeredPerms)); + 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 == null ? "None" : perm.getName(), registeredPerms)); } /**