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