-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly register world and teleport permissions
- Loading branch information
1 parent
ed5a13b
commit 9d54cc4
Showing
6 changed files
with
138 additions
and
57 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
52 changes: 52 additions & 0 deletions
52
src/main/java/org/mvplugins/multiverse/core/permissions/PermissionUtils.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,52 @@ | ||
package org.mvplugins.multiverse.core.permissions; | ||
|
||
import com.dumptruckman.minecraft.util.Logging; | ||
import org.bukkit.command.CommandSender; | ||
|
||
public final class PermissionUtils { | ||
|
||
private static boolean debugPermissions = false; | ||
|
||
private PermissionUtils() { | ||
// Prevent instantiation | ||
} | ||
|
||
public static boolean isDebugPermissions() { | ||
return debugPermissions; | ||
} | ||
|
||
public static void setDebugPermissions(boolean debugPermissions) { | ||
PermissionUtils.debugPermissions = debugPermissions; | ||
} | ||
|
||
/** | ||
* Joins permissions with a dot. | ||
* | ||
* @param permission The permission | ||
* @param child The string(s) to join | ||
* @return The newly joined permission node. | ||
*/ | ||
public static String concatPermission(String permission, String... child) { | ||
return permission + "." + String.join(".", child); | ||
} | ||
|
||
/** | ||
* Check and log if the sender has the permission. | ||
* | ||
* @param sender The sender | ||
* @param permission The permission | ||
* @return True if the sender has the permission, else false. | ||
*/ | ||
public static boolean hasPermission(CommandSender sender, String permission) { | ||
if (sender.hasPermission(permission)) { | ||
if (debugPermissions) { | ||
Logging.finer("Checking sender [%s] has permission [%s] : YES", sender.getName(), permission); | ||
} | ||
return true; | ||
} | ||
if (debugPermissions) { | ||
Logging.finer("Checking sender [%s] has permission [%s] : NO", sender.getName(), permission); | ||
} | ||
return false; | ||
} | ||
} |
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