Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Vault optional for PlayerFilter
- Loading branch information
Showing
4 changed files
with
44 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/net/citizensnpcs/api/util/PermissionUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package net.citizensnpcs.api.util; | ||
|
||
import java.util.Collection; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Player; | ||
|
||
import net.milkbowl.vault.permission.Permission; | ||
|
||
public class PermissionUtil { | ||
public static Boolean inGroup(Collection<String> groups, Player player) { | ||
if (!SUPPORT_PERMISSION) | ||
return null; | ||
try { | ||
Permission permission = Bukkit.getServicesManager().getRegistration(Permission.class).getProvider(); | ||
return groups.stream().anyMatch(group -> permission.playerInGroup(player, group)); | ||
} catch (Throwable t) { | ||
SUPPORT_PERMISSION = false; | ||
return null; | ||
} | ||
} | ||
|
||
private static boolean SUPPORT_PERMISSION = true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters