-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First iteration of an extendable and testable config system
- Loading branch information
1 parent
f8b58cf
commit 593bd74
Showing
7 changed files
with
134 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
commandapi-core/src/main/java/dev/jorel/commandapi/config/CommentedSection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package dev.jorel.commandapi.config; | ||
|
||
import java.util.List; | ||
|
||
record CommentedSection(List<String> comment) { | ||
} |
49 changes: 49 additions & 0 deletions
49
commandapi-core/src/main/java/dev/jorel/commandapi/config/DefaultedConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package dev.jorel.commandapi.config; | ||
|
||
import org.jetbrains.annotations.ApiStatus; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@SuppressWarnings("ClassEscapesDefinedScope") | ||
@ApiStatus.Internal | ||
public abstract class DefaultedConfig { | ||
|
||
final Map<String, CommentedConfigOption<?>> allOptions = new LinkedHashMap<>(); | ||
final Map<String, CommentedSection> allSections = new LinkedHashMap<>(); | ||
|
||
public static final CommentedConfigOption<Boolean> VERBOSE_OUTPUTS = new CommentedConfigOption<>( | ||
List.of( | ||
"Verbose outputs (default: false)", | ||
"If \"true\", outputs command registration and unregistration logs in the console" | ||
), false | ||
); | ||
|
||
public static final CommentedConfigOption<Boolean> SILENT_LOGS = new CommentedConfigOption<>( | ||
List.of( | ||
"Silent logs (default: false)", | ||
"If \"true\", turns off all logging from the CommandAPI, except for errors." | ||
), false | ||
); | ||
|
||
public static final CommentedConfigOption<String> MISSING_EXECUTOR_IMPLEMENTATION = new CommentedConfigOption<>( | ||
List.of( | ||
"Missing executor implementation (default: \"This command has no implementations for %s\")", | ||
"The message to display to senders when a command has no executor. Available", | ||
"parameters are:", | ||
" %s - the executor class (lowercase)", | ||
" %S - the executor class (normal case)" | ||
), "This command has no implementations for %s" | ||
); | ||
|
||
public static final CommentedConfigOption<Boolean> CREATE_DISPATCHER_JSON = new CommentedConfigOption<>( | ||
List.of( | ||
"Create dispatcher JSON (default: false)", | ||
"If \"true\", the CommandAPI creates a command_registration.json file showing the", | ||
"mapping of registered commands. This is designed to be used by developers -", | ||
"setting this to \"false\" will improve command registration performance." | ||
), false | ||
); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters