Update Permission #220
@ -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);
|
||||
}
|
||||
YoyoNow markierte diese Unterhaltung als gelöst
|
||||
|
||||
public static boolean hasPermission(Player member, Permission permission) {
|
||||
return permission.hasPermission(member);
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren
Wird das überhaupt noch benötigt? Jeder auf dem Server ist ja mindestens Member.