diff --git a/pom.xml b/pom.xml index 62bb914..faaaa53 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 dk.fido2603 semihardcore - 0.1.0 + 0.1.1 Semi-Hardcore diff --git a/src/main/java/dk/fido2603/semihardcore/PermissionsManager.java b/src/main/java/dk/fido2603/semihardcore/PermissionsManager.java index 9d33f73..e7387d3 100644 --- a/src/main/java/dk/fido2603/semihardcore/PermissionsManager.java +++ b/src/main/java/dk/fido2603/semihardcore/PermissionsManager.java @@ -17,11 +17,13 @@ public PermissionsManager(SemiHardcore p) { this.plugin = p; - RegisteredServiceProvider permissionProvider = plugin.getServer().getServicesManager().getRegistration(Permission.class); - vaultPermission = permissionProvider.getProvider(); - - RegisteredServiceProvider chatProvider = plugin.getServer().getServicesManager().getRegistration(Chat.class); - vaultChat = chatProvider.getProvider(); + if (p.vaultEnabled) { + RegisteredServiceProvider permissionProvider = plugin.getServer().getServicesManager().getRegistration(Permission.class); + vaultPermission = permissionProvider.getProvider(); + + RegisteredServiceProvider chatProvider = plugin.getServer().getServicesManager().getRegistration(Chat.class); + vaultChat = chatProvider.getProvider(); + } } public void load() @@ -41,32 +43,45 @@ public String getPermissionPluginName() public boolean hasPermission(Player player, String node) { - return vaultPermission.has(player, node); + if (this.plugin.vaultEnabled) { + return vaultPermission.has(player, node); + } + return false; } public boolean isGroup(String groupName) { - for(String str: vaultPermission.getGroups()) { - if(str.contains(groupName)) - return true; + if (this.plugin.vaultEnabled) { + for(String str: vaultPermission.getGroups()) { + if(str.contains(groupName)) + return true; + } } return false; } public String getGroup(String playerName) { - return vaultPermission.getPrimaryGroup(plugin.getServer().getPlayer(playerName)); + if (this.plugin.vaultEnabled) { + return vaultPermission.getPrimaryGroup(plugin.getServer().getPlayer(playerName)); + } + return ""; } public String getPrefix(String playerName) { - Player player = plugin.getServer().getPlayer(playerName); - return vaultChat.getPlayerPrefix(player); + if (this.plugin.vaultEnabled) { + Player player = plugin.getServer().getPlayer(playerName); + return vaultChat.getPlayerPrefix(player); + } + return ""; } public void setGroup(String playerName, String groupName) { - Player player = plugin.getServer().getPlayer(playerName); - vaultPermission.playerAddGroup(player, groupName); + if (this.plugin.vaultEnabled) { + Player player = plugin.getServer().getPlayer(playerName); + vaultPermission.playerAddGroup(player, groupName); + } } } \ No newline at end of file diff --git a/src/main/java/dk/fido2603/semihardcore/SemiHardcore.java b/src/main/java/dk/fido2603/semihardcore/SemiHardcore.java index d916d79..f0c1619 100644 --- a/src/main/java/dk/fido2603/semihardcore/SemiHardcore.java +++ b/src/main/java/dk/fido2603/semihardcore/SemiHardcore.java @@ -124,7 +124,6 @@ public void onEnable() pluginEnabled = true; - permissionsManager = new PermissionsManager(this); playerManager = new PlayerManager(this); playerListener = new PlayerListener(this); @@ -152,6 +151,8 @@ public void onEnable() { log("Vault not found."); } + + permissionsManager = new PermissionsManager(this); getServer().getPluginManager().registerEvents(playerListener, this); @@ -263,6 +264,7 @@ public void saveSettings() config.set("Messages.EndUHCDay", this.messageEndUHCDay); saveConfig(); + getPlayerManager().save(); } @Override