From 0366dd33ea5032132f3a5f2927f3576113f85e02 Mon Sep 17 00:00:00 2001 From: Xeiji Date: Fri, 1 May 2026 19:59:41 +0800 Subject: [PATCH 1/3] Fix ExprHash internal error when MD5 is used Added exception handling for MD5 warning suppression. --- src/main/java/ch/njol/skript/expressions/ExprHash.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/ch/njol/skript/expressions/ExprHash.java b/src/main/java/ch/njol/skript/expressions/ExprHash.java index 34aec0aefc7..f37c34cce44 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprHash.java +++ b/src/main/java/ch/njol/skript/expressions/ExprHash.java @@ -51,8 +51,11 @@ public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelaye String algorithm = parseResult.tags.get(0).toUpperCase(Locale.ENGLISH); try { digest = MessageDigest.getInstance(algorithm); - if (algorithm.equals("MD5") && !getParser().getCurrentScript().suppressesWarning(ScriptWarning.DEPRECATED_SYNTAX)) { - Skript.warning("MD5 is not secure and shouldn't be used if a cryptographically secure hashing algorithm is required."); + if (algorithm.equals("MD5")) { + try { + if (!getParser().getCurrentScript().suppressesWarning(ScriptWarning.DEPRECATED_SYNTAX)) + Skript.warning("MD5 is not secure and shouldn't be used if a cryptographically secure hashing algorithm is required."); + } catch (Exception e) {} } return true; } catch (NoSuchAlgorithmException e) { From 0b16f06dd2be55706155e11e85425b30735abec5 Mon Sep 17 00:00:00 2001 From: Xeiji Date: Fri, 1 May 2026 22:24:57 +0800 Subject: [PATCH 2/3] ParserInstance active check before calling getCurrentScript() Replaced try-catch with parser checker --- src/main/java/ch/njol/skript/expressions/ExprHash.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/ch/njol/skript/expressions/ExprHash.java b/src/main/java/ch/njol/skript/expressions/ExprHash.java index f37c34cce44..b6e95fb22bb 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprHash.java +++ b/src/main/java/ch/njol/skript/expressions/ExprHash.java @@ -51,11 +51,8 @@ public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelaye String algorithm = parseResult.tags.get(0).toUpperCase(Locale.ENGLISH); try { digest = MessageDigest.getInstance(algorithm); - if (algorithm.equals("MD5")) { - try { - if (!getParser().getCurrentScript().suppressesWarning(ScriptWarning.DEPRECATED_SYNTAX)) - Skript.warning("MD5 is not secure and shouldn't be used if a cryptographically secure hashing algorithm is required."); - } catch (Exception e) {} + if (algorithm.equals("MD5") && getParser().isActive() && !getParser().getCurrentScript().suppressesWarning(ScriptWarning.DEPRECATED_SYNTAX)) { + Skript.warning("MD5 is not secure and shouldn't be used if a cryptographically secure hashing algorithm is required."); } return true; } catch (NoSuchAlgorithmException e) { From 90aa06e2f2334da07a5b5d57f73d24089d2a542f Mon Sep 17 00:00:00 2001 From: Xeiji Date: Tue, 12 May 2026 05:43:54 +0800 Subject: [PATCH 3/3] Optimize parser calls by saving the result of getParser() --- src/main/java/ch/njol/skript/expressions/ExprHash.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/njol/skript/expressions/ExprHash.java b/src/main/java/ch/njol/skript/expressions/ExprHash.java index b6e95fb22bb..cbca80c9324 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprHash.java +++ b/src/main/java/ch/njol/skript/expressions/ExprHash.java @@ -7,6 +7,7 @@ import java.util.Locale; import ch.njol.skript.doc.*; +import ch.njol.skript.lang.parser.ParserInstance; import org.bukkit.event.Event; import org.jetbrains.annotations.Nullable; @@ -51,7 +52,8 @@ public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelaye String algorithm = parseResult.tags.get(0).toUpperCase(Locale.ENGLISH); try { digest = MessageDigest.getInstance(algorithm); - if (algorithm.equals("MD5") && getParser().isActive() && !getParser().getCurrentScript().suppressesWarning(ScriptWarning.DEPRECATED_SYNTAX)) { + ParserInstance parser = getParser(); + if (algorithm.equals("MD5") && parser.isActive() && !parser.getCurrentScript().suppressesWarning(ScriptWarning.DEPRECATED_SYNTAX)) { Skript.warning("MD5 is not secure and shouldn't be used if a cryptographically secure hashing algorithm is required."); } return true;