-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathWarp.java
More file actions
42 lines (37 loc) · 1.42 KB
/
Copy pathWarp.java
File metadata and controls
42 lines (37 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package fr.maxlego08.essentials.api.utils;
import fr.maxlego08.essentials.api.commands.Permission;
import org.bukkit.permissions.Permissible;
import java.util.Collection;
import java.util.Locale;
/**
* Represents a warp location.
* This record encapsulates data related to a warp, including its name and location.
*/
public record Warp(String name, SafeLocation location) {
/**
* Checks if the specified permissible entity has permission to warp to this location.
*
* @param permissible The permissible entity (e.g., player or command sender).
* @return true if the permissible entity has permission, false otherwise.
*/
public boolean hasPermission(Permissible permissible) {
if (permissible.hasPermission(Permission.ESSENTIALS_WARP.asPermission())) {
return true;
}
return permissible.hasPermission(Permission.ESSENTIALS_WARP_.asPermission(this.name.toLowerCase(Locale.ROOT)));
}
/**
* Checks if the permissible can use at least one warp or the global warp permission.
*/
public static boolean canAccessAnyWarp(Permissible permissible, Collection<Warp> warps) {
if (permissible.hasPermission(Permission.ESSENTIALS_WARP.asPermission())) {
return true;
}
for (Warp warp : warps) {
if (warp.hasPermission(permissible)) {
return true;
}
}
return false;
}
}