1313import org .mvplugins .multiverse .core .world .MultiverseWorld ;
1414
1515import static org .mvplugins .multiverse .core .permissions .PermissionUtils .concatPermission ;
16+ import static org .mvplugins .multiverse .core .permissions .PermissionUtils .registerPermissionWithWildcards ;
1617
1718@ Service
1819public final class CorePermissions {
@@ -60,28 +61,34 @@ public final class CorePermissions {
6061
6162 @ PostConstruct
6263 void registerBasePermissions () {
63- pluginManager .addPermission (new Permission (JOINLOCATION_BYPASS , PermissionDefault .FALSE ));
64- Logging .fine ("Successfully registered base permissions" );
64+ Try .run (() -> {
65+ registerPermissionWithWildcards (new Permission (JOINLOCATION_BYPASS , PermissionDefault .FALSE ));
66+ }).onSuccess (ignore -> {
67+ Logging .fine ("Successfully registered base permissions" );
68+ }).onFailure (e -> {
69+ Logging .fine ("Failed to register base permissions: %s" , e .getMessage ());
70+ });
6571 }
6672
6773 public Try <Void > addWorldPermissions (@ NotNull MultiverseWorld world ) {
6874 return Try .run (() -> {
69- pluginManager . addPermission (new Permission (
75+ registerPermissionWithWildcards (new Permission (
7076 concatPermission (WORLD_ACCESS , world .getName ()), PermissionDefault .OP ));
71- pluginManager . addPermission (new Permission (
77+ registerPermissionWithWildcards (new Permission (
7278 concatPermission (WORLD_EXEMPT , world .getName ()), PermissionDefault .OP ));
73- pluginManager . addPermission (new Permission (
79+ registerPermissionWithWildcards (new Permission (
7480 concatPermission (GAMEMODE_BYPASS , world .getName ()), PermissionDefault .FALSE ));
75- pluginManager . addPermission (new Permission (
81+ registerPermissionWithWildcards (new Permission (
7682 concatPermission (PLAYERLIMIT_BYPASS , world .getName ()), PermissionDefault .FALSE ));
77- pluginManager . addPermission (new Permission (
83+ registerPermissionWithWildcards (new Permission (
7884 concatPermission (SPAWN , world .getName ()), PermissionDefault .OP ));
79- pluginManager . addPermission (new Permission (
85+ registerPermissionWithWildcards (new Permission (
8086 concatPermission (SPAWN , "self" , world .getName ()), PermissionDefault .OP ));
81- pluginManager . addPermission (new Permission (
87+ registerPermissionWithWildcards (new Permission (
8288 concatPermission (SPAWN , "other" , world .getName ()), PermissionDefault .OP ));
8389 Logging .fine ("Successfully registered permissions for world %s" , world .getName ());
84- });
90+ }).onFailure (e -> Logging .fine ("Failed to register permissions for world %s: %s" ,
91+ world .getName (), e .getMessage ()));
8592 }
8693
8794 public Try <Void > removeWorldPermissions (@ NotNull MultiverseWorld world ) {
@@ -90,27 +97,31 @@ public Try<Void> removeWorldPermissions(@NotNull MultiverseWorld world) {
9097 pluginManager .removePermission (concatPermission (WORLD_EXEMPT , world .getName ()));
9198 pluginManager .removePermission (concatPermission (GAMEMODE_BYPASS , world .getName ()));
9299 pluginManager .removePermission (concatPermission (PLAYERLIMIT_BYPASS , world .getName ()));
100+ pluginManager .removePermission (concatPermission (SPAWN , world .getName ()));
93101 pluginManager .removePermission (concatPermission (SPAWN , "self" , world .getName ()));
94102 pluginManager .removePermission (concatPermission (SPAWN , "other" , world .getName ()));
95103 Logging .fine ("Successfully removed permissions for world %s" , world .getName ());
96- });
104+ }).onFailure (e -> Logging .fine ("Failed to remove permissions for world %s: %s" ,
105+ world .getName (), e .getMessage ()));
97106 }
98107
99108 public Try <Void > addDestinationPermissions (@ NotNull Destination destination ) {
100109 return Try .run (() -> {
101- pluginManager . addPermission (new Permission (
110+ registerPermissionWithWildcards (new Permission (
102111 concatPermission (TELEPORT , "self" , destination .getIdentifier ()), PermissionDefault .OP ));
103- pluginManager . addPermission (new Permission (
112+ registerPermissionWithWildcards (new Permission (
104113 concatPermission (TELEPORT , "other" , destination .getIdentifier ()), PermissionDefault .OP ));
105114 Logging .fine ("Successfully registered permissions for destination %s" , destination .getIdentifier ());
106- });
115+ }).onFailure (e -> Logging .fine ("Failed to register permissions for destination %s: %s" ,
116+ destination .getIdentifier (), e .getMessage ()));
107117 }
108118
109119 public Try <Void > removeDestinationPermissions (@ NotNull Destination destination ) {
110120 return Try .run (() -> {
111121 pluginManager .removePermission (concatPermission (TELEPORT , "self" , destination .getIdentifier ()));
112122 pluginManager .removePermission (concatPermission (TELEPORT , "other" , destination .getIdentifier ()));
113123 Logging .fine ("Successfully removed permissions for destination %s" , destination .getIdentifier ());
114- });
124+ }).onFailure (e -> Logging .fine ("Failed to remove permissions for destination %s: %s" ,
125+ destination .getIdentifier (), e .getMessage ()));
115126 }
116127}
0 commit comments