Dieser Commit ist enthalten in:
Ursprung
b73af3e2ec
Commit
1a6c0de502
@ -36,27 +36,21 @@ import java.util.function.Predicate;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum Permission {
|
public enum Permission {
|
||||||
|
|
||||||
WORLD(BauweltMember::isWorld),
|
OWNER(bauweltMember -> {
|
||||||
WORLDEDIT(BauweltMember::isWorldEdit),
|
return bauweltMember.getBauweltID() == BauServer.getInstance().getOwnerID();
|
||||||
MEMBER(bauweltMember -> true),
|
}),
|
||||||
OWNER(bauweltMember -> false);
|
SUPERVISOR(bauweltMember -> {
|
||||||
|
return OWNER.permissionPredicate.test(bauweltMember); // TODO: Needs to be changed later on
|
||||||
|
}),
|
||||||
|
BUILD(bauweltMember -> {
|
||||||
|
return bauweltMember.isWorld() || bauweltMember.isWorldEdit() || SUPERVISOR.permissionPredicate.test(bauweltMember);
|
||||||
|
});
|
||||||
|
|
||||||
private final Predicate<BauweltMember> permissionPredicate;
|
private final Predicate<BauweltMember> permissionPredicate;
|
||||||
|
|
||||||
public boolean hasPermission(Player member) {
|
public boolean hasPermission(Player member) {
|
||||||
if (member.getUniqueId().equals(BauServer.getInstance().getOwner())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
BauweltMember bauMember = BauweltMember.getBauMember(BauServer.getInstance().getOwner(), member.getUniqueId());
|
BauweltMember bauMember = BauweltMember.getBauMember(BauServer.getInstance().getOwner(), member.getUniqueId());
|
||||||
if (bauMember == null) {
|
if (bauMember == null) return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return permissionPredicate.test(bauMember);
|
return permissionPredicate.test(bauMember);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasPermission(Player member, Permission permission) {
|
|
||||||
return permission.hasPermission(member);
|
|
||||||
}
|
|
||||||
}
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren