Skip to content

Commit

Permalink
Fixed so Semi-Hardcore can work without Vault.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fido2603 committed Jul 18, 2019
1 parent bdaa908 commit b0ea733
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>dk.fido2603</groupId>
<artifactId>semihardcore</artifactId>
<version>0.1.0</version>
<version>0.1.1</version>
<name>Semi-Hardcore</name>
<repositories>
<!-- Spigot Repo for Spigot and Bukkit -->
Expand Down
43 changes: 29 additions & 14 deletions src/main/java/dk/fido2603/semihardcore/PermissionsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ public PermissionsManager(SemiHardcore p)
{
this.plugin = p;

RegisteredServiceProvider<Permission> permissionProvider = plugin.getServer().getServicesManager().getRegistration(Permission.class);
vaultPermission = permissionProvider.getProvider();

RegisteredServiceProvider<Chat> chatProvider = plugin.getServer().getServicesManager().getRegistration(Chat.class);
vaultChat = chatProvider.getProvider();
if (p.vaultEnabled) {
RegisteredServiceProvider<Permission> permissionProvider = plugin.getServer().getServicesManager().getRegistration(Permission.class);
vaultPermission = permissionProvider.getProvider();

RegisteredServiceProvider<Chat> chatProvider = plugin.getServer().getServicesManager().getRegistration(Chat.class);
vaultChat = chatProvider.getProvider();
}
}

public void load()
Expand All @@ -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);
}
}
}
4 changes: 3 additions & 1 deletion src/main/java/dk/fido2603/semihardcore/SemiHardcore.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public void onEnable()

pluginEnabled = true;

permissionsManager = new PermissionsManager(this);
playerManager = new PlayerManager(this);
playerListener = new PlayerListener(this);

Expand Down Expand Up @@ -152,6 +151,8 @@ public void onEnable()
{
log("Vault not found.");
}

permissionsManager = new PermissionsManager(this);

getServer().getPluginManager().registerEvents(playerListener, this);

Expand Down Expand Up @@ -263,6 +264,7 @@ public void saveSettings()
config.set("Messages.EndUHCDay", this.messageEndUHCDay);

saveConfig();
getPlayerManager().save();
}

@Override
Expand Down

0 comments on commit b0ea733

Please sign in to comment.