From 1a6c0de502df750703406fd256799867f6114d53 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 16 Dec 2023 14:01:42 +0100 Subject: [PATCH] Update Permission --- .../src/de/steamwar/bausystem/Permission.java | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java index b2f14e4f..6d9dbf96 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java @@ -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 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); - } } \ No newline at end of file