Skip to content

Commit 228184e

Browse files
committed
doc: Added documentation
1 parent 9a69d0b commit 228184e

File tree

6 files changed

+65
-7
lines changed

6 files changed

+65
-7
lines changed

src/main/java/dev/loat/command/Command.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,30 @@
88
import net.minecraft.network.chat.Component;
99
import net.minecraft.world.entity.player.Player;
1010

11+
/**
12+
* Represents a command.
13+
*/
1114
public class Command {
15+
/**
16+
* Checks if the given command context contains the given argument.
17+
*
18+
* @param context The command context to check.
19+
* @param argument The argument to check for.
20+
* @return True if the argument exists, false otherwise.
21+
*/
1222
protected static boolean hasArgument(
1323
CommandContext<CommandSourceStack> context,
1424
String argument
1525
) {
1626
return context.getNodes().stream().anyMatch(node -> node.getNode().getName().equals(argument));
1727
}
1828

29+
/**
30+
* Sends a success message to the player executing the command, if the command source is a player.
31+
*
32+
* @param context The command context to send the success message to.
33+
* @param supplier The supplier of the success message component.
34+
*/
1935
@SuppressWarnings("null")
2036
protected static void sendSuccess(
2137
CommandContext<CommandSourceStack> context,

src/main/java/dev/loat/command/CommandManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@
88
import dev.loat.command.sub_command.*;
99
import dev.loat.command.suggestion_provider.BackupFiles;
1010

11+
/**
12+
* Manages commands.
13+
*/
1114
public class CommandManager {
15+
/**
16+
* Registers all commands.
17+
*
18+
* @implNote This method is called by fabric during the initialization process.
19+
*/
1220
@SuppressWarnings("null")
1321
public static void register() {
1422
CommandRegistrationCallback.EVENT.register((

src/main/java/dev/loat/config/Config.java

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,23 @@
66
import java.io.File;
77
import java.nio.file.Path;
88

9-
9+
/**
10+
* Represents a configuration file.
11+
*
12+
* @param <ConfigFile> The config file type
13+
*/
1014
public class Config<ConfigFile> {
1115
private final Class<ConfigFile> configFileClass;
1216
private final YamlSerializer<ConfigFile> serializer;
1317
@SuppressWarnings("null")
1418
private ConfigFile config = null;
1519

20+
/**
21+
* Creates a new config instance.
22+
*
23+
* @param path The path to the config file
24+
* @param configFileClass The config file class
25+
*/
1626
public Config(
1727
Path path,
1828
Class<ConfigFile> configFileClass
@@ -37,10 +47,27 @@ public Config(
3747
}
3848
}
3949

50+
51+
/**
52+
* Returns the config file class associated with this config.
53+
*
54+
* @return The config file class
55+
*/
4056
Class<ConfigFile> getConfigFileClass() {
4157
return this.configFileClass;
4258
}
4359

60+
61+
/**
62+
* Loads the configuration from the file.
63+
*
64+
* If the file does not exist, it will be created with default values.
65+
*
66+
* If an error occurs while parsing the file, it will be caught and logged.
67+
* In this case, a new instance of the config class will be created using its default constructor.
68+
* If an error occurs while creating a new instance of the config class, it will be caught and logged.
69+
* In this case, the config will be set to null.
70+
*/
4471
@SuppressWarnings("null")
4572
public void load() {
4673
try {
@@ -58,6 +85,11 @@ public void load() {
5885
}
5986
}
6087

88+
/**
89+
* Returns the configuration associated with this config.
90+
*
91+
* @return The configuration associated with this config, or null if an error occurred while parsing or creating the config.
92+
*/
6193
public ConfigFile get() {
6294
return this.config;
6395
}

src/main/java/dev/loat/config/ConfigManager.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* Manages configuration files.
1414
*/
1515
public class ConfigManager {
16-
1716
public static final String path = "backup";
1817
private static final Map<Class<?>, Config<?>> configs = new HashMap<>();
1918

src/main/java/dev/loat/config/annotation/Comment.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import java.lang.annotation.RetentionPolicy;
66
import java.lang.annotation.Target;
77

8+
/**
9+
* Indicates a comment for a configuration field.
10+
*/
811
@Retention(RetentionPolicy.RUNTIME)
912
@Target(ElementType.FIELD)
1013
public @interface Comment {

src/main/java/dev/loat/logging/Logger.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class Logger {
1212
/**
1313
* This static function is used to set the class for logging.
1414
*
15-
* @param classInstance The instance to use for logging
15+
* @param classInstance The instance to use for logging.
1616
*/
1717
public static void setLoggerClass(Class<? extends ModInitializer> classInstance) {
1818
Logger.INSTANCE = LoggerFactory.getLogger(classInstance);
@@ -21,7 +21,7 @@ public static void setLoggerClass(Class<? extends ModInitializer> classInstance)
2121
/**
2222
* This static function is used for logging a message at debug level.
2323
*
24-
* @param message The message to log
24+
* @param message The message to log.
2525
*/
2626
public static void debug(String message) {
2727
Logger.INSTANCE.debug(message);
@@ -30,7 +30,7 @@ public static void debug(String message) {
3030
/**
3131
* This static function is used for logging a message at info level.
3232
*
33-
* @param message The message to log
33+
* @param message The message to log.
3434
*/
3535
public static void info(String message) {
3636
Logger.INSTANCE.info(message);
@@ -39,7 +39,7 @@ public static void info(String message) {
3939
/**
4040
* This static function is used for logging a message at warning level.
4141
*
42-
* @param message The message to log
42+
* @param message The message to log.
4343
*/
4444
public static void warning(String message) {
4545
Logger.INSTANCE.warn(message);
@@ -48,7 +48,7 @@ public static void warning(String message) {
4848
/**
4949
* This static function is used for logging a message at error level.
5050
*
51-
* @param message The message to log
51+
* @param message The message to log.
5252
*/
5353
public static void error(String message) {
5454
Logger.INSTANCE.error(message);

0 commit comments

Comments
 (0)