Skip to content

Commit

Permalink
Update All Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MeAlam1 committed Sep 18, 2024
1 parent 9be323e commit 67a4ac9
Show file tree
Hide file tree
Showing 23 changed files with 752 additions and 263 deletions.
29 changes: 15 additions & 14 deletions NeoForge/src/main/java/software/bluelib/BlueLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* This class serves as the entry point for the {@link BlueLib} mod, handling initialization by registering event handlers
* and setting up necessary configurations. For more details, refer to the <a href="https://github.com/MeAlam1/BlueLib/wiki">BlueLib Wiki</a>.
* </p>
*
* <p>
* Key Methods:
* <ul>
Expand All @@ -41,29 +40,31 @@
public class BlueLib {

/**
* A {@link ScheduledExecutorService} used for scheduling tasks, such as printing messages after a delay.
* A {@link ScheduledExecutorService} used to schedule tasks, such as printing messages after a delay.
* <p>
* This is initialized with a single-threaded pool to handle delayed tasks in a separate thread.
* This executor runs tasks on a single thread to ensure delayed tasks run in a separate thread from the main thread.
* </p>
* @Co-author MeAlam, Dan
* @since 1.0.0
*/
private static final ScheduledExecutorService SCHEDULER = Executors.newScheduledThreadPool(1);

/**
* The Mod ID for {@link BlueLib}. This serves as a unique identifier for the mod.
* A {@link String} representing the Mod ID for the {@link BlueLib} mod.
* <p>This serves as a unique identifier for the mod.</p>
* @Co-author MeAlam, Dan
* @since 1.0.0
*/
public static final String MODID = "bluelib";

// public static final Logger LOGGER = LogUtils.getLogger();

/**
* Constructs a new {@link BlueLib} instance and registers the mod event bus.
* <p>
* Registers necessary mod event listeners, and if in developer mode, additional client-side listeners for rendering and attributes.
* </p>
*
* @param pModEventBus {@link IEventBus} - The event bus to which the mod will register its event handlers.
* @param pModContainer {@link ModContainer} - The mod container for the mod instance.
* @param pModEventBus {@link IEventBus} - The event bus where the mod registers its handlers.
* @param pModContainer {@link ModContainer} - The mod container that holds the instance of the mod.
* @author MeAlam
* @Co-author Dan
* @since 1.0.0
Expand All @@ -80,12 +81,12 @@ public BlueLib(IEventBus pModEventBus, ModContainer pModContainer) {
}

/**
* Handles the {@link FMLLoadCompleteEvent}, which is triggered when the mod loading process is complete.
* a {@code void} that handles the {@link FMLLoadCompleteEvent}, which occurs when the mod finishes loading.
* <p>
* If the mod is running in developer mode, it schedules a task to print a thank-you message to the console after a short delay.
* If the mod is in developer mode, it schedules a task that prints a thank-you message after a short delay.
* </p>
*
* @param pEvent {@link FMLLoadCompleteEvent} - The event triggered upon the completion of the mod loading process.
* @param pEvent {@link FMLLoadCompleteEvent} - The event fired after the mod loading process completes.
* @author MeAlam
* @Co-author Dan
* @since 1.0.0
Expand All @@ -106,12 +107,12 @@ public void onLoadComplete(FMLLoadCompleteEvent pEvent) {
}

/**
* Checks if the mod is running in developer mode.
* a {@code void} that checks if the mod is running in developer mode.
* <p>
* Developer mode is determined by checking if the mod is not running in a production environment.
* Developer mode is active when the mod is not running in a production environment.
* </p>
*
* @return {@code true} if the mod is running in developer mode, {@code false} otherwise.
* @return {@code true} if running in developer mode, {@code false} otherwise.
* @author MeAlam
* @Co-author Dan
* @since 1.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
import software.bluelib.json.JSONMerger;
import software.bluelib.utils.logging.BaseLogger;

import java.io.File;
import java.util.*;

/**
* A {@link VariantLoader} class that loads and manages {@link VariantParameter} for entities by merging JSON data from multiple sources.
* A {@code class} that loads and manages {@link VariantParameter} instances for entities by merging JSON data from multiple sources.
* <p>
* The class handles loading of variant data from both the main mod and latest datapack, merging them, and parsing them into {@link VariantParameter} instances.
* </p>
* Key Methods:
* <ul>
* <li>{@link #loadVariants(String, MinecraftServer, String)} - Loads and merges variant data from both the main mod and the latest datapack.</li>
Expand All @@ -37,10 +38,12 @@ public class VariantLoader implements IVariantEntityBase {
private static final JSONMerger jsonMerger = new JSONMerger();

/**
* A {@code void} method that loads and merges variant data from both the Main Mod and the <strong>Latest</strong> Datapack.
* Parses the merged data into {@link VariantParameter}.
*
* @param pServer {@link MinecraftServer} - The {@link MinecraftServer} instance.
* A {@code void} that loads and merges variant data from both the main mod and the latest datapack.
* <p>
* This method parses the merged JSON data into {@link VariantParameter} instances and stores them in the internal map.
* </p>
* @param folderPath {@link String} - The path to the folder containing JSON resources.
* @param pServer {@link MinecraftServer} - The {@link MinecraftServer} instance used to access resources.
* @param pEntityName {@link String} - The name of the entity whose variants should be cleared before loading new ones.
*/
public static void loadVariants(String folderPath, MinecraftServer pServer, String pEntityName) {
Expand Down Expand Up @@ -69,12 +72,11 @@ public static void loadVariants(String folderPath, MinecraftServer pServer, Stri
parseVariants(mergedJsonObject);
}




/**
* A {@code void} method that clears variants for a specific entity type from the map.
*
* A {@code void} that clears variants for a specific entity type from the internal map.
* <p>
* This method removes all variants associated with the given entity name.
* </p>
* @param pEntityName {@link String} - The name of the entity whose variants should be cleared.
*/
private static void clearVariantsForEntity(String pEntityName) {
Expand All @@ -83,8 +85,10 @@ private static void clearVariantsForEntity(String pEntityName) {
}

/**
* A {@code void} method that parses the merged JSON data and converts it into {@link VariantParameter} instances.
*
* A {@code void} that parses the merged JSON data and converts it into {@link VariantParameter} instances.
* <p>
* This method processes each entry in the JSON object and stores the created {@link VariantParameter} instances in the internal map.
* </p>
* @param pJsonObject {@link JsonObject} - The merged {@link JsonObject} containing variant data.
*/
private static void parseVariants(JsonObject pJsonObject) {
Expand All @@ -109,8 +113,10 @@ private static void parseVariants(JsonObject pJsonObject) {
}

/**
* A {@link VariantParameter} method that creates a new {@link VariantParameter} instance from a JSON object.
*
* A {@link VariantParameter} that creates a new {@link VariantParameter} instance from a JSON object.
* <p>
* This method wraps the creation of {@link VariantParameter} instances for easier management and potential modification.
* </p>
* @param pJsonKey {@link String} - The key associated with this variant.
* @param pJsonObject {@link JsonObject} - The {@link JsonObject} containing the variant data.
* @return A {@link VariantParameter} instance.
Expand All @@ -120,9 +126,10 @@ private static VariantParameter getEntityVariant(String pJsonKey, JsonObject pJs
}

/**
* A {@link List} method that retrieves the {@link List} of loaded {@link VariantParameter}
* for a specific entity.
*
* A {@link List<VariantParameter>} that retrieves the {@link List} of loaded {@link VariantParameter} instances for a specific entity.
* <p>
* This method returns a list of variants for the given entity name. If no variants are found, an empty list is returned.
* </p>
* @param pEntityName {@link String} - The name of the entity to retrieve variants for.
* @return A {@link List} of {@link VariantParameter} instances for the specified entity.
*/
Expand All @@ -132,8 +139,10 @@ public static List<VariantParameter> getVariantsFromEntity(String pEntityName) {
}

/**
* A {@link VariantParameter} method that retrieves a {@link VariantParameter} by its name for a specific entity.
*
* A {@link VariantParameter} that retrieves a {@link VariantParameter} by its name for a specific entity.
* <p>
* This method searches for a variant with the specified name within the list of variants for the given entity.
* </p>
* @param pEntityName {@link String} - The name of the entity to retrieve variants for.
* @param pVariantName {@link String} - The name of the variant to retrieve.
* @return The {@link VariantParameter} with the specified name, or {@code null} if not found.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
import java.util.Set;

/**
* A {@code VariantParameter} class that represents the parameters associated with a specific variant of an entity.
* A {@code class} that represents the parameters associated with a specific variant of an entity.
* <p>
* This class extends {@link ParameterBase} to store and manage variant-specific parameters parsed from a JSON object.
* This class extends {@link ParameterBase} to store and manage variant-specific parameters parsed from a {@link JsonObject}.
* <p>
* The class is designed to handle various JSON element types, including {@code JsonPrimitive}, {@code JsonArray}, and {@code JsonObject}.
* The class handles various JSON element types, including {@code JsonPrimitive}, {@code JsonArray}, and {@code JsonObject}.
* </p>
* Key Methods:
* <ul>
Expand All @@ -40,19 +40,19 @@ public class VariantParameter extends ParameterBase {
private final String jsonKey;

/**
* Constructs a new {@code VariantParameter} instance by extracting parameters from a given JSON object.
* Constructs a new {@code VariantParameter} instance by extracting parameters from a given {@link JsonObject}.
* <p>
* This constructor processes different types of {@link JsonElement} values:
* <ul>
* <li>{@code JsonPrimitive}: Stored directly as a string.</li>
* <li>{@code JsonArray}: Converts array elements into a single comma-separated string.</li>
* <li>{@code JsonObject}: Converts the nested JSON object to a string representation.</li>
* <li>{@link com.google.gson.JsonPrimitive}: Stored directly as a string.</li>
* <li>{@link com.google.gson.JsonArray}: Converts array elements into a single comma-separated string.</li>
* <li>{@link JsonObject}: Converts the nested JSON object to a string representation.</li>
* <li>{@code Other Types}: Stores "null" for unhandled JSON types.</li>
* </ul>
* </p>
* @param pJsonKey {@link String} - The key that identifies this entity within the {@link JsonObject}.
* @param pJsonObject {@link JsonObject} - The {@link JsonObject} containing the variant parameters.
* @throws IllegalArgumentException if {@code pJsonKey} or {@code pJsonObject} is null.
* @throws IllegalArgumentException if {@code pJsonKey} or {@code pJsonObject} is {@code null}.
* @see ParameterBase
* @author MeAlam
* @Co-author Dan
Expand All @@ -76,8 +76,8 @@ public VariantParameter(String pJsonKey, JsonObject pJsonObject) {
} else if (element.isJsonArray()) {
StringBuilder arrayValues = new StringBuilder();
element.getAsJsonArray().forEach(e -> arrayValues.append(e.getAsString()).append(","));
if (!arrayValues.isEmpty()) {
arrayValues.setLength(arrayValues.length() - 1);
if (arrayValues.length() > 0) {
arrayValues.setLength(arrayValues.length() - 1); // Remove trailing comma
}
addParameter(entry.getKey(), arrayValues.toString());
BaseLogger.bluelibLogInfo("Added array parameter: " + entry.getKey() + " = " + arrayValues.toString());
Expand All @@ -92,12 +92,12 @@ public VariantParameter(String pJsonKey, JsonObject pJsonObject) {
}

/**
* A {@link String} method that returns the key of the {@link JsonObject} that identifies this entity.
* A {@link String} method that retrieves the key of the {@link JsonObject} that identifies this entity.
* <p>
* This key is typically used to retrieve or map the entity within a broader data structure.
* This key is used to retrieve or map the entity within a broader data structure.
* </p>
* @return The key of the JSON object representing this entity.
* @throws IllegalStateException if the key is unexpectedly null.
* @throws IllegalStateException if the key is unexpectedly {@code null}.
* @author MeAlam
* @Co-author Dan
* @since 1.0.0
Expand All @@ -116,7 +116,7 @@ public String getJsonKey() {
/**
* A {@link String} method that retrieves the name of the variant.
* <p>
* The variant name is expected to be stored under the key {@code "variantName"} in the parameters/JSON Files.
* The variant name is expected to be stored under the key {@code "variantName"} in the parameters/JSON files.
* </p>
* @return The name of the variant, or {@code null} if the variant name is not found.
* @author MeAlam
Expand Down
Loading

0 comments on commit 67a4ac9

Please sign in to comment.