Skip to content

Commit 9f87da5

Browse files
authored
Merge pull request #84 from TheNextLvl-net/javadocs
Added Javadocs for command registry and permission overrides
2 parents 51b4028 + ede43d4 commit 9f87da5

File tree

2 files changed

+129
-0
lines changed

2 files changed

+129
-0
lines changed

api/src/main/java/net/thenextlvl/commander/CommandRegistry.java

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,91 @@
77

88
@NullMarked
99
public interface CommandRegistry {
10+
/**
11+
* Retrieves the set of commands that are currently hidden from visibility.
12+
* <p>
13+
* Hidden commands are still accessible and executable but are not displayed
14+
* in suggestions or tab completions under normal conditions.
15+
*
16+
* @return an unmodifiable set of strings representing the commands that are currently hidden
17+
*/
1018
@Unmodifiable
1119
Set<String> hiddenCommands();
1220

21+
/**
22+
* Retrieves the set of commands that are currently unregistered in the system.
23+
*
24+
* @return an unmodifiable set of strings representing the commands that are unregistered
25+
*/
1326
@Unmodifiable
1427
Set<String> unregisteredCommands();
1528

29+
/**
30+
* Hides the specified command.
31+
* <p>
32+
* Hidden commands can be accessed as normal but are not shown during tab completion.
33+
* They remain visible to users who possess the appropriate bypass permission.
34+
*
35+
* @param command the name of the command to hide
36+
* @return true if the command was hidden, false if the command was already hidden or doesn't exist
37+
*/
1638
boolean hide(String command);
1739

40+
/**
41+
* Determines if the specified command is currently hidden.
42+
*
43+
* @param command the name of the command to check
44+
* @return true if the command is hidden, false otherwise
45+
*/
1846
boolean isHidden(String command);
1947

48+
/**
49+
* Checks if the specified command is currently unregistered.
50+
*
51+
* @param command the name of the command to check
52+
* @return true if the command is unregistered, false otherwise
53+
*/
2054
boolean isUnregistered(String command);
2155

56+
/**
57+
* Registers the specified command with the command registry.
58+
* <p>
59+
* This method attempts to add the given command back into the system's registry,
60+
* making it available for usage if it was previously unregistered.
61+
*
62+
* @param command the name of the command to register
63+
* @return true if the command was successfully registered,
64+
* false if the command was already registered or failed to register
65+
*/
2266
boolean register(String command);
2367

68+
/**
69+
* Reveals the specified command.
70+
* <p>
71+
* This method makes a previously hidden command visible again for suggestions and tab completions.
72+
*
73+
* @param command the name of the command to reveal
74+
* @return true if the command was successfully revealed,
75+
* false if the command was already visible or does not exist
76+
*/
2477
boolean reveal(String command);
2578

79+
/**
80+
* Unregisters the specified command from the command registry.
81+
* This method removes the command, making it unavailable for usage.
82+
*
83+
* @param command the name of the command to unregister
84+
* @return true if the command was successfully unregistered,
85+
* false if the command was already unregistered or does not exist
86+
*/
2687
boolean unregister(String command);
2788

89+
/**
90+
* Unregisters all currently registered commands in the command registry.
91+
* <p>
92+
* This method removes all commands from the registry, making them unavailable for execution
93+
* and preventing them from appearing in any suggestions or tab completions.
94+
* It is typically used during plugin lifecycle events to reset or clear the command state.
95+
*/
2896
void unregisterCommands();
2997
}

api/src/main/java/net/thenextlvl/commander/PermissionOverride.java

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,84 @@
88

99
@NullMarked
1010
public interface PermissionOverride {
11+
/**
12+
* Retrieves a mapping of commands and their associated original permissions.
13+
* <p>
14+
* The map provides a view of commands with the permissions initially assigned
15+
* to them before any modifications or overrides were applied.
16+
*
17+
* @return an unmodifiable map containing command names as keys and their initially assigned permissions as values.
18+
* The permission value may be null if no original permission was assigned.
19+
*/
1120
@Unmodifiable
1221
Map<String, @Nullable String> originalPermissions();
1322

23+
/**
24+
* Retrieves a mapping of commands and their associated permission overrides.
25+
* <p>
26+
* The map provides a view of commands with permissions that have been modified
27+
* or overridden from their original values.
28+
*
29+
* @return an unmodifiable map containing command names as keys and their overridden permissions as values.
30+
* The permission value may be null if no override is applied to the command.
31+
*/
1432
@Unmodifiable
1533
Map<String, @Nullable String> overrides();
1634

35+
/**
36+
* Retrieves the original permission assigned to the specified command before any overrides or modifications.
37+
*
38+
* @param command the name of the command whose original permission is to be retrieved
39+
* @return the originally assigned permission as a string, or null if no original permission exists for the command
40+
*/
1741
@Nullable
1842
String originalPermission(String command);
1943

44+
/**
45+
* Retrieves the current effective permission associated with the specified command.
46+
* The returned permission reflects any overrides that may have been applied.
47+
*
48+
* @param command the name of the command for which to retrieve the permission
49+
* @return the effective permission as a string, or null if no permission is assigned to the command
50+
*/
2051
@Nullable
2152
String permission(String command);
2253

54+
/**
55+
* Determines if the specified command has its permission overridden.
56+
* A command is considered overridden if it has a modified permission that differs from its original assignment.
57+
*
58+
* @param command the name of the command to check
59+
* @return true if the command's permission is overridden, false otherwise
60+
*/
2361
boolean isOverridden(String command);
2462

63+
/**
64+
* Overrides the permission associated with a command.
65+
* <p>
66+
* If the provided permission is null, the method attempts to remove the original permission,
67+
* effectively unassigning any existing permission.
68+
*
69+
* @param command the name of the command whose permission is to be overridden
70+
* @param permission the new permission to assign to the command, or null to remove
71+
* @return true if the operation was successful, false otherwise
72+
*/
2573
boolean override(String command, @Nullable String permission);
2674

75+
/**
76+
* Reverts the permission of the given command to its original state before any overrides were applied.
77+
*
78+
* @param command the name of the command whose permission is to be reset
79+
* @return true if the permission override was successfully reset, false otherwise
80+
*/
2781
boolean reset(String command);
2882

83+
/**
84+
* Applies permission overrides to all commands.
85+
* <p>
86+
* This method enforces the overridden permissions configured in the system,
87+
* replacing the original permissions for all applicable commands.
88+
* Any subsequent retrieval of permissions will reflect the overridden values.
89+
*/
2990
void overridePermissions();
3091
}

0 commit comments

Comments
 (0)