From 2da61dec5e543cbaef28c6ed386f7c8d083f220f Mon Sep 17 00:00:00 2001 From: TPGamesNL <29547183+TPGamesNL@users.noreply.github.com> Date: Wed, 3 Nov 2021 09:42:17 +0100 Subject: [PATCH] Remove 'Numeric ids are not supported anymore' error (#4371) --- src/main/java/ch/njol/skript/aliases/Aliases.java | 11 ++++------- .../njol/skript/lang/function/FunctionReference.java | 12 +++++++++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/ch/njol/skript/aliases/Aliases.java b/src/main/java/ch/njol/skript/aliases/Aliases.java index 9ecda6f9a93..16a2d1b0821 100644 --- a/src/main/java/ch/njol/skript/aliases/Aliases.java +++ b/src/main/java/ch/njol/skript/aliases/Aliases.java @@ -310,17 +310,14 @@ public static ItemType parseItemType(String s) { @Nullable private static ItemType parseType(final String s, final ItemType t, final boolean isAlias) { ItemType i; - final String type = s; - if (type.isEmpty()) { + if (s.isEmpty()) { t.add(new ItemData(Material.AIR)); return t; - } else if (type.matches("\\d+")) { - Skript.error("Numeric ids are not supported anymore."); + } else if (s.matches("\\d+")) { return null; - } else if ((i = getAlias(type)) != null) { + } else if ((i = getAlias(s)) != null) { for (ItemData d : i) { - d = d.clone(); - t.add(d); + t.add(d.clone()); } return t; } diff --git a/src/main/java/ch/njol/skript/lang/function/FunctionReference.java b/src/main/java/ch/njol/skript/lang/function/FunctionReference.java index 1394048ea7d..97d2d15dc1c 100644 --- a/src/main/java/ch/njol/skript/lang/function/FunctionReference.java +++ b/src/main/java/ch/njol/skript/lang/function/FunctionReference.java @@ -22,6 +22,8 @@ import java.util.Arrays; import java.util.List; +import ch.njol.skript.lang.UnparsedLiteral; +import ch.njol.skript.util.LiteralUtils; import org.bukkit.event.Event; import org.eclipse.jdt.annotation.Nullable; @@ -209,9 +211,13 @@ public boolean validateFunction(boolean first) { Expression e = parameters[i].getConvertedExpression(p.type.getC()); if (e == null) { if (first) { - Skript.error("The " + StringUtils.fancyOrderNumber(i + 1) + " argument given to the function '" + functionName + "' is not of the required type " + p.type + "." - + " Check the correct order of the arguments and put lists into parentheses if appropriate (e.g. 'give(player, (iron ore and gold ore))')." - + " Please note that storing the value in a variable and then using that variable as parameter will suppress this error, but it still won't work."); + if (LiteralUtils.hasUnparsedLiteral(parameters[i])) { + Skript.error("Can't understand this expression: " + parameters[i].toString()); + } else { + Skript.error("The " + StringUtils.fancyOrderNumber(i + 1) + " argument given to the function '" + functionName + "' is not of the required type " + p.type + "." + + " Check the correct order of the arguments and put lists into parentheses if appropriate (e.g. 'give(player, (iron ore and gold ore))')." + + " Please note that storing the value in a variable and then using that variable as parameter will suppress this error, but it still won't work."); + } } else { Skript.error("The function '" + functionName + "' was redefined with different, incompatible arguments, but is still used in other script(s)." + " These will continue to use the old version of the function until Skript restarts.");