From 2b1a999b38c712fc77c7199c8af0508449478d41 Mon Sep 17 00:00:00 2001 From: Aram Date: Tue, 19 Nov 2024 15:48:39 +0100 Subject: [PATCH] Made setVariantParameter static --- .../entity/variant/VariantParameter.java | 23 ++++++++++++++++--- .../variant/base/IVariantEntityBase.java | 2 +- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/software/bluelib/entity/variant/VariantParameter.java b/common/src/main/java/software/bluelib/entity/variant/VariantParameter.java index a3805dba..a3ff81a5 100644 --- a/common/src/main/java/software/bluelib/entity/variant/VariantParameter.java +++ b/common/src/main/java/software/bluelib/entity/variant/VariantParameter.java @@ -134,8 +134,25 @@ public String getJsonKey() { * @author MeAlam * @since 1.0.0 */ - public String getVariantParameter() { - String variantName = getParameter(variantParameterName); + public static String getVariantParameter() { + String variantName = variantParameterName; + BaseLogger.log(BaseLogLevel.INFO, "Retrieved parameter name: " + variantName, true); + return variantName; + } + + /** + * A {@link String} method that retrieves the name of the variant parameter. + *

+ * The variant name is, by default, stored under the key {@code "variantName"} in the parameters/JSON files. + * Otherwise, the key is stored in the {@link #variantParameterName} field. + *

+ * + * @return The name of the variant, or {@code null} if the variant name is not found. + * @author MeAlam + * @since 1.0.0 + */ + public String filterVariantParameter() { + String variantName = getParameter(variantParameterName); ; BaseLogger.log(BaseLogLevel.INFO, "Retrieved parameter name: " + variantName, true); return variantName; } @@ -150,7 +167,7 @@ public String getVariantParameter() { * @author MeAlam * @since 1.0.0 */ - public void setVariantParameter(String pCustomVariantName) { + public static void setVariantParameter(String pCustomVariantName) { variantParameterName = pCustomVariantName; BaseLogger.log(BaseLogLevel.INFO, "Setting parameter name: " + variantParameterName, true); } diff --git a/common/src/main/java/software/bluelib/interfaces/variant/base/IVariantEntityBase.java b/common/src/main/java/software/bluelib/interfaces/variant/base/IVariantEntityBase.java index b74779a0..8e9f2d2c 100644 --- a/common/src/main/java/software/bluelib/interfaces/variant/base/IVariantEntityBase.java +++ b/common/src/main/java/software/bluelib/interfaces/variant/base/IVariantEntityBase.java @@ -58,7 +58,7 @@ default ResourceLocation getTextureLocation(String pModId, String pPath) { default List getEntityVariants(String pEntityName) { List variants = VariantLoader.getVariantsFromEntity(pEntityName); List variantNames = variants.stream() - .map(VariantParameter::getVariantParameter) + .map(VariantParameter::filterVariantParameter) .collect(Collectors.toList()); BaseLogger.log(BaseLogLevel.SUCCESS, "Retrieved " + variantNames.size() + " variants for entity: " + pEntityName, true); return variantNames;