mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 06:28:49 +00:00
Closes #25, closes #26; Add permission restricted warps and warp/public home functionality via console
This commit is contained in:
1 parent
a168533ca3
commit
cd341785c8
12 files changed
+162
-22
No files matched your search
@@ -1,7 +1,11 @@
|
||||
package me.william278.huskhomes2.teleport.points;
|
||||
|
||||
import me.william278.huskhomes2.HuskHomes;
|
||||
import me.william278.huskhomes2.MessageManager;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
|
||||
/**
|
||||
* An object representing an in-game warp
|
||||
@@ -68,4 +72,24 @@ public class Warp extends TeleportationPoint {
|
||||
this.name = description;
|
||||
}
|
||||
|
||||
// Returns if the player has permission to access the warp
|
||||
public static boolean getWarpCanUse(Player p, String warpName) {
|
||||
if (!HuskHomes.getSettings().doPermissionRestrictedWarps()) {
|
||||
return true;
|
||||
}
|
||||
p.recalculatePermissions();
|
||||
String permissionFormat = HuskHomes.getSettings().getWarpRestrictionPermissionFormat();
|
||||
for (PermissionAttachmentInfo permissionAI : p.getEffectivePermissions()) {
|
||||
String permission = permissionAI.getPermission();
|
||||
if (permission.contains(permissionFormat)) {
|
||||
try {
|
||||
if (permission.split("\\.")[StringUtils.countMatches(permissionFormat, ".")].equalsIgnoreCase(warpName)) {
|
||||
return permissionAI.getValue();
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user