-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Robin
committed
Apr 4, 2023
1 parent
fba6dd5
commit 875ea46
Showing
10 changed files
with
428 additions
and
74 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package xyz.oribuin.eternaltags.hook; | ||
|
||
import net.milkbowl.vault.permission.Permission; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.plugin.RegisteredServiceProvider; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
public class VaultHook { | ||
|
||
private static final boolean enabled; | ||
|
||
static { | ||
enabled = Bukkit.getPluginManager().isPluginEnabled("Vault"); | ||
} | ||
|
||
/** | ||
* Get the vault permission instance | ||
* | ||
* @return The permission instance | ||
*/ | ||
@Nullable | ||
public static Permission getPermission() { | ||
if (!enabled) | ||
return null; | ||
|
||
RegisteredServiceProvider<Permission> rsp = Bukkit.getServicesManager().getRegistration(Permission.class); | ||
if (rsp == null) | ||
return null; | ||
|
||
return rsp.getProvider(); | ||
} | ||
|
||
/** | ||
* Get the highest group of a player | ||
* | ||
* @param player The player to get the group of | ||
* @return The highest group of the player | ||
*/ | ||
public static String getPrimaryGroup(Player player) { | ||
Permission permission = getPermission(); // Get the permission instance | ||
if (permission == null) | ||
return null; | ||
|
||
return permission.getPrimaryGroup(player); // Get the highest group (This is the group with the highest priority | ||
} | ||
|
||
/** | ||
* @return If vault is enabled or not | ||
*/ | ||
public static boolean isEnabled() { | ||
return enabled; | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.