File tree Expand file tree Collapse file tree
cloud-core/src/main/java/cloud/commandframework/permission Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,7 +50,15 @@ public final class AndPermission implements CommandPermission {
5050 * @return Constructed permission
5151 */
5252 public static @ NonNull CommandPermission of (final @ NonNull Collection <CommandPermission > permissions ) {
53- return new AndPermission (new HashSet <>(permissions ));
53+ final Set <CommandPermission > objects = new HashSet <>();
54+ for (final CommandPermission permission : permissions ) {
55+ if (permission instanceof AndPermission ) {
56+ objects .addAll (permission .getPermissions ());
57+ } else {
58+ objects .add (permission );
59+ }
60+ }
61+ return new AndPermission (objects );
5462 }
5563
5664 @ Override
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ public interface CommandPermission {
6464 final Set <CommandPermission > permission = new HashSet <>(2 );
6565 permission .add (this );
6666 permission .add (other );
67- return new OrPermission (permission );
67+ return OrPermission . of (permission );
6868 }
6969
7070 /**
@@ -79,7 +79,7 @@ public interface CommandPermission {
7979 final Set <CommandPermission > permission = new HashSet <>(other .length + 1 );
8080 permission .add (this );
8181 permission .addAll (Arrays .asList (other ));
82- return new OrPermission (permission );
82+ return OrPermission . of (permission );
8383 }
8484
8585 /**
@@ -94,7 +94,7 @@ public interface CommandPermission {
9494 final Set <CommandPermission > permission = new HashSet <>(2 );
9595 permission .add (this );
9696 permission .add (other );
97- return new AndPermission (permission );
97+ return AndPermission . of (permission );
9898 }
9999
100100 /**
@@ -109,7 +109,7 @@ public interface CommandPermission {
109109 final Set <CommandPermission > permission = new HashSet <>(other .length + 1 );
110110 permission .add (this );
111111 permission .addAll (Arrays .asList (other ));
112- return new AndPermission (permission );
112+ return AndPermission . of (permission );
113113 }
114114
115115}
Original file line number Diff line number Diff line change @@ -50,7 +50,15 @@ public final class OrPermission implements CommandPermission {
5050 * @return Constructed permission
5151 */
5252 public static @ NonNull CommandPermission of (final @ NonNull Collection <CommandPermission > permissions ) {
53- return new OrPermission (new HashSet <>(permissions ));
53+ final Set <CommandPermission > objects = new HashSet <>();
54+ for (final CommandPermission permission : permissions ) {
55+ if (permission instanceof OrPermission ) {
56+ objects .addAll (permission .getPermissions ());
57+ } else {
58+ objects .add (permission );
59+ }
60+ }
61+ return new OrPermission (objects );
5462 }
5563
5664 @ Override
You can’t perform that action at this time.
0 commit comments