Skip to content

Commit

Permalink
Cleaned up all Conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
MeAlam1 committed Oct 7, 2024
1 parent d76537c commit 22d2aec
Show file tree
Hide file tree
Showing 28 changed files with 266 additions and 249 deletions.
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* <li>{@link #loadJson(ResourceLocation, ResourceManager)} - Loads a JSON resource.</li>
* </ul>
* @author MeAlam
* @co-author Dan
* @since 1.0.0
*/
public class JSONLoader {
Expand All @@ -48,7 +48,7 @@
* @return The value of the custom parameter identified by {@code pParameterKey}
* for the variant specified by {@code pVariantName}.
* @author MeAlam
* @co-author Dan
* @since 1.0.0
*/
public String getCustomParameter(String pVariantName, String pParameterKey) {
Expand All @@ -67,7 +67,7 @@
* @return The value of the custom parameter identified by {@code pParameterKey}
* for the variant specified by {@code pVariantName}.
* @author MeAlam
* @co-author Dan
* @since 1.0.0
*/
public String getCustomParameter(String pVariantName, String pParameterKey) {
Expand Down Expand Up @@ -101,7 +101,7 @@
* <strong>TODO: Testing with Multiple Entities and Datapacks required before Deletion/Refactoring.</strong><br>
* @return A map containing the parameters added to this builder.
* @author MeAlam
* @co-author Dan
* @since 1.0.0
* @see #newMethod()
*/
Expand Down
12 changes: 1 addition & 11 deletions Forge/src/main/java/software/bluelib/BlueLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.FMLEnvironment;
import software.bluelib.utils.logging.BaseLogLevel;
import software.bluelib.utils.logging.BaseLogger;

import java.util.concurrent.TimeUnit;

import static software.bluelib.BlueLibConstants.SCHEDULER;

/**
* The main class of the {@link BlueLib} mod.
Expand All @@ -30,9 +23,8 @@
* </ul>
* </p>
*
* @author MeAlam, Dan and All Contributors of BlueLib!
* @see <a href="https://github.com/MeAlam1/BlueLib/wiki">BlueLib Wiki</a>
* @author MeAlam, Dan
* @co-author All Contributors of BlueLib!
* @since 1.0.0
*/
@Mod(BlueLibConstants.MOD_ID)
Expand All @@ -42,7 +34,6 @@ public class BlueLib {
* Constructs a new {@link BlueLib} instance and registers the mod event bus.
*
* @author MeAlam
* @co-author Dan
* @since 1.0.0
*/
public BlueLib() {
Expand All @@ -55,7 +46,6 @@ public BlueLib() {
*
* @param pEvent {@link FMLLoadCompleteEvent} - The event fired after the mod loading process completes.
* @author MeAlam
* @co-author Dan
* @since 1.0.0
*/
@SubscribeEvent
Expand Down
14 changes: 2 additions & 12 deletions NeoForge/src/main/java/software/bluelib/BlueLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLLoadCompleteEvent;
import net.neoforged.fml.loading.FMLEnvironment;
import org.spongepowered.asm.launch.MixinBootstrap;
import software.bluelib.utils.logging.BaseLogLevel;
import software.bluelib.utils.logging.BaseLogger;

import java.util.concurrent.TimeUnit;

import static software.bluelib.BlueLibConstants.SCHEDULER;

/**
* The main class of the {@code BlueLib} mod.
Expand All @@ -30,9 +23,8 @@
* </ul>
* </p>
*
* @author MeAlam, Dan and All Contributors of BlueLib!
* @see <a href="https://github.com/MeAlam1/BlueLib/wiki">BlueLib Wiki</a>
* @author MeAlam, Dan
* @co-author All Contributors of BlueLib!
* @since 1.0.0
*/
@Mod(BlueLibConstants.MOD_ID)
Expand All @@ -44,10 +36,9 @@ public class BlueLib {
* 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 where the mod registers its handlers.
* @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
*/
public BlueLib(IEventBus pModEventBus, ModContainer pModContainer) {
Expand All @@ -60,7 +51,6 @@ public BlueLib(IEventBus pModEventBus, ModContainer pModContainer) {
*
* @param pEvent {@link FMLLoadCompleteEvent} - The event fired after the mod loading process completes.
* @author MeAlam
* @co-author Dan
* @since 1.0.0
*/
@SubscribeEvent
Expand Down
5 changes: 2 additions & 3 deletions common/src/main/java/software/bluelib/BlueLibCommon.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,14 @@ public static void init() {
*
* @return {@code true} if running in developer mode, {@code false} otherwise.
* @author MeAlam
* @co-author Dan
* @since 1.0.0
*/
static boolean isDeveloperMode() {
boolean isDevMode = PLATFORM.isDevelopmentEnvironment();
if (isDevMode) {
BaseLogger.log(BaseLogLevel.INFO ,"Running in Developer mode.", true);
BaseLogger.log(BaseLogLevel.INFO, "Running in Developer mode.", true);
} else {
BaseLogger.log(BaseLogLevel.INFO ,"Running in Production mode.", true);
BaseLogger.log(BaseLogLevel.INFO, "Running in Production mode.", true);
}
return isDevMode;
}
Expand Down
42 changes: 25 additions & 17 deletions common/src/main/java/software/bluelib/BlueLibConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,31 @@

public class BlueLibConstants {

/**
* A {@code public static final} {@link ScheduledExecutorService} used to schedule tasks, such as printing messages after a delay.
* <p>
* 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
*/
public static final ScheduledExecutorService SCHEDULER = Executors.newScheduledThreadPool(1);
/**
* A {@code public static final} {@link ScheduledExecutorService} used to schedule tasks, such as printing messages after a delay.
* <p>
* 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
*/
public static final ScheduledExecutorService SCHEDULER = Executors.newScheduledThreadPool(1);

/**
* A {@code public static final} {@link String} representing the Mod ID for the {@code 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 MOD_ID = "bluelib";
/**
* A {@code public static final} {@link String} representing the Mod ID for the {@code 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 MOD_ID = "bluelib";

public static final String MOD_NAME = "BlueLib";
/**
* A {@code public static final} {@link String} representing the Mod Name for the {@code BlueLib} mod.
*
* @co-author MeAlam, Dan
* @since 1.0.0
*/
public static final String MOD_NAME = "BlueLib";
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
* <li>{@link #getVariantsFromEntity(String)} - Retrieves the list of loaded {@link VariantParameter} for a specific entity.</li>
* <li>{@link #getVariantByName(String, String)} - Retrieves a specific {@link VariantParameter} by its name for a given entity.</li>
* </ul>
*
* @author MeAlam
* @co-author Dan
* @since 1.0.0
*/
public class VariantLoader implements IVariantEntityBase {
Expand All @@ -40,13 +40,15 @@ public class VariantLoader implements IVariantEntityBase {
* <p>
* This {@link Map<String>} holds entity names and their corresponding list of {@link VariantParameter} instances.
* </p>
*
* @co-author MeAlam, Dan
* @since 1.0.0
*/
private static final Map<String, List<VariantParameter>> entityVariantsMap = new HashMap<>();

/**
* A {@code private static final} {@link JSONLoader} to load JSON data from resources.
*
* @co-author MeAlam, Dan
* @since 1.0.0
*/
Expand All @@ -57,6 +59,7 @@ public class VariantLoader implements IVariantEntityBase {
* <p>
* This {@link JSONMerger} instance is used to merge JSON data into a single {@link JsonObject}.
* </p>
*
* @co-author MeAlam, Dan
* @since 1.0.0
*/
Expand All @@ -68,12 +71,13 @@ public class VariantLoader implements IVariantEntityBase {
* The method loops through all resources in the folder and merges them into a single {@link JsonObject}. <br>
* The merged JSON data is then parsed into {@link VariantParameter} instances and stored in {@link #entityVariantsMap}.
* </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 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) {
BaseLogger.log(BaseLogLevel.INFO,"Starting to load variants for entity: " + pEntityName);
BaseLogger.log(BaseLogLevel.INFO, "Starting to load variants for entity: " + pEntityName);

clearVariantsForEntity(pEntityName);

Expand All @@ -82,19 +86,19 @@ public static void loadVariants(String folderPath, MinecraftServer pServer, Stri

Collection<ResourceLocation> collection = resourceManager.listResources(folderPath, pFiles -> pFiles.getPath().endsWith(".json")).keySet();

BaseLogger.log(BaseLogLevel.INFO,"Found resources: " + collection);
BaseLogger.log(BaseLogLevel.INFO, "Found resources: " + collection);

for (ResourceLocation resourceLocation : collection) {
try {
BaseLogger.log(BaseLogLevel.INFO,"Loading JSON data from resource: " + resourceLocation.toString());
BaseLogger.log(BaseLogLevel.INFO, "Loading JSON data from resource: " + resourceLocation.toString());
JsonObject jsonObject = jsonLoader.loadJson(resourceLocation, resourceManager);
jsonMerger.mergeJsonObjects(mergedJsonObject, jsonObject);
} catch (Exception pException) {
BaseLogger.log(BaseLogLevel.ERROR,"Failed to load JSON data from resource: " + resourceLocation.toString(), pException);
BaseLogger.log(BaseLogLevel.ERROR, "Failed to load JSON data from resource: " + resourceLocation.toString(), pException);
}
}

BaseLogger.log(BaseLogLevel.INFO,"Successfully loaded and merged JSON data for entity: " + pEntityName);
BaseLogger.log(BaseLogLevel.INFO, "Successfully loaded and merged JSON data for entity: " + pEntityName);
parseVariants(mergedJsonObject);
}

Expand All @@ -103,10 +107,11 @@ public static void loadVariants(String folderPath, MinecraftServer pServer, Stri
* <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) {
BaseLogger.log(BaseLogLevel.INFO,"Clearing variants for entity: " + pEntityName);
BaseLogger.log(BaseLogLevel.INFO, "Clearing variants for entity: " + pEntityName);
entityVariantsMap.remove(pEntityName);
}

Expand All @@ -115,14 +120,15 @@ private static void clearVariantsForEntity(String pEntityName) {
* <p>
* This method processes each entry in the JSON object and stores the created {@link VariantParameter} instances in {@link #entityVariantsMap}.
* </p>
*
* @param pJsonObject {@link JsonObject} - The merged {@link JsonObject} containing variant data.
*/
private static void parseVariants(JsonObject pJsonObject) {
for (Map.Entry<String, JsonElement> entry : pJsonObject.entrySet()) {
String entityName = entry.getKey();
JsonArray textureArray = entry.getValue().getAsJsonArray();

BaseLogger.log(BaseLogLevel.INFO,"Parsing variants for entity: " + entityName);
BaseLogger.log(BaseLogLevel.INFO, "Parsing variants for entity: " + entityName);
List<VariantParameter> variantList = entityVariantsMap.computeIfAbsent(entityName, k -> new ArrayList<>());

for (JsonElement variant : textureArray) {
Expand All @@ -143,7 +149,8 @@ private static void parseVariants(JsonObject pJsonObject) {
* <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 pJsonKey {@link String} - The key associated with this variant.
* @param pJsonObject {@link JsonObject} - The {@link JsonObject} containing the variant data.
* @return {@link VariantParameter} - A {@link VariantParameter} instance.
*/
Expand All @@ -156,11 +163,12 @@ private static VariantParameter getEntityVariant(String pJsonKey, JsonObject pJs
* <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 {@link List<VariantParameter>} - A {@link List<VariantParameter>} of {@link VariantParameter} instances for the specified entity.
*/
public static List<VariantParameter> getVariantsFromEntity(String pEntityName) {
BaseLogger.log(BaseLogLevel.INFO,"Retrieving variants for entity: " + pEntityName);
BaseLogger.log(BaseLogLevel.INFO, "Retrieving variants for entity: " + pEntityName);
return entityVariantsMap.getOrDefault(pEntityName, new ArrayList<>());
}

Expand All @@ -169,19 +177,20 @@ public static List<VariantParameter> getVariantsFromEntity(String pEntityName) {
* <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 pEntityName {@link String} - The name of the entity to retrieve variants for.
* @param pVariantName {@link String} - The name of the variant to retrieve.
* @return {@link VariantParameter} - The {@link VariantParameter} with the specified name, or {@code null} if not found.
*/
public static VariantParameter getVariantByName(String pEntityName, String pVariantName) {
BaseLogger.log(BaseLogLevel.INFO,"Retrieving variant by name: " + pVariantName + " for entity: " + pEntityName);
BaseLogger.log(BaseLogLevel.INFO, "Retrieving variant by name: " + pVariantName + " for entity: " + pEntityName);
List<VariantParameter> variants = getVariantsFromEntity(pEntityName);
for (VariantParameter variant : variants) {
if (variant.getVariantName().equals(pVariantName)) {
return variant;
}
}
BaseLogger.log(BaseLogLevel.INFO,"Variant with name: " + pVariantName + " not found for entity: " + pEntityName);
BaseLogger.log(BaseLogLevel.INFO, "Variant with name: " + pVariantName + " not found for entity: " + pEntityName);
return null;
}
}
Loading

0 comments on commit 22d2aec

Please sign in to comment.